In [28]: df = DataFrame({ 'A' : np.random.rand(5),
'B' : range(5),
'C' : date_range('20130101',periods=5,freq='T')})
In [29]: df
Out[29]:
A B C
0 0.067509 0 2013-01-01 00:00:00
1 0.872840 1 2013-01-01 00:01:00
2 0.379634 2 2013-01-01 00:02:00
3 0.552827 3 2013-01-01 00:03:00
4 0.996150 4 2013-01-01 00:04:00
[5 rows x 3 columns]
In [30]: df.dtypes
Out[30]:
A float64
B int64
C datetime64[ns]
dtype: object
Table
형식을 작성하십시오.
In [32]: df.to_hdf('test.h5','df',mode='w',format='table')
(이 NumPy와 저장 기본 데이터와 동일하다)
In [33]: !ptdump -avd test.h5
/(RootGroup) ''
/._v_attrs (AttributeSet), 4 attributes:
n [32]: df.to_hdf('test.h5','df',mode='w',format='table')
In [33]: !ptdump -avd test.h5
/(RootGroup) ''
/._v_attrs (AttributeSet), 4 attributes:
[CLASS := 'GROUP',
PYTABLES_FORMAT_VERSION := '2.1',
TITLE := '',
VERSION := '1.0']
/df (Group) ''
/df._v_attrs (AttributeSet), 14 attributes:
[CLASS := 'GROUP',
TITLE := '',
VERSION := '1.0',
data_columns := [],
encoding := None,
index_cols := [(0, 'index')],
info := {1: {'type': 'Index', 'names': [None]}, 'index': {}},
levels := 1,
nan_rep := 'nan',
non_index_axes := [(1, ['A', 'B', 'C'])],
pandas_type := 'frame_table',
pandas_version := '0.10.1',
table_type := 'appendable_frame',
values_cols := ['values_block_0', 'values_block_1', 'values_block_2']]
/df/table (Table(5,)) ''
description := {
"index": Int64Col(shape=(), dflt=0, pos=0),
"values_block_0": Float64Col(shape=(1,), dflt=0.0, pos=1),
"values_block_1": Int64Col(shape=(1,), dflt=0, pos=2),
"values_block_2": Int64Col(shape=(1,), dflt=0, pos=3)}
byteorder := 'little'
chunkshape := (2048,)
autoindex := True
colindexes := {
"index": Index(6, medium, shuffle, zlib(1)).is_csi=False}
/df/table._v_attrs (AttributeSet), 19 attributes:
[CLASS := 'TABLE',
FIELD_0_FILL := 0,
FIELD_0_NAME := 'index',
FIELD_1_FILL := 0.0,
FIELD_1_NAME := 'values_block_0',
FIELD_2_FILL := 0,
FIELD_2_NAME := 'values_block_1',
FIELD_3_FILL := 0,
FIELD_3_NAME := 'values_block_2',
NROWS := 5,
TITLE := '',
VERSION := '2.7',
index_kind := 'integer',
values_block_0_dtype := 'float64',
values_block_0_kind := ['A'],
values_block_1_dtype := 'int64',
values_block_1_kind := ['B'],
values_block_2_dtype := 'datetime64',
values_block_2_kind := ['C']]
Data dump:
[0] (0, [0.06750856214219292], [0], [1356998400000000000])
[1] (1, [0.8728395428343044], [1], [1356998460000000000])
[2] (2, [0.37963409103250334], [2], [1356998520000000000])
[3] (3, [0.5528271410494643], [3], [1356998580000000000])
[4] (4, [0.9961498806897623], [4], [1356998640000000000])
datetime64[ns]
가 UTC에서 에포크 나노초 직렬화 및 int64
열 형식으로 저장된 파일의 내부 구조를 나타낸다. 따라서 표준 HDF5 형식이므로이를 읽는 것이 매우 간단합니다. 그러나 메타 데이터를 해석하려면 필요합니다. 소스 파일은 pandas/io/pytables.py
을 참조하십시오.
기본적으로 datetime64
종류의 블록을 찾습니다 (종류에 따라 해당 이름이 매핑됩니다). 그럼 당신은 당신이 pd.to_datetime(ns_since_epoch,unit='ns')
할 것 팬더에서 IDL/MATLAB에서 변환을 (리버스 수있는 값은 UTC, 그리고 시간대가 info
특성에 저장됩니다으로 시간대가 조금 더 까다 롭
참고 :..이 약간 다르다 Fixed
형식의 메타 데이터 해석 또는 data_columns
(매우 어렵지는 않음)이있는 경우 (매우 어렵지는 않음)
http://stackoverflow.com/questions/8776414/python-datetime-to-matlab-datenum –
나는 그것을 보았지만, 대답은 단지 그것을 피할 수 있다면, 내가 원한 것이 아닌 파이썬 측의 문자열로 직렬화하도록 제안한다. datetime 객체를 저장하는 것이 훨씬 효율적일 것이다. –
@TomRon 참조 된 질문에 답할 수 없다. 이거, 그냥 "끈으로 만들라"고 말하는거야? –