1
resposta

como corrigir esse erro?

código:


porcentagem_conta_linha = sns.relplot(x='valor_da_conta', y='porcentagem', kind='line', data=gorjetas)

Erro:

C:\Users\tersi\anaconda3\Lib\site-packages\seaborn\axisgrid.py:257: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  none_na = np.zeros(len(data), np.bool)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[520], line 1
----> 1 porcentagem_conta_linha = sns.relplot(x='valor_da_conta', y='porcentagem', kind='line', data=gorjetas)

File ~\anaconda3\Lib\site-packages\seaborn\relational.py:1603, in relplot(x, y, hue, size, style, data, row, col, col_wrap, row_order, col_order, palette, hue_order, hue_norm, sizes, size_order, size_norm, markers, dashes, style_order, legend, kind, height, aspect, facet_kws, **kwargs)
   1601 # Set up the FacetGrid object
   1602 facet_kws = {} if facet_kws is None else facet_kws
-> 1603 g = FacetGrid(
   1604     data=data, row=row, col=col, col_wrap=col_wrap,
   1605     row_order=row_order, col_order=col_order,
   1606     height=height, aspect=aspect, dropna=False,
   1607     **facet_kws
   1608 )
   1610 # Draw the plot
   1611 g.map_dataframe(func, x, y,
   1612                 hue=hue, size=size, style=style,
   1613                 **plot_kws)

File ~\anaconda3\Lib\site-packages\seaborn\axisgrid.py:257, in FacetGrid.__init__(self, data, row, col, hue, col_wrap, sharex, sharey, height, aspect, palette, row_order, col_order, hue_order, hue_kws, dropna, legend_out, despine, margin_titles, xlim, ylim, subplot_kws, gridspec_kws, size)
    253 hue_kws = hue_kws if hue_kws is not None else {}
    255 # Make a boolean mask that is True anywhere there is an NA
    256 # value in one of the faceting variables, but only if dropna is True
--> 257 none_na = np.zeros(len(data), np.bool)
    258 if dropna:
    259     row_na = none_na if row is None else data[row].isnull()

File ~\anaconda3\Lib\site-packages\numpy\__init__.py:305, in __getattr__(attr)
    300     warnings.warn(
    301         f"In the future `np.{attr}` will be defined as the "
    302         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    304 if attr in __former_attrs__:
--> 305     raise AttributeError(__former_attrs__[attr])
    307 # Importing Tester requires importing all of UnitTest which is not a
    308 # cheap import Since it is mainly used in test suits, we lazy import it
    309 # here to save on the order of 10 ms of import time for most users
    310 #
    311 # The previous way Tester was imported also had a side effect of adding
    312 # the full `numpy.testing` namespace
    313 if attr == 'testing':

AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
1 resposta

Olá Térsio, tudo bem com você?

Isso pode ocorrer devido a uma incompatibilidade entre a versão do Seaborn que você está usando e a versão do NumPy.

Uma alternativa é atualizar essas duas bibliotecas digitando o seguinte comando:

pip install --upgrade numpy
pip install --upgrade seaborn

Observação: caso esteja utilizando notebooks, para o executar os comandos acima dentro da célula, coloque o sinal de exclamação como precedente, exemplo: !pip install --upgrade seaborn.

Todavia, ressalto que o curso "Data Visualization: explorando com Seaborn" foi atualizado e recomendo que você acompanhe o curso na versão mais recente, basta acessar este link.

Espero ter ajudado. Continue mergulhando em conhecimento e não hesite em voltar ao fórum para continuar aprendendo e interagindo com a comunidade.

Em caso de dúvidas estou à disposição.

Abraços e bons estudos!

Caso este post tenha lhe ajudado, por favor, marcar como solucionado ✓. Bons Estudos!