serenade
serenade

Reputation: 359

AttributeError: 'list' object has no attribute 'dtype'

I have trouble with Bollinger Band algorithm. I want to apply this algorithm to my time series data.

The code:

length = 1440

dataframe = pd.DataFrame(speed)

ave = pd.stats.moments.rolling_mean(speed,length)

sd = pd.stats.moments.rolling_std(speed,length=1440)

upband = ave + (sd*2)

dnband = ave - (sd*2)

print np.round(ave,3), np.round(upband,3), np.round(dnband,3)

Input:

speed=[96.5, 97.0, 93.75, 96.0, 94.5, 95.0, 94.75, 96.0, 96.5, 97.0, 94.75, 97.5, 94.5, 96.0, 92.75, 96.5, 91.5, 97.75, 93.0, 96.5, 92.25, 95.5, 92.5, 95.5, 94.0, 96.5, 94.25, 97.75, 93.0]

Result of "ave" variable:

[1440 rows x 1 columns] 0 0 NaN 1 NaN 2 NaN 3 NaN 4 NaN 5 NaN 6 NaN 7 NaN 8 NaN 9 NaN 10 NaN 11 NaN 12 NaN 13 NaN 14 NaN 15 NaN 16 NaN 17 NaN

Upvotes: 0

Views: 14625

Answers (1)

Stefan Reinhardt
Stefan Reinhardt

Reputation: 622

The first point is, as i allready mentioned in the comment rolling_mean needs a DataFrame you can achieve this by inserting the line

speed = pd.DataFrame(data=speed) 

before the ave = ... line. Nonetheless you also missed to define the window attribute in rolling_std (See: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.rolling_std.html)

Upvotes: 1

Related Questions