Black Lives Matter. Please consider donating to Black Girls Code today.

Time series Scatter Plot on DASH

Hi all.
I have a .csv file which I read it to plot a scatter on my DASH app. My dataset looks like this:

and I want to do Scatter Plot (line chart) in DASH.
Dataset is a .csv like below:

date enrolled
6/18/2018 1
6/18/2018 1
6/19/2018 1
6/20/2018 1
6/22/2018 1
6/20/2018 1
6/20/2018 1
6/20/2018 1
6/22/2018 1
6/18/2018 1
6/18/2018 1
6/18/2018 1
6/20/2018 1
6/22/2018 1
6/19/2018 1
6/21/2018 1
6/22/2018 1
6/22/2018 1

My inside code is:
dfb=pd.read_csv(‘date_vs_enrolled.csv’, encoding=“latin-1”)

trace1=go.Scatter(
x=dfb[‘date’],
y=dfb[dfb[“enrolled”] == 1].sum(),
name=‘Study Enrollment’
)

trace2=go.Scatter(
x=dfb[‘date’],
y=dfb[dfb[‘enrolled’] != 1].sum(),
name=‘Rejected Participation’,
)

Note: enrolled (1 is Yes, 2 is NO) but here we just have 1.

The result is so strange without a number of cases enrolled per day along the time.

What is my mistake in the above code?
Thanks.

Plotly dates have to either be:
1 - Datetime objects (you can modify your pd.read_csv to automatically parse datetimes)
2 - Strings that are formatted as e.g. 2018-06-22

Thanks Chris for your quick response, can I share my full code to let you modify or can you please, explain in ore details? I am new to DASH. I did not understand well your suggestion. Thanks

I included parse_dates=True to be like this:
dfb=pd.read_csv(‘date_vs_enrolled.csv’, encoding=“latin-1”, parse_dates=True)
but did not solve it.

@MGBpy
In both traces define x as follows:

x=pd.to_datetime(df['date'])

newplot
I think that the problem is any thing related with the line plot. Look at attached file.
Thanks

There is no line chart in the scatter plot.

I found a way to almost fix my concern but it need some adjustment because the dates are not in order.

y=dfb.groupby(‘date’)[‘enrolled’].value_counts(),

y=dfb[‘date’].groupby(dfb.date).agg(‘count’),

y=dfb.groupby(‘date’).size(),

y=dfb.groupby(‘date’)[‘enrolled’].sum(),

I got to plot barchart only for total and not groupby with this code:
trace1=go.Bar(
x=pd.to_datetime(dfb[‘date’]),
y=dfb.set_index(‘date’).resample(‘M’)[“enrolled”].sum(),
)
How to do groupby date?
Thanks