Skip to content

BUG/CLN: Repeated time-series plot may raise TypeError #9852

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

Merged
merged 1 commit into from
Apr 12, 2015

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Apr 11, 2015

This repeated time-series plotting works:

import pandas.util.testing as tm
s1 = tm.makeTimeSeries()
s2 = s1[[0, 5, 10, 11, 12, 13, 14, 15]]
ax = s1.plot()
ax2 = s2.plot(style='g')

line_incorrectsecondary

But if converted to DateFrame, it doesn't:

s1 = s1.to_frame()
s2 = s1.iloc[[0, 5, 10, 11, 12, 13, 14, 15]]
print(s2.index.freq)
ax = s1.plot()
ax2 = s2.plot(style='g', ax=ax)
# TypeError: expected string or buffer

Fixed the problem, and cleaned up the code to merge Series and DataFrame flows.

After the Fix:

import pandas.util.testing as tm
fig, axes = plt.subplots(2, 1)
s1 = tm.makeTimeSeries()
s2 = s1[[0, 5, 10, 11, 12, 13, 14, 15]]
ax = s1.plot(ax=axes[0])
ax2 = s2.plot(style='g', ax=axes[0])

s1 = s1.to_frame(name='x')
s2 = s1.iloc[[0, 5, 10, 11, 12, 13, 14, 15]]
ax = s1.plot(ax=axes[1])
ax2 = s2.plot(style='g', ax=axes[1])

line_incorrectsecondary

@@ -108,6 +108,7 @@ Bug Fixes
- Bug in plotting continuously using ``secondary_y`` may not show legend properly. (:issue:`9610`, :issue:`9779`)

- Bug in ``DataFrame.plot(kind="hist")`` results in ``TypeError`` when ``DataFrame`` contains non-numeric columns (:issue:`9853`)
- Bug in continuous ``DataFrame`` with ``DatatimeIndex`` plot may raise ``TypeError`` (:issue:`9852`)
Copy link
Member

Choose a reason for hiding this comment

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

I would describe this as Bug where repeated plotting of DataFrame with a DatetimeIndex may raise TypeError

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, changed the description. Also attached output after the fix on the top.

@shoyer
Copy link
Member

shoyer commented Apr 11, 2015

awesome, this has bitten me before!

jreback added a commit that referenced this pull request Apr 12, 2015
BUG/CLN: Repeated time-series plot may raise TypeError
@jreback jreback merged commit 37d763f into pandas-dev:master Apr 12, 2015
@jreback
Copy link
Contributor

jreback commented Apr 12, 2015

@sinhrks thank you sir!

@sinhrks sinhrks deleted the plot_series branch April 18, 2015 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants