I convert an excel file to a h5 file with pandas
and tqdm
.
Following is reduced version of the code I am using:
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')
Above code gives me a weird output like following:
HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=9.0), HTML(value='')))
H5 file is ready
I am guessing this HBox
thing is a way of showing the h5-file creation process like a loading bar. However it does not show anything and write this line ...children=(HTML...
. Since it does not give me any information, I would like to remove this HBox
line. But I am not sure which command above in the script, creates this. Any ideas?
Btw a working progress bar could be also good if it is easy to achieve.
HBox
is related totqdm.notebook
. so removetqdm
in this:If you want to show progress, you can use usual
tqdm
: