Home > Enterprise >  Is there a function to filter out NaN/Na and a word in panda?
Is there a function to filter out NaN/Na and a word in panda?

Time:07-26

I have tried in combination df2 = df.loc[['Entity'] != ('World')] df2.loc[['Code'].str.contains('',na=False)]

result from memory showing code NaN World removed

both have succeeded my needs the problem is combining them together. it seems to just not want to work. In one column titled 'Code' in the data the continents came with 'NaN' so I filtered that out using 'df.loc[['Code'].str.contains('',na=False)]' and it worked but then combined with "df2 = df.loc[['Entity'] != ('World')]" I apologise for wasting anyones time this is for an assessment and the thought of it is bugging me out. Did i do anything wrong or misread the purpose of a function?

CodePudding user response:

To check your missing values you could use function isnull() or notnull() to filter, then correct them.

To remove and replace null values in Pandas DataFrame You could use ‘fillna()’. This is commonly replaced with 0 but depends on your DataFrame.

  • Related