FILE: docs/quickstart.md¶
Quickstart Guide¶
This guide will get you up and running with DataKit in less than 5 minutes.
Installation¶
pip install datakit
Requires Python 3.9 or newer.
Your first DataKit analysis¶
Let's walk through a complete analysis on a sample dataset.
1. Import and load data¶
import datakit as dk
import pandas as pd
import numpy as np
# Create a sample dataset (or load your own CSV)
np.random.seed(42)
df = pd.DataFrame({
'Customer ID': range(1, 101),
'Age': np.random.randint(18, 70, 100),
'Income ($)': np.random.normal(50000, 15000, 100).round(2),
'City': np.random.choice(['NYC', 'LA', 'Chicago', 'Houston'], 100),
'Purchase Date': pd.date_range('2024-01-01', periods=100),
'Satisfaction': np.random.uniform(1, 5, 100).round(1)
})
# Add some missing values to make it realistic
df.loc[10:20, 'Income ($)'] = np.nan
df.loc[30:35, 'Satisfaction'] = np.nan
df.loc[50, 'City'] = np.nan
print(df.head())
2. Quick EDA (Exploratory Data Analysis)¶
One line gives you a full profile, distribution plots, and a correlation heatmap.
dk.quick_eda(df)
3. Clean column names and data types¶
df = dk.clean_columns(df, style='snake_case')
df = dk.fix_dtypes(df)
print(df.columns.tolist())
4. Handle missing values automatically¶
df = dk.auto_impute(df, verbose=True)
print(f"Remaining nulls: {df.isnull().sum().sum()}")
5. Encode categorical variables¶
df = dk.encode_categoricals(df, method='auto')
print(df.head())
6. Visualise distributions¶
dk.plot_distributions(df, cols=['age', 'income', 'satisfaction'])
7. Correlation heatmap¶
dk.plot_corr(df, method='pearson', threshold=0.5)
8. Compare two groups¶
Compare income between NYC and LA customers:
nyc_income = df[df['city'] == 'NYC']['income'].dropna()
la_income = df[df['city'] == 'LA']['income'].dropna()
result = dk.compare_groups(nyc_income, la_income)
print(result['interpretation'])
9. Group by and chart¶
Average satisfaction by city:
dk.groupby_chart(df, by='city', metric='satisfaction', agg='mean', chart_type='bar')
Next steps¶
- Read the API Reference for detailed function documentation
- Check out the example notebooks
- Learn about configuration to set default parameters
Common patterns¶
| Task | DataKit code |
|---|---|
| Profile a DataFrame | dk.profile_df(df) |
| Clean column names | dk.clean_columns(df) |
| Fix data types | dk.fix_dtypes(df) |
| Impute missing values | dk.auto_impute(df) |
| Plot all numeric distributions | dk.plot_distributions(df) |
| Correlation heatmap | dk.plot_corr(df) |
| Automatic statistical test | dk.compare_groups(a, b) |
| Curve fitting | dk.fit_and_plot(model, x, y) |
| Set random seed | dk.set_seed(42) |
That's it! You're now ready to use DataKit in your own projects.