446 questions
3
votes
0
answers
142
views
Can't parse a valid ISO 8601 datetime string pulled from CSV
I have a set of data that I am pulling from an Excel CSV. The column I am using has the timestamps in ISO 8601 format with fractional seconds (YYYY-MM-DDTHH:MM:SS.SSZ)
I have tried using dateutil, ...
0
votes
1
answer
48
views
Groupby column with relativedelta value
I have a dataframe with a column of the dateutil.relativedelta type. When I try grouping by this column, I get the error TypeError: '<' not supported between instances of 'relativedelta' and '...
-1
votes
1
answer
67
views
Python dateutil is being inconsistent with American vs British date formats
I am using the dateutil library with its 'fuzzy' ability to parse dates out of strings. It seemed to be actually quite good at it but on careful inspection it was jumping back and forth between ...
1
vote
1
answer
207
views
Django Query calculate date with `relativedelta` error: can't adapt type 'relativedelta'
I'm facing a tricky problem and couldn't find a solution online. I hope someone here can help me figure out a "clean" way to do this.
This is my current function to retrieve all expired ...
1
vote
1
answer
50
views
Parse datetime string in python ---> Fri Dec 01 2023 00:00:00 GMT 0530 (India Standard Time)
Trying this code snippet:-
from dateutil import parser as date_parser
print(date_parser.parse("Fri Dec 01 2023 00:00:00 GMT 0530 (India Standard Time)"))
Getting this error:-
raise ...
0
votes
0
answers
248
views
Need to convert a datetime.tzinfo *region* to a ZoneInfo region
I'm writing a calendar application, and I have been trying to track down why canceled / rescheduled calendar entries keep appearing on my calendar. I traced the problem to a time zone issue with ...
1
vote
1
answer
98
views
speed up parse function dateutil
Using dateutil I created function which check if data from csv is date and if not remove it from dataframe, but I have problem with speed, similar checking for string or int takes 1-2 seconds for ...
1
vote
2
answers
926
views
What is the difference between relativedelta() and DateOffset()
I am having trouble understanding the differences between the relativedelta() function from the dateutil module and the DateOffset() function from Pandas. To me their syntax and outcomes are the same. ...
1
vote
2
answers
350
views
How do I check whether a date input includes days in Python?
I'm working on a block of Python code that is meant to test inputs to determine whether they're numeric, timestamps, free text, etc. To detect dates, it uses the dateutil parser, then checks if the ...
0
votes
0
answers
126
views
dateutil: No module named 'dateutil' error when Pandas installing using pipenv
I installed pandas usng
pipenv install pandas
command when i run my script getting errors as
ImportError: Unable to import required dependencies:
dateutil: No module named 'dateutil'
and checked ...
1
vote
1
answer
91
views
dateutil parser returns a bad date when it should raise a ValueError
from dateutil.parser import parse
def convert_to_ddmmyy(date_string):
try:
date = parse(date_string)
formatted_date = date.strftime("%d%m%y")
return ...
0
votes
1
answer
83
views
Python Time zone conversion confusion
I have this simple function and test here:
def convert_to_current_time_zone(server_time, test_timezone = None):
"""
Converts a time from server time to the users time zone, taking ...
1
vote
1
answer
1k
views
Shifting daily data exactly one month forward (not 30 days)
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 ...
1
vote
1
answer
1k
views
Could not install python package due to OSError: Permission denied
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: 'C:\Users\path\AppData\Roaming\Python\Python311\site-packages\dateutil\zoneinfo\dateutil-zoneinfo.tar.gz'
Check the ...
1
vote
2
answers
217
views
Check whether timezone is dateutil.tz instance
There are several Python packages that implement the datetime.tzinfo interface, including pytz and dateutil. If someone hands me a timezone object and wants me to apply it to a datetime, the ...
2
votes
2
answers
1k
views
Calculating rate of return for multiple time frames (annualized, quarterly) with daily time series data (S&P 500 (SPX index) daily prices)
I have a CSV file with some 30 years worth of daily close prices for the S&P 500 (SPX) stock market index, and I read it as Dataframe Series with Dates set as Index.
Dataframe:
Date
Open
High
Low
...
2
votes
1
answer
145
views
Why does read_csv give me a timezone warning?
I try reading a CSV file using pandas and get a warning I do not understand:
Lib\site-packages\dateutil\parser\_parser.py:1207: UnknownTimezoneWarning: tzname B identified but not understood. Pass `...
0
votes
2
answers
7k
views
Python3: No module named dateutil
I am unable to get dateutil installed in my Python code.
from dateutil import tz
ImportError: No module named dateutil
I had date-util installed (Python version is 3.7.3)
> pip3 install ...
2
votes
2
answers
321
views
Python Datetime Subtraction include 0 to hour section
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 ...
0
votes
2
answers
2k
views
Extract date from string in a pandas dataframe column
I am trying to extract date from a DF column containing strings and store in another column.
from dateutil.parser import parse
extract = parse("January 24, 1976", fuzzy_with_tokens=True)
...
0
votes
1
answer
6k
views
How to fix dateutil.parser._parser.ParserError: Unknown string format error?
I have the following error on a code sample:
raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: Fall Semester 2018 Printed: ...
3
votes
1
answer
2k
views
Python - Fuzzy in dateutil.parser
I'm trying to find dates in a string. This is what I'm doing.
def _is_date(string, fuzzy=False):
try:
return parse(string, fuzzy=fuzzy)
except ValueError:
return False
It ...
-1
votes
1
answer
710
views
How do I go about incrementing a datetime value by one month using 'relativedelta(months=1)' without affecting the numerical day value?
enter image description here
The code I wrote above works fine except I want the numerical day (%d) of the month to stay unchanged (30th) for all the months bar February (28th). The fact that the day ...
0
votes
1
answer
755
views
dateutil.relativedelta handles years incorrectly
There's something wrong with adding years:
from datetime import datetime
from dateutil.relativedelta import relativedelta
if __name__ == '__main__':
date = datetime.today().date()
print(date)
...
0
votes
0
answers
181
views
How to infer dayfirst for dateutil.parser.parse based on pytz timezone to parse string date
Trying to parse string dates to datetime.date that might be in the format DD/MM/YY or MM/DD/YY. The only info I have is the pytz.tz to help me figure out the format of the string date.
I am using ...