具有非数字数据的pandas数据帧列将在resample上删除

时间:2015-01-11 01:46:19

标签: python pandas

我有pandas dataframe floatobject数据类型。 在resample ...

之前
Blended O2 (PPM)                int64
Eng Oil P (PSIG)              float64
Reactor T OUT1 (F)            float64
Reactor T OUT2 (F)            float64
Tank P (Oz/in^2)              float64
Stg1 Scrb P (PSIA)            float64
Active SD                      object
delta                 timedelta64[ns]
dtype: object

resample ...

之后
Blended O2 (PPM)      float64
Eng Oil P (PSIG)      float64
Reactor T OUT1 (F)    float64
Reactor T OUT2 (F)    float64
Tank P (Oz/in^2)      float64
Stg1 Scrb P (PSIA)    float64
dtype: object

当我resample数据时,objecttimedelta64[ns]列会被删除。

有解决方法吗?

1 个答案:

答案 0 :(得分:0)

找到它。您必须指定how='first',否则默认为mean无法使用非数字数据

df = df.resample('1Min',fill_method='ffill', how='first', limit=5)