2

I am getting the following error: No variables found for grid columns? In the console it prints the dataframe ok, but when I want to display it in seaborn, it doesn't work.

%matplotlib inline
import seaborn as sns
from ipywidgets import interact
import matplotlib.pyplot as plt

cars_url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data'
cars_columns = ['buying', 'maint', 'doors', 'persons', 'lug_boot', 'safety', 'class']
data = pd.read_csv(cars_url, names = cars_columns)
data1 = pd.DataFrame(data)
plot(data1)

@interact(hue = ['buying'])
def plot(hue):
    _ = sns.pairplot(data1, hue = hue)
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Paul Viorel
  • 234
  • 1
  • 11

1 Answers1

3

Pairtplot works only with numerical data. You should use Label Encoder before paiplot.

For example:

from sklearn.preprocessing import OrdinalEncoder

encoder = OrdinalEncoder()
data = encoder.fit_transform(data)
Andrew
  • 176
  • 2
  • 8