gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 03:58:32 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com