How can I get the right return type for np.nditer? I need to iterate through ax object here:
fig, ax = plt.subplots(figsize=(16,9), ncols=3, nrows=2)
for col, elem in zip(df.columns[:-1], np.nditer(ax, flags = ['refs_ok'])):
sns.countplot(x="CLASS", hue=col, data=df, ax=elem)
I know I could have iterated here using the dimension of ax array, but I wonder, if I can make this work. Basically, ax=elem should look like ax=ax[i][j] in iteration. But it turns out they have different types:
print(type(elem))
print(type(ax[0][0]))
returns:
<class 'numpy.ndarray'>
<class 'matplotlib.axes._subplots.AxesSubplot'>