I am using Google colab to generate graphs and charts using plotly in python. I have 6,97,000 rows of data stored in a csv
file that I am analyzing. I am using the following code to generate a bar chart and it works perfectly.
fig = px.bar(df, x='IP', y="Epid_ID")
fig.update_traces(marker=dict(line=dict(width=3,color='blue')))
fig.show()
Now, I want a chart showing cumulative data. Following is an example of my dataset.
IP Epid_ID
05/08/2021 COV-NEP-PR4-LAM-21-01936
05/08/2021 COV-NEP-PR4-LAM-21-01937
06/08/2021 COV-NEP-PR4-LAM-21-01938
06/08/2021 COV-NEP-PR4-LAM-21-01939
07/08/2021 COV-NEP-PR4-LAM-21-01940
My expected output is a bar chart showing cumulative data. Current output:
Expected Output
I tried to use cumsum using the following link. https://www.codegrepper.com/code-examples/python/cumulative+chart+python+plotly
And tried to keep the Date variable as x using the following codes.
x = df['IP']
y = df['Epid_ID']
cumsum = np.cumsum(x)
However, my runtime crashes when I use this code. Please help!
Building a histogram will provide you the expected output cause it distributes data in ranges.
Try using this
import plotly.express as px
import plotly.graph_objects as go
df = px.data.iris()
fig = go.Figure(data=[go.Histogram(y=df['sepal_width'], cumulative_enabled=True)])
fig.show()