请问我如何在这个数据框上绘制折线图,​​我想在折线图中显示每月的出勤总和

Please how can i plot a line graph on this data frame, I want to show the sum of attendance on a monthly basis in line graph

visit_date sex age marital_status
0 2021-04-05 Female 66 Widowed
1 2021-04-05 Female 65 Widowed
2 2021-04-05 Female 39 Married
3 2021-04-05 Male 56 Married
4 2021-04-05 Female 31 Married
5 2021-04-05 Female 24 Single
6 2021-04-05 Male 37 Married
7 2021-04-05 Female 43 Widowed
8 2021-04-05 Male 29 Married
9 2021-04-05 Male 44 Single

如果我理解正确的话这应该有效

import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame(data)
df['visit_date'] = pd.to_datetime(df['visit_date'])
attendance = df.groupby(pd.Grouper(key="visit_date", freq='M')).size().reset_index(name='attendance')
attendance.plot(x='visit_date', y='attendance', kind='line')
plt.show()