How can I remove Nan from list Python/NumPy

前端 未结 10 1948
挽巷
挽巷 2020-12-04 10:56

I have a list that countain values, one of the values I got is \'nan\'

countries= [nan, \'USA\', \'UK\', \'France\']

I tried to remove it,

10条回答
  •  囚心锁ツ
    2020-12-04 11:51

    Another way to do it would include using filter like this:

    countries = list(filter(lambda x: str(x) != 'nan', countries))
    

提交回复
热议问题