In a DataFrame I have created a Month column, where I have taken the number of the month from another column that had the format 2015.06.12. From the .06. removed, I have converted it into a number with a:
str.extract('(\.\d{2}\.)')
And I've removed the colon like this:
str.extract('(\d{2})')
Now what I wanted to do is change those numbers to the corresponding month. I have seen that it is possible to do it with the calendar module, I have tried to do it like this:
def month(x):
return calendar.month_name[x]
df['Month'] = df.Month.apply(month)
But I get the error: "list indices must be integers or slices, not float"
Also say that there are NaN cells, that in principle I want to leave them like this.
Any suggestions how I can do it?
Thank you!