Skip to content
Advertisement

Unable to fix “ValueError: DataFrame constructor not properly called!”

I was asked to write a program for Linear Regression with the following steps.

  1. Load the R data set mtcars as a pandas dataframe.
  2. Build another linear regression model by considering the log of independent variable wt, and log of dependent variable mpg.
  3. Fit the model with data, and display the R-squared value

I am a beginner at Statistics with Python.

I have tried getting the log values without converting to a new DataFrame but that gave an error saying “TypeError: ‘OLS’ object is not subscriptable”

JavaScript

The expected result is the table after linear regression but the actual output is an error

[ValueError: DataFrame constructor not properly called!]

Advertisement

Answer

This might work for you.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement