Tool: Gemini (web, Google Workspace account), temporary chat, Thinking Saved at: 2026-10-18T17:26:28Z Attached file: sales-jan-jun-2026.csv --- Prompt --- The attached file is our sales export for January to June 2026. Before any analysis, describe this data: number of rows, each column and its type, empty cells, duplicate rows and values that look wrong. Then answer: 1. What was total revenue for each region in Q1 (January to March)? 2. Which product had the highest total revenue over the six months, and how much? 3. By what percentage did total revenue change from March to April? For every number you report, show the formula or code that produced it. If a number needs an assumption, state it. --- Reply, as copied with the site's Copy button --- ```python import os import pandas as pd import numpy as np # Check files in directory print("Files:", os.listdir('.')) # Load sales-jan-jun-2026.csv if present df = pd.read_csv('sales-jan-jun-2026.csv') print("Shape:", df.shape) print(" Info:") print(df.info()) print(" Head:") print(df.head(10)) print(" Tail:") print(df.tail(10)) ``` ```text Files: ['sales-jan-jun-2026.csv'] Shape: (244, 7) Info: RangeIndex: 244 entries, 0 to 243 Data columns (total 7 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 order_id 244 non-null object 1 order_date 244 non-null object 2 region 244 non-null object 3 product 244 non-null object 4 units 244 non-null int64 5 unit_price 244 non-null int64 6 revenue 244 non-null object dtypes: int64(2), object(5) memory usage: 13.5+ KB None Head: order_id order_date region product units unit_price revenue 0 SO-1029 2026-01-02 West Monitor arm 9 89 801.00 1 SO-1040 2026-01-02 North Keyboard 6 59 354.00 2 SO-1006 2026-01-03 South Keyboard 4 59 236.00 3 SO-1006 2026-01-03 South Keyboard 4 59 236.00 4 SO-1013 2026-01-03 South Monitor arm 9 89 801.00 5 SO-1017 2026-01-05 East Keyboard 2 59 118.00 6 SO-1024 2026-01-06 West Keyboard 8 59 472.00 7 SO-1020 2026-01-07 North Desk lamp 10 39 390.00 8 SO-1025 2026-01-07 West Keyboard 5 59 295.00 9 SO-1005 2026-01-08 North Office chair 11 249 2739.00 Tail: order_id order_date region product units unit_price revenue 234 SO-1208 2026-06-19 North Desk lamp 1 39 39.00 235 SO-1227 2026-06-19 South Standing desk 9 499 4491.00 236 SO-1212 2026-06-22 North Monitor arm 11 89 979.00 237 SO-1221 2026-06-22 West Desk lamp 8 39 312.00 238 SO-1226 2026-06-22 North Office chair 7 249 1743.00 239 SO-1213 2026-06-23 East Monitor arm 10 89 890.00 240 SO-1207 2026-06-25 East Standing desk 3 499 1497.00 241 SO-1230 2026-06-25 South Office chair 12 249 2988.00 242 SO-1235 2026-06-26 North Keyboard 7 59 413.00 243 SO-1220 2026-06-28 East Standing desk 7 499 3493.00 ``` ```python # Check duplicates print("Exact duplicate rows:", df.duplicated().sum()) print("Duplicate rows: ", df[df.duplicated(keep=False)]) print(" Duplicate order_id:", df.order_id.duplicated().sum()) # Check nulls / empty strings / whitespace for col in df.columns: n_null = df[col].isnull().sum() n_empty_str = (df[col].astype(str).str.strip() == '').sum() print(f"Column '{col}': nulls={n_null}, empty_str={n_empty_str}") # Check unique values and distributions for categorical columns print(" Unique regions:", df['region'].unique()) print("Unique products:", df['product'].unique()) # Check order_date print(" Min date:", df['order_date'].min(), "Max date:", df['order_date'].max()) # Check if any dates fail parsing invalid_dates = pd.to_datetime(df['order_date'], errors='coerce').isnull().sum() print("Invalid dates count:", invalid_dates) # Check units and unit_price print(" Units describe:") print(df['units'].describe()) print(" Unit price describe:") print(df['unit_price'].describe()) # Check revenue # Why is revenue object? print(" Non-numeric revenue values:") non_num_rev = pd.to_numeric(df['revenue'], errors='coerce') print("Count of coerce NaNs in revenue:", non_num_rev.isnull().sum()) print(df[non_num_rev.isnull()]) ``` ```text Exact duplicate rows: 4 Duplicate rows: order_id order_date region product units unit_price revenue 2 SO-1006 2026-01-03 South Keyboard 4 59 236.00 3 SO-1006 2026-01-03 South Keyboard 4 59 236.00 81 SO-1095 2026-03-01 East Desk lamp 3 39 117.00 82 SO-1095 2026-03-01 East Desk lamp 3 39 117.00 124 SO-1123 2026-04-03 West Keyboard 12 59 708.00 125 SO-1123 2026-04-03 West Keyboard 12 59 708.00 128 SO-1146 2026-04-04 North Desk lamp 5 39 195.00 129 SO-1146 2026-04-04 North Desk lamp 5 39 195.00 Duplicate order_id: 4 Column 'order_id': nulls=0, empty_str=0 Column 'order_date': nulls=0, empty_str=0 Column 'region': nulls=0, empty_str=0 Column 'product': nulls=0, empty_str=0 Column 'units': nulls=0, empty_str=0 Column 'unit_price': nulls=0, empty_str=0 Column 'revenue': nulls=0, empty_str=0 Unique regions: ['West' 'North' 'South' 'East' 'Nort'] Unique products: ['Monitor arm' 'Keyboard' 'Desk lamp' 'Office chair' 'Standing desk'] Min date: 2026-01-02 Max date: 2026-06-28 Invalid dates count: 0 Units describe: count 244.000000 mean 6.000000 std 3.437867 min 1.000000 25% 3.000000 50% 6.000000 75% 9.000000 max 12.000000 Name: units, dtype: float64 Unit price describe: count 244.000000 mean 180.270492 std 159.390637 min 39.000000 25% 59.000000 50% 89.000000 75% 249.000000 max 499.000000 Name: unit_price, dtype: float64 Non-numeric revenue values: Count of coerce NaNs in revenue: 1 order_id order_date region product units unit_price revenue 84 SO-1110 2026-03-01 North Office chair 5 249 1,245.00 ``` ```python # Clean revenue string to float clean_rev = df['revenue'].astype(str).str.replace(',', '').astype(float) expected_rev = df['units'] * df['unit_price'] diff = np.abs(clean_rev - expected_rev) print("Any revenue != units * unit_price?") mismatch = df[diff > 1e-4] print("Mismatches count:", len(mismatch)) if len(mismatch) > 0: print(mismatch.assign(expected=expected_rev[diff > 1e-4], actual=clean_rev[diff > 1e-4], diff=clean_rev[diff > 1e-4] - expected_rev[diff > 1e-4])) # Check 'Nort' print(" Region value counts:") print(df['region'].value_counts()) print(" Rows with 'Nort':") print(df[df['region'] == 'Nort']) # Check unit prices per product print(" Unit price by product:") print(df.groupby('product')['unit_price'].unique()) # Check order_id format print(" Order id format check:") print(df['order_id'].str.match(r'^SO-\d{4}$').all()) print(df['order_id'].value_counts().head(10)) # Check date distribution df['order_date'] = pd.to_datetime(df['order_date']) print(" Monthly order counts:") print(df['order_date'].dt.to_period('M').value_counts().sort_index()) ``` ```text Any revenue != units * unit_price? Mismatches count: 0 Region value counts: region North 72 West 66 South 54 East 51 Nort 1 Name: count, dtype: int64 Rows with 'Nort': order_id order_date region product units unit_price revenue 43 SO-1047 2026-02-02 Nort Keyboard 12 59 708.00 Unit price by product: product Desk lamp [39] Keyboard [59] Monitor arm [89] Office chair [249] Standing desk [499] Name: unit_price, dtype: object Order id format check: True order_id SO-1123 2 SO-1006 2 SO-1146 2 SO-1095 2 SO-1187 1 SO-1156 1 SO-1137 1 SO-1142 1 SO-1124 1 SO-1128 1 Name: count, dtype: int64 Monthly order counts: order_date 2026-01 41 2026-02 40 2026-03 41 2026-04 42 2026-05 40 2026-06 40 Freq: M, Name: count, dtype: int64 ``` ```python # Let's write code to compute the exact figures under both interpretations # Clean revenue column df['revenue_clean'] = df['revenue'].astype(str).str.replace(',', '').astype(float) df['order_date'] = pd.to_datetime(df['order_date']) df['month'] = df['order_date'].dt.month df['quarter'] = df['order_date'].dt.to_period('Q') # Deduplicated dataframe df_dedup = df.drop_duplicates(subset=['order_id', 'order_date', 'region', 'product', 'units', 'unit_price', 'revenue']).copy() print("--- SCENARIO A: RAW DATA (Keep duplicates) ---") print(" 1. Q1 Revenue by Region (without fixing 'Nort'):") q1_df = df[df['order_date'].between('2026-01-01', '2026-03-31')] print(q1_df.groupby('region')['revenue_clean'].sum()) print(" 1. Q1 Revenue by Region (with 'Nort' -> 'North'):") q1_df_fixed = q1_df.copy() q1_df_fixed['region_clean'] = q1_df_fixed['region'].replace({'Nort': 'North'}) print(q1_df_fixed.groupby('region_clean')['revenue_clean'].sum()) print(" 2. Highest revenue product over 6 months:") prod_rev = df.groupby('product')['revenue_clean'].sum().sort_values(ascending=False) print(prod_rev) print(" 3. Revenue change March to April:") mar_rev = df[df['order_date'].dt.month == 3]['revenue_clean'].sum() apr_rev = df[df['order_date'].dt.month == 4]['revenue_clean'].sum() pct_change = ((apr_rev - mar_rev) / mar_rev) * 100 print(f"March: {mar_rev:,.2f}, April: {apr_rev:,.2f}, Pct change: {pct_change:.2f}% (or {pct_change:.4f}%)") print(" --- SCENARIO B: DEDUPLICATED DATA (Drop 4 duplicate rows) ---") print(" 1. Q1 Revenue by Region (without fixing 'Nort'):") q1_dedup = df_dedup[df_dedup['order_date'].between('2026-01-01', '2026-03-31')] print(q1_dedup.groupby('region')['revenue_clean'].sum()) print(" 1. Q1 Revenue by Region (with 'Nort' -> 'North'):") q1_dedup_fixed = q1_dedup.copy() q1_dedup_fixed['region_clean'] = q1_dedup_fixed['region'].replace({'Nort': 'North'}) print(q1_dedup_fixed.groupby('region_clean')['revenue_clean'].sum()) print(" 2. Highest revenue product over 6 months:") prod_rev_dedup = df_dedup.groupby('product')['revenue_clean'].sum().sort_values(ascending=False) print(prod_rev_dedup) print(" 3. Revenue change March to April:") mar_rev_dedup = df_dedup[df_dedup['order_date'].dt.month == 3]['revenue_clean'].sum() apr_rev_dedup = df_dedup[df_dedup['order_date'].dt.month == 4]['revenue_clean'].sum() pct_change_dedup = ((apr_rev_dedup - mar_rev_dedup) / mar_rev_dedup) * 100 print(f"March: {mar_rev_dedup:,.2f}, April: {apr_rev_dedup:,.2f}, Pct change: {pct_change_dedup:.2f}% (or {pct_change_dedup:.4f}%)") ``` ```text --- SCENARIO A: RAW DATA (Keep duplicates) --- 1. Q1 Revenue by Region (without fixing 'Nort'): region East 28280.0 Nort 708.0 North 35679.0 South 23565.0 West 31594.0 Name: revenue_clean, dtype: float64 1. Q1 Revenue by Region (with 'Nort' -> 'North'): region_clean East 28280.0 North 36387.0 South 23565.0 West 31594.0 Name: revenue_clean, dtype: float64 2. Highest revenue product over 6 months: product Standing desk 107784.0 Office chair 91881.0 Monitor arm 23941.0 Keyboard 22243.0 Desk lamp 9087.0 Name: revenue_clean, dtype: float64 3. Revenue change March to April: March: 50,825.00, April: 43,969.00, Pct change: -13.49% (or -13.4894%) --- SCENARIO B: DEDUPLICATED DATA (Drop 4 duplicate rows) --- 1. Q1 Revenue by Region (without fixing 'Nort'): region East 28163.0 Nort 708.0 North 35679.0 South 23329.0 West 31594.0 Name: revenue_clean, dtype: float64 1. Q1 Revenue by Region (with 'Nort' -> 'North'): region_clean East 28163.0 North 36387.0 South 23329.0 West 31594.0 Name: revenue_clean, dtype: float64 2. Highest revenue product over 6 months: product Standing desk 107784.0 Office chair 91881.0 Monitor arm 23941.0 Keyboard 21299.0 Desk lamp 8775.0 Name: revenue_clean, dtype: float64 3. Revenue change March to April: March: 50,708.00, April: 43,066.00, Pct change: -15.07% (or -15.0706%) ``` ```python dups = df[df.duplicated(keep=False)].sort_values('order_id') print(dups[['order_id', 'order_date', 'region', 'product', 'units', 'unit_price', 'revenue_clean']]) ``` ```text order_id order_date region product units unit_price revenue_clean 2 SO-1006 2026-01-03 South Keyboard 4 59 236.0 3 SO-1006 2026-01-03 South Keyboard 4 59 236.0 81 SO-1095 2026-03-01 East Desk lamp 3 39 117.0 82 SO-1095 2026-03-01 East Desk lamp 3 39 117.0 124 SO-1123 2026-04-03 West Keyboard 12 59 708.0 125 SO-1123 2026-04-03 West Keyboard 12 59 708.0 128 SO-1146 2026-04-04 North Desk lamp 5 39 195.0 129 SO-1146 2026-04-04 North Desk lamp 5 39 195.0 ``` ```python for col in ['order_id', 'region', 'product']: trailing = df[col].astype(str).str.strip() != df[col].astype(str) print(f"Trailing spaces in {col}: {trailing.sum()}") ``` ```text Trailing spaces in order_id: 0 Trailing spaces in region: 0 Trailing spaces in product: 0 ``` ```python print("Order date range:", df['order_date'].min(), "to", df['order_date'].max()) print("Unique order IDs count:", df['order_id'].nunique(), "Total rows:", len(df)) # Check if any order_id appears multiple times with different values dup_ids = df[df.order_id.duplicated(keep=False)] print("Total rows with duplicate order_id:", len(dup_ids)) print(dup_ids.sort_values('order_id')) ``` ```text Order date range: 2026-01-02 00:00:00 to 2026-06-28 00:00:00 Unique order IDs count: 240 Total rows: 244 Total rows with duplicate order_id: 8 order_id order_date region product units unit_price revenue revenue_clean month quarter 2 SO-1006 2026-01-03 South Keyboard 4 59 236.00 236.0 1 2026Q1 3 SO-1006 2026-01-03 South Keyboard 4 59 236.00 236.0 1 2026Q1 81 SO-1095 2026-03-01 East Desk lamp 3 39 117.00 117.0 3 2026Q1 82 SO-1095 2026-03-01 East Desk lamp 3 39 117.00 117.0 3 2026Q1 124 SO-1123 2026-04-03 West Keyboard 12 59 708.00 708.0 4 2026Q2 125 SO-1123 2026-04-03 West Keyboard 12 59 708.00 708.0 4 2026Q2 128 SO-1146 2026-04-04 North Desk lamp 5 39 195.00 195.0 4 2026Q2 129 SO-1146 2026-04-04 North Desk lamp 5 39 195.00 195.0 4 2026Q2 ``` ```python # Let's verify all figures in detail # Cleaning step: df_clean = df.copy() df_clean['revenue_numeric'] = df_clean['revenue'].str.replace(',', '').astype(float) df_clean['region_corrected'] = df_clean['region'].replace({'Nort': 'North'}) df_clean['order_date'] = pd.to_datetime(df_clean['order_date']) # Q1 mask: Jan 1 to Mar 31 q1_mask = df_clean['order_date'].dt.quarter == 1 # Scenario 1: Cleaned & Deduplicated (Recommended) df_dedup = df_clean.drop_duplicates(subset=['order_id', 'order_date', 'region', 'product', 'units', 'unit_price', 'revenue']) print("--- Scenario 1: Deduplicated & 'Nort' -> 'North' ---") q1_dedup = df_dedup[df_dedup['order_date'].dt.quarter == 1] q1_by_region_dedup = q1_dedup.groupby('region_corrected')['revenue_numeric'].sum() print("Q1 Revenue by Region:") for reg, val in q1_by_region_dedup.items(): print(f" {reg}: ${val:,.2f}") print(f" Total Q1: ${q1_by_region_dedup.sum():,.2f}") prod_rev_dedup = df_dedup.groupby('product')['revenue_numeric'].sum().sort_values(ascending=False) print(" Product revenue over 6 months:") for p, v in prod_rev_dedup.items(): print(f" {p}: ${v:,.2f}") mar_rev_dedup = df_dedup[df_dedup['order_date'].dt.month == 3]['revenue_numeric'].sum() apr_rev_dedup = df_dedup[df_dedup['order_date'].dt.month == 4]['revenue_numeric'].sum() pct_dedup = ((apr_rev_dedup - mar_rev_dedup) / mar_rev_dedup) * 100 print(f" March Revenue: ${mar_rev_dedup:,.2f}") print(f"April Revenue: ${apr_rev_dedup:,.2f}") print(f"Percentage Change: {pct_dedup:.4f}% ({pct_dedup:.2f}%)") print(" --- Scenario 2: Raw data (Duplicates Kept) ---") q1_raw = df_clean[q1_mask] print("Q1 Revenue by Region (with 'Nort' corrected to 'North'):") q1_by_region_raw_fixed = q1_raw.groupby('region_corrected')['revenue_numeric'].sum() for reg, val in q1_by_region_raw_fixed.items(): print(f" {reg}: ${val:,.2f}") print(" Q1 Revenue by Region (with 'Nort' kept separate):") q1_by_region_raw_unfixed = q1_raw.groupby('region')['revenue_numeric'].sum() for reg, val in q1_by_region_raw_unfixed.items(): print(f" {reg}: ${val:,.2f}") prod_rev_raw = df_clean.groupby('product')['revenue_numeric'].sum().sort_values(ascending=False) print(" Product revenue over 6 months (raw):") for p, v in prod_rev_raw.items(): print(f" {p}: ${v:,.2f}") mar_rev_raw = df_clean[df_clean['order_date'].dt.month == 3]['revenue_numeric'].sum() apr_rev_raw = df_clean[df_clean['order_date'].dt.month == 4]['revenue_numeric'].sum() pct_raw = ((apr_rev_raw - mar_rev_raw) / mar_rev_raw) * 100 print(f" March Revenue: ${mar_rev_raw:,.2f}") print(f"April Revenue: ${apr_rev_raw:,.2f}") print(f"Percentage Change: {pct_raw:.4f}% ({pct_raw:.2f}%)") ``` ```text --- Scenario 1: Deduplicated & 'Nort' -> 'North' --- Q1 Revenue by Region: East: $28,163.00 North: $36,387.00 South: $23,329.00 West: $31,594.00 Total Q1: $119,473.00 Product revenue over 6 months: Standing desk: $107,784.00 Office chair: $91,881.00 Monitor arm: $23,941.00 Keyboard: $21,299.00 Desk lamp: $8,775.00 March Revenue: $50,708.00 April Revenue: $43,066.00 Percentage Change: -15.0706% (-15.07%) --- Scenario 2: Raw data (Duplicates Kept) --- Q1 Revenue by Region (with 'Nort' corrected to 'North'): East: $28,280.00 North: $36,387.00 South: $23,565.00 West: $31,594.00 Q1 Revenue by Region (with 'Nort' kept separate): East: $28,280.00 Nort: $708.00 North: $35,679.00 South: $23,565.00 West: $31,594.00 Product revenue over 6 months (raw): Standing desk: $107,784.00 Office chair: $91,881.00 Monitor arm: $23,941.00 Keyboard: $22,243.00 Desk lamp: $9,087.00 March Revenue: $50,825.00 April Revenue: $43,969.00 Percentage Change: -13.4894% (-13.49%) ``` The dataset contains **244 rows** and **7 columns** covering sales transactions between January 2, 2026, and June 28, 2026. --- ### Data Description #### 1. Columns and Data Types | Column Name | Inferred Dtype | Logical Type | Description & Domain | | --- | --- | --- | --- | | `order_id` | `object` (string) | Categorical / ID | Unique identifier per order (format `SO-XXXX`). | | `order_date` | `object` (string) | Date (`datetime64`) | Transaction date ranging from `2026-01-02` to `2026-06-28`. | | `region` | `object` (string) | Categorical | Geographic sales territories (`East`, `North`, `South`, `West`, plus 1 typo). | | `product` | `object` (string) | Categorical | 5 distinct products (`Desk lamp`, `Keyboard`, `Monitor arm`, `Office chair`, `Standing desk`). | | `units` | `int64` | Integer | Quantity sold per order (integers from 1 to 12). | | `unit_price` | `int64` | Currency / Float | Unit price: Desk lamp ($39), Keyboard ($59), Monitor arm ($89), Office chair ($249), Standing desk ($499). | | `revenue` | `object` (string) | Currency / Float | Line item revenue. Inferred as string due to comma formatting in one entry. | #### 2. Empty Cells * **0 empty cells**: There are no null, `NaN`, or empty string values in any of the 7 columns. #### 3. Duplicate Rows There are **4 exact duplicate rows** (8 rows total involved across all columns): * `SO-1006` (Rows 2 & 3): `2026-01-03`, South, Keyboard, 4 units, $59/unit, $236.00 * `SO-1095` (Rows 81 & 82): `2026-03-01`, East, Desk lamp, 3 units, $39/unit, $117.00 * `SO-1123` (Rows 124 & 125): `2026-04-03`, West, Keyboard, 12 units, $59/unit, $708.00 * `SO-1146` (Rows 128 & 129): `2026-04-04`, North, Desk lamp, 5 units, $39/unit, $195.00 #### 4. Values That Look Wrong / Anomalies * **Region Typo**: Row 43 (`SO-1047`) has `region = "Nort"`, a misspelling of `"North"`. * **String Formatting in Numeric Field**: Row 84 (`SO-1110`) formats revenue with a comma thousands separator (`"1,245.00"`), whereas all other 243 rows are formatted without commas (e.g., `2739.00`). This causes standard CSV parsers to treat the entire `revenue` column as string text rather than numeric float. * **Exact Duplicate Records**: The 4 duplicate rows noted above artificially inflate sales counts and revenue if not deduplicated. * *Note on Internal Consistency*: For all 244 rows, after removing the comma, $ ext{units} imes ext{unit\_price} = ext{revenue}$ holds true without discrepancy. --- ### Data Preparation Code & Assumptions Because of these anomalies, figures are calculated under two scenarios: 1. **Cleaned (Recommended)**: Deduplicates the 4 redundant rows, maps `"Nort"` to `"North"`, and strips commas to convert `revenue` to numeric float. 2. **Raw Data (As-is)**: Keeps all 244 rows (retaining duplicates) and converts `revenue` to numeric float. ```python import pandas as pd # Load and clean revenue column df = pd.read_csv("sales-jan-jun-2026.csv") df["revenue_clean"] = ( df["revenue"].astype(str).str.replace(",", "").astype(float) ) df["order_date"] = pd.to_datetime(df["order_date"]) # Scenario 1: Cleaned & Deduplicated (Recommended) df_clean = df.drop_duplicates().copy() df_clean["region"] = df_clean["region"].replace({"Nort": "North"}) # Scenario 2: Raw data (df retains duplicates) ``` --- ### Analysis Answers #### 1. Total Revenue for Each Region in Q1 (January to March 2026) **Formula:** $$ ext{Revenue}_{ ext{Region, Q1}} = \sum_{\substack{ ext{Region} = r \ ext{2026-01-01} \le ext{Date} \le ext{2026-03-31}}} ext{Revenue}$$ **Code:** ```python q1_clean = df_clean[df_clean["order_date"].dt.quarter == 1] q1_by_region_clean = q1_clean.groupby("region")["revenue_clean"].sum() q1_raw = df[df["order_date"].dt.quarter == 1] q1_by_region_raw = q1_raw.groupby("region")["revenue_clean"].sum() ``` | Region | Q1 Revenue (Cleaned / Deduplicated) | Q1 Revenue (Raw Data) | Notes | | --- | --- | --- | --- | | **North** | **$36,387.00** | **$36,387.00** | Includes 1 order ($708.00) from typo `"Nort"` | | **West** | **$31,594.00** | **$31,594.00** | No duplicates occurred in Q1 for West | | **East** | **$28,163.00** | **$28,280.00** | Raw includes duplicate order `SO-1095` (+$117.00) | | **South** | **$23,329.00** | **$23,565.00** | Raw includes duplicate order `SO-1006` (+$236.00) | | **Total Q1** | **$119,473.00** | **$119,826.00** | Difference: $353.00 in Q1 duplicate orders | *(If `"Nort"` is kept strictly unmerged in raw data: North = **$35,679.00**, Nort = **$708.00**).* --- #### 2. Product with the Highest Total Revenue Over the Six Months **Formula:** $$ ext{Top Product} = rg\max_p \left( \sum_{ ext{Product} = p} ext{Revenue} ight)$$ **Code:** ```python top_product = ( df_clean.groupby("product")["revenue_clean"].sum().sort_values(ascending=False) ) ``` **Standing desk** generated the highest total revenue over the six months: **$107,784.00**. Because none of the Standing desk orders were duplicated, the total is identical under both Cleaned and Raw assumptions: | Product | 6-Month Revenue (Cleaned) | 6-Month Revenue (Raw) | | --- | --- | --- | | **Standing desk** | **$107,784.00** | **$107,784.00** | | Office chair | $91,881.00 | $91,881.00 | | Monitor arm | $23,941.00 | $23,941.00 | | Keyboard | $21,299.00 | $22,243.00 | | Desk lamp | $8,775.00 | $9,087.00 | --- #### 3. Percentage Change in Total Revenue from March to April **Formula:** $$ ext{Percentage Change} = rac{ ext{Revenue}_{ ext{April}} - ext{Revenue}_{ ext{March}}}{ ext{Revenue}_{ ext{March}}} imes 100$$ **Code:** ```python # Cleaned / Deduplicated mar_clean = df_clean[df_clean["order_date"].dt.month == 3][ "revenue_clean" ].sum() # 50,708.00 apr_clean = df_clean[df_clean["order_date"].dt.month == 4][ "revenue_clean" ].sum() # 43,066.00 pct_clean = ((apr_clean - mar_clean) / mar_clean) * 100 # Raw Data mar_raw = df[df["order_date"].dt.month == 3]["revenue_clean"].sum() # 50,825.00 apr_raw = df[df["order_date"].dt.month == 4]["revenue_clean"].sum() # 43,969.00 pct_raw = ((apr_raw - mar_raw) / mar_raw) * 100 ``` * **Cleaned (Recommended)**: Total revenue changed by **-15.07%** (declined from **$50,708.00** in March to **$43,066.00** in April; absolute change of -$7,642.00). * **Raw Data**: Total revenue changed by **-13.49%** (declined from **$50,825.00** in March to **$43,969.00** in April; absolute change of -$6,856.00).