Skip to content

Error when trying to plot time series with different frequencies #1732

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
kdebrab opened this issue Aug 4, 2012 · 2 comments
Closed

Error when trying to plot time series with different frequencies #1732

kdebrab opened this issue Aug 4, 2012 · 2 comments
Labels
Milestone

Comments

@kdebrab
Copy link
Contributor

kdebrab commented Aug 4, 2012

Pandas 0.8.1:

import pandas as pd
import matplotlib.pyplot as plt
rng_a = pd.date_range('1/1/2012', periods=4, freq='2H'')
rng_b = pd.date_range('1/1/2012', periods=4, freq='H')
rng_c = pd.date_range('1/1/2012', periods=4, freq='30T')
a = pd.Series([0, 1, 3, 6], rng_a)
b = pd.Series([0, 1, 3, 6], rng_b)
c = pd.Series([0, 1, 3, 6], rng_c)
a.plot()
b.plot() # works fine
c.plot() # ValueError: Incompatible frequency conversion
plt.show() # only a and b are plotted

b.plot() works fine, but c.plot() doesn't and returns the following error:

ValueError: Incompatible frequency conversion

When building the timeseries without specifying their frequency, no error is reported when trying to plot them, but there seems to be another issue occuring:

a = pd.Series([0, 1, 2, 3], ['1/1/2012 00:00:00', '1/1/2012 02:00:00', '1/1/2012 04:00:00', '1/1/2012 06:00:00'])
b = pd.Series([0, 1, 2, 3], ['1/1/2012 00:00:00', '1/1/2012 01:00:00', '1/1/2012 02:00:00', '1/1/2012 03:00:00'])
c = pd.Series([0, 1, 2, 3], ['1/1/2012 00:00:00', '1/1/2012 00:30:00', '1/1/2012 01:00:00', '1/1/2012 01:30:00'])
a.plot()
b.plot() # no error
c.plot() # no error
plt.show() # only c is plotted

No errors are reported, but only series c is plotted.

@dalejung
Copy link
Contributor

dalejung commented Aug 7, 2012

import pandas as pd
a = pd.Series([0, 1, 2, 3], ['1/1/2012 00:00:00', '1/1/2012 02:00:00', '1/1/2012 04:00:00', '1/1/2012 06:00:00'])
b = pd.Series([0, 2, 3, 4], ['1/1/2012 00:00:00', '1/1/2012 01:00:00', '1/1/2012 02:00:00', '1/1/2012 03:00:00'])
c = pd.Series([0, 3, 4, 7], ['1/1/2012 00:00:00', '1/1/2012 00:30:00', '1/1/2012 01:00:00', '1/1/2012 01:30:00'])
a.plot(label='a')
b.plot(marker="o") # no error
c.plot(marker="*") # no error
plt.legend()
plt.show() # only c is plotted

The lines are plotting but are on top of each other. See the above code.

@changhiskhan
Copy link
Contributor

Should work now. Thanks for the bug report. @dalejung should also have fixed the example you gave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants