This program is very simple, but I do not know why I get this error:
IndexError: too many indices for array
The error is caught for df1
(doesn't even go to df2
). Can someone explain why I get this error? I think the bigger question is what's the logic for having a 2 by 1 subplot that I am not understanding.
Here is the program:
import pandas as pd
import matplotlib.pyplot as plt
x = range(5)
y = range(0,10,2)
w = x
z = y
df1 = pd.DataFrame(data = {'col1':x,'col2':y})
df2 = pd.DataFrame(data = {'col1':w,'col2':z})
fig, axes = plt.subplots(2,1)
df1.plot(ax=axes[0,0])
df2.plot(ax=axes[1,0])