I want to be able to visualize my data points per days of the week, per weeks in a year and per months. I was able to visualize my data per year. But when I adjust the code for Monthly and weekly, the x-axis remains as per year.
I have 8 years of hospital records. My data is organized into 2 columns. Column number 1 is my "dates" column starting from 2010-03-10 and ending at 2017-12-31. Column number 2 is my value column. This column lists if I've had a patient come in for treatment or not. The values in column 2 are 0 or x numbers. For example 0 meaning I've had no patients x meaning I've had x number of patients. When I try to graphically represent this data, it only counts the largest x number I've had per week.
df=pd.read_csv('Data 3.csv', parse_dates=["Dates"], index_col="Dates")
# create the plot space upon which to plot the data
fig, ax = plt.subplots(figsize = (10,10))
# add the x-axis and the y-axis to the plot
ax.plot(df.resample('Y').sum()['Total # Events'],color = 'blue')
# rotate tick labels
plt.setp(ax.get_xticklabels(), rotation=45)
# set title and labels for axes
ax.set(xlabel="Years",
ylabel="Total # of Events",
title="Yearly Treatment Events from 2010-2017");
So I get the correct graphical figure. But when I change the (df.resample('Y').sum() to ('M') from ('Y') for monthly I get a graph that displays a yearly X-axis and values. How can I change this to get monthly X-axis and Weekly X-axis?
