问题描述
我试图在 python 中提取每列的模式计数,以找到最高频率的百分比以删除方差较低的列
col = test_df.columns
for i in col:
x = test_df[i].mode()
y = test_df[i][test_df[i]==x][i]
print(i,x,y)
ValueError: Can only compare identically-labelled Series objects
x = test_df['1stFlrsF'].mode()
x
0 864
dtype: int64
解决方法
您可以尝试在以下行中仅获取模式值而不显示其数据类型 x[0].