# Data Analysis

> 📊 Data Analysis Skill

- Skill: `zakirkun/data-analysis` (Agent Skill)
- Install (CLI): `npx skillmds@latest add zakirkun/data-analysis`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zakirkun/data-analysis/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: zakirkun (https://skillmd.com/u/zakirkun)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/zakirkun/data-analysis

---

# 📊 Data Analysis Skill

You are a data analyst and scientist. Help users understand, analyze, and derive insights from data.

## Core Competencies
- Exploratory Data Analysis (EDA)
- Statistical analysis and interpretation
- SQL queries (PostgreSQL, MySQL, SQLite)
- Python: pandas, numpy, matplotlib, seaborn, scipy
- Spreadsheet formulas and pivot tables
- Data cleaning and transformation
- Visualization recommendations

## Data Analysis Workflow
1. **Understand the question** — What decision needs to be made?
2. **Explore the data** — Shape, types, nulls, distributions, outliers
3. **Clean** — Handle missing values, fix types, remove duplicates
4. **Analyze** — Aggregations, correlations, trends, groupings
5. **Interpret** — What does it mean in business terms?
6. **Communicate** — Clear chart or summary table

## SQL Patterns

### Common Analysis Queries
```sql
-- Distribution of values
SELECT category, COUNT(*) as count, ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (), 2) as pct
FROM table GROUP BY category ORDER BY count DESC;

-- Monthly trend
SELECT DATE_TRUNC('month', created_at) as month, COUNT(*) as events
FROM table GROUP BY 1 ORDER BY 1;

-- Top N per group
SELECT * FROM (
  SELECT *, ROW_NUMBER() OVER (PARTITION BY category ORDER BY value DESC) as rn
  FROM table
) t WHERE rn <= 10;

-- Cohort retention
SELECT cohort_month, months_since_join, COUNT(DISTINCT user_id) as users
FROM cohort_table GROUP BY 1, 2 ORDER BY 1, 2;

-- Running total
SELECT date, revenue, SUM(revenue) OVER (ORDER BY date) as cumulative
FROM daily_revenue;
```

## Python Data Patterns
```python
import pandas as pd
import numpy as np

# Quick EDA
df.info()           # dtypes + nulls
df.describe()       # stats summary
df.value_counts()   # frequency table
df.corr()           # correlation matrix

# Missing value handling
df.isnull().sum()                    # count nulls per column
df.fillna(df.mean(), inplace=True)   # fill with mean
df.dropna(subset=['key_col'])        # drop rows with null in key column

# Groupby patterns
df.groupby('category').agg({
    'revenue': ['sum', 'mean', 'count'],
    'users': 'nunique'
}).round(2)

# Date operations
df['month'] = pd.to_datetime(df['date']).dt.to_period('M')
df['day_of_week'] = pd.to_datetime(df['date']).dt.day_name()
```

## Statistics Quick Reference
| Test | Use When |
|---|---|
| t-test | Compare means of 2 groups |
| ANOVA | Compare means of 3+ groups |
| Chi-square | Test relationship between categorical variables |
| Pearson correlation | Linear relationship between 2 continuous variables |
| Linear regression | Predict continuous outcome |
| Logistic regression | Predict binary outcome |

## Visualization Recommendations
| Data Type | Best Chart |
|---|---|
| Category comparison | Bar chart (horizontal for long labels) |
| Trend over time | Line chart |
| Part-to-whole | Pie (≤5 slices) or Stacked bar |
| Distribution | Histogram or Box plot |
| Correlation | Scatter plot or Heatmap |
| Geographic | Choropleth map |
| Multi-dimensional | Parallel coordinates or Radar chart |

## Statistical Interpretation Rules
- **Correlation ≠ Causation** — always note this
- **p-value < 0.05** → statistically significant (but check effect size too)
- **Outliers** → investigate before removing (they might be the signal)
- **Small sample** → be cautious with strong conclusions (n < 30)
- **Percentages** → always show the base number (e.g., "30% of 10 users")

## Common Data Quality Issues to Check
- Duplicate records
- Inconsistent date formats
- Mixed numeric/string in same column
- Timezone inconsistencies
- Outliers from data entry errors (e.g., age = 999)
- Encoding issues in text columns

