| name | ydata-profiling-1-basic-profile-report-generation |
| description | Sub-skill of ydata-profiling: 1. Basic Profile Report Generation (+1). |
| version | 1.0.0 |
| category | data-analysis |
| type | reference |
| scripts_exempt | true |
1. Basic Profile Report Generation (+1)
1. Basic Profile Report Generation
Simplest Usage:
from ydata_profiling import ProfileReport
import pandas as pd
df = pd.read_csv("data.csv")
profile = ProfileReport(df, title="Data Quality Report")
profile.to_file("report.html")
profile.to_notebook_iframe()
With Configuration:
from ydata_profiling import ProfileReport
import pandas as pd
df = pd.read_csv("sales_data.csv")
profile = ProfileReport(
df,
title="Sales Data Quality Report",
explorative=True,
dark_mode=False,
orange_mode=False,
config_file=None,
lazy=True
)
print(profile.description_set)
print(profile.get_description())
profile.to_file("sales_report.html")
From DataFrame with Sample Data:
from ydata_profiling import ProfileReport
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
np.random.seed(42)
n = 5000
df = pd.DataFrame({
"customer_id": range(1, n + 1),
"name": [f"Customer_{i}" for i in range(n)],
"age": np.random.normal(40, 15, n).astype(int),
"income": np.random.exponential(50000, n),
"category": np.random.choice(["A", "B", "C", "D"], n, p=[0.4, 0.3, 0.2, 0.1]),
"registration_date": [
datetime(2020, 1, 1) + timedelta(days=int(d))
for d in np.random.uniform(0, 1825, n)
],
"is_active": np.random.choice([True, False], n, p=[0.8, 0.2]),
"score": np.random.uniform(0, , n),
: [ i (n)]
})
df.loc[np.random.choice(n, ), ] = np.nan
df.loc[np.random.choice(n, ), ] = np.nan
profile = ProfileReport(df, title=)
profile.to_file()
2. Variable Analysis
Understanding Variable Types:
from ydata_profiling import ProfileReport
import pandas as pd
import numpy as np
df = pd.DataFrame({
"integer_col": np.random.randint(1, 100, 1000),
"float_col": np.random.randn(1000) * 100,
"category_high_card": [f"cat_{i}" for i in np.random.randint(1, 100, 1000)],
"category_low_card": np.random.choice(["A", "B", "C"], 1000),
"boolean_col": np.random.choice([True, False], 1000),
"date_col": pd.date_range("2020-01-01", periods=1000, freq="H"),
"text_col": ["Sample text " * np.random.randint(1, 10) for _ in range(1000)],
"url_col": [f"https://example.com/page/" i ()],
: [] * ,
: ()
})
profile = ProfileReport(
df,
title=,
explorative=
)
profile.to_file()
Detailed Variable Statistics:
from ydata_profiling import ProfileReport
import pandas as pd
import numpy as np
df = pd.DataFrame({
"revenue": np.random.exponential(1000, 5000),
"quantity": np.random.randint(1, 100, 5000),
"discount": np.random.uniform(0, 0.5, 5000),
"category": np.random.choice(["Electronics", "Clothing", "Food"], 5000)
})
profile = ProfileReport(df, title="Sales Variables Analysis")
description = profile.get_description()
for var_name, var_data in description.variables.items():
print(f"\n{var_name}:")
print(f" Type: {var_data['type']}")
if "mean" in var_data:
print(f" Mean: {var_data['mean']:.2f}")
print(f" Std: {var_data['std']:.2f}")
print(f" Min: {var_data['min']:f}")
()