Remove NaN values from a Pandas series


import pandas as pd
import numpy as np
#create series
s = pd.Series([0,4,12,np.NaN,55,np.NaN,2,np.NaN])
#dropna - will work with pandas dataframe as well
s.dropna()

0 0.0

1 4.0

2 12.0

4 55.0

6 2.0

dtype: float64




Ace your next data science interview

Get better at data science interviews by solving a few questions per week



Find a bug? Submit a suggested change on Github, or message me on Twitter.