def write_data(self, result_dict):
for key, result in six.iteritems(result_dict):
is_null = False
if isinstance(result, pd.DataFrame):
if result.isnull().any().any():
is_null = True
elif isinstance(result, pd.Series):
if result.isnull().any():
is_null = True
else:
raise ValueError("PandasHDFDataHandler doesn't support type "
"{} (in key {})".format(type(result), key))
if is_null:
raise ValueError("data {} have nan".format(key))
with SimpleTimer("Writing generated data {} to hdf5 file"
.format(key),
end_in_new_line=False):
if (isinstance(result, pd.DataFrame)
and isinstance(result.index, pd.MultiIndex)
and isinstance(result.columns, pd.MultiIndex)):
self.hdf_store.put(key, result)
else:
self.hdf_store.put(key, result, format='table')
self.hdf_store.flush(fsync=True)
评论列表
文章目录