题解 | #牛客网最多的用户等级#
牛客网最多的用户等级
https://www.nowcoder.com/practice/56cd529bcdd1488f87f2ec5c72387ce6
目标:求众数
pd.mode()为pandas中求众数的函数,同时题目说名结果格式,得用DateFrame格式,Series格式将会报错
type(Nowcider.Level.mode()),type(Nowcider.loc[:,['Level']].mode()) (pandas.core.series.Series, pandas.core.frame.DataFrame)四种方式
import pandas as pd Nowcoder = pd.read_csv('Nowcoder.csv', sep=',') print(Nowcoder.loc[:,['Level']].mode()) # print(Nowcoder.iloc[:,[1]].mode()) # print(Nowcoder[['Level']].mode()) # res = Nowcoder['Level'].mode() # print(pd.DataFrame(res,columns = ['Level']))
数据分析刷题专栏 文章被收录于专栏
这个专栏就是刷题!刷题!刷题!