数据分析小技巧1:使用map对列做特征工程
点击上方蓝色字体,关注程序员zhenguo
你好,我是 zhenguo
接下来逐步分析常用的数据分析小技巧
小技巧1:如何使用map对某些列做特征工程?
先生成数据:
d = {
"gender":["male", "female", "male","female"],
"color":["red", "green", "blue","green"],
"age":[25, 30, 15, 32]
}
df = pd.DataFrame(d)
df
在
gender
列上,使用 map 方法,快速完成如下映射:d = {"male": 0, "female": 1}
df["gender2"] = df["gender"].map(d)
zhenguo原创精华PDF,倾情奉献给你,后台回复对应关键词下载,给文章点个赞:
阅读原文 关键词
小技巧
特征
数据分析
常用
后台
最新评论
推荐文章
作者最新文章
你可能感兴趣的文章
Copyright Disclaimer: The copyright of contents (including texts, images, videos and audios) posted above belong to the User who shared or the third-party website which the User shared from. If you found your copyright have been infringed, please send a DMCA takedown notice to [email protected]. For more detail of the source, please click on the button "Read Original Post" below. For other communications, please send to [email protected].
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。