Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
ind = pd.date_range("1/1/2021", "1/5/2021") - pd.Timestamp("1/3/2019")
ind.shift(1)
Issue Description
This only occurs on main. NOT a current bug in pandas.
Gives error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Code\pandas_dev\pandas\pandas\core\indexes\datetimelike.py", line 512, in shift
raise NullFrequencyError("Cannot shift with no freq")
pandas.errors.NullFrequencyError: Cannot shift with no freq
The above code works fine with pandas 2.3.
Expected Behavior
No error. A user doing a calculation that produces a TimedeltaIndex can't be expected to set the freq of the index.
I think was introduced by @jbrockmendel in #61985
Installed Versions
Comment From: jbrockmendel
Should be straightforward to add this case to _get_arithmetic_result_freq. Marking as Good First Issue.
Comment From: Divyanshu-spec-code
Hi, I’m new to open source and would like to work on this issue. Could you please assign it to me?
Comment From: GouravPriyadarshi
Hello all, This is the first time I am attempting for open source contribution. Any suggestions or how can I move forward on this issue?
Comment From: nikitakumari2
take
Comment From: meet-vasita
take
Comment From: Chenghaoxiang
take