IconResources
Conduct analysis

Extract data

Create a subset of your data based on filters or conditions.

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 rarely use all the data at once. Instead, we extract a relevant subset: perhaps transactions over $10 million, or only those involving a specific country. This allows us to focus on the question we’re trying to answer. Extracting data is like zooming in on one part of a graph — it gives clarity and insight.

In this section, you'll learn how to create new tables based on a condition, such as value thresholds, country names, or transaction types.

Extract rows based on one condition

Excel

In Excel, you use filters or conditional formatting to show only rows that meet a certain condition.

t0 Prompt

Give me all rows where the amount is over 10 million

Extract transactions from Sweden

Show only goods transactions

Code

The python code looks as follows:

transactions["Amount"] = pd.to_numeric(transactions["Amount"])
high_value = transactions[transactions["Amount"] > 10_000_000]
high_value

Extract rows based on multiple conditions

Excel

In Excel, you might apply filters to multiple columns or use formulas like =AND() or =OR().

t0 Prompt

Show me rows where amount is over 10 million and buyer country is Brazil

Extract transactions that are services and from Italy

Filter column X by condition Z and Y

Code

The python code looks as follows:

transactions["Amount"] = pd.to_numeric(transactions["Amount"])
subset = transactions[
    (transactions["Amount"] > 10_000_000) &
    (transactions["Buyer Country"] == "Brazil")
]
subset

Extract specific columns only

Excel

In Excel, you might copy specific columns into a new worksheet to focus your analysis.

t0 Prompt

Give me only the date, amount, and seller

I want to work with a smaller table

Extract columns X and Y

Code

The python code looks as follows:

small_table = transactions[["Date", "Amount", "Seller"]]
small_table
FunctionDescription
df[condition]Extracts rows where the condition is True
df[["col1", "col2"]]Selects specific columns

On this page