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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pandas/src/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ def extract_ordinals(ndarray[object] values, freq):
object p

freqstr = Period._maybe_convert_freq(freq).freqstr
base_freq = frequencies.get_base_alias(freqstr)

for i in range(n):
p = values[i]
Expand All @@ -479,8 +480,9 @@ def extract_ordinals(ndarray[object] values, freq):
try:
ordinals[i] = p.ordinal

if p.freqstr != freqstr:
msg = _DIFFERENT_FREQ_INDEX.format(freqstr, p.freqstr)
p_base_freq = frequencies.get_base_alias(p.freqstr)
if p_base_freq != base_freq:
msg = _DIFFERENT_FREQ_INDEX.format(base_freq, p_base_freq)
raise IncompatibleFrequency(msg)

except AttributeError:
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/plotting/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?

s = Series(np.random.randn(len(idx)), index=idx)
_check_plot_works(s.plot)


if __name__ == '__main__':
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
Expand Down