python matplotlib groupby - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: python matplotlib groupby (/thread-32415.html) |
python matplotlib groupby - okpython - Feb-08-2021 I am trying to use matplotlib to plot the data to mimic the behaviour in the excel screenshot below. I am not able to groupby twice, subsequently, I am getting a join between the 2 series, and they're only being plotted in the single series. My code: fig, ax = plt.subplots(figsize=(8,6)) for lab, d in df.groupby(['label']): df.groupby(['model']) ax.plot(df[df.label==label]["xValue"],df[df.label==label].yValue, label=label, marker='o') The 2nd groupby is not working.How can I fix this? dataframe:
|