Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: Buffer dtype mismatch, expected 'float64_t' but got 'float'

Tags:

python

pandas

There is a DataFrame 'modtso':

In [4]: modtso
Out[4]: 
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 74006 entries, 2002-07-27 15:00:00 to 2010-12-31 22:58:08
Data columns:
0    74006  non-null values
dtypes: float32(1)

In [5]: modtso[1:10]
Out[5]: 
                         0
2002-07-27 16:01:53   9.336845
2002-07-27 16:58:08   9.337487
2002-07-27 18:00:00   9.343308
2002-07-27 19:01:53   9.364368
2002-07-27 19:58:08   9.389445
...

Now I want to resample it as below:

a=modtso.resample('D',how='std')

it will raise a exception:

ValueError: Buffer dtype mismatch, expected 'float64_t' but got 'float'

what's the problem? how can I fix it? thanks

like image 399
wuwucat Avatar asked Feb 20 '13 16:02

wuwucat


2 Answers

this is fully supported on 0.11-dev in 0.10 I think it will work, but your float32 will become float64 for almost any operation

and FYI to convert types explicitly

df.astype('float64')

see the examples here http://pandas.pydata.org/pandas-docs/dev/whatsnew.html#v0-11-0-march-2013

like image 148
Jeff Avatar answered Oct 19 '22 13:10

Jeff


do this can solve this problem:

from numpy import float64
remod=float64(modtso[0]).resample('D',how=['std'])
like image 25
wuwucat Avatar answered Oct 19 '22 13:10

wuwucat