Python fillna串联无
我想在上面的系列中为NaNs填充None,但它告诉我们: ValueError:必须指定填充“值”或“方法” 我找到的所有解决方案都使用数据帧,但我需要一个系列。我如何才能做到这一点?尝试:Python fillna串联无,python,pandas,Python,Pandas,我想在上面的系列中为NaNs填充None,但它告诉我们: ValueError:必须指定填充“值”或“方法” 我找到的所有解决方案都使用数据帧,但我需要一个系列。我如何才能做到这一点?尝试: pd.Series([1,1,1,1, "something", 1]).astype(float).cumsum().fillna(None) 注意:pd.Series([1,1,1,1,“something”,1]).astype(float).cumsum()如果在pd.to\u numeric中
pd.Series([1,1,1,1, "something", 1]).astype(float).cumsum().fillna(None)
注意:
pd.Series([1,1,1,1,“something”,1]).astype(float).cumsum()
如果在pd.to\u numeric
中没有errors='concurve
,将无法工作。另外,返回的dtype
是dtype:object
s=pd.to_numeric(pd.Series([1,1,1,1, "something", 1]),errors='coerce').cumsum()
s.mask(s.isnull(),None)
0 1
1 2
2 3
3 4
4 None
5 5