本文整理汇总了Python中pandas.HDFStore.get_storer方法的典型用法代码示例。如果您正苦于以下问题:Python HDFStore.get_storer方法的具体用法?Python HDFStore.get_storer怎么用?Python HDFStore.get_storer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.HDFStore
的用法示例。
在下文中一共展示了HDFStore.get_storer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_xarray_to_HDF5
# 需要导入模块: from pandas import HDFStore [as 别名]
# 或者: from pandas.HDFStore import get_storer [as 别名]
def save_xarray_to_HDF5(dataArray, filename, complib=None):
"""Save the xarray DataArray to HDF file using pandas HDFStore
attrs will be saved as metadata via pickle
requries pytables
complib : {'zlib', 'bzip2', 'lzo', 'blosc', None}, default None"""
from pandas import HDFStore
f = HDFStore(filename, mode='w', complib=complib)
f.put('data', dataArray.to_pandas())
if len(dataArray.attrs) > 0:
f.get_storer('data').attrs.metadata = dataArray.attrs
f.close()
示例2: HDFStore
# 需要导入模块: from pandas import HDFStore [as 别名]
# 或者: from pandas.HDFStore import get_storer [as 别名]
import save_dist_m
import traintest as tt
import plot_results
df = gdb.get_current_data()
df.to_csv("per_day_from_pandas.csv")
# df = pd.read_csv("per_day_from_pandas.csv")
preprocess.normalize_by_event_count(df)
# hdf5 doesn't like unicode
df["country"] = df["country"].apply(lambda x: x.encode("ascii", "ignore"))
countrydict = preprocess.get_country_lookup(df)
hdf = HDFStore("project_data.h5")
hdf.put("per_day_preprocessed", df, format="table", data_columns=True)
hdf.get_storer("per_day_preprocessed").attrs.country_lookup = countrydict
##END PREPROCESSING
train_years = 5
test_years = 1
hdf = HDFStore("project_data.h5")
df = hdf["per_day_preprocessed"]
basename_out = "last_6_years"
train_start = 20091030
trainxy, testxy, countrylist = gtt.get_train_test(df, train_start, train_years, test_years)
train_x = trainxy[0]
train_y = trainxy[1]
test_x = testxy[0]
test_y = testxy[1]
np.savez(
"train_test_" + basename_out + ".npz",