-3

I am a student, just starting with python and I have a problem with the .drop function in pandas.

  1. I have created some dummies (for many variables, here I give only 1 example)
  2. Now I want to get rid of the initial columns / variables but the function doesn't work.
dummy = pd.get_dummies(leads['MainTariffInsuranceGroupSF'], prefix ='MainTariffInsuranceGroupSF')

leads = pd.concat([leads,dummy], 1)
#leads = leads.drop(['LeadCreation_Weekday','MainTariffInsuranceGroupSF','LeadCreation_DecadeInMonth', 'Nationality', 'Language', 'AgeGroupStandard', 'OccupationType', 'Region'], axis=1, implace=True)

I also have to say: I don't get any error. Variables are just not removed. And the last time (a few days ago, when I worked on this jupiter notebook this same lines of code worked without a problem.

1 Answers1

0

can you provide a minimum working example (MWE)?

Did you work through the official doc of the pd.dataframe.drop() function?

The documentation states for inplance: inplacebool, default False If False, return a copy. Otherwise, do operation inplace and return None.

Did you try to run the code in a Python file (without notebook)?

There is a typo in the line: implace -> inplace

leads.drop(['LeadCreation_Weekday','MainTariffInsuranceGroupSF','LeadCreation_DecadeInMonth', 'Nationality', 'Language', 'AgeGroupStandard', 'OccupationType', 'Region'], axis=1, inplace=True)

or

leads = leads.drop(['LeadCreation_Weekday','MainTariffInsuranceGroupSF','LeadCreation_DecadeInMonth', 'Nationality', 'Language', 'AgeGroupStandard', 'OccupationType', 'Region'], axis=1)

should do the trick. This is after seeing the comment below your initial post.

moschmdt
  • 1
  • 1
  • 3
  • 1
    Thanks for pointing that out. Kind of new to contributing to SO. Updated the answer with solution proposals. I hope that is sufficient for an answer? – moschmdt Mar 06 '22 at 10:14