dataframe plot distribution of dates 1

dataframe plot distribution of dates

df["date"] = df["date"].astype("datetime64")
df.groupby([df["date"].dt.year, df["date"].dt.month]).count().plot(kind="bar")

Here is what the above code is Doing:
1. We’re grouping the dataframe by year and month.
2. We’re counting the number of rows in each group.
3. We’re plotting the result as a bar chart.

Similar Posts