I am having an issue with a Plotly scatter graph. The X axis is a date in the format YYYY-WW. WW stands for week number. If I convert that to date time format, Plotly is unable to interpret it, since it is expecting a month. If I leave it as a string, then Plotly complains "ValueError: Could not convert value of 'x' ('x') into a numeric type. If 'x' contains stringified dates, please convert to a datetime column.".
I just want Plotly to use X axis as a category for the scatter graph. Not a date, and don't try to convert into numeric type.
year_week = [ '2020-00', '2020-01', '2020-02', '2020-03' ]
num_accidents = [ 2, 3, 4, 5 ]
fig_ = px.scatter(
x=year_week,
y=num_accidents,
trendline='ols',
title="Number of Accidents Per Week")
fig.update_xaxes(type='category')
fig.update_layout(xaxis_type='category')
fig.update_traces(mode='lines')
