ValueError: Wrong number of items passed 2, placement implies 1

ValueError: Wrong number of items passed 2, placement implies 1

Table 看起来像:

问题: 在分类为 错误范围为 0-10% 的所有案例中,学科物理、return table 学生百分比大于或等于 BSchool1(基准) 中学生百分比的 95% 的值,误差范围为 0-10% 并且学科物理。

[IN]

import pandas as pd
data = [['B1', 'Grade_physics', '0-10%', 70],['B1', 'Grade_physics', '10-20%', 5],['B1', 'Grade_physics', '20-30%', 25],['B1', 'Grade_Maths', '10-20%', 20],['B1', 'Grade_Maths', '0-10%', 60],['B1', 'Grade_Maths', '20-30%',20 ],['B2', 'Grade_Maths', '0-10%', 50],['B2', 'Grade_Maths', '10-20%', 15],['B2', 'Grade_Maths', '20-30%', 35],['B2', 'Grade_physics', '10-20%', 30],['B2', 'Grade_physics', '0-10%', 60],['B2', 'Grade_physics', '20-30%',10 ]]
df = pd.DataFrame(data, columns = ['BSchool Name', 'Graded in','Error Bucket','Stu_perc'])
df 
     [OUT]
       BSchool Name      Graded in      Error Bucket  Stu_perc
    0            B1  Grade_physics             0-10%        70
    1            B1  Grade_physics            10-20%         5
    2            B1  Grade_physics            20-30%        25
    3            B1    Grade_Maths            10-20%        20
    4            B1    Grade_Maths             0-10%        60
    5            B1    Grade_Maths            20-30%        20
    6            B2    Grade_Maths             0-10%        50
    7            B2    Grade_Maths            10-20%        15
    8            B2    Grade_Maths            20-30%        35
    9            B2  Grade_physics            10-20%        30
    10           B2  Grade_physics             0-10%        60
    11           B2  Grade_physics            20-30%        10

[IN]:

#Subset of values where error bucket and subject are sliced
filter1 = df['Graded in'].str.contains('Grade_physics')
filter2=df['Error Bucket'].str.contains('0-10%')
df2 = df[filter1 & filter2]

#Compare the value of student percentage in sliced data to benchmark value 
#(in this case student percentage in BSchool1) 
filter3 = df2['BSchool Name'].str.contains('B1')
benchmark_value = df2[filter3]['Stu_perc']
df['Qualifyinglist']=(df2[['Stu_perc']]>=0.95*benchmark_value)
[OUT]:
ValueError: Wrong number of items passed 2, placement implies 1
[IN]:
df['Qualifyinglist']=(df2['Stu_perc']>=0.95*benchmark_value)
[OUT]:
ValueError: Can only compare identically-labeled Series objects

我想做什么:

我们与商学院有合作关系,我们正试图预测每所商学院学生的总体成绩。然后,我们尝试根据 0-10%、10-20% 等范围对预测不准确的案例进行分类。例如,对于商学院 1 的物理学,70% 的案例被正确识别,误差范围为 0- 10%、5% 的案例预测在 BSchool 1 等物理领域有 10-20% 的误差,等等。我们在 B-School 1 中的模型是成功的。所以我们希望看看我们现在可以定位哪些商学院。

但是我收到如上所示的错误。

Value Error:Wrong number of items passed 2, placement implies 1 这对我没有帮助。请帮助

val=benchmark_value.iat[0]

df['Qualifyinglist']=df2['Stu_perc'].where(df2['Stu_perc']>=0.95*val)

这对我有用。