BUG/CLN: Repeated time-series plot may raise TypeError by sinhrks · Pull Request #9852 · pandas-dev/pandas (original) (raw)
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')
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])