Pandas dataframe: how to plot candlesticks
<p>I have following data in dataframe to plot candlesticks. </p>

<pre><code>     open   high    close   low
date                
2013-10-08  3.21    3.28    3.27    3.20
2013-10-09  3.25    3.28    3.26    3.22
2013-10-10  3.26    3.27    3.23    3.21
2013-10-11  3.25    3.28    3.27    3.23
2013-10-14  3.28    3.35    3.31    3.26
</code></pre>

<p>I tried to use candlestick_ohlc function from matplotlib.finance, but it seems that somehow I needed to change the data type of the index 'date'. I am new to python, still trying to figure out a way. </p>

<p>Any help would be appreciated, thank you. </p>

<p>If the index is not a <code>datetime</code> (use <code>df.index.dtype</code> to find out which type it is), you can change the type to a datetime by using:</p>

<pre><code>df.index = pd.to_datetime(df.index)
</code></pre>

<p>(assuming your dataframe is called <code>df</code>)</p>

python pandas matplotlib dataframe