类型为“ float”的Python LSTM数据加载器对象没有len()

时间:2019-07-31 09:24:41

标签: python pandas csv typeerror

我正在加载一个csv文件,但是它给了我一个意外的错误。我想知道如何解决它。 我在网上搜索了解决方案,但找不到任何解决方法。

我使用的代码:

dataset = read_csv('household_power_consumption.csv', header=0, infer_datetime_format=True, parse_dates=['datetime'], index_col=['datetime'])

它生成的错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
c:\program files\python36\lib\site-packages\numpy\lib\shape_base.py in split(ary, indices_or_sections, axis)
    842     try:
--> 843         len(indices_or_sections)
    844     except TypeError:

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

CSV数据示例:

datetime,Global_active_power,Global_reactive_power,Voltage,Global_intensity,Sub_metering_1,Sub_metering_2,Sub_metering_3,sub_metering_4
2006-12-16 17:24:00,4.216,0.418,234.84,18.4,0.0,1.0,17.0,52.26667
2006-12-16 17:25:00,5.36,0.436,233.63,23.0,0.0,1.0,16.0,72.333336
2006-12-16 17:26:00,5.374,0.498,233.29,23.0,0.0,2.0,17.0,70.566666

0 个答案:

没有答案