Skip to content

Commit d2141a1

Browse files
authored
fix: Convert MultiIndex columns to string representation (#1672)
1 parent 7e41dde commit d2141a1

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/ydata_profiling/model/pandas/dataframe_pandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ def pandas_preprocess(config: Settings, df: pd.DataFrame) -> pd.DataFrame:
3232
df = rename_index(df)
3333

3434
# Ensure that columns are strings
35-
df.columns = df.columns.astype("str")
35+
df.columns = df.columns.map(str)
3636
return df

tests/unit/test_multiindex_columns.py

Lines changed: 20 additions & 0 deletions
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", "one"): [1, 2, 3],
12+
("bar", "two"): [4, 5, 6],
13+
}
14+
)
15+
return df
16+
17+
18+
def test_multiindex_columns(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)