import pandas as pd # 数据处理
import numpy as np # 科学运算
from pyecharts.charts import * # 可视化图表
from pyecharts import options as opts
df = pd.read_csv(‘./中国大学综合排名2021.csv’, encoding=‘gb2312’)
df.describe()
df.isnull().sum()
df.fillna(0, inplace=True)
df.isnull().sum()
df[df[‘升/降’] == 0]
统计前50名中排名下降的学校
df.loc[(df[‘排名’] < 50) & (df[‘升/降’] < 0), :]
数据分组 各省大学数量
g = df.groupby(‘省市’)
df_counts = g.count()[‘排名’]
df0 = df_counts.copy()
df0.sort_values(ascending=False, inplace=True)
df_mean0 = g.mean()[‘总分’]
df_means = df_mean0.round(2)
df1 = pd.concat([df_counts, df_means], join=‘outer’, axis=1)
df1.columns = [‘数量’, ‘平均分’]
df1.sort_values(by=[‘平均分’], ascending=False, inplace