Get startedGet started for free

Parts of a DataFrame

To better understand DataFrame objects, it's useful to know that they consist of three components:

  • values: A two-dimensional NumPy array, accessed via the .to_numpy() method.
  • columns: An index of column names, accessed via the .columns attribute.
  • index: An index for the rows, accessed via the .index attribute.

You can usually think of indexes as a list of strings or numbers, though the pandas Index data type allows for more sophisticated options. (These will be covered later in the course.)

homelessness is available.

This exercise is part of the course

Data Manipulation with pandas

View Course

Exercise instructions

  • Import pandas using the alias pd.
  • Print a 2D NumPy array of the values in homelessness.
  • Print the column names of homelessness.
  • Print the index of homelessness.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import pandas using the alias pd
____

# Print the values of homelessness as a NumPy array
____

# Print the column index of homelessness
____

# Print the row index of homelessness
____
Edit and Run Code