繁体   English   中英

具有非数值数据的pandas数据框列在重新采样时被删除

[英]pandas dataframe columns with non-numeric data get deleted on resample

我有一个带有floatobject数据类型的pandas dataframe 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]列将被删除。

有没有解决的办法?

找到了。 您必须指定how='first'否则默认为非数值数据无法完成的mean

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM