pythonintermediate
Statistical Analysis with SciPy
Run hypothesis tests, correlations, and descriptive statistics on dataset columns with SciPy.
pythonPress ⌘/Ctrl + Shift + C to copy
from scipy import stats
import numpy as np
np.random.seed(42)
group_a = np.random.normal(50, 10, 100)
group_b = np.random.normal(55, 10, 100)
t_stat, p_value = stats.ttest_ind(group_a, group_b, equal_var=False)
print(f't={t_stat:.3f}, p={p_value:.4f}')
u_stat, p_mw = stats.mannwhitneyu(group_a, group_b, alternative='two-sided')
print(f'U={u_stat:.0f}, p={p_mw:.4f}')
corr, p_corr = stats.pearsonr(group_a, group_b)
print(f'r={corr:.3f}, p={p_corr:.4f}')Use Cases
- A/B testing
- data exploration
- reporting pipelines
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
pythonintermediate
OLS Regression with statsmodels
Fit and interpret an Ordinary Least Squares regression model with diagnostics using statsmodels.
Best for: econometric analysis
#statsmodels#regression
pythonbeginner
Pandas Rank with Tie-Breaking Methods
Apply different ranking strategies (min, dense, average) and handle ties in pandas.
Best for: leaderboards
#pandas#ranking
sqladvanced
SQL Window Functions for Analytics
Advanced SQL window functions for running totals, rankings, moving averages, and gap analysis.
Best for: Building analytics dashboards with running totals
#sql#window-functions
sqladvanced
SQL Window Functions for Analytics
Use window functions for running totals, rankings, moving averages, and gap detection in analytics.
Best for: Building cumulative revenue dashboards
#sql#window-functions