1>>> df['C'] = df['C'].apply(np.int64)
2>>> print(df)
3... A B C D
4... 0 8 0 1 6.226750
5... 1 1 9 9 8.522808
6... 2 1 4 2 7.739108
1>>> df
2 A B C D
30 0.475103 0.355453 0.66 0.869336
41 0.260395 0.200287 NaN 0.617024
52 0.517692 0.735613 0.18 0.657106
6>>> df[list("ABCD")] = df[list("ABCD")].fillna(0.0).astype(int)
7>>> df
8 A B C D
90 0 0 0 0
101 0 0 0 0
112 0 0 0 0
1In [39]:
2
3df['2nd'] = df['2nd'].str.replace(',','').astype(int)
4df['CTR'] = df['CTR'].str.replace('%','').astype(np.float64)
5df.dtypes
6Out[39]:
7Date object
8WD int64
9Manpower float64
102nd int32
11CTR float64
122ndU float64
13T1 int64
14T2 int64
15T3 int64
16T4 object
17dtype: object
18In [40]:
19
20df.head()
21Out[40]:
22 Date WD Manpower 2nd CTR 2ndU T1 T2 T3 T4
230 2013/4/6 6 NaN 2645 5.27 0.29 407 533 454 368
241 2013/4/7 7 NaN 2118 5.89 0.31 257 659 583 369
252 2013/4/13 6 NaN 2470 5.38 0.29 354 531 473 383
263 2013/4/14 7 NaN 2033 6.77 0.37 396 748 681 458
274 2013/4/20 6 NaN 2690 5.38 0.29 361 528 541 381
28