如何使用 csv 文件制作折线图。有 4 列。今年是十年

How to make Line graph using csv file. with 4 columns. and the year is by decade

我是新手,想做折线图。 我想在 x 轴上绘制几十年的折线图,在 y 轴上绘制宗教数量,但有两条线,一条是宗教学校,一条是非宗教学校。

这是我的 csv 文件。

https://drive.google.com/file/d/16XuvoQKSrSMaUPsfHOWY6cBy1ry6UNz6/view?usp=sharing

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = pd.read_csv('ReligiousRate.csv', dtype='string')

df_religious = df[['Religious', 'founded1']]
df_non_religious = df[['Non-Religious', 'founded2']]

dfs = [df_religious, df_non_religious]
names = ['Religious Schools', 'Non Religious Schools']

counts = []
for df, name in zip(dfs, names):
    df.columns = ['Name', 'Founded']
    df['Founded'] = pd.to_datetime(df['Founded'], yearfirst=True)
    df = df.set_index('Founded')
    df_decades = df.resample('10AS').count()
    df_decades.columns = [name]
    counts.append(df_decades)

sns.set_palette(["#090364", "#ff0000"])
sns.lineplot(data=pd.concat(counts), dashes=False)
plt.show()

输出: