Seaborn pairplot() error, OptionError: "No such keys(s): 'mode.use_inf_as_null'", any idea?
Asked Answered
S

5

19

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?

Slapdash answered 30/5, 2023 at 12:38 Comment(8)
What is your seaborn version (print(sns.__version__))? If I run your code with v0.12.2, I don't see any error.Llovera
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?Slapdash
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.Llovera
Current channels: - conda.anaconda.org/conda-forge/osx-arm64 - conda.anaconda.org/conda-forge/noarchSlapdash
Are you saying it still doesn't install with the above command? If so, I'm not sure why.Llovera
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 conda.io/projects/conda/en/latest/user-guide/tasks/…Lamoreaux
conda install -c conda-forge seaborn=0.12.2 solved my problem! conda-forge channel does the magic.Slapdash
@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.Kieserite
V
17

Just do the following:

pip install --upgrade seaborn
Vanzant answered 24/9, 2023 at 4:59 Comment(0)
L
7

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
Llovera answered 1/8, 2023 at 16:9 Comment(1)
I tried upgrading seaborn and it didn't help. I had to uninstall pandas too like @Jakhon suggested.Caller
A
3

It is due to pandas. For some reason, pandas and seaborn are not getting well. If you uninstall both pandas and seaborn and install only seaborn, the seaborn will automatically install the right pandas it works well with. Thus, your error will go away. At least, that worked for me.

Adsorb answered 17/9, 2023 at 1:14 Comment(0)
M
0

This issue could be specific to your environment or code setup. To troubleshoot further, please consider the following steps:

pip uninstall seaborn matplotlib
pip install seaborn matplotlib

I had issues with the following code:

 sns.distplot(df_benign['mean area'], 
         bins=5, 
         ax=ax[0], 
         label='Benign',
         hist_kws={"hatch": "x"})

I did those step and it worked for me.

Maremma answered 5/10, 2023 at 10:19 Comment(0)
D
-1

Hi there i am getting the same error - followed all the above steps but cannot seem to get there. I used the following code

sns.histplot(np.random.randn(100), kde = True

Error Message

Dehiscent answered 11/7 at 14:29 Comment(2)
You're posting a different problem as an answer, which is not helpful. Please ask a seperate / own question instead.Telescopy
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewFlunky

© 2022 - 2024 — McMap. All rights reserved.