-
-
Notifications
You must be signed in to change notification settings - Fork 141
period_range and Period should accept date, datetime and pd.Timestamp #728
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
period_range and Period should accept date, datetime and pd.Timestamp #728
Conversation
@Dr-Irv looks like this was indeed a documentation issue, I submitted pandas-dev/pandas#53611 and pandas-dev/pandas#53632 to address the issue reported there (pandas-dev/pandas#53038). The first one has been merged, but the solution was incomplete to I submitted the second one (pending review). |
pandas-stubs/core/series.pyi
Outdated
@@ -851,7 +851,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): | |||
@overload | |||
def apply( | |||
self, | |||
func: Callable[..., Scalar | Sequence | set | Mapping | None], | |||
func: Callable[..., Scalar | Sequence | set | Mapping | NAType | None], |
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.
I think this change came up because you haven't merged with main
. Can you make sure you have done that?
tests/test_series.py
Outdated
@@ -470,6 +471,8 @@ def get_depth(url: str) -> int: | |||
ss = s.astype(str) | |||
check(assert_type(ss.apply(get_depth), pd.Series), pd.Series, np.int64) | |||
|
|||
check(assert_type(s.apply(lambda x: pd.NA), pd.Series), pd.Series, NAType) |
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.
same comment as above - this change is already in main
tests/test_timefuncs.py
Outdated
check( | ||
assert_type( | ||
pd.period_range(pd.Timestamp("2001-01-01"), end="2002-01-01", freq="Q"), | ||
pd.PeriodIndex, | ||
), | ||
pd.PeriodIndex, | ||
) | ||
check( | ||
assert_type( | ||
pd.period_range(dt.datetime(2001, 1, 1), end="2002-01-01", freq="Q"), | ||
pd.PeriodIndex, | ||
), | ||
pd.PeriodIndex, | ||
) | ||
check( | ||
assert_type( | ||
pd.period_range(dt.date(2001, 1, 1), end="2002-01-01", freq="Q"), | ||
pd.PeriodIndex, | ||
), | ||
pd.PeriodIndex, | ||
) |
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.
For these tests, you should also change the end
argument to be the corresponding type.
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.
Done
Thanks! Just made the changes |
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.
thanks @ABizzinotto
period_range
andPeriod
should acceptdate
,datetime
andpd.Timestamp
#675 (Replace xxxx with the Github issue number)assert_type()
to assert the type of any return value