Seleccionar Datos

DataFrame students

+-------------+--------+ | Column Name | Type | +-------------+--------+ | student_id | int | | name | object | | age | int | +-------------+--------+

Escribe una solución para seleccionar el nombre y la edad del estudiante con student_id = 101.

Ejemplo

Input

+------------+---------+-----+ | student_id | name | age | +------------+---------+-----+ | 101 | Ulysses | 13 | | 53 | William | 10 | | 128 | Henry | 6 | | 3 | Henry | 11 | +------------+---------+-----+

Output

+---------+-----+ | name | age | +---------+-----+ | Ulysses | 13 | +---------+-----+ Explicación: El estudiante Ulises tiene student_id = 101, seleccionamos el nombre y la edad.

Soluciones

Python
import pandas as pd

def selectData(students: pd.DataFrame) -> pd.DataFrame:
    return students[students['student_id'] == 101][['name','age']] 
BUSCARCtrl K