Delete data
Remove rows or columns from your table to simplify your dataset.
Example Data
Follow along with right out of the box example data. Copy following data in the information request of the agent you are working in.
We often focus on only the data that’s relevant to a specific question. Sometimes this means removing rows we don’t need — like transactions below a certain amount — or dropping entire columns that don’t help our analysis. Deleting unnecessary data makes your table easier to work with and interpret, just like trimming excess text in a report.
In this section, you’ll learn how to remove rows and columns from your dataset using simple Python commands.
Delete a column
Excel
In Excel, you right-click the column header and choose "Delete" or press the delete key after selecting the column.
t0 Prompt
Delete the "Currency" column
Remove the column called "Transaction"
Drop column X from the table
Code
The python code looks as follows:
Delete multiple columns
Excel
In Excel, you select several columns and delete them together.
t0 Prompt
Drop the columns "Seller" and "Buyer"
Remove columns X and Z from my data
Code
The python code looks as follows:
Delete rows by condition
Excel
In Excel, you might filter rows and then delete them manually, or use a formula to flag which rows to remove.
t0 Prompt
Delete all rows where amount is less than 5 million
Remove transactions before 2025.2.1
Drop rows that meet condition X > Y
Code
The python code looks as follows:
Function | Description |
---|---|
drop(columns=["..."]) | Deletes one or more columns |
df[df["Column"] >= value] | Keeps only rows that meet a condition |