-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix incorrect exception raised by Series[datetime64] + int #19147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1241994
1fe5732
0aee07a
29a4931
4fd68c1
efcde8e
df545a0
1a03a68
878e689
fd0ac99
a623d00
aab851d
66d6bce
15b5f08
63ae039
edebbe2
2231505
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
from itertools import product | ||
import pandas as pd | ||
from pandas.errors import NullFrequencyError | ||
import pandas._libs.tslib as tslib | ||
from pandas._libs.tslibs.offsets import shift_months | ||
import pandas.util.testing as tm | ||
|
@@ -593,6 +594,12 @@ def test_nat_new(self): | |
exp = np.array([tslib.iNaT] * 5, dtype=np.int64) | ||
tm.assert_numpy_array_equal(result, exp) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are very likely tests that are raising ValueError that should now be NullFrequencyError, pls change them. You can find them very easily, by temporarly changing the error where NullFrequencyInhertis to something else (e.g. KeyError) and then seeing what raises There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Found and changed one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok great |
||
def test_shift_no_freq(self): | ||
# GH#19147 | ||
dti = pd.DatetimeIndex(['2011-01-01 10:00', '2011-01-01'], freq=None) | ||
with pytest.raises(NullFrequencyError): | ||
dti.shift(2) | ||
|
||
def test_shift(self): | ||
# GH 9903 | ||
for tz in self.tz: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just make this a ValueError, we don't want to have custom error messages normally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to catch this specifically in core.ops. Want to catch by checking the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message here "Cannot shift with no freq" is the same as the error message raised if adding just an integer when
self.freq
is None.