问题描述
我在某些数据帧上做了一些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 (将#修改为@)