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?
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.,: