| name | ydata-profiling-5-large-dataset-handling |
| description | Sub-skill of ydata-profiling: 5. Large Dataset Handling. |
| version | 1.0.0 |
| category | data-analysis |
| type | reference |
| scripts_exempt | true |
5. Large Dataset Handling
5. Large Dataset Handling
Minimal Mode for Speed:
from ydata_profiling import ProfileReport
import pandas as pd
import numpy as np
large_df = pd.DataFrame({
f"col_{i}": np.random.randn(1000000)
for i in range(50)
})
large_df["category"] = np.random.choice(["A", "B", "C"], 1000000)
print(f"Dataset size: {large_df.shape}")
profile = ProfileReport(
large_df,
title="Large Dataset Profile",
minimal=True
)
profile.to_file("large_dataset_minimal.html")
Sampling for Large Datasets:
from ydata_profiling import ProfileReport
import pandas as pd
import numpy as np
def profile_large_dataset(
df: pd.DataFrame,
sample_size: int = 100000,
title: str = "Sampled Profile"
) -> ProfileReport:
"""
Profile large dataset using sampling.
Args:
df: Input DataFrame
sample_size: Number of rows to sample
title: Report title
Returns:
ProfileReport object
"""
if len(df) > sample_size:
df_sampled = df.sample(n=sample_size, random_state=42)
print(f"Sampled {sample_size} rows from {len(df)}")
else:
df_sampled = df
print(f"Using full dataset: {len(df)} rows")
return ProfileReport(
df_sampled,
title=f"{title} (n={len(df_sampled):,})",
minimal=len(df_sampled) > 50000
)
Explorative vs Minimal Configuration:
from ydata_profiling import ProfileReport
import pandas as pd
df = pd.read_csv("data.csv")
profile_full = ProfileReport(
df,
title="Full Explorative Report",
explorative=True,
correlations={
"pearson": {"calculate": True},
"spearman": {"calculate": True},
"kendall": {"calculate": True},
"phi_k": {"calculate": True}
},
missing_diagrams={
"bar": True,
"matrix": True,
"heatmap": True
},
interactions={
"continuous": True
}
)
profile_minimal = ProfileReport(
df,
title="Minimal Quick Report",
minimal=True,
correlations=None,
missing_diagrams={"bar": False, "matrix": False, "heatmap": False},
interactions={"continuous": False}
)