Olá,
Quando tento fazer o scatterplor igual ao da aula dá erro e não consigo identificar o que é, comparei com o curso passado, mas está igual. Abaixo o código:
ax = sns.scatterplot(x = y_previsto_train, y = y_train)
ax.figure.set_size_inches(12, 6)
ax.set_title('Previsão X Real', fontsize=18)
ax.set_xlabel('log do Preço - Previsão', fontsize=14)
ax.set_ylabel('log do Preço - Real', fontsize=14)
ax
Erro apresentado:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-74-52505796e876> in <module>
----> 1 ax = sns.scatterplot(x = y_previsto_train, y = y_train)
2 ax.figure.set_size_inches(12, 6)
3 ax.set_title('Previsão X Real', fontsize=18)
4 ax.set_xlabel('log do Preço - Previsão', fontsize=14)
5 ax.set_ylabel('log do Preço - Real', fontsize=14)
~\anaconda3\lib\site-packages\seaborn\_decorators.py in inner_f(*args, **kwargs)
44 )
45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 46 return f(**kwargs)
47 return inner_f
48
~\anaconda3\lib\site-packages\seaborn\relational.py in scatterplot(x, y, hue, style, size, data, palette, hue_order, hue_norm, sizes, size_order, size_norm, markers, style_order, x_bins, y_bins, units, estimator, ci, n_boot, alpha, x_jitter, y_jitter, legend, ax, **kwargs)
792
793 variables = _ScatterPlotter.get_semantics(locals())
--> 794 p = _ScatterPlotter(
795 data=data, variables=variables,
796 x_bins=x_bins, y_bins=y_bins,
~\anaconda3\lib\site-packages\seaborn\relational.py in __init__(self, data, variables, x_bins, y_bins, estimator, ci, n_boot, alpha, x_jitter, y_jitter, legend)
578 )
579
--> 580 super().__init__(data=data, variables=variables)
581
582 self.alpha = alpha
~\anaconda3\lib\site-packages\seaborn\_core.py in __init__(self, data, variables)
602 def __init__(self, data=None, variables={}):
603
--> 604 self.assign_variables(data, variables)
605
606 for var, cls in self._semantic_mappings.items():
~\anaconda3\lib\site-packages\seaborn\_core.py in assign_variables(self, data, variables)
665 else:
666 self.input_format = "long"
--> 667 plot_data, variables = self._assign_variables_longform(
668 data, **variables,
669 )
~\anaconda3\lib\site-packages\seaborn\_core.py in _assign_variables_longform(self, data, **kwargs)
909 # Construct a tidy plot DataFrame. This will convert a number of
910 # types automatically, aligning on index in case of pandas objects
--> 911 plot_data = pd.DataFrame(plot_data)
912
913 # Reduce the variables dictionary to fields with valid data
~\anaconda3\lib\site-packages\pandas\core\frame.py in __init__(self, data, index, columns, dtype, copy)
466
467 elif isinstance(data, dict):
--> 468 mgr = init_dict(data, index, columns, dtype=dtype)
469 elif isinstance(data, ma.MaskedArray):
470 import numpy.ma.mrecords as mrecords
~\anaconda3\lib\site-packages\pandas\core\internals\construction.py in init_dict(data, index, columns, dtype)
281 arr if not is_datetime64tz_dtype(arr) else arr.copy() for arr in arrays
282 ]
--> 283 return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
284
285
~\anaconda3\lib\site-packages\pandas\core\internals\construction.py in arrays_to_mgr(arrays, arr_names, index, columns, dtype, verify_integrity)
76 # figure out the index, if necessary
77 if index is None:
---> 78 index = extract_index(arrays)
79 else:
80 index = ensure_index(index)
~\anaconda3\lib\site-packages\pandas\core\internals\construction.py in extract_index(data)
385
386 if not indexes and not raw_lengths:
--> 387 raise ValueError("If using all scalar values, you must pass an index")
388
389 if have_series:
ValueError: If using all scalar values, you must pass an index