《利用Python进行数据分析》,第7章-离散化和面元划分,这一章节提到Categorical对象,含有一个表示不同分类名称的levels数组和一个标号的labels属性。
按照书中代码测试的时候,系统反馈:
'Categorical' object has no attribute 'levels' 'Categorical' object has no attribute 'index'
经至官方文档查询,结果如下:
Categorical.labels:Get the category labels (deprecated). Deprecated, use .codes!
labels属性停止使用,现在为Categorical.codes
Categorical.levels:Gets the levels deprecated, use “categories”
levels属性停止使用,现在为Categorical.categories