<p>我是熊猫的新手,我想检查一下df的所有列是否相同。然而,我试着这样做,但我得到了一个错误</p>
<pre><code>print(df.columns)
Index(['age', 'car', 'car_name'], dtype='object')
</code></pre>
<p>其中,age、car是int,float和car_name是一个对象</p>
<pre><code>for i in df:
if df[i].dtypes == int or df[i].dtypes == float:
print('yes')
else:
print('no')
this gives:
yes
yes
no
</code></pre>
<p>但我想给出的是总体上的结果,比如如果所有列都有int或float,那么它应该打印yes或no(通过使用<code>if else</code>条件)</p>
<p>例外输出:</p>
<pre><code>for i in df:
if all column of df == int or all column of df == float:
print('yes')
else:
print('no')
output: 'No'
</code></pre>