New columns from old ones
Compute revenue, conversions and yes/no flags for every row.
Often the number you need is not in the table yet, but can be built from columns that are. Assigning to a new name creates a column: sales["revenue"] = sales["units"] * sales["price"] multiplies row by row, all at once. You can also store a comparison as a True/False flag column, or round with .round(2). New columns make later steps (sorting, grouping, charting) much simpler.
import io
import pandas as pd
csv_text = """day,store,item,units,price
Mon,North,Coffee,30,3.5
Mon,North,Muffin,12,2.75
Mon,South,Coffee,22,3.5
Mon,South,Tea,9,3.0
Tue,North,Coffee,35,3.5
Tue,North,Tea,7,3.0
Tue,South,Coffee,18,3.5
Tue,South,Muffin,15,2.75
Wed,North,Muffin,10,2.75
Wed,South,Coffee,27,3.5
"""
sales = pd.read_csv(io.StringIO(csv_text))
sales["revenue"] = sales["units"] * sales["price"]
sales["big_order"] = sales["units"] >= 20
print(sales.head())
print(sales["revenue"].sum())Row by row, units times price gives revenue (30 * 3.5 = 105 for the first row). big_order is True when a row sold 20 or more units. Total revenue is 611.75.
Assigning to an existing column name replaces it. That is handy for fixing a column, but be careful not to overwrite data you still need.