Python:使用try / except循环将pandas df转换为hdf5

时间:2017-11-16 17:11:11

标签: python pandas hdf5 try-except

尝试以col为单位运行150 cols和700000行的df,并将每个col附加到.hdf5文件。我如何在try / except循环中工作,只是打印异常,跳过col并继续下一个?现在我有这个:

def appendto_hdf5(df):
    _df = df
    for col in _df:
        try:
            _df[col].to_hdf('data.h5', 'df', format='table', data_columns=True, mode = 'a')
        except (Exception) as e:
            print(e)
            pass

哪个有效,直到第一个异常,然后才退出(可能是因为我在异常之下没有任何东西?

0 个答案:

没有答案
相关问题