Home > Software engineering >  Year Column shows "2016.0"
Year Column shows "2016.0"

Time:11-20

I have a Data frame with year values. It is displayed at 2016.0. How to get rid of .0?

Time    StartDate   Start_year
0   3   2/8/2016 0:37   2/8/2016 6:37   40.10891    -83.09286   Dublin  OH  Light Rain  2016    False   ... False   False   False   False   False   False   False   00:37:00    2016-02-08  2016.0
1   2   2/8/2016 5:56   2/8/2016 11:56  39.86542    -84.06280   Dayton  OH  Light Rain  2016    False   ... False   False   False   False   False   False   False   05:56:00    2016-02-08  2016.0
2   2   2/8/2016 6:15   2/8/2016 12:15  39.10266    -84.52468   Cincinnati  OH  Overcast    2016    False   ... False   False   False   False   False   False   False   06:15:00    2016-02-08  2016.0
3   2   2/8/2016 6:15   2/8/2016 12:15  39.10148    -84.52341   Cincinnati  OH  Overcast    2016    False   ... False   False   False   False   False   False   False   06:15:00    2016-02-08  2016.0
4   2   2/8/2016 6:51   2/8/2016 12:51  41.06213    -81.53784   Akron   OH  Overcast    2016    False   ... False   False   False   False   False   False   False   06:51:00    2016-02-08  2016.0

CodePudding user response:

Just convert the columns you want to remove the .0 from to int:

cols = ['ColA', 'ColB', ...]
df[cols] = df[cols].astype(int)
  • Related