Square brackets after a DataFrame pick columns.
- One name gives a Series, a single column with the index:
df["revenue"]
- A list of names gives a DataFrame, so you write two pairs of brackets. The outer pair selects; the inner pair is the Python list:
df[["product", "revenue"]]
The columns come back in the order you list them, which is how you reorder a table for a report. To keep everything except a few columns, drop them instead: df.drop(columns=["order_id"]).
You can also write df.revenue for a column whose name has no spaces, but brackets always work, so this course uses them. A Series has its own methods: df["revenue"].sum() adds up one column, and df["revenue"].max() finds its largest value.
Column names are case-sensitive. df["Revenue"] fails with a KeyError because the column is called revenue.