-
-
Notifications
You must be signed in to change notification settings - Fork 154
Closed
Description
pd.period_range and pd.Period currently only accept str and pd.Period as arguments, but the implementation also accepts datetime, date and pd.Timestamp as can be seen here in the cython implementation: https://github.com/pandas-dev/pandas/blob/v2.0.1/pandas/_libs/tslibs/period.pyx#L2626-L2643
It technically also allows integers/floats. period_range internally uses Period to convert the start and end arguments, so the type annotations can be used interchangeably between those two.
To Reproduce
import pandas as pd
pd.Period(pd.Timestamp('2020-01-01'), freq='Q') # mypy: arg-type — Argument 1 to "Period" has incompatible type "Timestamp"
pd.period_range(pd.Timestamp('2020-01-01), '2020-06-01', freq='Q') # mypy: arg-type — Argument 1 to "period_range" has incompatible type "Timestamp"- OS: Linux (OpenSUSE Tumbleweed)
- Python 3.10
- mypy 1.0.1
- pandas-stubs 2.0.1.230501
Metadata
Metadata
Assignees
Labels
No labels