【发布时间】:2022-02-18 16:55:30
【问题描述】:
得到数据框df
State Item Space Date
AAA Grape 0.125 2022-02-11
Beans 0.0
AAA Mango 0.25 2022-02-11
AAA Beetroot 0.375 2022-02-11
Carrot 0.5
需要用该列的唯一值填充行中的空值。
试过df['State'].fillna(df['State'].unique(), inplace=True),没用。
预期输出:
State Item Space Date
AAA Grape 0.125 2022-02-11
AAA Beans 0.0 2022-02-11
AAA Mango 0.25 2022-02-11
AAA Beetroot 0.375 2022-02-11
AAA Carrot 0.5 2022-02-11
【问题讨论】:
-
您需要第一列和最后一列的常量值吗?还是有一些群?
标签: python-3.x pandas dataframe unique fillna