📜  pandas 将多列转换为分类 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:12.542000             🧑  作者: Mango

代码示例1
#Two ways to do this
df[['parks', 'playgrounds', 'sports']].apply(lambda x: x.astype('category'))

cols = ['parks', 'playgrounds', 'sports', 'roading']:
public[cols] = public[cols].astype('category')