在 jupyter 上使用 pandas_gbq 时删除所有日志
Posted
技术标签:
【中文标题】在 jupyter 上使用 pandas_gbq 时删除所有日志【英文标题】:Remove all logs when using pandas_gbq on jupyter 【发布时间】:2019-12-30 11:05:16 【问题描述】:在 jupyter 上使用 pandas_gbq 时是否可以删除所有日志?
示例:
sql = """
SELECT country_name, alpha_2_code
FROM [bigquery-public-data:utility_us.country_code_iso]
WHERE alpha_2_code LIKE 'Z%'
"""
for i in range(10):
df = pandas_gbq.read_gbq(
sql,
project_id=project_id,
# Set the dialect to "legacy" to use legacy SQL syntax. As of
# pandas-gbq version 0.10.0, the default dialect is "standard".
dialect="legacy",
)
结果:
Downloading: 100%|██████████| 3/3 [00:00<00:00, 3.08rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 3.06rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 8.72rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 6.15rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 3.24rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 8.40rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 3.27rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 3.18rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 3.55rows/s]
Downloading: 100%|██████████| 3/3 [00:00<00:00, 3.26rows/s]
我希望结果什么都不是。 谢谢
【问题讨论】:
【参考方案1】:那些不是日志,我也想了一段时间,但是在玩了logging
库之后无法删除消息,这是handle log verbosity的文档推荐的消息,没有成功。
我跳到code 并意识到pandas_gbq.read_gbq()
中有一个progress_bar_type
参数function 必须设置为None
才能关闭您要删除的消息。 See the options.
因此,当您调用该函数时,它应该如下所示:
pandas_gbq.read_gbq(sql, project_id=project_id, dialect="legacy", progress_bar_type=None)
【讨论】:
以上是关于在 jupyter 上使用 pandas_gbq 时删除所有日志的主要内容,如果未能解决你的问题,请参考以下文章
访问在 Docker 容器上运行的 Jupyter notebook
是否可以使用 pyqtgraph 函数在 Jupyter Notebook 上内联绘图?
在 Ubuntu 上启动时运行 Jupyter-notebook