import pandas as pd
import matplotlib . pyplot as plt
plt . rcParams [ " font . sans-serif " ] = [ " SimHei " ] #中文显示df = pd . read_excel ("选课情况. xlsx")
g = df . groupby ("班级").技术.
df1 = pd . DataFrame ( { "班级":, "技术人数" : g . values } ) df1 = df1 . sort_values ( "" , ascending = False )
x =
y = df1 . 技术人数 [ 0 : 3 ]
plt . bar ( x , y , lable = "选技术人数" )
plt . title ( "技术选科人数最多的三个班级" ) plt . xlabel ( "班级" )
plt . ylabel ( "人数" ) plt . legend ( )
plt . ylim( 40 , 50 ) plt . show ( )