Skip to Content
Learn
Creating, Loading, and Selecting Data with Pandas
Inspect a DataFrame

When we load a new DataFrame from a CSV, we want to know what it looks like.

If it’s a small DataFrame, you can display it by typing print(df).

If it’s a larger DataFrame, it’s helpful to be able to inspect a few items without having to look at the entire DataFrame.

The method .head() gives the first 5 rows of a DataFrame. If you want to see more rows, you can pass in the positional argument n. For example, df.head(10) would show the first 10 rows.

The method df.info() gives some statistics for each column.

Instructions

1.

You’re working for a Hollywood studio, trying to use data to predict the next big hit. Load the CSV imdb.csv into a variable called df, so that you can learn about popular movies from the past 90 years.

2.

Let’s learn about these movies.

Paste the following code into script.py:

print(df.head())

What happens when you press “Run”?

3.

What exactly is in this dataset?

Paste the following code into script.py to learn more about this data:

print(df.info())

What happens when you press “Run”?

Folder Icon

Sign up to start coding

Already have an account?