DataFrames
Work with two-dimensional tables, columns and the index.
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.
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
EasyBuild a DataFrame
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 inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.