SELECT customerName, Yearly_Income
FROM customers
WHERE Yearly_Income BETWEEN 21000 AND 100000
LIMIT 5;
EVALUATE
TOPN(
5,
SELECTCOLUMNS(
FILTER(
Customer,
Customer[Yearly Income] >= 21000 && Customers[Yearly Income] <= 100000
),
"CustomerName", Customer[Name],
"CreditLimit", Customer[Yearly Income]
)
)
import pandas as pd
df = pd.read_csv('customers.csv')
# Filter the DataFrame to include rows where Yearly Income is between 21,000 and 100,000
result = df[(df['Yearly Income'] >= 21000) & (df['Yearly Income'] <= 100000)][['customerName', 'creditLimit']]
# Limit the results to 5 rows
result = result.head(5)
# Convert to a list of lists
result_list = result.values.tolist()
print(result_list)
| John Doe | 45000 |
| Jane Smith | 22000 |
| Bob Brown | 80000 |
| Chris Green | 25000 |
FILTER(Customers, Customers[Yearly Income] >= 21000 && Customers[Yearly Income] <= 100000): Filters the Customers table to include rows where the Yearly Income is between 21,000 and 100,000. SELECTCOLUMNS: Selects the customerName and creditLimit columns and returns them as "CustomerName" and "Yearly Income" in the output. TOPN(5, ...): Limits the number of rows returned to 5
Leave a Comment