Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Convert MultiIndex columns to string representation #1672

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ydata_profiling/model/pandas/dataframe_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ def pandas_preprocess(config: Settings, df: pd.DataFrame) -> pd.DataFrame:
df = rename_index(df)

# Ensure that columns are strings
df.columns = df.columns.astype("str")
df.columns = df.columns.map(str)
return df
20 changes: 20 additions & 0 deletions tests/unit/test_multiindex_columns.py
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", "one"): [1, 2, 3],
("bar", "two"): [4, 5, 6],
}
)
return df


def test_multiindex_columns(df: pd.DataFrame):
profile_report = ProfileReport(df, title="Test Report", progress_bar=False)
assert len(profile_report.to_html()) > 0