[英]Removing HBox terminal output
我將 excel 文件轉換為帶有pandas
和tqdm
的 h5 文件。
以下是我正在使用的代碼的簡化版本:
import pandas as pd
from tqdm.notebook import tqdm
# read raw table
pd.set_option('io.hdf.default.format', 'table')
store = pd.HDFStore('test.h5')
# get original file
original_file = ('test.xlsx')
# tables
table_names = ['A', 'B', 'C']
for name in tqdm(table_names):
# some pre-process data
df = pd.read_excel(original_file, sheet_name=name, skiprows=2)
df.columns = [i.strip() for i in df.columns]
df.index = pd.date_range('2020-01-01 00:00', periods=len(df.index),
freq='H', tz='UTC')
del df['Date from']
del df['Date to']
df.index.name = 'date_time'
# rename columns
mapping = {...}
if 'xxx' in name:
df = df.rename(columns=mapping)
# inject table to hdf store
store[name] = df.copy()
del df
store.close()
print('H5 file is ready')
上面的代碼給了我一個奇怪的 output ,如下所示:
HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=9.0), HTML(value='')))
H5 file is ready
我猜這個HBox
是一種顯示 h5 文件創建過程的方式,就像加載欄一樣。 但是它沒有顯示任何內容並寫下這一行...children=(HTML...
。由於它沒有給我任何信息,我想刪除這個HBox
行。但我不確定腳本中上面的哪個命令, 創建這個。有什么想法嗎?
順便說一句,如果它很容易實現,工作進度條也可能很好。
HBox
與tqdm.notebook
相關。 所以刪除tqdm
:
for name in tqdm(table_names):
如果要顯示進度,可以使用通常的tqdm
:
from tqdm import tqdm # not tqdm.notebook
for name in tqdm(table_names):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.