Python Forum

Full Version: Regression plotting + minor issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello guys! I'm trying to plot a regression like this from the attached file,
but I ran into these 2 problems;
1)It won't plot the size-price
2)I can't drop 'Tudor'
could you please help me...
thank you🙏
import pandas as pd
import numpy as np
from pandas import *
data = pd.read_csv('houseprices.csv')
datalog = data.drop(['STYLE','SPLIT','RANCH','COLONIAL','TUDOR'], axis=1)
import seaborn as sns
%matplotlib inline
sns.pairplot(data, x_vars=['SIZE','BEDROOMS'],y_vars='PRICE', kind ='reg')
Error:
KeyError Traceback (most recent call last) <ipython-input-101-fc9a9ec29243> in <module> ----> 1 datalog = data.drop(['STYLE','SPLIT','RANCH','COLONIAL','TUDOR'], axis=1) ~\anaconda3\lib\site-packages\pandas\core\frame.py in drop(self, labels, axis, index, columns, level, inplace, errors) 4161 weight 1.0 0.8 4162 """ -> 4163 return super().drop( 4164 labels=labels, 4165 axis=axis, ~\anaconda3\lib\site-packages\pandas\core\generic.py in drop(self, labels, axis, index, columns, level, inplace, errors) 3885 for axis, labels in axes.items(): 3886 if labels is not None: -> 3887 obj = obj._drop_axis(labels, axis, level=level, errors=errors) 3888 3889 if inplace: ~\anaconda3\lib\site-packages\pandas\core\generic.py in _drop_axis(self, labels, axis, level, errors) 3919 new_axis = axis.drop(labels, level=level, errors=errors) 3920 else: -> 3921 new_axis = axis.drop(labels, errors=errors) 3922 result = self.reindex(**{axis_name: new_axis}) 3923 ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in drop(self, labels, errors) 5280 if mask.any(): 5281 if errors != "ignore": -> 5282 raise KeyError(f"{labels[mask]} not found in axis") 5283 indexer = indexer[~mask] 5284 return self.delete(indexer) KeyError: "['TUDOR'] not found in axis"
and the second one is that it won't show the size-price

file: https://gofile.io/d/jRYaL2