用法:
Series.combine_first(other)
使用 ‘other’ 中相同位置的值更新 null 元素。
通過將一個 Series 中的 null 值與另一個 Series 中的非 null 值填充來組合兩個 Series 對象。結果索引將是兩個索引的並集。
- other:Series
用於填充空值的值。
- Series
將提供的 Series 與其他對象組合的結果。
參數:
返回:
例子:
>>> s1 = pd.Series([1, np.nan]) >>> s2 = pd.Series([3, 4, 5]) >>> s1.combine_first(s2) 0 1.0 1 4.0 2 5.0 dtype:float64
如果空值的位置在
other
中不存在,空值仍然存在>>> s1 = pd.Series({'falcon':np.nan, 'eagle':160.0}) >>> s2 = pd.Series({'eagle':200.0, 'duck':30.0}) >>> s1.combine_first(s2) duck 30.0 eagle 160.0 falcon NaN dtype:float64
相關用法
- Python pandas.Series.combine用法及代碼示例
- Python pandas.Series.compare用法及代碼示例
- Python pandas.Series.convert_dtypes用法及代碼示例
- Python pandas.Series.copy用法及代碼示例
- Python pandas.Series.cov用法及代碼示例
- Python pandas.Series.count用法及代碼示例
- Python pandas.Series.corr用法及代碼示例
- Python pandas.Series.cat.remove_categories用法及代碼示例
- Python pandas.Series.cat用法及代碼示例
- Python pandas.Series.cat.rename_categories用法及代碼示例
- Python pandas.Series.cumsum用法及代碼示例
- Python pandas.Series.cat.add_categories用法及代碼示例
- Python pandas.Series.cumprod用法及代碼示例
- Python pandas.Series.cummin用法及代碼示例
- Python pandas.Series.cummax用法及代碼示例
- Python pandas.Series.clip用法及代碼示例
- Python pandas.Series.cat.remove_unused_categories用法及代碼示例
- Python pandas.Series.add_prefix用法及代碼示例
- Python pandas.Series.map用法及代碼示例
- Python pandas.Series.max用法及代碼示例
注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.Series.combine_first。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。