Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Seleccionar Filas y Columnas Específicas | Get Familiar With Indexing and Selecting Data
course content

Contenido del Curso

Advanced Techniques in pandas

Seleccionar Filas y Columnas EspecíficasSeleccionar Filas y Columnas Específicas

Bien, ya te has ocupado de los capítulos anteriores, y ahora es el momento de combinar tus conocimientos. Puedes especificar tanto filas como columnas; para ello, sólo necesitas estar familiarizado con la función .loc[].

Esta función nos permite hacer un montón de operaciones de corte diferentes, pero por ahora, nos limitaremos a consolidar los conocimientos de los capítulos anteriores.

Como siempre, mira el ejemplo y luego la salida.

  • data.loc[2:5, ['Director', 'ReleaseYear']] - produce filas con los índices 2, 3, 4, 5(pero recuerda que los índices empiezan en 0) de las columnas 'Director' y 'ReleaseYear'(.loc[] incluye el último índice que hayas puesto en []).

Tarea

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

¿Todo estuvo claro?

Sección 1. Capítulo 3
toggle bottom row
course content

Contenido del Curso

Advanced Techniques in pandas

Seleccionar Filas y Columnas EspecíficasSeleccionar Filas y Columnas Específicas

Bien, ya te has ocupado de los capítulos anteriores, y ahora es el momento de combinar tus conocimientos. Puedes especificar tanto filas como columnas; para ello, sólo necesitas estar familiarizado con la función .loc[].

Esta función nos permite hacer un montón de operaciones de corte diferentes, pero por ahora, nos limitaremos a consolidar los conocimientos de los capítulos anteriores.

Como siempre, mira el ejemplo y luego la salida.

  • data.loc[2:5, ['Director', 'ReleaseYear']] - produce filas con los índices 2, 3, 4, 5(pero recuerda que los índices empiezan en 0) de las columnas 'Director' y 'ReleaseYear'(.loc[] incluye el último índice que hayas puesto en []).

Tarea

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

¿Todo estuvo claro?

Sección 1. Capítulo 3
toggle bottom row
some-alt