I want to show one line graph for each group of data from pandas dataframe.
Dataframe:
tag | date | value | |
---|---|---|---|
0 | 1 | 20 | 1 |
1 | 1 | 21 | 5 |
2 | 1 | 22 | 3 |
3 | 2 | 20 | 8 |
4 | 2 | 21 | 6 |
5 | 2 | 22 | 14 |
I tried to execute the below:
for tag_g in df.groupby('tag'):
tag_g.plot( 'date' , 'value' )
It gives an error:
AttributeError: 'tuple' object has no attribute 'plot'
Notes:
- Will there be only 2 groups? No, its dynamic. Can have 1 or n number
- Will there be 3 rows for each group? No, its dynamic. But minimum 3 for sure