I have a dataset and I want to draw scatterplots for all the columns with the last column (Result), using subplots.
fig, ax = plt.subplots(figsize=(10, 6))
for i in range(len(columns)-1):
columns = df.columns[i]
ax.scatter(x = df[columns], y = df['Result'])
plt.xlabel(columns[i])
plt.ylabel("Result")
plt.show
I tried using subplots to make the scatter plots but its giving me this error
IndexError Traceback (most recent call last)
/var/folders/pn/ly3sp5n508v11pnffllvyl6h0000gn/T/ipykernel_34526/1242862654.py in <module>
18 fig, ax = plt.subplots(figsize=(10, 6))
19 for i in range(len(columns)-1):
---> 20 columns = df.columns[i]
21 ax.scatter(x = df[columns], y = df['Result'])
22 plt.xlabel(columns[i])
~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py in __getitem__(self, key)
5051 # GH#44051 exclude bool, which would return a 2d ndarray
5052 key = com.cast_scalar_indexer(key, warn_float=True)
-> 5053 return getitem(key)
5054
5055 if isinstance(key, slice):
IndexError: index 7 is out of bounds for axis 0 with size 7