I have a pandas dataframe that contains a date
column. I would like to add another column called day_of_week
to this df that tells the day of the week in German. Based on this answer, I understand that I can do this by using the Babel package.
>>> from datetime import date, datetime, time
>>> from babel.dates import format_date, format_datetime, format_time
>>> d = date(2007, 4, 1)
>>> format_date(d, locale='en')
u'Apr 1, 2007'
>>> format_date(d, locale='de_DE')
u'01.04.2007'
However, when I try to apply this to a pandas dataframe column, I get an AssertionError:
:
df['day_of_week'] = format_date(df['date'], "E", locale='de_DE')
Does anyone have an idea how to fix this?