Skip to content

PeriodIndex annotation is missing a bunch of fields #395

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

Closed
gandhis1 opened this issue Oct 24, 2022 · 1 comment · Fixed by #505
Closed

PeriodIndex annotation is missing a bunch of fields #395

gandhis1 opened this issue Oct 24, 2022 · 1 comment · Fixed by #505

Comments

@gandhis1
Copy link
Contributor

gandhis1 commented Oct 24, 2022

https://github.com/pandas-dev/pandas-stubs/blob/main/pandas-stubs/core/indexes/period.pyi#L20

Missing these attributes, per https://pandas.pydata.org/docs/reference/api/pandas.PeriodIndex.html:

attribute description
day The days of the period.
dayofweek The day of the week with Monday=0, Sunday=6.
day_of_week The day of the week with Monday=0, Sunday=6.
dayofyear The ordinal day of the year.
day_of_year The ordinal day of the year.
days_in_month The number of days in the month.
daysinmonth The number of days in the month.
end_time Get the Timestamp for the end of the period.
freq Return the frequency object if it is set, otherwise None.
freqstr Return the frequency object as a string if its set, otherwise None.
hour The hour of the period.
is_leap_year Logical indicating if the date belongs to a leap year.
minute The minute of the period.
month The month as January=1, December=12.
quarter The quarter of the date.
second The second of the period.
start_time Get the Timestamp for the start of the period.
week The week ordinal of the year.
weekday The day of the week with Monday=0, Sunday=6.
weekofyear The week ordinal of the year.
year The year of the period.

And these methods:

method description
asfreq([freq, how]) Convert the PeriodArray to the specified frequency freq.
strftime(*args, **kwargs) Convert to Index using specified date_format.
to_timestamp([freq, how]) Cast to DatetimeArray/Index.

Example error:

error: "PeriodIndex" has no attribute "start_time"

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Oct 24, 2022

Thanks for reporting this. Because of how pandas implements these accessors, it wasn't picked up when stubgen was used a long time ago.

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 a pull request may close this issue.

2 participants