Dec-13-2018, 12:30 PM
1 2 3 4 5 6 7 8 9 10 11 12 |
import pandas as pd import numpy as np df3 = pd.DataFrame({ 'T' : [ 11.0 , 22.0 , 11.23 , 20.03 ], 'v2' : [ 11.0 , 13.0 , 55.1 , 33.0 ], 'v3' : [ 112.1 , 2.0 , 2.1 , 366.0 ], 'v4' : [np.nan, "blue" , 1.0 , 2.0 ] }) df3[ 'T' ] = np.nan_to_num(df3[ 'T' ]).astype( int ) print (df3[ 'T' ]) |
0 11
1 22
2 11
3 20
Name: T, dtype: int32
The column T has values 11.0 ,22.0 ,11.23,20.03 the output should be like 11,22,11.23,20.03
how to remove the zeros and retain the other values after decimal(.)