如何解决分析列中的混合dtype
我在某些数据帧上做了一些merge
,另存为csv,然后,最终的数据集有很多列。通过分析这些列,我意识到其中一些具有混合dtype。
我试图创建任何def
函数来遍历所有列,并发现它是否发生在其他列上(逐列)。我做了,但是结果似乎是“ nonetype”对象。我无法将def
的结果放入变量并视为表格。
我的输出:
df['customer_zip_code_prefix'].map(type).value_counts()
<class 'int'> 101617
<class 'str'> 16384
Name: customer_zip_code_prefix,dtype: int64
- 然后我创建
def
def hasmix_0(df):
coluna_lista = df.columns.tolist()
for cada in coluna_lista:
print(df[cada].map(type).value_counts())
<class 'str'> 117998
<class 'float'> 3
Name: customer_id,dtype: int64
<class 'str'> 118001
Name: customer_unique_id,dtype: int64
<class 'int'> 101617
<class 'str'> 16384
Name: customer_zip_code_prefix,dtype: int64
<class 'str'> 117998
<class 'float'> 3
Name: customer_city,dtype: int64
<class 'str'> 117998
<class 'float'> 3
Name: customer_state,dtype: int64
<class 'float'> 118001
Name: geolocation_zip_code_prefix,dtype: int64
<class 'float'> 118001
Name: geolocation_lat,dtype: int64
我读到一些NaN
值变成浮点数,但是我提到的例子并非如此。我想验证在merge
之后是否可能犯了任何错误。
如何将结果转换为表/数据框?
先谢谢大家
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。