3

I am thrown an error when I am trying to apply searbor pairplot. My full script is easy, and is copied as follows:

import seaborn as sns
import pandas as pd
import numpy as np

# Creating a sample DataFrame
data = {
    'A': np.random.randn(100),
    'B': np.random.randn(100),
    'C': np.random.randn(100),
    'D': np.random.randn(100)
}
df = pd.DataFrame(data)

# Create a pair plot
sns.pairplot(df)

But I am thrown this error:

---------------------------------------------------------------------------
OptionError                               Traceback (most recent call last)
Cell In[26], line 15
     12 df = pd.DataFrame(data)
     14 # Create a pair plot
---> 15 sns.pairplot(df)

File ~/miniforge3/envs/marketing/lib/python3.9/site-packages/seaborn/_decorators.py:46, in _deprecate_positional_args..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 ~/miniforge3/envs/marketing/lib/python3.9/site-packages/seaborn/axisgrid.py:2126, in pairplot(data, hue, hue_order, palette, vars, x_vars, y_vars, kind, diag_kind, markers, height, aspect, corner, dropna, plot_kws, diag_kws, grid_kws, size)
   2124 diag_kws.setdefault("legend", False)
   2125 if diag_kind == "hist":
-> 2126     grid.map_diag(histplot, **diag_kws)
   2127 elif diag_kind == "kde":
   2128     diag_kws.setdefault("fill", True)

File ~/miniforge3/envs/marketing/lib/python3.9/site-packages/seaborn/axisgrid.py:1478, in PairGrid.map_diag(self, func, **kwargs)
...
--> 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'"

I have tried removing Seaborn, and reinstalled again with the conda command, but the error is the same.

Have anyone encountered this error before?

yts61
  • 1,142
  • 2
  • 20
  • 33
  • 6
    What is your seaborn version (`print(sns.__version__)`)? If I run your code with v0.12.2, I don't see any error. – Matt Pitkin May 30 '23 at 12:49
  • thank you for dropping by! it was v 0.11.2, I used `conda remove`, then `conda install`. But the old version 0.11.2 was so sturdy and stayed no matter what. I then tried `conda install seaborn=v0.12.2`, and `=v0.12'` but both gave me an error `PackagesNotFoundError: The following packages are not available from current channels`. I am guessing maybe because mine is a M1 Mac? – yts61 May 30 '23 at 15:08
  • 2
    Just try `conda install -c conda-forge seaborn=0.12.2`. I've tried on an M1 Mac and that seems to work for me. – Matt Pitkin May 30 '23 at 15:14
  • Current channels: - https://conda.anaconda.org/conda-forge/osx-arm64 - https://conda.anaconda.org/conda-forge/noarch – yts61 May 30 '23 at 15:17
  • Are you saying it still doesn't install with the above command? If so, I'm not sure why. – Matt Pitkin May 30 '23 at 15:24
  • You're using `miniforge3` as opposed to a full version of anaconda, so maybe something go updated and caused a conflict. I'd try `conda update --all`. Optionally, create a new environment as shown in https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html – Trenton McKinney May 30 '23 at 15:47
  • `conda install -c conda-forge seaborn=0.12.2` solved my problem! conda-forge channel does the magic. – yts61 May 30 '23 at 16:21
  • 1
    @MattPitkin could you write your comment as an answer? I was getting the same error but updated from v0.12.0 to v0.12.2 and everything was solved. I think that's the best answer we're going to get. – beyarkay Aug 01 '23 at 15:22

1 Answers1

0

This seems to just be an issue with a particular seaborn version that is solved by using seaborn v0.12.2 or above. This can be installed in a conda environment with, e.g.,:

conda install -c conda-forge seaborn=0.12.2
Matt Pitkin
  • 3,989
  • 1
  • 18
  • 32