data = pd.read_csv("AUDCAD.csv", header=0, index_col=0, sep=",", parse_dates=True)
mpf.plot(data, type='candle')
Dont know what is wrong in my code or in data that when I try to plet getting
TypeError: Expect data.index as DatetimeIndex
Any advise will be highly appreciated............... Thank
`
this is how my data looks like
Possibly, although you said parsedates=True
, it is possible that something in your index column prevented at least one date from being parsed as a date. If one row can't be parsed as a date, then pandas will likely decide to keep the entire column as strings. You can check this by looking at the type of index you now have:
data = pd.read_csv("AUDCAD.csv", header=0, index_col=0,
sep=",", parse_dates=True)
print(type(data.index))
print(data.index)
If you don't have a DatetimeIndex, then you will need to convert it to a datetime index. See also How can I deal with Expect data.index as DatetimeIndex? for further details. This can sometimes happen if there is a stray character somewhere in the column. I am wondering also (but I don't know for sure) if the fact that your dates do not all have the same time zone offset is a problem for pandas to parse the dates correct. Let me know if this information helps.