0

I am very new, like going through school new. I am trying to do multiple linear regression and the columns I am trying to stop are still in the linear regression.

df= df.drop('Income','Yearly_equip_failure','Email','Techie','Population',
    'Port_modem','PaperlessBilling')

I run the sm.OLS code

model = sm.OLS(Y, X).fit()
predictions = model.predict(X)
print_model = model.summary()
print(print_model)

These are some of the few columns

Outage_sec_perweek                         0.0003      0.000      0.809      0.419      -0.000       0.001
Email                                   -6.71e-05      0.000     -0.189      0.850      -0.001       0.001
Contacts 
Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
Max66
  • 1
  • 1
    Does this answer your question? [Delete a column from a Pandas DataFrame](https://stackoverflow.com/questions/13411544/delete-a-column-from-a-pandas-dataframe) – Henry Ecker Jul 21 '21 at 22:19

2 Answers2

0

Your format is incorrect. If you're dropping multiple rows, you have to specify them in a sequence -- usually a list.

df= df.drop( [ 'Income', 'Yearly_equip_failure', 'Email',
               'Techie', 'Population',
               'Port_modem','PaperlessBilling' 
             ] )
Prune
  • 76,765
  • 14
  • 60
  • 81
0

As mentioned by @Prune the syntax used is incorrect:

Adding to that I suggest you to please refer to Pandas for more information.

Please remember that it is much more prudent to explicitly define what features you aim to drop i.e.

df = df.drop([A,B,C])

This may create an issue as it doesn't specify what are you trying to drop. It is a better practice to use

df = df.drop(columns = [A,B,C])

as it improves readability of your code.

Note: Always remember to toggle inplace flag when working with df.drop

  • Thank you very much. The second way worked. I should have known this but I guess I have been staring at this too long. – Max66 Jul 22 '21 at 04:45