Skip to content

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

Merged
merged 6 commits into from
Jun 13, 2023

Conversation

ABizzinotto
Copy link
Contributor

@ABizzinotto
Copy link
Contributor Author

@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).

@@ -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],
Copy link
Collaborator

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?

@@ -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)
Copy link
Collaborator

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

Comment on lines 841 to 861
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,
)
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@ABizzinotto ABizzinotto requested a review from Dr-Irv June 13, 2023 17:14
@ABizzinotto
Copy link
Contributor Author

Thanks! Just made the changes

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ABizzinotto

@Dr-Irv Dr-Irv merged commit e54943a into pandas-dev:main Jun 13, 2023
@ABizzinotto ABizzinotto deleted the update-period-value-types branch June 13, 2023 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

period_range and Period should accept date, datetime and pd.Timestamp
2 participants