← Pandas
Lesson 1 of 5
Series and DataFrames
Watch, read the card, then practise. Creating DataFrames · Looking at your data · Selecting columns
The video for this lesson is being recorded.
Meanwhile, the notes below and the 60-second cards cover the same ideas.
Practise this topicCreating DataFrames
A DataFrame is a table with named columns. Each column is a Series.
Remember: Think of a DataFrame as a spreadsheet you control with code.
Looking at your data
Look at your data before analysing it: its size, first rows and column types.
Remember: head, info, describe: run these first, every time.
Selecting columns
Pick one column with df['col'] (a Series) or several with df[['a', 'b']] (a DataFrame).
Remember: One bracket: a column. Two brackets: a table.
Try the example in Code Lab
import pandas as pd
df = pd.DataFrame({"name": ["Asha", "Ravi"], "marks": [82, 67]})
print(df.shape, list(df.columns))