replace nan with 0 lists if list python code example Example: python list replace nan with 0 mylist = [0 if x != x else x for x in mylist]