Python 具有非数字数据的数据帧列在重新采样时被删除
我有一个带有Python 具有非数字数据的数据帧列在重新采样时被删除,python,pandas,Python,Pandas,我有一个带有float和object数据类型的pandas数据帧。 在重新采样之前 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)
float
和object
数据类型的pandas数据帧。
在重新采样之前
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
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
在之后重新采样
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
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
当我对数据进行重采样时,对象和timedelta64[ns]
列将被删除
有办法解决这个问题吗?找到了。您必须指定how='first'
,否则它默认为mean
,这不能用非数字数据完成
df = df.resample('1Min',fill_method='ffill', how='first', limit=5)