-3
for i in Leads.columns:
    if (Leads[i].isnull().sum()/Leads.shape[0]) > 0.40:
        Leads = Leads.drop(i,axis=1,inplace = True)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17092/1952428833.py in <module>
      2 
      3 for i in Leads.columns:
----> 4     if (Leads[i].isnull().sum()/Leads.shape[0]) > 0.40:
      5         Leads = Leads.drop(i,axis=1,inplace = True)

TypeError: 'NoneType' object is not subscriptable
for i in Leads.columns:
    if (Leads[i].isnull().sum()/Leads.shape[0]) > 0.40:
        Leads = Leads.drop(i,axis=1,inplace = True)

I was expecting the columns having more than 40% missing values to be dropped

Iguananaut
  • 21,810
  • 5
  • 50
  • 63
  • You have used `inplace` so the method returns nothing – azro Dec 26 '22 at 11:22
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 26 '22 at 11:44

1 Answers1

0

inplace parameter makes the modificaiton on the called object, and returns nothing

Either remove the assignment

for i in Leads.columns:
    if (Leads[i].isnull().sum() / Leads.shape[0]) > 0.40:
        Leads.drop(i, axis=1, inplace=True)

Or remove the inplace

for i in Leads.columns:
    if (Leads[i].isnull().sum() / Leads.shape[0]) > 0.40:
        Leads = Leads.drop(i, axis=1)
azro
  • 53,056
  • 7
  • 34
  • 70