I have a pandas dataframe with different columns, one being year and another being doy. I would like to loop over the years (2001 to 2019) and plot the doy in different seaborn countplots for each year.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.read_csv("file.csv")
print(df.head())
ID doy Year ... NA_L1NAME B_year number
1772 1774 199 2001 ... 1.1 1934.0 7.942371e+06
1786 1788 160 2002 ... 1.1 1953.0 2.146587e+05
1792 1794 199 2003 ... 1.2 1960.0 2.017792e+07
1801 1803 199 2004 ... 1.3 1968.0 4.293173e+05
1802 1804 195 2005 ... 1.4 1969.0 1.824599e+07
f, axes = plt.subplots(4,5)
for f,ax in zip(AKB.Year, axes.ravel()):
sns.countplot(AKB.doy, ax = ax)
ax.set_title(f)
However, this does not work.
How can I do it?
