使用Python将int64类型转换为分类

时间:2015-03-12 11:49:34

标签: python pandas types dataframe

如何将类型为int64的数据帧(所有列)转换为分类?

dfTrain.info()

<class 'pandas.core.frame.DataFrame'>
Int64Index: 25010 entries, 0 to 25009
Data columns (total 11 columns):
S1      25010 non-null int64
C1      25010 non-null int64
S2      25010 non-null int64
C2      25010 non-null int64
S3      25010 non-null int64
C3      25010 non-null int64
S4      25010 non-null int64
C4      25010 non-null int64
S5      25010 non-null int64
C5      25010 non-null int64
hand    25010 non-null int64
dtypes: int64(11)

以下是数据框架的概述:

dfTrain.head()
Out[145]:
S1  C1  S2  C2  S3  C3  S4  C4  S5  C5  hand    hand2
0   4   9   2   1   2   2   4   7   2   8   0   0
1   1   4   3   6   1   12  3   11  2   7   0   0
2   1   11  4   1   3   7   4   11  2   1   2   2
3   2   9   2   4   3   6   1   9   4   9   3   3
4   1   8   2   4   2   11  2   2   2   1   0   0

0 个答案:

没有答案