【发布时间】:2019-08-23 02:59:47
【问题描述】:
我想打印从字典的第 25 个百分位点到第 75 个百分位点的所有值没有 numpy。
这是我试过的代码sn-p。
# No Numpy allowed
import pandas as pd
def display_dashboard():
df=pd.DataFrame({'student':student_list,'marks':marks_list})
sorte=df.sort_values('marks',ascending=False)
per_25=round(0.25*len(marks_list))
per_75=round(0.75*len(marks_list))
sor=df.sort_values('marks')
new_dict = {k:v for k, v in sor.items() for v in range(per_25,per_75)}
print("Students whose marks are between 25th % and 75th % are:-")
print(new_dict)
它给出的答案是:-
Students whose marks are between 25th % and 75th % in ascending order of marks are:-
{'student': 7, 'marks': 7}
我想要一本字典,其中显示学生及其分数在字典总分的第 25 个百分位和第 75 个百分位之间。
【问题讨论】:
-
你知道 pandas 需要 numpy 对吧?
标签: python python-3.x dictionary percentile