简体   繁体   中英

How to convert weeks,months into days in python pandas?

The dataset is of hotel and there is a column name "calender updated".Below are the values in this column.Can Anybody help to convert months into days?

array(['2 months ago', '12 months ago', 'yesterday', 'today',
       '5 weeks ago', 'a week ago', '3 days ago', '3 months ago',
       '4 months ago', '4 days ago', '2 weeks ago', '6 months ago',
       '7 months ago', '1 week ago', '3 weeks ago', '5 months ago',
       '2 days ago', '18 months ago', '11 months ago', '14 months ago',
       '4 weeks ago', '6 weeks ago', '8 months ago', 'never',
       '15 months ago', '6 days ago', '10 months ago', '7 weeks ago',
       '5 days ago', '16 months ago', '9 months ago', '13 months ago',
       '20 months ago', '19 months ago', '17 months ago', '21 months ago',
       '22 months ago', '29 months ago', '25 months ago', '24 months ago',
       '54 months ago', '27 months ago', '39 months ago', '30 months ago',
       '37 months ago', '44 months ago', '23 months ago', '28 months ago',
       '35 months ago', '47 months ago', '42 months ago', '40 months ago',
       '43 months ago', '52 months ago', '50 months ago', '32 months ago',
       '46 months ago', '34 months ago'], dtype=object)

Welcome to Stack Overflow. When you have a chance, take a look at the help pages to see how to format your question to increase the chances that someone will be able to help you.

How to convert weeks,months into days in python pandas?

Take a look at the dateparser module. I think this will do precisely what you're looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM