When I plot my data with just the index the graph looks fine. But when I try to plot it with a datetime object in the x axis, the plot gets messed up. Does anyone know why? I provided the head of my data and also the two plots.
import plotly.express as px
fig = px.line(y=data.iloc[:,3])
fig.show()
fig = px.line(y=data.iloc[:,3],x=data.iloc[:,0])
fig.show()
It is probably because of missing dates as you have around 180 data points but your second plot shows data spans from 2014 to 2019 that means it does not have many data points in between that's why your second graph looks like that.
Instead of datetime try plotting converting it into string but then it will not be a time series as you will have many missing dates