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

第二章第一节数据清洗及特征处理 #11

Open
Summerfat opened this issue Jan 15, 2022 · 0 comments
Open

第二章第一节数据清洗及特征处理 #11

Summerfat opened this issue Jan 15, 2022 · 0 comments

Comments

@Summerfat
Copy link

for循环,numpy.map转换对文本变量进行转换,构造映射时,.nunique()函数里的参数dropna应该是False
for feat in ['Cabin', 'Ticket']:
label_dict = dict(zip(df[feat].unique(), range(df[feat].nunique(dropna=False))))
df[feat + "_labelEncode"] = df[feat].map(label_dict)

不然的话,'Cabin'的C148这里会返回一个NaN值

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