![](/img/trans.png)
[英]Sum all columns in a Pandas DataFrame where there are non-numeric values
[英]pandas dataframe columns with non-numeric data get deleted on resample
我有一个带有float
和object
数据类型的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
数据时, object
和timedelta64[ns]
列将被删除。
有没有解决的办法?
找到了。 您必须指定how='first'
否则默认为非数值数据无法完成的mean
df = df.resample('1Min',fill_method='ffill', how='first', limit=5)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.