Python- Pandas : AttributeError: 'numpy.ndarray' object has no attribute 'start'

标签 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 中的一个错误?

最佳答案

看起来包含 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 ...

关于Python- Pandas : AttributeError: 'numpy.ndarray' object has no attribute 'start' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17044808/

相关文章:

python - 来自数组的直方图 matplotlib

python - matplotlib 中的复杂极坐标图

python - 使用字典映射 numpy 数组?

python - 如何使用Python从特定位置读取文件到特定位置?

Python - 用于列表理解的动态过滤器?

python - 拉取历史 channel 消息python

python - 如何将 boolean 掩码存储为 Cython 类的属性?

python - 安装Matplotlib : Command "python setup.py egg_info" failed with error code 1 (proposed solutions did not work)

python - Selenium Python - 无法定位元素 - 该网站被屏蔽了吗? (影子 DOM)

python - 如何使用 Torch Vision 在 Google Colab 上加载 CelebA 数据集,而不会耗尽内存?