【发布时间】:2021-04-24 13:38:39
【问题描述】:
用于重现问题、笔记本、数据、输出:github link
我的数据集中有合同变量/列,看起来像这样,看起来都像数字,但它们实际上是分类的。
当使用 pandas 读取时,信息显示它被读取为 int。由于合同变量是一个类别(来自我收到的元数据),所以我手动更改了变量类型,如下所示
df['Contract'] = df['Contract'].astype('categorical')
df.dtypes # shows modified dtype now
然后我尝试从pandas_profiling 获取报告。生成的报告显示contact 被解释为实数,即使我将类型从int 更改为str/category。
# Tried both, but resulted in same.
ProfileReport(df)
df.profile_report()
您能解释一下用pandas_profiling 解释数据类型的正确方法吗?即,将contract 变量更改为categorical 类型。
【问题讨论】:
-
你能做一个可重现的例子吗?
-
这属于问题,而不是要点
-
将该信息复制并粘贴到问题中。链接腐烂了,这个问题没有任何意义
标签: python python-3.x pandas data-analysis pandas-profiling