'Filtering out None from column in Pandas Dataframe

Let df be a dataframe and assume df["Scores"] is a column of dtype: object.

Some elements of "Scores" have the value None. I would like to filter out the None values from the Pandas series df["Scores].

I tried using the boolean series

df["Scores"] != None

however this returns True everywhere so did not help.

On the other hand the following will extract the values that are not None.

vals = []

for x in df["Scores"]:
    if x!= None:
        vals.append(x)

Would like to know why the first does not work.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source