Python Forum

Full Version: 'AxesSubplot' object is not subscriptable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am trying to run a corelation. code is:

df[["sqft_living","price"]].corr()

i get following error: can someone please help.

Error:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-33-53edee4cd1ce> in <module> 2 height = 8 3 plt.figure(figsize=(width, height)) ----> 4 sns.regplot(x="sqft_above", y="price", data=df) 5 plt.ylim(0,) ~/conda/envs/python/lib/python3.6/site-packages/seaborn/regression.py in regplot(x, y, data, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, dropna, x_jitter, y_jitter, label, color, marker, scatter_kws, line_kws, ax) 779 order, logistic, lowess, robust, logx, 780 x_partial, y_partial, truncate, dropna, --> 781 x_jitter, y_jitter, color, label) 782 783 if ax is None: ~/conda/envs/python/lib/python3.6/site-packages/seaborn/regression.py in __init__(self, x, y, data, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, dropna, x_jitter, y_jitter, color, label) 103 # Extract the data vals from the arguments or passed dataframe 104 self.establish_variables(data, x=x, y=y, units=units, --> 105 x_partial=x_partial, y_partial=y_partial) 106 107 # Drop null observations ~/conda/envs/python/lib/python3.6/site-packages/seaborn/regression.py in establish_variables(self, data, **kws) 46 for var, val in kws.items(): 47 if isinstance(val, string_types): ---> 48 setattr(self, var, data[val]) 49 elif isinstance(val, list): 50 setattr(self, var, np.asarray(val)) TypeError: 'AxesSubplot' object is not subscriptable