Reputation: 89
I'm just trying to add 1 to all values in the column 'day' in df:
df
day
1 1
2 2
3 3
0 0
I need:
df
day
0 1
1 2
2 3
3 4
I tried:
df['day']=df['day'].apply(lambda x: x + 1)
and
df['day']+=1
Both results in ERROR: TypeError: must be str, not int
Upvotes: 2
Views: 6424
Reputation: 863611
It seems error is:
ERROR: TypeError: must be int, not str
And solution:
df['day']=df['day'].astype(int) + 1
Upvotes: 3