Dlaczego ten skrypt
# Box Plots
fig, axs = plt.subplots(9,1,dpi=95, figsize=(7,17))
i = 0
for col in loan.columns:
axs[i].boxplot(loan[col], vert=False)
axs[i].set_ylabel(col)
i+=1
plt.show()
nie działa prawidłowo i generuje błędy
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[23], line 5
3 i = 0
4 for col in loan.columns:
----> 5 axs[i].boxplot(loan[col], vert=False)
6 axs[i].set_ylabel(col)
7 i+=1
File E:\Anaconda\Lib\site-packages\matplotlib\__init__.py:1446, in _preprocess_data.<locals>.inner(ax, data, *args, **kwargs)
1443 @functools.wraps(func)
1444 def inner(ax, *args, data=None, **kwargs):
1445 if data is None:
-> 1446 return func(ax, *map(sanitize_sequence, args), **kwargs)
1448 bound = new_sig.bind(ax, *args, **kwargs)
1449 auto_label = (bound.arguments.get(label_namer)
1450 or bound.kwargs.get(label_namer))
File E:\Anaconda\Lib\site-packages\matplotlib\axes\_axes.py:3908, in Axes.boxplot(self, x, notch, sym, vert, whis, positions, widths, patch_artist, bootstrap, usermedians, conf_intervals, meanline, showmeans, showcaps, showbox, showfliers, boxprops, labels, flierprops, medianprops, meanprops, capprops, whiskerprops, manage_ticks, autorange, zorder, capwidths)
3905 if bootstrap is None:
3906 bootstrap = mpl.rcParams['boxplot.bootstrap']
-> 3908 bxpstats = cbook.boxplot_stats(x, whis=whis, bootstrap=bootstrap,
3909 labels=labels, autorange=autorange)
3910 if notch is None:
3911 notch = mpl.rcParams['boxplot.notch']
File E:\Anaconda\Lib\site-packages\matplotlib\cbook\__init__.py:1237, in boxplot_stats(X, whis, bootstrap, labels, autorange)
1234 x = np.asarray(x)
1236 # arithmetic mean
-> 1237 stats['mean'] = np.mean(x)
1239 # medians and quartiles
1240 q1, med, q3 = np.percentile(x, [25, 50, 75])
File <__array_function__ internals>:200, in mean(*args, **kwargs)
File E:\Anaconda\Lib\site-packages\numpy\core\fromnumeric.py:3464, in mean(a, axis, dtype, out, keepdims, where)
3461 else:
3462 return mean(axis=axis, dtype=dtype, out=out, **kwargs)
-> 3464 return _methods._mean(a, axis=axis, dtype=dtype,
3465 out=out, **kwargs)
File E:\Anaconda\Lib\site-packages\numpy\core\_methods.py:194, in _mean(a, axis, dtype, out, keepdims, where)
192 ret = ret.dtype.type(ret / rcount)
193 else:
--> 194 ret = ret / rcount
196 return ret
TypeError: ufunc 'divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''