Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第二章项目集合-第二章:第一节数据清洗及特征处理.ipynb部分答案错误 #15

Open
mrcangye opened this issue Jun 26, 2022 · 0 comments

Comments

@mrcangye
Copy link

1.df[df['Age']==None]

df[df['Age']==None]=0
df.head(3)

以上代码无法筛选出NaN值
2.df[df['Age'].isnull()]

df[df['Age'].isnull()] = 0 # 还好
df.head(3)

以上代码可以筛选出NaN值,但是df[df['Age'].isnull()] = 0会将NaN值所在行全部置0,使得结果有误,且后面的重复值相关代码使用的也是这一行代码生成的数据
3.df[df['Age'] == np.nan]

df[df['Age'] == np.nan] = 0
df.head()

以上代码中,np.nan不可以与任何数进行比较。使用np.isnan()进行修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant