Reputation: 1465
I have a dataframe with columns as Country, 2015.0,2016.0,2017.0 these are suppose to be years. But the column name has .0 in it. I tried to rename them but rename is not working. I am not able to remove the .0 at the end. Any suggestions.
Upvotes: 1
Views: 448
Reputation: 294508
rename
def f(x):
try:
return int(float(x))
except ValueError:
return x
df.rename(columns=f)
Upvotes: 4