0

I have the following Pandas DataSeries:

Date
2006-01    16.050000
2006-02    14.052632
2006-03    15.565217
             ...    
2019-11    31.650000
2019-12    20.350000
Freq: M, Name: Value, Length: 168, dtype: float64

print(type(data_month2))
<class 'pandas.core.series.Series'>

print(type(data_month2.index))
<class 'pandas.core.indexes.period.PeriodIndex'>

I want to display the series values in Matplotlib, I have tried this:

%matplotlib inline

import matplotlib as mpl
import matplotlib.pyplot as plt

fig = plt.figure()
ax = plt.axes()

ax.plot(data_month2.index, data_month2);

But I get:

TypeError: float() argument must be a string or a number, not 'Period'
3
  • 2
    You could have asked me this in a follow up to my post. This is a simple plot call: data_month2.plot.line(); plt.show() Commented Dec 28, 2020 at 0:15
  • Being a matplotlib I preferred to make a separate question. Thanks a lot for the answer, feel free to add it as answer. For you it might be easy, but it is not for many others. Commented Dec 28, 2020 at 0:18
  • No worries, I think this has been asked before as well. I will mark as duplicate but happy to have helped. Commented Dec 28, 2020 at 1:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.