擅长:python、mysql、java
<p>首先注意,数据类型不一定反映Python内置类型。例如,没有<code>str</code>dtype这样的东西。在Pandas中,字符串存储在<code>object</code>dtype系列中,表示指向任意对象的指针</p>
<p>您可以使用列表理解并指定给列:</p>
<pre><code>df.columns = [f'{col} ({col_type})' for col, col_type in zip(df, df.dtypes)]
print(df)
animal (object) age (int64)
0 alligator 12
1 bee 13
2 falcon 1
3 lion 15
4 monkey 14
5 parrot 44
6 shark 100
7 whale 200
8 zebra 14
</code></pre>
<p>对于您的用例,只需打印<code>df.dtypes</code>就足够了</p>