Skip to content

seaborn 0.11.2 completely broken with pandas 2.0.1 with my settings - mode.use_inf_as_null error #3350

@loftusa

Description

@loftusa

See below. This happens with every plot I try.

Screenshot 2023-04-28 at 12 45 38 PM

The full error is here:

---------------------------------------------------------------------------
OptionError                               Traceback (most recent call last)
Cell In[108], line 1
----> 1 sns.kdeplot(data=test_data)

File /opt/conda/lib/python3.10/site-packages/seaborn/_decorators.py:46, in _deprecate_positional_args.<locals>.inner_f(*args, **kwargs)
     36     warnings.warn(
     37         "Pass the following variable{} as {}keyword arg{}: {}. "
     38         "From version 0.12, the only valid positional argument "
   (...)
     43         FutureWarning
     44     )
     45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 46 return f(**kwargs)

File /opt/conda/lib/python3.10/site-packages/seaborn/distributions.py:1770, in kdeplot(x, y, shade, vertical, kernel, bw, gridsize, cut, clip, legend, cumulative, shade_lowest, cbar, cbar_ax, cbar_kws, ax, weights, hue, palette, hue_order, hue_norm, multiple, common_norm, common_grid, levels, thresh, bw_method, bw_adjust, log_scale, color, fill, data, data2, warn_singular, **kwargs)
   1767     if color is not None:
   1768         plot_kws["color"] = color
-> 1770     p.plot_univariate_density(
   1771         multiple=multiple,
   1772         common_norm=common_norm,
   1773         common_grid=common_grid,
   1774         fill=fill,
   1775         legend=legend,
   1776         warn_singular=warn_singular,
   1777         estimate_kws=estimate_kws,
   1778         **plot_kws,
   1779     )
   1781 else:
   1783     p.plot_bivariate_density(
   1784         common_norm=common_norm,
   1785         fill=fill,
   (...)
   1795         **kwargs,
   1796     )

File /opt/conda/lib/python3.10/site-packages/seaborn/distributions.py:928, in _DistributionPlotter.plot_univariate_density(self, multiple, common_norm, common_grid, warn_singular, fill, legend, estimate_kws, **plot_kws)
    925 log_scale = self._log_scaled(self.data_variable)
    927 # Do the computation
--> 928 densities = self._compute_univariate_density(
    929     self.data_variable,
    930     common_norm,
    931     common_grid,
    932     estimate_kws,
    933     log_scale,
    934     warn_singular,
    935 )
    937 # Adjust densities based on the `multiple` rule
    938 densities, baselines = self._resolve_multiple(densities, multiple)

File /opt/conda/lib/python3.10/site-packages/seaborn/distributions.py:303, in _DistributionPlotter._compute_univariate_density(self, data_variable, common_norm, common_grid, estimate_kws, log_scale, warn_singular)
    299     common_norm = False
    301 densities = {}
--> 303 for sub_vars, sub_data in self.iter_data("hue", from_comp_data=True):
    304 
    305     # Extract the data points from this sub set and remove nulls
    306     sub_data = sub_data.dropna()
    307     observations = sub_data[data_variable]

File /opt/conda/lib/python3.10/site-packages/seaborn/_core.py:983, in VectorPlotter.iter_data(self, grouping_vars, reverse, from_comp_data)
    978 grouping_vars = [
    979     var for var in grouping_vars if var in self.variables
    980 ]
    982 if from_comp_data:
--> 983     data = self.comp_data
    984 else:
    985     data = self.plot_data

File /opt/conda/lib/python3.10/site-packages/seaborn/_core.py:1054, in VectorPlotter.comp_data(self)
   1050 axis = getattr(ax, f"{var}axis")
   1052 # Use the converter assigned to the axis to get a float representation
   1053 # of the data, passing np.nan or pd.NA through (pd.NA becomes np.nan)
-> 1054 with pd.option_context('mode.use_inf_as_null', True):
   1055     orig = self.plot_data[var].dropna()
   1056 comp_col = pd.Series(index=orig.index, dtype=float, name=var)

File /opt/conda/lib/python3.10/site-packages/pandas/_config/config.py:441, in option_context.__enter__(self)
    440 def __enter__(self) -> None:
--> 441     self.undo = [(pat, _get_option(pat, silent=True)) for pat, val in self.ops]
    443     for pat, val in self.ops:
    444         _set_option(pat, val, silent=True)

File /opt/conda/lib/python3.10/site-packages/pandas/_config/config.py:441, in <listcomp>(.0)
    440 def __enter__(self) -> None:
--> 441     self.undo = [(pat, _get_option(pat, silent=True)) for pat, val in self.ops]
    443     for pat, val in self.ops:
    444         _set_option(pat, val, silent=True)

File /opt/conda/lib/python3.10/site-packages/pandas/_config/config.py:135, in _get_option(pat, silent)
    134 def _get_option(pat: str, silent: bool = False) -> Any:
--> 135     key = _get_single_key(pat, silent)
    137     # walk the nested dict
    138     root, k = _get_root(key)

File /opt/conda/lib/python3.10/site-packages/pandas/_config/config.py:121, in _get_single_key(pat, silent)
    119     if not silent:
    120         _warn_if_deprecated(pat)
--> 121     raise OptionError(f"No such keys(s): {repr(pat)}")
    122 if len(keys) > 1:
    123     raise OptionError("Pattern matched multiple keys")

OptionError: No such keys(s): 'mode.use_inf_as_null'

This also happens when I try both of the following:

pd.set_option('mode.use_inf_as_na', True)
sns.kdeplot(data=test_data)
pd.set_option('mode.use_inf_as_na', False)
sns.kdeplot(data=test_data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions