Python - Pandas:AttributeError:'numpy.ndarray'对象没有属性'start'

时间:2013-06-11 13:02:30

标签: python numpy matplotlib pandas

Python - Pandas:AttributeError:'numpy.ndarray'对象没有属性'start'

生成错误的代码:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from datetime import time

data = pd.read_csv('/temp/zondata/pvlog.csv', delimiter=';', parse_dates=True, index_col=1)
Gewenst = data['T_Sanyo_Open']

不会出现任何错误,并提供类似于此问题底部的表格的结果:

Gewenst['2010']

Gewenst['2010-09']

当我想要特定的有限数据范围时,给我之前描述的错误:

Gewenst['2010-9':'2010-10']

我在添加此规则代码时找到了解决方案:

Gewenst = Gewenst.resample('1Min', fill_method='ffill') 

但我不想重新取样数据。

表:

2010-08-31 12:36:53    30.37
2010-08-31 12:45:08    28.03
2010-08-31 12:55:09    25.16
2010-08-31 13:00:09    23.28
2010-08-31 13:05:09    22.37
2010-08-31 13:10:09    21.84
2010-08-31 13:15:08    22.19
2010-08-31 13:20:09    22.41
2010-08-31 13:25:09    23.16
2010-08-31 13:35:09    23.59
2010-08-31 13:40:09    26.75
2010-08-31 13:45:09    29.47
2010-08-31 13:50:10    33.13
2010-08-31 13:55:08    35.91
2010-08-31 14:00:08    37.78
...
2013-06-07 01:35:10    40.00
2013-06-07 01:40:10    40.00
2013-06-07 01:45:10    39.50
2013-06-07 01:50:12    39.75
2013-06-07 01:55:10    39.25
2013-06-07 02:00:10    39.50
2013-06-07 02:05:11    39.25
2013-06-07 02:10:11    39.25
2013-06-07 02:15:10    38.75
2013-06-07 02:20:11    38.75
2013-06-07 02:25:11    38.75
2013-06-07 02:30:10    39.25
2013-06-07 02:40:10    39.25
2013-06-07 02:45:10    39.00
2013-06-07 02:50:10    39.25

有没有人有解决方案,或者这是Pandas中的错误?

1 个答案:

答案 0 :(得分:2)

包含0

似乎很重要
In [11]: df1['2010-7':'2010-10']
Out[11]:
Empty DataFrame
Columns: [value]
Index: []

In [12]: df1['2010-07':'2010-10']
Out[12]:
                     value
date
2010-08-31 12:36:53  30.37
2010-08-31 12:45:08  28.03
2010-08-31 12:55:09  25.16
2010-08-31 13:00:09  23.28
...

值得filing an issue ...