Skip to content

Commit cf853bd

Browse files
authored
fix: avoid failure when index level shares name with a column (#1673)
removes index names to avoid errors
1 parent 6d36c8a commit cf853bd

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/ydata_profiling/model/pandas/duplicates_pandas.py

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def pandas_get_duplicates(
3535
duplicated_rows = df.duplicated(subset=supported_columns, keep=False)
3636
duplicated_rows = (
3737
df[duplicated_rows]
38+
.rename_axis(index=lambda _: None)
3839
.groupby(supported_columns, dropna=False, observed=True)
3940
.size()
4041
.reset_index(name=duplicates_key)
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pandas as pd
2+
import pytest
3+
4+
from ydata_profiling import ProfileReport
5+
6+
7+
@pytest.fixture()
8+
def df():
9+
df = pd.DataFrame(
10+
{
11+
"foo": [1, 2, 3],
12+
},
13+
index=pd.Index([1, 2, 3], name="foo"),
14+
)
15+
return df
16+
17+
18+
def test_index_column_name_clash(df: pd.DataFrame):
19+
profile_report = ProfileReport(df, title="Test Report", progress_bar=False)
20+
assert len(profile_report.to_html()) > 0

0 commit comments

Comments
 (0)