boa noite
esta dando um erro no item 3.2 Mediana
notas_beltrano.median()
saida:
TypeError Traceback (most recent call last)
Cell In[65], line 1
----> 1 notas_beltrano.median()
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py:11706, in DataFrame.median(self, axis, skipna, numeric_only, **kwargs)
11698 @doc(make_doc("median", ndim=2))
11699 def median(
11700 self,
(...)
11704 **kwargs,
11705 ):
> 11706 result = super().median(axis, skipna, numeric_only, **kwargs)
11707 if isinstance(result, Series):
11708 result = result.__finalize__(self, method="median")
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\generic.py:12431, in NDFrame.median(self, axis, skipna, numeric_only, **kwargs)
12424 def median(
12425 self,
12426 axis: Axis | None = 0,
(...)
12429 **kwargs,
12430 ) -> Series | float:
> 12431 return self._stat_function(
12432 "median", nanops.nanmedian, axis, skipna, numeric_only, **kwargs
12433 )
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\generic.py:12377, in NDFrame._stat_function(self, name, func, axis, skipna, numeric_only, **kwargs)
12373 nv.validate_func(name, (), kwargs)
12375 validate_bool_kwarg(skipna, "skipna", none_allowed=False)
> 12377 return self._reduce(
12378 func, name=name, axis=axis, skipna=skipna, numeric_only=numeric_only
12379 )
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py:11562, in DataFrame._reduce(self, op, name, axis, skipna, numeric_only, filter_type, **kwds)
11558 df = df.T
11560 # After possibly _get_data and transposing, we are now in the
11561 # simple case where we can use BlockManager.reduce
> 11562 res = df._mgr.reduce(blk_func)
11563 out = df._constructor_from_mgr(res, axes=res.axes).iloc[0]
11564 if out_dtype is not None and out.dtype != "boolean":
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\internals\managers.py:1500, in BlockManager.reduce(self, func)
1498 res_blocks: list[Block] = []
1499 for blk in self.blocks:
-> 1500 nbs = blk.reduce(func)
1501 res_blocks.extend(nbs)
1503 index = Index([None]) # placeholder
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\internals\blocks.py:404, in Block.reduce(self, func)
398 @final
399 def reduce(self, func) -> list[Block]:
400 # We will apply the function and reshape the result into a single-row
401 # Block with the same mgr_locs; squeezing will be done at a higher level
402 assert self.ndim == 2
--> 404 result = func(self.values)
406 if self.values.ndim == 1:
407 res_values = result
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py:11481, in DataFrame._reduce.<locals>.blk_func(values, axis)
11479 return np.array([result])
11480 else:
> 11481 return op(values, axis=axis, skipna=skipna, **kwds)
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\nanops.py:147, in bottleneck_switch.__call__.<locals>.f(values, axis, skipna, **kwds)
145 result = alt(values, axis=axis, skipna=skipna, **kwds)
146 else:
--> 147 result = alt(values, axis=axis, skipna=skipna, **kwds)
149 return result
File c:\Users\JUNIOR\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\nanops.py:787, in nanmedian(values, axis, skipna, mask)
785 inferred = lib.infer_dtype(values)
786 if inferred in ["string", "mixed"]:
--> 787 raise TypeError(f"Cannot convert {values} to numeric")
788 try:
789 values = values.astype("f8")
TypeError: Cannot convert [['Matemática' 'Inglês' 'Física' 'História' 'Química' 'Português']] to numeric