Skip to content

BUG: Spurious IncompatibleFrequency error prevented plotting of non-standard intervals (Fixes #14763) #14850

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
wants to merge 4 commits into from

Conversation

jeffcarey
Copy link
Contributor

Fix Summary: A check on frequency compatibility was unnecessarily strict. Now IncompatibleFrequency exceptions will only get raised if the unit types differ.

@codecov-io
Copy link

codecov-io commented Dec 10, 2016

Current coverage is 85.26% (diff: 100%)

Merging #14850 into master will increase coverage by <.01%

@@             master     #14850   diff @@
==========================================
  Files           144        144          
  Lines         50979      50979          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43468      43469     +1   
+ Misses         7511       7510     -1   
  Partials          0          0          

Powered by Codecov. Last update 856476b...fb5f046

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Can you add

  • a whatsnew notice in v0.20.0.txt in the bug fixes section?
  • a test for PeriodIndex(array of Periods) with different but compatible freqs

cc @sinhrks

@@ -802,6 +802,11 @@ def test_custom_business_day_freq(self):

_check_plot_works(s.plot)

def test_non_standard_intervals(self):
idx = pd.period_range('2000-01-01', '2000-01-05', freq='6H')
Copy link
Member

Choose a reason for hiding this comment

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

Can you add the github issue number as a comment?

@jorisvandenbossche jorisvandenbossche added Bug Period Period data type Visualization plotting labels Dec 10, 2016
@jreback
Copy link
Contributor

jreback commented Dec 16, 2016

pls also add a whatsnew entry (0.20.0) is fine.

@jeffcarey
Copy link
Contributor Author

@jorisvandenbossche @jreback @sinhrks

After doing some more testing I don't think the fix I've made here is the correct one, so I am going to close this pull request for now. What I submitted does result in the desired plots but I believe it also breaks some behavior in PeriodIndex. The right way to do this is a good deal more complicated than I originally thought, and I don't think I am the right one to do it given my relative inexperience working with this codebase. Happy to discuss my findings if anyone else wants to try to solve this.

Example of an undesired side effect of the fix:

idx1 = PeriodIndex(period_range('2000-01-01', '2000-01-02', freq='6H'))
idx2 = idx1.append([ period_range('2000-01-03', '2000-01-04', freq='5H')])

# idx2
PeriodIndex(['2000-01-01 00:00', '2000-01-01 06:00', '2000-01-01 12:00',
'2000-01-01 18:00', '2000-01-02 00:00', '2000-01-03 00:00',
'2000-01-03 05:00', '2000-01-03 10:00', '2000-01-03 15:00',
'2000-01-03 20:00'],
dtype='period[6H]', freq='6H')

As you can see, you get a PeriodIndex which says its freq is 6H, but some of the points have a 5H difference. In the current master this code would just result in a plain ndarray.

@jeffcarey jeffcarey closed this Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Period Period data type Visualization plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Period Index plotting method, non standard intervals
4 participants