Pandas & Data Analysis·Pandas from first Series to analysis project

DataFrames

Work with two-dimensional tables, columns and the index.

Beginner 13 min read Lesson 2 of 300 Challenge included
What you will be able to do
  • Use pd.DataFrame with a dictionary of columns.
  • Inspect with shape, dtypes, head and info.
  • Select columns with df["name"].
  • Avoid modifying a slice; use .loc.

In plain English

A DataFrame is a collection of Series that share an index. Columns can have different types. Inspect shape, dtypes and missing values before doing any analysis.

dataframe.pyPython
import pandas as pd

df = pd.DataFrame({
    'course': ['HTML', 'CSS', 'SQL'],
    'minutes': [12, 18, 9],
})
print(df.shape)
print(df.dtypes)
print(df['minutes'].sum())
Your turn

Build a DataFrame

Easy

Create a DataFrame with course and minutes columns and print its shape.

PYTHON · starter
df = pd.DataFrame({})
Check your understanding before moving on.
Knowledge checkQuestion 1

What does df.shape return?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Loading data
Lesson 2 of 300 · 0% of course