【发布时间】:2020-02-22 23:24:57
【问题描述】:
product_ID Prodcut_Price Product_monthly_sale
1 24 2000.00
1 Nan 2500.00
1 26 Nan
1 28 2700.00
2 25 2400.00
2 Nan Nan
2 27 2600.00
我想根据product_id填写product_price列和product_sale列的nan值
【问题讨论】:
-
提供您预期的输出。还要说明你尝试了什么
-
也许你可以先做
df.groupby('product_id').mean()并将其临时存储。然后遍历dataframe,遇到Nan时,从临时dataframe中获取值。 -
我希望 NAN 值是使用 Fillna(median or mean) 替换但基于 product_id
-
到底是什么问题?你有没有尝试过,做过任何研究? Stack Overflow 不是免费的代码编写服务。 请参阅:tour、How to Ask、help center、meta.stackoverflow.com/questions/261592/…。
-
另外,这怎么不是你之前的问题的重复:stackoverflow.com/questions/60302731/… 你为什么不编辑那个问题呢?