AttributeError: 'DataFrame' object has no attribute 'fit'

I’m working on the final project for Machine Learning Engineering.

I’m using jupyter notebook to fit the data.

When I try to fit the data, I keep getting an error message saying:
" AttributeError: ‘DataFrame’ object has no attribute ‘fit’"
I’ve attached some screenshot for reference. Thanks,


Because you’re using a method, .fit() that’s not available to a dataframe object.
Do you have a link to the project?

How can I use the metho ,fit() for the data?


That’s a file on your computer that isn’t viewable.

You have to use that method, .fit() on an existing model. Maybe this will help(?)

1 Like

HI Thanks for the article.
It looks like I need to reshape the data.
When I try to reshape the data, I keep getting a message saying:

AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_18380\ in ?()
1 X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=11, test_size=0.20)
2 regressor = DummyRegressor()
----> 3, 1), y_train)

~\anaconda3\Lib\site-packages\pandas\core\ in ?(self, name)
6200 and name not in self._accessors
6201 and self._info_axis._can_hold_identifiers_and_holds_name(name)
6202 ):
6203 return self[name]
→ 6204 return object.getattribute(self, name)

AttributeError: ‘Series’ object has no attribute ‘reshape’

When you get attribute errors, it means you’re trying to use a function—in this case .reshape() on an object that doesn’t “allow” that function. It’s not available to use on a one-dimensional object such as a series.
If you’re going to use .reshape(), you have to use it on a 2-D object like an (NumPy) array. So you’d have to convert it first.


Also, .reshape() was deprecated in Pandas 0.19.


1 Like

Thanks, I was able to get it to work correctly now.

1 Like