dataframe remove nan code example
Example 1: remove nan from list python
cleanedList = [x for x in countries if str(x) != 'nan']
Example 2: drop if nan in column pandas
df = df[df['EPS'].notna()]
Example 3: pandas filter non nan
filtered_df = df[df['name'].notnull()]
Example 4: drop na pandas
>>> df.dropna(subset=['name', 'born'])
name toy born
1 Batman Batmobile 1940-04-25
Example 5: python remove nan rows
df = df[df['my_var'].notna()]
Example 6: delete nans in df python
df[~np.isnan(df)]