我的剧本是这样的:
trc
文件读取时间序列(UHF测量)pd.DataFrame
DataFrames
保存到一个hdf5
文件中这很好,但是tables
模块似乎为每个DataFrame
抛出了一个NaturalNameWarning
。你知道吗
这是DataFrames
保存到hdf5
的地方:
num = 0
for idx, row in df_oszi.iloc[peaks].iterrows():
start_peak = idx - 1*1e-3
end_peak = idx + 10*1e-3 #tges=11us
df_pos = df_oszi[start_peak:end_peak]
df_pos.to_hdf('pos.h5', key=str(num))
num += 1
输出:
Warning (from warnings module):
File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\tables\path.py", line 157
check_attribute_name(name)
NaturalNameWarning: object name is not a valid Python identifier: '185'; it does not match the pattern ``^[a-zA-Z_][a-zA-Z0-9_]*$``; you will not be able to use natural naming to access this object; using ``getattr()`` will still work, though
这是一个警告。这意味着您不能使用PyTables自然命名约定来访问名为
185
的数据集。如果您不打算使用PyTables,这不是问题。如果要使用PyTables,则必须使用File.get_node(where)
访问此组名。两种方法的比较(其中h5f是我的HDF5文件对象):
h5f.get_node('/185') # works
tb1nn = h5f.root.185 # gives Python invalid syntax error
将组名更改为
t185
,就可以使用自然命名。 请参见下面的PyTables代码示例以显示差异:相关问题 更多 >
编程相关推荐