python - categories the age of year and month using python pandas
问题描述
I am trying to categories the age of some people to a new columns
but I am facing a problem in doing that
I want to say if the his/her age in month >> put 0
def age(Age):
if Age < 6 :
return 0
elif Age <11 :
return 1
elif Age <16 :
return 2
elif Age <21 :
return 3
elif Age <26 :
return 4
elif Age <31 :
return 5
elif Age <36 :
return 6
else:
return 7
data['AGE_CD']=data['Age'].apply(age)
thank you.
解决方案
推荐阅读
- html - 移动网站背景图片未调整大小
- c - 有什么方法可以让我的函数更快地测试字符串的相等性?
- python - 如何获取 Pandas 索引位置和名称
- angular - Ionic 4 应用程序无法在 android Lollipop 中运行
- php - 将毫秒转换为分钟:得到不正确的结果
- html - Required attribute in multi step form
- webforms - 报告查看器 14 错误:无法加载表达式宿主程序集
- scala - 在 gradle 中使用 sbt Avrohugger 插件
- c# - jqgrid loadError没有触发
- for-loop - for循环中矩阵的特征值