pandasのdataframeで各列の型確認方法
df.dtypes
サンプル
import pandas as pd
df = pd.DataFrame([[25,'pika',88],[131,'rara',80],[143,'gon',82],
[3,'fushi',84],[6,'kage',84],[9,'kame',84]],
columns=['no','name','level'])
print(df)
"""
no name level
0 25 pika 88
1 131 rara 80
2 143 gon 82
3 3 fushi 84
4 6 kage 84
5 9 kame 84
"""
print(df.dtypes)
"""
no int64
name object
level int64
dtype: object
"""
pandas APIリファレンス
property DataFrame.dtypes
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.dtypes.html
コメント