ValueError: dtype buffer mismatch, expected value 'float64_t', but received 'float'

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 redo it as shown below:

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

it will throw an exception:

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

what problem? how can i fix this? thanks

+3
source share
2 answers

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

and FYI for direct type conversion

 df.astype('float64') 

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

+5
source

this can solve this problem:

 from numpy import float64 remod=float64(modtso[0]).resample('D',how=['std']) 
0
source

Source: https://habr.com/ru/post/1201958/


All Articles