title: matplotlib error : AttributeError: 'int' object has no attribute 'toordinal'
body: <p>I am trying to plot a graph using matplotlib .
  I am using this code from : <a href="https://stackoverflow.com/questions/53697655/how-to-plot-candlesticks-in-python">how to plot candlesticks in python</a> </p>
  
  <p>The code is :</p>
  
  <pre><code>from pandas_datareader import data
  import matplotlib.pyplot as plt
  from mpl_finance import candlestick2_ohlc
  import matplotlib.dates as mdates
  import fix_yahoo_finance as yf
  import datetime
  
  start = datetime.date(2018, 1, 1)
  end = datetime.date.today()
  
  aapl = yf.download("AAPL",start,end) 
  aapl.reset_index(inplace=True)
  
  aapl['Date'] = aapl.index.map(mdates.date2num)
  
  fig, ax = plt.subplots()
  plt.xlabel("Date")
  plt.ylabel("Price")
  
  candlestick2_ohlc(ax, aapl.Open, aapl.High, aapl.Low, aapl.Close, width=1, colorup='g')
  plt.savefig('my_figure.png')
  plt.show() 
  </code></pre>
  
  <p>When I run this code in google colab , I get this error :</p>
  
  <pre><code>AttributeError                            Traceback (most recent call last)
      &lt;ipython-input-21-521826b3b41d&gt; in &lt;module&gt;()
           16 
           17 
      ---&gt; 18 aapl['Date'] = aapl.index.map(mdates.date2num)
           19 
           20 
  
  3 frames
  pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
  
  /usr/local/lib/python3.6/dist-packages/matplotlib/dates.py in _to_ordinalf(dt)
      226         tzi = UTC
      227 
  --&gt; 228     base = float(dt.toordinal())
      229 
      230     # If it's sufficiently datetime-like, it will have a `date()` method
  
  AttributeError: 'int' object has no attribute 'toordinal'
  </code></pre>
  
  <p>The line of code causing the issue is this :
  <code>aapl['Date'] = aapl.index.map(mdates.date2num)</code></p>
  
  <p>When I change this line to : <code>aapl['Date'] = mdates.date2num</code> , the entire code works without any issues .</p>
  
  <p>I am using :</p>
  
  <p>matplotlib: 3.0.3
  Pandas : 0.24.2</p>
  
  <p>Can someone please inform me as to why the previous code will not work ?
  Any help will be greatly appreciated .</p>