【发布时间】:2020-04-21 07:02:18
【问题描述】:
low_enrollment = df[ df['total_enrollment'] < 1000 ]
low_enrollment = df[df['sat_score'] < 1000]
如何将它们组合成一行?这不起作用。
low_enrollment = df[ df['total_enrollment'] < 1000 and df['sat_score'] < 1000]
【问题讨论】:
low_enrollment = df[ df['total_enrollment'] < 1000 ]
low_enrollment = df[df['sat_score'] < 1000]
如何将它们组合成一行?这不起作用。
low_enrollment = df[ df['total_enrollment'] < 1000 and df['sat_score'] < 1000]
【问题讨论】:
您应该使用 & 运算符进行逻辑运算,而不是 Python and:
low_enrollment = df[(df['total_enrollment'] < 1000) & (df['sat_score'] < 1000)]
【讨论】: