← 返回题库
初级

数据分析-数据过滤

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve():
    import pandas as pd
    df = pd.read_csv('https://liangdaima.com/static/data/ds_iris.csv')
    result = df[(df['sepal_length'] > 5) & (df['petal_length'] < 4)]
    print(result.head(5))

示例

输入
solve()
期望输出
sepal_length  sepal_width  petal_length  petal_width     species
5            5.4          3.9           1.7          0.4      setosa
6            4.6          3.4           1.4          0.3      setosa
7            5.0          3.4           1.5          0.2      setosa
10           5.4          3.7           1.5          0.2      setosa
11           4.8          3.4           1.6          0.2      setosa
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码