Skip to content

Commit

Permalink
Make copy
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Jul 24, 2023
1 parent c9e3330 commit ebe275f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions seaborn/_core/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,21 +1588,23 @@ def split_generator(keep_na=False) -> Generator:

axes_df = self._filter_subplot_data(df, view)

axes_df = axes_df.replace(np.inf, np.nan).replace(-np.inf, np.nan)
axes_df_inf_as_nan = axes_df.copy()
axes_df_inf_as_nan = axes_df_inf_as_nan.replace(np.inf, np.nan)
axes_df_inf_as_nan = axes_df_inf_as_nan.replace(-np.inf, np.nan)
if keep_na:
# The simpler thing to do would be x.dropna().reindex(x.index).
# But that doesn't work with the way that the subset iteration
# is written below, which assumes data for grouping vars.
# Matplotlib (usually?) masks nan data, so this should "work".
# Downstream code can also drop these rows, at some speed cost.
present = axes_df.notna().all(axis=1)
present = axes_df_inf_as_nan.notna().all(axis=1)
nulled = {}
for axis in "xy":
if axis in axes_df:
nulled[axis] = axes_df[axis].where(present)
axes_df = axes_df.assign(**nulled)
axes_df = axes_df_inf_as_nan.assign(**nulled)
else:
axes_df = axes_df.dropna()
axes_df = axes_df_inf_as_nan.dropna()

subplot_keys = {}
for dim in ["col", "row"]:
Expand Down

0 comments on commit ebe275f

Please sign in to comment.