-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Avoid failure when index level shares name with a column
Previously, report generation failed for DataFrames where an index level had the same name as a column, resulting in a "ValueError: 'foo' is both an index level and a column label, which is ambiguous." This update removes index names for the relevant groupby operation, ensuring the column is prioritized.
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pandas as pd | ||
import pytest | ||
|
||
from ydata_profiling import ProfileReport | ||
|
||
|
||
@pytest.fixture() | ||
def df(): | ||
df = pd.DataFrame( | ||
{ | ||
"foo": [1, 2, 3], | ||
}, | ||
index=pd.Index([1, 2, 3], name="foo"), | ||
) | ||
return df | ||
|
||
|
||
def test_index_column_name_clash(df: pd.DataFrame): | ||
profile_report = ProfileReport(df, title="Test Report", progress_bar=False) | ||
assert len(profile_report.to_html()) > 0 |