Search code examples
pythonpandasdataframempf

TypeError after trying to plot dataframe with mpf.plot


I have a panda dataframe with the following columns: enter image description here

Now I would like to plot out a chart with mpf.plot. But I am getting the following error: enter image description here

How can I avoid the above TypeError Message? I did set the df index with the following command:

dfnew_plot = dfnew_plot.set_index('Date')

Solution

  • Your index isn't the correct dtype. It needs to be converted using:

    dfnew_plot.index = pd.to_datetime(dfnew_plot.index)