Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing date with French month abbreviations

Tags:

python

pandas

I have a pandas dataframe with the date column containing dates with month abbreviations in French, such as:

u'18-oct.-2015'
u'12-nov.-2015'
u'02-d\xe9c.-2015'
u'26-janv.-2016'
u'02-f\xe9vr.-2016'
u'31-mai-2016'
u'01-juin-2016'

What is the proper way of using to_datetime to parse them?

like image 776
sl1129 Avatar asked Nov 29 '25 16:11

sl1129


1 Answers

I suspect that you can just set your locale:

import locale

locale.setlocale(locale.LC_ALL, 'fr_FR') # Windows may be a different locale name

# do your pandas read here

You might need to tell Pandas that that column is a datetime column... though it's also possible that you'll need to fix the column values - jan is the appropriate abbreviation for janvier. But Pandas may be smart enough to handle it.

like image 150
Wayne Werner Avatar answered Dec 02 '25 05:12

Wayne Werner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!