I have following Python dataframe and I want to plot Sno. vs each column values using plotly .
TT AN AP AR AS BR CH CT DN DL ... PY PB RJ SK TN TG TR UP UT WB
Sno.
1 81 0 1 0 0 0 0 0 0 7 ... 0 1 3 0 1 1 0 12 0 0
2 27 0 0 0 0 0 0 0 0 0 ... 0 0 1 0 0 2 0 1 0 0
3 15 0 0 0 0 0 0 0 0 0 ... 1 0 0 0 0 1 0 0 1 0
4 11 0 0 0 0 0 0 0 0 1 ... 0 0 0 0 0 1 0 2 0 1
5 37 0 0 0 0 0 0 0 0 2 ... 0 1 3 0 1 8 0 2 1 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
147 rows × 36 columns
So here is my approach :
def plot_case(df):
for i in df.columns.values :
dn = df.index.values
dc = df[i].values
xaxis = go.layout.XAxis(title="Day number")
yaxis = go.layout.YAxis(title="New cases")
fig = go.Figure(layout=go.Layout(title=i, xaxis=xaxis, yaxis=yaxis))
fig.add_trace(go.Scatter(x=dn, y=dc))
plot_case(df)
But I am not getting any output in jupyter notebook, that cell just runs without giving any errors .
So I tried this approach for single column TT
xaxis = go.layout.XAxis(title="Day number")
yaxis = go.layout.YAxis(title="New cases")
fig = go.Figure(layout=go.Layout(title="TT", xaxis=xaxis, yaxis=yaxis))
fig.add_trace(go.Scatter(x=df.index.values, y=df.TT.values))
And it worked ! So can someone please explain me what's wrong in that for loop ? Thank you !