【问题标题】:Appending HDFStore pandas TypeError附加 HDFStore 熊猫 TypeError
【发布时间】:2020-07-29 18:14:01
【问题描述】:

根据https://stackoverflow.com/a/46206376/11578009我正在尝试追加HDFStore文件

import pandas as pd
hdfStore = pd.HDFStore('dataframe.h5')

#df=
#a              b               c                       d   f
#0             125           -6.450  ...                0  2020-04-#16T02:30:00
#2             124           -6.403  ...                0  2020-04-#16T02:30:00
#4             128           -6.403  ...                0  2020-04-#16T02:30:00
#
#[3 rows x 5 columns]

hdfStore.append('df', df,  format='t',data_columns=True )

尝试将此 df 附加到 hdfStore 会抛出:

TypeError: object of type 'int' has no len()

【问题讨论】:

    标签: python pandas hdf5


    【解决方案1】:

    我在复制错误时找到了答案,但也许对某人有用。

    当使用的 pd.DataFrame 中的 dtypes 为时不会发生错误

    df.dtypes
    Out[65]: 
    time_diffrences     int64
    temp_diffrences     int64
    label              object
    dtype: object
    

    所以 dtypes 不能是例如整数的“对象”

    【讨论】:

      猜你喜欢
      • 2014-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      相关资源
      最近更新 更多