title: How can I deal with Expect data.index as DatetimeIndex?
body: <p>I am planning to get a candlestick plot from the bitcoin data.
  Here is my code for select the dataframe I want after loading the csv file.</p>
  <pre><code>df['Date'] = pd.to_datetime(df['Date'])
  start_date = '2016-02-27'
  end_date = '2021-02-27'
  mask = (df['Date'] &gt;= start_date) &amp; (df['Date'] &lt;= end_date)
  df = df.loc[mask]
  df
  </code></pre>
  <p>and then, I entered the code for making the candlestick plot like below:</p>
  <pre><code>import matplotlib.pyplot as plt
  ! pip install --upgrade mplfinance
  import mplfinance as mpf
  import matplotlib.dates as mpl_dates
  
  
  mpf.plot(df, type = 'candle', style = 'charles',
          title = 'Bitcoin Price',
          ylabel = 'Price (USD$)',
          volume = True,
          ylabel_lower = 'Shares \nTraded',
          mav = (3,6,9),
          savefig = 'chart-mplfinance.png')
  </code></pre>
  <p>It said &quot;TypeError: Expect data.index as DatetimeIndex&quot;.
  So I looked up the solution for this on google and I tried out this:</p>
  <pre><code>df = dict()
  df['Date'] = []
  df['High'] = []
  df['Low'] = []
  df['Open'] = []
  df['Close'] = []
  df['Volume'] = []
  for dict in df:
      df['Date'].append(datetime.datetime.fromtimestamp(t).strftime('%Y-%m-%d %H:%M:%S')
      df['High'].append(dict['High'])
      df['Low'].append(dict['Low'])
      df['Open'].append(dict['Open'])
      df['Close'].append(dict['Close'])
      df['Volume'].append(dict['Vol'])
  print(&quot;df:&quot;, df)
  pdata = pd.DataFrame.from_dict(df) 
  pdata.set_index('Date', inplace=True)
  mpf.plot(pdata)
  </code></pre>
  <p>This time, it said &quot;invalid syntax&quot;
  I'm not sure where I get this wrong, is there anything that I have missed?</p>