iso

Convert a common date format in an ISO week date format

Convert a common date format in an ISO week date format Question: i have this dataframe with this kind of date format Date Week Number Influenza[it] Febbre[it] Rinorrea[it] 0 2008-01-01 1 220 585 103 1 2008-01-08 2 403 915 147 2 2008-01-15 3 366 895 136 3 2008-01-22 4 305 825 136 4 2008-01-29 5 …

Total answers: 3

Print datetime in ISO format without milliseconds

Print datetime in ISO format without milliseconds Question: I’m trying to serialize datetime in an API, but I don’t want milliseconds. What I want is here: https://en.wikipedia.org/wiki/ISO_8601 – “2015-09-14T17:51:31+00:00” tz = pytz.timezone(‘Asia/Taipei’) dt = datetime.datetime.now() loc_dt = tz.localize(dt) Try A: loc_dt.isoformat() >> ‘2015-09-17T10:46:15.767000+08:00’ Try B: loc_dt.strftime(“%Y-%m-%dT%H:%M:%S%z”) >> ‘2015-09-17T10:46:15+0800’ The latter one is almost perfect except …

Total answers: 2

Extracting double-digit months and days from a Python date

Extracting double-digit months and days from a Python date Question: Is there a way to extract month and day using isoformats? Lets assume today’s date is March 8, 2013. >>> d = datetime.date.today() >>> d.month 3 >>> d.day 8 I want: >>> d = datetime.date.today() >>> d.month 03 >>> d.day 08 I can do this …

Total answers: 2

Convert JSON date string to Python datetime

Convert JSON date string to Python datetime Question: When translating dates to JSON, javascript is saving dates in this format: 2012-05-29T19:30:03.283Z However, I am not sure how to get this into a python datetime object. I’ve tried these: # Throws an error because the ‘Z’ isn’t accounted for: datetime.datetime.strptime(obj[key], ‘%Y-%m-%dT%H:%M:%S.%f’) # Throws an error because …

Total answers: 3

Get date from ISO week number in Python

Get date from ISO week number in Python Question: Possible Duplicate: What’s the best way to find the inverse of datetime.isocalendar()? I have an ISO 8601 year and week number, and I need to translate this to the date of the first day in that week (Monday). How can I do this? datetime.strptime() takes both …

Total answers: 2