1
    SAT GPA
0   1714    2.40
1   1664    2.52
2   1760    2.54
3   1685    2.74
4   1693    2.83

The above is the first 5 rows of my data set, however i want make a simple linear regression model of SAT score against GPA. i tried changing my independent variable(SAT) to 2D with the format below but i got an error message saying "series object has no attribute 'reshape'". kindly help pls

y=data.GPA
x=data.SAT.reshape([-1, 1])
--------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-57-11d5bd96e44d> in <module>()
      1 y=data.GPA
----> 2 x=data.SAT.reshape([-1, 1])
      3 x

~\Downloads\Anaconda2\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5139             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5140                 return self[name]
-> 5141             return object.__getattribute__(self, name)
   5142 
   5143     def __setattr__(self, name: str, value) -> None:

AttributeError: 'Series' object has no attribute 'reshape'
j1-lee
  • 13,764
  • 3
  • 14
  • 26
  • 3
    You need `data.SAT.values.reshape(-1, 1)` – ddejohn Oct 26 '21 at 03:48
  • 2
    Does this answer your question? [AttributeError: 'Series' object has no attribute 'reshape'](https://stackoverflow.com/questions/53723928/attributeerror-series-object-has-no-attribute-reshape) – ddejohn Oct 26 '21 at 03:53

0 Answers0