I have below list
import pandas as pd
import numpy as np
dat = pd.DataFrame({'name' : ['A', 'C', 'A', 'B', 'C'], 'val' : [1,2,1,2,4]})
List = [dat, np.nan, dat, np.nan, np.nan]
List
I want to retain only those elements where they are not nan.
There is a similar discussion in How can I remove Nan from list Python/NumPy, but it is only applicable if all elements are scalar.
Is there any way to remove nan if some elements are matrix/dataframe?