python-dateutil

Shifting daily data exactly one month forward (not 30 days)

Shifting daily data exactly one month forward (not 30 days) Question: I want to shift the date index of my daily data forward by one month. This is in order to calculate a rolling month-on-month change on the daily data by calculating on two dataframes – the existing one with the correct time stamps and …

Total answers: 1

Python Datetime Subtration include 0 to hour section

Python Datetime Subtraction include 0 to hour section Question: I’ve 2 strings of datetime, I need to subtract those to get duration but when subtracted for hour section it only contain 1 digit eg: 1:30, 2:30 So, my question is can we get subtracted datetime or string which includes 0 at the beginning eg: 01:30, …

Total answers: 2

Convert datetime.datetime from UTC to CEST one hour to less

Convert datetime.datetime from UTC to CEST one hour to less Question: If I run the following code I convert the datetime.datetime from utc to cest, but it does not work right. Correct would be if it would change from 21:29 to 23:29 because the time difference is 2 hours from_zone = tz.gettz(‘UTC’) to_zone = tz.gettz(‘CEST’) …

Total answers: 1

python get the quarterly dates from a date range

python get the quarterly dates from a date range Question: python get the quarterly dates from a date range example : start date = 01/04/2020 end date = 01/04/2021 Here I need to get the Quaternary dates from this date range. Asked By: sabari || Source Answers: Try: start_date = “01/04/2020” end_date = “01/04/2021” pd.date_range(start_date, …

Total answers: 3

Getting timezone from dateutil.parser.parse in Python

Getting timezone from dateutil.parser.parse in Python Question: Trying to parse the datetime string with timezone info and get the utc offset from dateutil.parser import parse as parse_date s = ‘2017-08-28 06:08:20,488 CDT’ dt = parse_date(s) print(dt.utcoffset()) # prints `None` Why is utcoffset returning None rather than -5 as offset? Asked By: frazman || Source Answers: …

Total answers: 1

Upgrade the Python package dateutil: Could not find a version

Upgrade the Python package dateutil: Could not find a version Question: I tried to upgrade dateutil from 2.5.3 to the newest version 2.6.0 with pip install dateutil –upgrade, but got the issue Could not find a version. $ pip install dateutil –upgrade Collecting dateutil Could not find a version that satisfies the requirement dateutil (from …

Total answers: 1

Get the last thursday of the current month using python

Get the last thursday of the current month using python Question: Following this answer I tried to get the date for last Thursday of the current month. But my code doesn’t get out of loop. from datetime import datetime from dateutil.relativedelta import relativedelta, TH todayte = datetime.today() cmon = todayte.month nthu = todayte while nthu.month …

Total answers: 10

Python dateutil.parser.parse parses month first, not day

Python dateutil.parser.parse parses month first, not day Question: I’m using dateutil.parser.parse to format a date from a string. But now it mixes up the month and the day. I have a string that contains 05.01.2015. After dateutil.parser.parse(“05.01.2015”) it returns: datetime.datetime(2015, 5, 1, 0, 0) I hoped the it would return (2015, 1, 5, 0, 0) …

Total answers: 2