I have the following pandas DataFrame:
time Group blocks
0 1 A 4
1 2 A 7
2 3 A 12
3 4 A 17
4 5 A 21
5 6 A 26
6 7 A 33
7 8 A 39
8 9 A 48
9 10 A 59
.... .... ....
36 35 A 231
37 1 B 1
38 2 B 1.5
39 3 B 3
40 4 B 5
41 5 B 6
.... .... ....
911 35 Z 349
This is a dataframe with multiple time series-ques data, from min=1
to max=35
. Each Group
has a time series like this.
I would like to plot each individual time series A through Z against an x-axis of 1 to 35. The y-axis would be the blocks
at each time.
I was thinking of using something like an Andrews Curves plot, which would plot each series against one another. Each "hue" would be set to a different group. (Other ideas are welcome.)
My problem: how do you format this dataframe to plot multiple series? Should the columns be GroupA
, GroupB
, etc.?
How do you get the dataframe to be in the format:
time GroupA blocksA GroupsB blocksB GroupsC blocksC....
Is this the correct format for an Andrews plot as shown?
EDIT
If I try:
df.groupby('Group').plot(legend=False)
the x-axis is completely incorrect. All time series should be plotted from 0 to 35, all in one series.
How do I solve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…