题解 | #修补缺失的用户数据#
修补缺失的用户数据
https://www.nowcoder.com/practice/9863e81c8eba4c33817b26b801a17313
import pandas as pd data = pd.read_csv("Nowcoder.csv") pd.set_option("display.width", 300) # 设置字符显示宽度 pd.set_option("display.max_rows", None) # 设置显示最大行 pd.set_option("display.max_columns", None) max_year = data["Graduate_year"].max() avg_achieve = data["Achievement_value"].mean() data["Language"].fillna("Python") data["Achievement_value"].fillna(int(avg_achieve)) data["Graduate_year"].fillna(max_year) print(data)
针对列进行缺失值修补