I have a dataFrame for example:
In [1]: import pandas as pd
In [2]: df = pd.DataFrame(data = [{'key': '1', 'value': '1', 'metadata': '3'}, {'key': '2', 'value': '2', 'metadata': '3'}, {'key': '1', 'value': '3', 'metadata': '3'}, {'key': '2', 'value': '4', 'metadata':
...: '3'}])
In [3]: df
Out[3]:
key value metadata
0 1 1 3
1 2 2 3
2 1 3 3
3 2 4 3
I want to split the df by the "key", i.e.
In [4]: df_list = [d for _, d in df.groupby(['key'])]
In [5]: df_list
Out[5]:
[ key value metadata
0 1 1 3
2 1 3 3,
key value metadata
1 2 2 3
3 2 4 3]
Now I have list of N (2) dataFrame
s based on number of unique keys. How can I plot this using plotly
?
I can
In [6]: import plotly.express as px
In [7]: fig = px.line(df_list[0])
but how can I add the other lines? plotly.express.Figure
has no add_line
method...