how to plot duplicated columns on python pandas

Question:

i have this data where the year column is duplicated for every month from 2018 to 2022 i want to plot the ORDNUM on monthly basis with year as my legend here is the data

data = pd.DataFrame({"Year": [2018, 2018, 2018, 2019], "Month": [3, 4, 5, 3], "ORDNUM": [4459, 2332, 1224, 4322]})

the data frame view of it

Asked By: Adika Stadevant

||

Answers:

The following code generates the following picture.

import pandas as pd
import matplotlib.pyplot as plt
import seaborn

data = pd.DataFrame({"Year": [2018, 2018, 2018, 2019], "Month": [3, 4, 5, 3], "ORDNUM": [4459, 2332, 1224, 4322]})

seaborn.relplot(data=data, x="Month", y="ORDNUM", hue="Year")

plt.show()

enter image description here

Answered By: Michael Kopp
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.