Skip to content

Pandas: AttributeError: 'numpy.ndarray' object has no attribute 'start' #3901

Closed
Jomme5 opened this Issue Jun 14, 2013 · 5 comments

2 participants

@Jomme5
Jomme5 commented Jun 14, 2013
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']

Next 2 examples(in Ipython console) gives no errors, and gives a result like the table at the bottom of this question:

Gewenst['2010']

Gewenst['2010-09']

Example below gives me previously described error when I want a specific bounded range of data:

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

I found a solution when I add this rule of code:

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

But I don't want to resample the data.

table:

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

Does anyone have solution, or is this a bug in Pandas?

@jreback
jreback commented Jun 14, 2013

can you do Gewenst.index
what version are you on?

this works fine on master

In [22]: idx=date_range('20100831 12:36:12','20130607 02:50:10',freq='5min')

In [23]: s = Series(randn(len(idx)),index=idx)

In [24]: s
Out[24]: 
2010-08-31 12:36:12    0.353337
2010-08-31 12:41:12   -0.130280
2010-08-31 12:46:12   -0.877314
2010-08-31 12:51:12   -0.083523
2010-08-31 12:56:12    0.726122
2010-08-31 13:01:12   -0.494465
2010-08-31 13:06:12    3.297751
2010-08-31 13:11:12   -0.008441
2010-08-31 13:16:12    0.004054
2010-08-31 13:21:12   -0.817801
2010-08-31 13:26:12    1.033889
2010-08-31 13:31:12    0.243261
2010-08-31 13:36:12   -1.968894
2010-08-31 13:41:12   -0.964785
2010-08-31 13:46:12    0.684730
...
2013-06-07 01:41:12   -0.069272
2013-06-07 01:46:12    0.515349
2013-06-07 01:51:12    1.647108
2013-06-07 01:56:12   -1.778900
2013-06-07 02:01:12    0.399315
2013-06-07 02:06:12    2.351048
2013-06-07 02:11:12   -0.601412
2013-06-07 02:16:12   -1.263214
2013-06-07 02:21:12    0.560712
2013-06-07 02:26:12   -2.050404
2013-06-07 02:31:12   -0.816541
2013-06-07 02:36:12   -0.795148
2013-06-07 02:41:12   -1.639828
2013-06-07 02:46:12    1.830096
2013-06-07 02:51:12    0.130479
Freq: 5T, Length: 291052, dtype: float64

In [25]: s['2010-9':'2010-10']
Out[25]: 
2010-09-01 00:01:12    0.543788
2010-09-01 00:06:12   -0.814028
2010-09-01 00:11:12    0.172852
2010-09-01 00:16:12   -0.819149
2010-09-01 00:21:12    0.243942
2010-09-01 00:26:12    1.416024
2010-09-01 00:31:12    2.495747
2010-09-01 00:36:12    2.117359
2010-09-01 00:41:12    1.457635
2010-09-01 00:46:12    0.787397
2010-09-01 00:51:12    0.704301
2010-09-01 00:56:12    0.500297
2010-09-01 01:01:12   -1.336083
2010-09-01 01:06:12    0.605212
2010-09-01 01:11:12   -0.465229
...
2010-10-31 22:46:12   -0.785330
2010-10-31 22:51:12   -0.562162
2010-10-31 22:56:12    0.630652
2010-10-31 23:01:12   -2.633188
2010-10-31 23:06:12   -1.085584
2010-10-31 23:11:12    0.273801
2010-10-31 23:16:12    0.405266
2010-10-31 23:21:12   -1.119378
2010-10-31 23:26:12   -0.209942
2010-10-31 23:31:12   -0.141423
2010-10-31 23:36:12    1.998829
2010-10-31 23:41:12   -1.081393
2010-10-31 23:46:12   -1.339726
2010-10-31 23:51:12    1.960962
2010-10-31 23:56:12    0.616947
Freq: 5T, Length: 17568, dtype: float64

In [26]: s.index
Out[26]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2010-08-31 12:36:12, ..., 2013-06-07 02:51:12]
Length: 291052, Freq: 5T, Timezone: None

In [27]: pd.__version__
Out[27]: '0.11.1.dev-5745a93'

@Jomme5
Jomme5 commented Jun 17, 2013

Pandas version: '0.11.0'

Your example given does also work on my system. I think you have to load the data explicitly from a csv-file instead of generating random data.. When I do a Gewenst.index call on the csv-loaded data I get 'Freq: None' Maybe that has something to do with it.

@jreback
jreback commented Jun 17, 2013

Works even w/o frequency. Please post a sample of your csv, something else is going on

In [15]: idx=pd.DatetimeIndex(list(date_range('20100831 12:36:12',periods=100)) + [Timestamp('20130607 3:00:00')])

In [16]: s = Series(randn(len(idx)),index=idx)

In [17]: s['2010-9':'2010-10']
Out[17]: 
2010-09-01 12:36:12    2.507662
2010-09-02 12:36:12   -1.251990
2010-09-03 12:36:12   -0.072563
2010-09-04 12:36:12   -2.117106
2010-09-05 12:36:12    0.470904
2010-09-06 12:36:12    0.289158
2010-09-07 12:36:12    0.288090
2010-09-08 12:36:12   -0.985163
2010-09-09 12:36:12    0.091366
2010-09-10 12:36:12   -0.741078
2010-09-11 12:36:12   -0.406727
2010-09-12 12:36:12    0.701876
2010-09-13 12:36:12    1.323663
2010-09-14 12:36:12    1.039989
2010-09-15 12:36:12    0.369407
...
2010-10-17 12:36:12    0.541333
2010-10-18 12:36:12   -0.831149
2010-10-19 12:36:12   -0.906107
2010-10-20 12:36:12    0.971526
2010-10-21 12:36:12    0.881118
2010-10-22 12:36:12   -0.152908
2010-10-23 12:36:12    0.483988
2010-10-24 12:36:12    1.725090
2010-10-25 12:36:12   -0.156820
2010-10-26 12:36:12    0.167400
2010-10-27 12:36:12   -0.237716
2010-10-28 12:36:12    1.450586
2010-10-29 12:36:12   -0.095264
2010-10-30 12:36:12   -0.526731
2010-10-31 12:36:12   -0.332295
Length: 61, dtype: float64

In [18]: s.index
Out[18]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2010-08-31 12:36:12, ..., 2013-06-07 03:00:00]
Length: 101, Freq: None, Timezone: None
@Jomme5
Jomme5 commented Jun 18, 2013

You can download the complete datafile from: http://www.tempfiles.net/download/201306/306175/pvlog.html

@jreback
jreback commented Jun 18, 2013

@Jomme5

ok this shows the same error on 0.11.0, but is fixed in master

thanks

@jreback jreback closed this Jun 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.