lundi 11 juillet 2016

pandas: Why does the dtype of a column change on assignment to a data frame

I have a pandas DataFrame bla with a MultiIndex for columns:

ipdb> bla.dtypes
phases      end              datetime64[ns]
            name                     object
            start            datetime64[ns]
parameters  scanFrequency           float64
            tideFile                 object

Now I am performing some simple interpolation on a part of that frame and assign the result back to it:

bla['parameters'] = bla['parameters'].ffill()

Strangely, I end up with a data frame where the dtype of scanFrequency has changed:

ipdb> bla.dtypes
phases      end              datetime64[ns]
            name                     object
            start            datetime64[ns]
parameters  scanFrequency            object
            tideFile                 object
dtype: object

Why does this happen? The ffill doesn't change the type:

ipdb> bla['parameters'].ffill().dtypes
scanFrequency    float64
tideFile          object
dtype: object

Aucun commentaire:

Enregistrer un commentaire