Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

[Bug] AttributeError: module 'numpy' has no attribute 'float'.

**AttributeError: module 'numpy' has no attribute 'float'.
***`np.float` was a deprecated alias for the builtin `flo**at`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.

-- Projeto importado pelo instrutor referente ao módulo 4.3 do curso de análise e visualização de modos. O meu anterior funcionava até o mesmo ponto, e então apresentava o mesmo erro. Decidi então tentar com o projeto do instrutor e recebi o mesmo bug.

AttributeError                            Traceback (most recent call last)
Cell In[7], line 45
     42 contagem_de_lingua.columns = ["original_language", "total"]
     43 contagem_de_lingua.head()
---> 45 sns.barplot(x="original_language", y = "total", data = contagem_de_lingua)
     47 sns.catplot(x = "original_language", kind="count", data = tmdb)
     49 plt.pie(contagem_de_lingua["total"], labels = contagem_de_lingua["original_language"])

File ~\AppData\Roaming\Python\Python311\site-packages\seaborn\categorical.py:3146, in barplot(x, y, hue, data, order, hue_order, estimator, ci, n_boot, units, orient, color, palette, saturation, errcolor, errwidth, capsize, dodge, ax, **kwargs)
   3140 def barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None,
   3141             estimator=np.mean, ci=95, n_boot=1000, units=None,
   3142             orient=None, color=None, palette=None, saturation=.75,
   3143             errcolor=".26", errwidth=None, capsize=None, dodge=True,
   3144             ax=None, **kwargs):
-> 3146     plotter = _BarPlotter(x, y, hue, data, order, hue_order,
   3147                           estimator, ci, n_boot, units,
   3148                           orient, color, palette, saturation,
   3149                           errcolor, errwidth, capsize, dodge)
   3151     if ax is None:
   3152         ax = plt.gca()

File ~\AppData\Roaming\Python\Python311\site-packages\seaborn\categorical.py:1606, in _BarPlotter.__init__(self, x, y, hue, data, order, hue_order, estimator, ci, n_boot, units, orient, color, palette, saturation, errcolor, errwidth, capsize, dodge)
   1601 def __init__(self, x, y, hue, data, order, hue_order,
   1602              estimator, ci, n_boot, units,
   1603              orient, color, palette, saturation, errcolor,
   1604              errwidth, capsize, dodge):
   1605     """Initialize the plotter."""
-> 1606     self.establish_variables(x, y, hue, data, orient,
   1607                              order, hue_order, units)
   1608     self.establish_colors(color, palette, saturation)
   1609     self.estimate_statistic(estimator, ci, n_boot)

File ~\AppData\Roaming\Python\Python311\site-packages\seaborn\categorical.py:158, in _CategoricalPlotter.establish_variables(self, x, y, hue, data, orient, order, hue_order, units)
    155         raise ValueError(err)
    157 # Figure out the plotting orientation
--> 158 orient = self.infer_orient(x, y, orient)
    160 # Option 2a:
    161 # We are plotting a single set of data
    162 # ------------------------------------
    163 if x is None or y is None:
    164 
    165     # Determine where the data are

File ~\AppData\Roaming\Python\Python311\site-packages\seaborn\categorical.py:359, in _CategoricalPlotter.infer_orient(self, x, y, orient)
    357     else:
    358         return "h"
--> 359 elif is_not_numeric(y):
    360     if is_not_numeric(x):
    361         raise ValueError(no_numeric)

File ~\AppData\Roaming\Python\Python311\site-packages\seaborn\categorical.py:339, in _CategoricalPlotter.infer_orient.<locals>.is_not_numeric(s)
    337 def is_not_numeric(s):
    338     try:
--> 339         np.asarray(s, dtype=np.float)
    340     except ValueError:
    341         return True

File ~\AppData\Roaming\Python\Python311\site-packages\numpy\__init__.py:338, in __getattr__(attr)
    333     warnings.warn(
    334         f"In the future `np.{attr}` will be defined as the "
    335         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    337 if attr in __former_attrs__:
--> 338     raise AttributeError(__former_attrs__[attr])
    340 if attr == 'testing':
    341     import numpy.testing as testing
1 resposta
solução!

Oi, Gabriel! Como vai?

O código está certinho. O que está gerando o erro, provavelmente, é a versão do Seaborn que está no seu ambiente.

No curso, estamos utilizando a versão 0.9.0:

!pip install seaborn==0.9.0

import seaborn as sns
print(sns.__version__)

Rode essa célula e tente executar novamente.

Qualquer coisa me avise, tá? Estou por aqui!

Abraços.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software