I have this table in excel which I am trying to analyze. I am not able to plot the number of S and D (in column 3) according to months (in Col4). I am plotting the number of S and D in col3 using the following. But how to plot the number of S & D according to the months. How to do that?
I would like to get two line plots showing the number of S and D respectively with the corresponding months on the X-axis.
#to plot the number of S and D in col3
df = pd.read_csv (r'C:\Users\data.csv', usecols = ['Col1','Col2','Col3','Col4'])
df['Col4'] = pd.to_datetime(df['Col4'], format="%m/%d/%Y").dt.date
df.head()
df1 = df[['Col3']].copy()
my_dict = df1['Col3'].value_counts().to_dict()
myList = my_dict.items()
x, y = zip(*myList)
plt.bar(x, y, color = "tomato")
plt.ylabel('Count')
plt.title('Outcome')
plt.show()
Col1 Col2 Col3 Col4
0 Y MA S 2/2/2022
1 N YJ D 4/25/2022
2 N YJ D 3/11/2022
3 N YJ D 4/28/2022
4 Y YJ D 4/21/2022
5 N YJ D 4/21/2022
6 Y WE D 5/25/2022
7 Y WE S 5/7/2022
8 N WE D 3/30/2022
9 N PR D 3/22/2022
10 Y PR S 3/22/2022

