“.cat” 在 “.cat.categories” 中是什么?

huangapple go评论61阅读模式
英文:

what is ".cat" in ".cat.categories"?

问题

我不确定.cat是什么,以及为什么我们需要它,而.categories本身已经在要求解释器列出所选类别了?例如,为什么我要使用这个:

housing_df.REMODEL.cat.categories

而不是这个:

housing_df.REMODEL.categories

Pandas文档解释了"String.cat.categories",但我不理解那个。

英文:

I am not sure what .cat is and why we need it while .categories itself is already asking the interpreter to list the category of choice ?
For example, why should I use this:

housing_df.REMODEL.cat.categories

And not this:

housing_df.REMODEL.categories

Pandas documentation explains "String.cat.categories" but I do not understand that.

答案1

得分: 0

.cat 被称为访问器对象。它允许您访问特定于分类列的属性和方法。在pandas中有类似的访问器:.dt 用于日期时间,.str 用于字符串,.plot 用于绘图等等。这是pandas开发人员做出的设计决策。通常,这些用于命名空间,以便更好地组织属性和方法,以避免名称冲突。

英文:

.cat is called an accessor object. It allows you to access attributes and methods that are specific to categorical columns. There are similar accessors in pandas: .dt for date-time, .str for string, .plot for plotting and so on. This is a design decision made by pandas developers. In general, these are used for namespacing so that attributes and methods are better organized and they don't cause name collision.

huangapple
  • 本文由 发表于 2023年7月3日 16:38:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76603130.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定