I have a pandas DataFrame object named xiv that has an int64 column of int64 Dimensions.
In[]: xiv['Volume'].head(5) Out[]: 0 252000 1 484000 2 62000 3 168000 4 232000 Name: Volume, dtype: int64
I read other posts (like this and this ) that offer the following solutions. But when I use any approach, it does not change the dtype underlying data:
In[]: xiv['Volume'] = pd.to_numeric(xiv['Volume']) In[]: xiv['Volume'].dtypes Out[]: dtype('int64')
Or...
In[]: xiv['Volume'] = pd.to_numeric(xiv['Volume']) Out[]: In[]: xiv['Volume'].dtypes Out[]: dtype('int64') In[]: xiv['Volume'] = xiv['Volume'].apply(pd.to_numeric) In[]: xiv['Volume'].dtypes Out[]: dtype('int64')
I also tried to make a separate pandas Series and use the methods listed above in this series and reassign to the object x['Volume'] , which is the object pandas.core.series.Series .
However, I found a solution to this problem using the numpy package float64 type - , but I don't know why it is different .
In[]: xiv['Volume'] = xiv['Volume'].astype(np.float64) In[]: xiv['Volume'].dtypes Out[]: dtype('float64')
Can someone explain how to do with the pandas library what the numpy library seems to do easily with its class float64 ; i.e. convert the column in xiv DataFrame to float64 in place.
source share