Estou com o mesmo problema dos demais, em plotar o gráfico de Correlação do Seaborn. Avariavel 'corr' roda perfeitamente no gráfico heatmap. O problema está neste gráfico. A resposta dada nesta questão pelo instrutir, não esclarece uma vírgula.
sns.set(style="white")
# Generate a mask for the upper triangle
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(11, 9))
# Generate a custom diverging colormap
cmap = sns.diverging_palette(220, 20, as_cmap=True)
# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr, mask=mask, vmax=.3, center=0, cmap=cmap,
square=True, linewidths=.5, cbar_kws={"shrink": .5})
Obtenho como resposta: TypeError Traceback (most recent call last) in 9 10 # Generate a custom diverging colormap ---> 11 cmap = sns.diverging_palette(220, 20, as_cmap=True) 12 13 # Draw the heatmap with the mask and correct aspect ratio
~\anaconda3\lib\site-packages\seaborn\palettes.py in diverging_palette(h_neg, h_pos, s, l, sep, n, center, as_cmap) 742 """ 743 palfunc = dark_palette if center == "dark" else light_palette --> 744 neg = palfunc((h_neg, s, l), 128 - (sep / 2), reverse=True, input="husl") 745 pos = palfunc((h_pos, s, l), 128 - (sep / 2), input="husl") 746 midpoint = dict(light=[(.95, .95, .95, 1.)],
~\anaconda3\lib\site-packages\seaborn\palettes.py in light_palette(color, n_colors, reverse, as_cmap, input) 639 light = set_hls_values(color, l=.95) # noqa 640 colors = [color, light] if reverse else [light, color] --> 641 return blend_palette(colors, n_colors, as_cmap) 642 643
~\anaconda3\lib\site-packages\seaborn\palettes.py in blend_palette(colors, n_colors, as_cmap, input) 775 pal = mpl.colors.LinearSegmentedColormap.from_list(name, colors) 776 if not as_cmap: --> 777 pal = ColorPalette(pal(np.linspace(0, 1, ncolors))) 778 return pal 779
<array_function internals> in linspace(args, *kwargs)
~\anaconda3\lib\site-packages\numpy\core\function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis) 118 119 """ --> 120 num = operator.index(num) 121 if num < 0: 122 raise ValueError("Number of samples, %s, must be non-negative." % num)
TypeError: 'float' object cannot be interpreted as an integer