Skip to content

Commit

Permalink
Don't fiddle with pandas options, work around warning another way
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Apr 3, 2024
1 parent e08fb96 commit 351ccbb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,6 @@ def __init__(
# performance.
self._search_schema_last_result: Optional[Tuple[str, List[ColumnSchema]]] = None

# squelch a warning from pandas 2.2.0 about the use below of
# fillna
pd_.set_option("future.no_silent_downcasting", True)

# Putting this here rather than in the class body before
# Python < 3.10 has fussier rules about staticmethods
self._SUMMARIZERS = {
Expand Down Expand Up @@ -560,9 +556,12 @@ def _eval_filter(self, filt: RowFilter):
elif params.type == SearchFilterParamsType.EndsWith:
mask = col.str.endswith(term)

assert mask is not None

# Nulls are possible in the mask, so we just fill them if any
if mask.dtype != bool:
mask = mask.fillna(False).infer_objects(copy=False)
mask[mask.isna()] = False
mask = mask.astype(bool)

return mask.to_numpy()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ def test_pandas_filter_search(dxf: DataExplorerFixture):
]

for search_type, column_index, term, cs, mask in cases:
ex_table = df[mask.fillna(False)]
mask[mask.isna()] = False
ex_table = df[mask.astype(bool)]
dxf.check_filter_case(
df,
[
Expand Down

0 comments on commit 351ccbb

Please sign in to comment.