'Why does my function does not work anymore
I am a student, just starting with python and I have a problem with the .drop function in pandas.
- I have created some dummies (for many variables, here I give only 1 example)
- 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.
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |