Compute specialty spend share and top age band
Problem Description
You are provided with healthcare claims data distributed across several tables. Your task is to perform a series of data manipulation operations using SQL and Python (Pandas) to derive specific insights.
Data Model
The following table schemas are provided. Data types should be adapted to your specific SQL dialect.
mem1
member_id(INT, PRIMARY KEY)age_band(VARCHAR)
mem2
member_id(INT, PRIMARY KEY)age_band(VARCHAR)
claim
claim_id(INT, PRIMARY KEY)member_id(INT)specialty(VARCHAR)paid_amt(DECIMAL(12,2))claim_date(DATE)
risk (Optional)
member_id(INT)risk_score(DECIMAL(10,4))
This table is provided but may not be necessary for the tasks.
Assumptions
- A
claim.member_idwill correspond to an entry in eithermem1.member_idormem2.member_id. claim_datevalues are in UTC.- "Year = 2017" refers to the calendar year 2017.
Part A: SQL Analysis - Specialty Spend Share
For each unique specialty, calculate:
- The
total_paid_amt: The sum of allpaid_amtfor that specialty. - The
paid_share: The percentage share of that specialty'stotal_paid_amtrelative to the totalpaid_amtacross all claims.
Expected Output Columns: specialty, total_paid_amt, paid_share.
Part B: SQL Analysis - Top Age Band by Claim Count (2017)
Focusing exclusively on claims from calendar year 2017, perform the following steps:
- Consolidate all members from
mem1andmem2into a single, unified member set. - Join this unified member set with the relevant claims data.
- Compute the total count of claims for each distinct
age_band. - Identify and return the
age_band(s) that have the maximum number of claims. If multiple age bands share the maximum count, all such age bands should be included in the output.
Expected Output Columns: age_band, claim_cnt.
Part C: Python / Pandas Analysis - Monthly Gender Spend
You will be provided with a Pandas DataFrame named df_claims containing the following columns:
paid_amt(numeric)gender(string, with values 'M' or 'F')claim_timestamp(string or datetime-like object)
Perform the following tasks:
- Recode the
gendercolumn: change 'M' to 'male' and 'F' to 'female'. - Calculate the total
paid_amtfor each month in the year 2017, grouped bygenderand month.
Expected Output: A Pandas DataFrame with columns such as gender, month (representing months 1-12), and total_paid_amt. An optional year column may also be included.
AI interview prep
Core dilemma
Ensuring accurate and efficient data aggregation across potentially disparate data sources while handling data quality nuances and performance at scale.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Compute specialty spend share and top age band
Problem Description
You are provided with healthcare claims data distributed across several tables. Your task is to perform a series of data manipulation operations using SQL and Python (Pandas) to derive specific insights.
Data Model
The following table schemas are provided. Data types should be adapted to your specific SQL dialect.
mem1
member_id(INT, PRIMARY KEY)age_band(VARCHAR)
mem2
member_id(INT, PRIMARY KEY)age_band(VARCHAR)
claim
claim_id(INT, PRIMARY KEY)member_id(INT)specialty(VARCHAR)paid_amt(DECIMAL(12,2))claim_date(DATE)
risk (Optional)
member_id(INT)risk_score(DECIMAL(10,4))
This table is provided but may not be necessary for the tasks.
Assumptions
- A
claim.member_idwill correspond to an entry in eithermem1.member_idormem2.member_id. claim_datevalues are in UTC.- "Year = 2017" refers to the calendar year 2017.
Part A: SQL Analysis - Specialty Spend Share
For each unique specialty, calculate:
- The
total_paid_amt: The sum of allpaid_amtfor that specialty. - The
paid_share: The percentage share of that specialty'stotal_paid_amtrelative to the totalpaid_amtacross all claims.
Expected Output Columns: specialty, total_paid_amt, paid_share.
Part B: SQL Analysis - Top Age Band by Claim Count (2017)
Focusing exclusively on claims from calendar year 2017, perform the following steps:
- Consolidate all members from
mem1andmem2into a single, unified member set. - Join this unified member set with the relevant claims data.
- Compute the total count of claims for each distinct
age_band. - Identify and return the
age_band(s) that have the maximum number of claims. If multiple age bands share the maximum count, all such age bands should be included in the output.
Expected Output Columns: age_band, claim_cnt.
Part C: Python / Pandas Analysis - Monthly Gender Spend
You will be provided with a Pandas DataFrame named df_claims containing the following columns:
paid_amt(numeric)gender(string, with values 'M' or 'F')claim_timestamp(string or datetime-like object)
Perform the following tasks:
- Recode the
gendercolumn: change 'M' to 'male' and 'F' to 'female'. - Calculate the total
paid_amtfor each month in the year 2017, grouped bygenderand month.
Expected Output: A Pandas DataFrame with columns such as gender, month (representing months 1-12), and total_paid_amt. An optional year column may also be included.