id
int64 1
92
| question
stringlengths 30
96
| expected_answer
stringlengths 1
60
| code
stringlengths 7
155
| category
stringclasses 15
values | difficulty
stringclasses 3
values |
|---|---|---|---|---|---|
1
|
What is the total number of transactions in the dataset?
|
38000
|
len(df)
|
basic_statistics
|
easy
|
2
|
How many unique clients are in the dataset?
|
1218
|
df['client_id'].nunique()
|
basic_statistics
|
easy
|
3
|
How many unique cards are in the dataset?
|
3838
|
df['card_id'].nunique()
|
basic_statistics
|
easy
|
4
|
What is the average transaction amount?
|
43.07
|
df['amount'].mean()
|
basic_statistics
|
easy
|
5
|
What is the median transaction amount?
|
29.15
|
df['amount'].median()
|
basic_statistics
|
easy
|
6
|
What is the maximum transaction amount?
|
1773.35
|
df['amount'].max()
|
basic_statistics
|
easy
|
7
|
What is the minimum transaction amount?
|
-498.00
|
df['amount'].min()
|
basic_statistics
|
easy
|
8
|
What is the standard deviation of transaction amounts?
|
81.05
|
df['amount'].std()
|
basic_statistics
|
medium
|
9
|
How many transactions are made with Visa cards?
|
14249
|
len(df[df['card_brand'] == 'Visa'])
|
card_analysis
|
easy
|
10
|
How many transactions are made with Mastercard cards?
|
20405
|
len(df[df['card_brand'] == 'Mastercard'])
|
card_analysis
|
easy
|
11
|
Which card brand has the most transactions?
|
Mastercard
|
df['card_brand'].value_counts().index[0]
|
card_analysis
|
easy
|
12
|
What percentage of transactions use Swipe Transactions?
|
52.50%
|
(len(df[df['use_chip'] == 'Swipe Transaction']) / len(df) * 100)
|
card_analysis
|
medium
|
13
|
How many transactions are made with Amex cards?
|
2409
|
len(df[df['card_brand'] == 'Amex'])
|
card_analysis
|
easy
|
14
|
How many unique merchant cities are in the dataset?
|
3459
|
df['merchant_city'].nunique()
|
geographic
|
easy
|
15
|
Which merchant state has the most transactions?
|
CA
|
df['merchant_state'].value_counts().index[0]
|
geographic
|
easy
|
16
|
How many transactions have missing merchant_state information?
|
4390
|
df['merchant_state'].isna().sum()
|
geographic
|
medium
|
17
|
What is the most common merchant city?
|
ONLINE
|
df['merchant_city'].value_counts().index[0]
|
geographic
|
easy
|
18
|
How many transactions are labeled as fraudulent?
|
27
|
len(df[df['fraud_label'] == 'Yes'])
|
fraud_analysis
|
easy
|
19
|
How many transactions are not fraudulent?
|
25408
|
len(df[df['fraud_label'] == 'No'])
|
fraud_analysis
|
easy
|
20
|
What percentage of transactions are fraudulent?
|
0.11%
|
(len(df[df['fraud_label'] == 'Yes']) / len(df[df['fraud_label'].notna()]) * 100)
|
fraud_analysis
|
medium
|
21
|
How many transactions have missing fraud labels?
|
12565
|
df['fraud_label'].isna().sum()
|
fraud_analysis
|
easy
|
22
|
What is the average credit score in the dataset?
|
713.26
|
df['credit_score'].mean()
|
credit_analysis
|
easy
|
23
|
What is the maximum credit score?
|
850
|
int(df['credit_score'].max())
|
credit_analysis
|
easy
|
24
|
What is the minimum credit score?
|
488
|
int(df['credit_score'].min())
|
credit_analysis
|
easy
|
25
|
How many clients have a credit score above 750?
|
10492
|
len(df[df['credit_score'] > 750])
|
credit_analysis
|
medium
|
26
|
What is the average yearly income in the dataset?
|
46717.33
|
df['yearly_income'].mean()
|
income_analysis
|
easy
|
27
|
What is the average per capita income?
|
24003.13
|
df['per_capita_income'].mean()
|
income_analysis
|
easy
|
28
|
What is the maximum yearly income?
|
280199.00
|
df['yearly_income'].max()
|
income_analysis
|
easy
|
29
|
How many clients have yearly income greater than 50000?
|
11949
|
len(df[df['yearly_income'] > 50000])
|
income_analysis
|
medium
|
30
|
What is the average total debt in the dataset?
|
58032.68
|
df['total_debt'].mean()
|
debt_analysis
|
easy
|
31
|
What is the maximum total debt?
|
461854.00
|
df['total_debt'].max()
|
debt_analysis
|
easy
|
32
|
How many clients have total debt greater than 100000?
|
6866
|
len(df[df['total_debt'] > 100000])
|
debt_analysis
|
medium
|
33
|
What is the average credit limit?
|
15620.43
|
df['credit_limit'].mean()
|
credit_limit
|
easy
|
34
|
What is the maximum credit limit?
|
141391.00
|
df['credit_limit'].max()
|
credit_limit
|
easy
|
35
|
How many cards have credit limit of 0?
|
158
|
len(df[df['credit_limit'] == 0])
|
credit_limit
|
medium
|
36
|
What is the average age of clients?
|
54.09
|
df['current_age'].mean()
|
demographics
|
easy
|
37
|
What is the oldest client age?
|
101
|
int(df['current_age'].max())
|
demographics
|
easy
|
38
|
What is the youngest client age?
|
23
|
int(df['current_age'].min())
|
demographics
|
easy
|
39
|
How many clients are over 60 years old?
|
11986
|
len(df[df['current_age'] > 60])
|
demographics
|
medium
|
40
|
How many male clients are in the dataset?
|
18544
|
len(df[df['gender'] == 'Male'])
|
demographics
|
easy
|
41
|
How many female clients are in the dataset?
|
19456
|
len(df[df['gender'] == 'Female'])
|
demographics
|
easy
|
42
|
What is the gender ratio (Male:Female)?
|
18544:19456
|
f"{len(df[df['gender'] == 'Male'])}:{len(df[df['gender'] == 'Female'])}"
|
demographics
|
medium
|
43
|
How many unique merchant categories are in the dataset?
|
104
|
df['mcc_description'].nunique()
|
merchant
|
easy
|
44
|
What is the most common merchant category?
|
Grocery Stores, Supermarkets
|
df['mcc_description'].value_counts().index[0]
|
merchant
|
easy
|
45
|
How many transactions are for Eating Places and Restaurants?
|
2972
|
len(df[df['mcc_description'] == 'Eating Places and Restaurants'])
|
merchant
|
medium
|
46
|
How many Debit card transactions are there?
|
23789
|
len(df[df['card_type'] == 'Debit'])
|
card_analysis
|
easy
|
47
|
How many Credit card transactions are there?
|
11658
|
len(df[df['card_type'] == 'Credit'])
|
card_analysis
|
easy
|
48
|
What is the most common card type?
|
Debit
|
df['card_type'].value_counts().index[0]
|
card_analysis
|
easy
|
49
|
How many Online transactions are there?
|
4371
|
len(df[df['use_chip'] == 'Online Transaction'])
|
transaction_type
|
easy
|
50
|
How many Chip transactions are there?
|
13680
|
len(df[df['use_chip'] == 'Chip Transaction'])
|
transaction_type
|
easy
|
51
|
What percentage of transactions are Online?
|
11.50%
|
(len(df[df['use_chip'] == 'Online Transaction']) / len(df) * 100)
|
transaction_type
|
medium
|
52
|
How many transactions have errors?
|
614
|
df['errors'].notna().sum()
|
error_analysis
|
easy
|
53
|
What percentage of transactions have errors?
|
1.62%
|
(df['errors'].notna().sum() / len(df) * 100)
|
error_analysis
|
medium
|
54
|
What is the most common error type?
|
Insufficient Balance
|
df['errors'].value_counts().index[0]
|
error_analysis
|
medium
|
55
|
What is the earliest transaction date?
|
2010-01-01
|
df['transaction_date'].min().split()[0]
|
temporal
|
easy
|
56
|
What is the latest transaction date?
|
2019-10-31
|
df['transaction_date'].max().split()[0]
|
temporal
|
easy
|
57
|
How many Visa card transactions are fraudulent?
|
13
|
len(df[(df['card_brand'] == 'Visa') & (df['fraud_label'] == 'Yes')])
|
complex_query
|
medium
|
58
|
How many clients have more than 3 credit cards?
|
21850
|
len(df[df['num_credit_cards'] > 3])
|
complex_query
|
medium
|
59
|
How many transactions are made with cards that have chips?
|
34242
|
len(df[df['has_chip'] == 'YES'])
|
card_analysis
|
easy
|
60
|
What percentage of cards have EMV chips?
|
90.11%
|
(len(df[df['has_chip'] == 'YES']) / len(df) * 100)
|
card_analysis
|
medium
|
61
|
How many transactions occurred in Texas (TX)?
|
2841
|
len(df[df['merchant_state'] == 'TX'])
|
geographic
|
medium
|
62
|
How many retired clients (age > 65) are in the dataset?
|
8485
|
len(df[df['current_age'] > 65])
|
demographics
|
medium
|
63
|
How many clients are issued exactly 2 cards?
|
19330
|
len(df[df['num_cards_issued'] == 2])
|
card_analysis
|
medium
|
64
|
What is the most common number of credit cards clients have?
|
4
|
int(df['num_credit_cards'].mode()[0])
|
demographics
|
medium
|
65
|
How many unique merchant IDs are in the dataset?
|
6183
|
df['merchant_id'].nunique()
|
merchant
|
easy
|
66
|
What is the average number of cards issued per client?
|
1.52
|
df['num_cards_issued'].mean()
|
card_analysis
|
medium
|
67
|
How many transactions have negative amounts?
|
1925
|
len(df[df['amount'] < 0])
|
data_quality
|
medium
|
68
|
How many transactions are from clients born in the 1960s?
|
8823
|
len(df[(df['birth_year'] >= 1960) & (df['birth_year'] < 1970)])
|
demographics
|
medium
|
69
|
What is the latitude range for client addresses?
|
21.30 to 48.53
|
f"{df['latitude'].min():.2f} to {df['latitude'].max():.2f}"
|
geographic
|
medium
|
70
|
What is the longitude range for client addresses?
|
-158.18 to -68.67
|
f"{df['longitude'].min():.2f} to {df['longitude'].max():.2f}"
|
geographic
|
medium
|
71
|
How many transactions involve clients with credit score above 700 AND yearly income above 50000?
|
7322
|
len(df[(df['credit_score'] > 700) & (df['yearly_income'] > 50000)])
|
complex_query
|
hard
|
72
|
What is the average transaction amount for fraudulent transactions?
|
80.78
|
df[df['fraud_label'] == 'Yes']['amount'].mean()
|
complex_query
|
hard
|
73
|
What is the average transaction amount for non-fraudulent transactions?
|
42.94
|
df[df['fraud_label'] == 'No']['amount'].mean()
|
complex_query
|
hard
|
74
|
What is the average credit limit for clients with high debt (>100000)?
|
22458.09
|
df[df['total_debt'] > 100000]['credit_limit'].mean()
|
complex_query
|
hard
|
75
|
What percentage of the dataset has missing values?
|
3.98%
|
(df.isna().sum().sum() / (len(df) * len(df.columns)) * 100)
|
data_quality
|
hard
|
76
|
What is the average amount for transactions in Texas?
|
45.15
|
df[df['merchant_state'] == 'TX']['amount'].mean()
|
geographic
|
hard
|
77
|
What is the debt-to-income ratio for the average client?
|
1.24
|
df['total_debt'].mean() / df['yearly_income'].mean()
|
complex_query
|
hard
|
78
|
How many transactions were made by clients older than the median age?
|
18121
|
len(df[df['current_age'] > df['current_age'].median()])
|
demographics
|
hard
|
79
|
What is the correlation between credit score and yearly income?
|
-0.0329
|
df['credit_score'].corr(df['yearly_income'])
|
complex_query
|
hard
|
80
|
How many transactions involve amounts greater than 2 standard deviations from the mean?
|
1094
|
len(df[np.abs(df['amount'] - df['amount'].mean()) > 2 * df['amount'].std()])
|
complex_query
|
hard
|
81
|
What is the fraud rate for clients with credit score below 650?
|
0.04%
|
(len(df[(df['credit_score'] < 650) & (df['fraud_label'] == 'Yes')]) / len(df[df['credit_score'] < 650]) * 100)
|
fraud_analysis
|
hard
|
82
|
How many transactions are from the top 10 merchant cities by volume?
|
6563
|
len(df[df['merchant_city'].isin(df['merchant_city'].value_counts().head(10).index)])
|
merchant
|
hard
|
83
|
What is the average transaction amount for each card brand?
|
Visa: 41.17, Mastercard: 43.79, Amex: 46.48, Discover: 44.14
|
df.groupby('card_brand')['amount'].mean().round(2).to_dict()
|
complex_query
|
hard
|
84
|
What percentage of fraudulent transactions use Online payment method?
|
40.74%
|
(len(df[(df['fraud_label'] == 'Yes') & (df['use_chip'] == 'Online Transaction')]) / len(df[df['fraud_label'] == 'Yes']) * 100)
|
fraud_analysis
|
hard
|
85
|
What is the average credit score for clients with fraudulent transactions?
|
718.04
|
df[df['fraud_label'] == 'Yes']['credit_score'].mean()
|
fraud_analysis
|
hard
|
86
|
How does average transaction amount vary by card type?
|
Debit: 42.51, Credit: 43.91, Debit (Prepaid): 45.32
|
df.groupby('card_type')['amount'].mean().round(2).to_dict()
|
complex_query
|
hard
|
87
|
What percentage of clients with total debt > yearly income exist?
|
1825.86%
|
len(df[df['total_debt'] > df['yearly_income']]) / len(df.drop_duplicates('client_id')) * 100
|
complex_query
|
hard
|
88
|
What is the median transaction amount by fraud status?
|
Fraudulent: 27.50, Non-Fraudulent: 29.28
|
df.groupby('fraud_label')['amount'].median().round(2).to_dict()
|
fraud_analysis
|
hard
|
89
|
How many transactions exceed the typical transaction amount by more than 3 standard deviations?
|
465
|
len(df[df['amount'] > df['amount'].mean() + 3 * df['amount'].std()])
|
data_quality
|
hard
|
90
|
What is the relationship between number of credit cards and fraud rate?
|
Requires groupby analysis
|
df.groupby('num_credit_cards').apply(lambda x: (x['fraud_label'] == 'Yes').sum() / x['fraud_label'].notna().sum() * 100)
|
complex_query
|
hard
|
91
|
Which states have the highest average transaction amount?
|
Requires top states analysis
|
df.groupby('merchant_state')['amount'].mean().nlargest(5)
|
geographic
|
hard
|
92
|
What is the average age difference between clients with high vs low debt?
|
-19.85
|
df[df['total_debt'] > df['total_debt'].quantile(0.75)]['current_age'].mean() - df[df['total_debt'] < df['total_debt'].quantile(0.25)]['current_age'].mean()
|
demographics
|
hard
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.