Exploratory Data Analysis

Exploratory Data Analysis

Guides an AI agent through exploratory data analysis in Python: profiling, distributions, relationships, outliers and data quality checks before modelling.

Skill files3 files

scripts/

templates/

SKILL.md233 lines
1
---
2
name: Exploratory Data Analysis
3
description: Discover patterns, distributions, and relationships in data through visualization, summary statistics, and hypothesis generation for exploratory data analysis, data profiling, and initial insights
4
---
5
6
# Exploratory Data Analysis (EDA)
7
8
## Overview
9
10
Exploratory Data Analysis (EDA) is the critical first step in data science projects, systematically examining datasets to understand their characteristics, identify patterns, and assess data quality before formal modeling.
11
12
## Core Concepts
13
14
- **Data Profiling**: Understanding basic statistics and data types
15
- **Distribution Analysis**: Examining how variables are distributed
16
- **Relationship Discovery**: Identifying patterns between variables
17
- **Anomaly Detection**: Finding outliers and unusual patterns
18
- **Data Quality Assessment**: Evaluating completeness and consistency
19
20
## When to Use
21
22
- Starting a new dataset analysis
23
- Understanding data before modeling
24
- Identifying data quality issues
25
- Generating hypotheses for testing
26
- Communicating insights to stakeholders
27
28
## Implementation with Python
29
30
```python
31
import pandas as pd
32
import numpy as np
33
import matplotlib.pyplot as plt
34
import seaborn as sns
35
36
# Load and explore data
37
df = pd.read_csv('customer_data.csv')
38
39
# Basic profiling
40
print(f"Shape: {df.shape}")
41
print(f"Data types:\n{df.dtypes}")
42
print(f"Missing values:\n{df.isnull().sum()}")
43
print(f"Duplicates: {df.duplicated().sum()}")
44
45
# Statistical summary
46
print(df.describe())
47
print(df.describe(include='object'))
48
49
# Distribution analysis - numerical columns
50
fig, axes = plt.subplots(2, 2, figsize=(12, 8))
51
df['age'].hist(bins=30, ax=axes[0, 0])
52
axes[0, 0].set_title('Age Distribution')
53
54
df['income'].hist(bins=30, ax=axes[0, 1])
55
axes[0, 1].set_title('Income Distribution')
56
57
# Box plots for outlier detection
58
df.boxplot(column='age', by='region', ax=axes[1, 0])
59
axes[1, 0].set_title('Age by Region')
60
61
# Categorical analysis
62
df['category'].value_counts().plot(kind='bar', ax=axes[1, 1])
63
axes[1, 1].set_title('Category Distribution')
64
plt.tight_layout()
65
plt.show()
66
67
# Correlation analysis
68
numeric_df = df.select_dtypes(include=[np.number])
69
correlation_matrix = numeric_df.corr()
70
71
plt.figure(figsize=(10, 8))
72
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', center=0)
73
plt.title('Correlation Matrix')
74
plt.show()
75
76
# Multivariate relationships
77
sns.pairplot(df[['age', 'income', 'education_years']], diag_kind='hist')
78
plt.show()
79
80
# Skewness and kurtosis
81
print("\nSkewness:")
82
print(numeric_df.skew())
83
print("\nKurtosis:")
84
print(numeric_df.kurtosis())
85
86
# Percentile analysis
87
print("\nPercentiles for Age:")
88
print(df['age'].quantile([0.25, 0.5, 0.75, 0.95, 0.99]))
89
90
# Missing data patterns
91
missing_pct = (df.isnull().sum() / len(df) * 100)
92
missing_pct[missing_pct > 0].sort_values(ascending=False)
93
94
# Value count analysis
95
print("\nCustomer Types Distribution:")
96
print(df['customer_type'].value_counts(normalize=True))
97
98
# Advanced EDA: Groupby analysis
99
print("\nGroupBy Analysis:")
100
print(df.groupby('region')[['age', 'income']].agg(['mean', 'median', 'std']))
101
102
# Correlation with target variable
103
if 'target' in df.columns:
104
target_corr = df.corr()['target'].sort_values(ascending=False)
105
print("\nFeature Correlation with Target:")
106
print(target_corr)
107
108
# Data type breakdown
109
print("\nData Type Summary:")
110
print(df.dtypes.value_counts())
111
112
# Unique value count
113
print("\nUnique Value Counts:")
114
print(df.nunique().sort_values(ascending=False))
115
116
# Variance analysis
117
print("\nVariance per Feature:")
118
numeric_cols = df.select_dtypes(include=[np.number]).columns
119
for col in numeric_cols:
120
variance = df[col].var()
121
print(f" {col}: {variance:.2f}")
122
123
# Distribution patterns
124
for col in df.select_dtypes(include=[np.number]).columns:
125
skew = df[col].skew()
126
kurt = df[col].kurtosis()
127
print(f"{col} - Skew: {skew:.2f}, Kurtosis: {kurt:.2f}")
128
129
# Bivariate analysis
130
fig, axes = plt.subplots(1, 2, figsize=(12, 4))
131
df.groupby('region')['income'].mean().plot(kind='bar', ax=axes[0])
132
axes[0].set_title('Average Income by Region')
133
df.groupby('category')['age'].mean().plot(kind='bar', ax=axes[1])
134
axes[1].set_title('Average Age by Category')
135
plt.tight_layout()
136
plt.show()
137
138
# Summary statistics profile
139
print("\nComprehensive Data Profile:")
140
profile = {
141
'Variable': df.columns,
142
'Type': df.dtypes,
143
'Non-Null Count': df.count(),
144
'Null Count': df.isnull().sum(),
145
'Unique Values': df.nunique(),
146
}
147
profile_df = pd.DataFrame(profile)
148
print(profile_df)
149
```
150
151
## Advanced EDA Techniques
152
153
```python
154
# Step 15: Interaction analysis
155
import itertools
156
157
numeric_cols = df.select_dtypes(include=[np.number]).columns
158
interaction_strengths = []
159
160
for col1, col2 in itertools.combinations(numeric_cols[:5], 2):
161
interaction_score = abs(df[col1].corr(df[col2]))
162
interaction_strengths.append({
163
'Pair': f"{col1} × {col2}",
164
'Correlation': interaction_score,
165
})
166
167
interaction_df = pd.DataFrame(interaction_strengths).sort_values('Correlation', ascending=False)
168
print("\nTop Interactions:")
169
print(interaction_df.head())
170
171
# Step 16: Outlier summary
172
for col in numeric_cols:
173
Q1, Q3 = df[col].quantile([0.25, 0.75])
174
IQR = Q3 - Q1
175
outliers = df[(df[col] < Q1 - 1.5*IQR) | (df[col] > Q3 + 1.5*IQR)]
176
if len(outliers) > 0:
177
print(f"\n{col}: {len(outliers)} outliers detected ({len(outliers)/len(df)*100:.1f}%)")
178
179
# Step 17: Generate automated insights
180
print("\n" + "="*60)
181
print("AUTOMATED DATA INSIGHTS")
182
print("="*60)
183
184
for col in numeric_cols:
185
skewness = df[col].skew()
186
mean_val = df[col].mean()
187
median_val = df[col].median()
188
189
if abs(skewness) > 1:
190
direction = "right" if skewness > 0 else "left"
191
print(f"{col}: Highly {direction}-skewed distribution")
192
193
if abs(mean_val - median_val) > 0.1 * median_val:
194
print(f"{col}: Mean and median differ significantly")
195
196
print("="*60)
197
```
198
199
## Key Questions to Ask
200
201
1. What are the data dimensions and types?
202
2. How are key variables distributed?
203
3. What patterns exist between variables?
204
4. Are there obvious data quality issues?
205
5. What outliers or anomalies exist?
206
6. What hypotheses can we generate?
207
208
## Best Practices
209
210
- Start with data profiling before visualization
211
- Check data types and missing values early
212
- Visualize distributions before jumping to analysis
213
- Document interesting findings and anomalies
214
- Create summaries for stakeholder communication
215
- Use domain knowledge to interpret patterns
216
217
## Common Pitfalls
218
219
- Skipping data quality checks
220
- Over-interpreting patterns in small datasets
221
- Ignoring domain context
222
- Insufficient data visualization
223
- Not documenting findings systematically
224
225
## Deliverables
226
227
- Data quality report with missing values and duplicates
228
- Summary statistics and distribution charts
229
- Correlation and relationship visualizations
230
- List of notable patterns and anomalies
231
- Hypotheses for further investigation
232
- Data cleaning recommendations
233

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,584 prompts

More by @OpenSourceBuffGuy

See all
Teal duotone fashion poster with SAY HELLO doodles prompt image

Teal duotone fashion poster with SAY HELLO doodles

Turns an uploaded portrait into a vertical fashion poster: black-and-white duotone on solid teal with an oversized coat, white doodles and handwritten text.

image-prompt, reference-image, poster, fashion-shoot, editorial, portrait, man, doodle, collage, black-and-white, limited-palette, text-rendering, vertical-format, medium-shot, photo-editing, gpt-image, fashion, for-designers, for-content-creators, quick, vibrant-colors

Monochrome Vector Vogue Portrait prompt image

Monochrome Vector Vogue Portrait

Turns a portrait into a high-contrast black-and-white vector comic illustration with red neon rim lighting on a pure black background, in a magazine-cover style.

image-prompt, reference-image, gpt-image, vector-art, comics, black-and-white, limited-palette, neon, dramatic-lighting, portrait, woman, poster, magazine-cover, fashion, jewelry, editorial, negative-space, style-transfer, vertical-format

CI/CD Secrets Management prompt image

CI/CD Secrets Management

Explains how to manage secrets in CI/CD pipelines with Vault, AWS Secrets Manager and native platform tools, including rotation and least-privilege access.

agent-skill, best-practices, ci-cd, devops, cybersecurity, cloud-security, aws, azure, google-cloud, github-actions, kubernetes, authentication, code, for-devops-engineers, for-developers, advanced, long-form, step-by-step-guide, bash, security-review, cloud, hashicorp-vault

Reviews

Loading reviews…

Discussion

Loading comments…