例如:
df = pd.DataFrame([[int(1),2,3],[int(5),6,'a'],[0.1,4,True]], columns = list("abc"))
df
a b c
0 1.0 2 3
1 5.0 6 a
2 0.1 4 True
副问题:为什么声明 int
不会有任何影响?
现在,df.dtypes
返回
a float64
b int64
c object
dtype: object
但是在一列中列出所有不同的数据类型是否可能?
比如:
a int64, float64
b int64
c int64, str, bool
include=[df[c].dtype for c in df.columns]
。 - Raksha