Skip to content

DatetimeIndex.to_period with freq #33358

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
2 tasks done
yohplala opened this issue Apr 7, 2020 · 3 comments · Fixed by #33406
Closed
2 tasks done

DatetimeIndex.to_period with freq #33358

yohplala opened this issue Apr 7, 2020 · 3 comments · Fixed by #33406
Labels
Bug Datetime Datetime data dtype Period Period data type
Milestone

Comments

@yohplala
Copy link

yohplala commented Apr 7, 2020

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandas (1.0.3).

Code Sample

# Input date range:
pi5m = pd.date_range(start='2019-12-22 06:40:00+00:00', end='2019-12-22 08:45:00+00:00', freq='5min')

# Converting to PeriodIndex
pi5m.to_period()

  File "/home/p/.local/lib/python3.7/site-packages/pandas/core/arrays/period.py", line 938, in dt64arr_to_periodarr
    freq = Period._maybe_convert_freq(freq)

  File "pandas/_libs/tslibs/period.pyx", line 1580, in pandas._libs.tslibs.period._Period._maybe_convert_freq

AttributeError: 'NoneType' object has no attribute 'n'

# Working
pi5m.to_period('5min')

Problem description

It is specified in documentation that if not provided, freq is inferred.
However, with above-provided input, I get the error message indicated.
Is this a bug?

Thanks for your feedback.
Bests,

@yohplala yohplala added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 7, 2020
@TomAugspurger TomAugspurger changed the title BUG: Better error message for DatetimeIndex.to_period with no freq Apr 7, 2020
@TomAugspurger TomAugspurger changed the title Better error message for DatetimeIndex.to_period with no freq DatetimeIndex.to_period with freq Apr 7, 2020
@TomAugspurger
Copy link
Contributor

Thanks for the report. Looks like a bug if you're interested in investigating more.

@TomAugspurger TomAugspurger added Period Period data type Datetime Datetime data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 7, 2020
@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Apr 7, 2020
@ShaharNaveh
Copy link
Member

take

@yohplala
Copy link
Author

yohplala commented Apr 9, 2020

Hi, thanks, I am not that at ease with development at the moment.

@jreback jreback modified the milestones: Contributions Welcome, 1.1 Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants