I have this example DataFrame:
d = {'col1': [1, 2, np.NaN], 'col2': [3, np.NaN, 4], 'col3': [np.NaN, 5, 6]}
df = pd.DataFrame(data=d)
and want to drop NaN values in that way to get the resulting dataFrame in this shape
I tried to iterate over columns and use dropna() function on each column but that didn't work:
for i in columns:
df3[i].dropna()
Next when I tried :
df = df.dropna(subset=['col1', 'col2','col3'])
I ended up with df with all rows dropped: