Plotly express line chart with cumulative sum

Hello,

Sorry, newbie.

I have a dataframe with 2colum: date and value
I had 2 other where I put the extracted month and year from the date.
Let’s say I have

df = pd.DataFrame({
    "date"
    "value"
    "months"
    "years"
})

Was able to put a histo graph with sum of values by month for a selected year.
fig = px.histogram(df_filtered[mask], x=‘months’, y=‘value’, histfunc=‘sum’)

Sure it is not pretty, but it is working.

What I can’t make it work is to have a line graph, with

  • a line by year ( color=‘year’)
  • x my months
  • y my sum value

Seems simple, but right know my head is in the wall… :frowning:

Regards from France,
Me

Almost have it, data are consistant at the very least, but the line graph do funny things (saw form):

I did like that:

df_filtered["value_cumsum"] = df_filtered.groupby(['date_months','date_year'])['PrĂŠcipitations'].cumsum()
fig2 = px.line(df_filtered, x="date_months", y="value_cumsum", color='date_year')

An idea ?

Oooo it is because there are all the data for each month and not just one, the last.
Well, my way seems to be “of course by a long shot” :face_with_spiral_eyes: