Use Python and Pandas to calculate correlation.
For this SQL version, calculate the Pearson correlation between x_value and y_value for each category. Exclude incomplete pairs, but retain categories with no valid pairs.
category_name, pearson_correlation, and valid_observationsNULL correlation and a count of zerocategory_id ascending| Column | Type | Description |
|---|---|---|
| category_idPK | INT | Unique category identifier |
| category_name | VARCHAR(100) | Category label |
| Column | Type | Description |
|---|---|---|
| observation_idPK | INT | Unique observation identifier |
| category_id | INT | Category associated with the observation |
| x_value | DECIMAL(10,2) | First numeric variable |
| y_value | DECIMAL(10,2) | Second numeric variable |