age income student credit_rating Class_buys_computer
0 youth high no fair no
1 youth high no excellent no
2 middle_aged high no fair yes
3 senior medium no fair yes
4 senior low yes fair yes
5 senior low yes excellent no
6 middle_aged low yes excellent yes
7 youth medium no fair no
8 youth low yes fair yes
9 senior medium yes fair yes
10 youth medium yes excellent yes
11 middle_aged medium no excellent yes
12 middle_aged high yes fair yes
13 senior medium no excellent no
我正在使用这个数据集,并且希望像age
,income
等变量像factor variables
在R
中,我如何在python中做到这一点
您可以将^{} 与参数
category
一起使用:如果需要转换所有列:
^{pr2}$您需要循环,因为如果使用:
Pandas documentation about categorical。在
按注释编辑:
如果需要有序分类,请使用另一个带有^{} 的解决方案:
然后可以按列
age
对数据帧进行排序:相关问题 更多 >
编程相关推荐