-
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: Support Pandas future.infer_string=True in report generation
Previously, report generation encountered issues when `future.infer_string=True` was set. This resulted in multiple warnings ("FutureWarning: Dtype inference on a pandas object is deprecated") and failures when string columns contained only empty strings ("AttributeError: 'StringDtype' object has no attribute 'pyarrow_dtype'"). This change resolves the issue by explicitly setting the dtype to "object" for the relevant operations.
- Loading branch information
Showing
3 changed files
with
26 additions
and
4 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
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,21 @@ | ||
import pandas as pd | ||
import pytest | ||
|
||
from ydata_profiling import ProfileReport | ||
|
||
|
||
@pytest.fixture() | ||
def df(): | ||
df = pd.DataFrame( | ||
{ | ||
"foo": [1, 2, 3], | ||
"bar": ["", "", ""], | ||
} | ||
) | ||
return df | ||
|
||
|
||
def test_pd_future_infer_string(df: pd.DataFrame): | ||
with pd.option_context("future.infer_string", True): | ||
profile_report = ProfileReport(df, title="Test Report", progress_bar=False) | ||
assert len(profile_report.to_html()) > 0 |