I have a dataframe like the following (but longer) with some rows containing None values:
data = {'first Column': ['she is', 'they are',NaN,'we are',NaN],
'second Column ': ['my', 'her',NaN,'his',NaN],
'third column': ['friend', 'brothers',NaN,'sisters',NaN]
}
df = pd.DataFrame (data, columns = ['first Column','second Column','third column])
my_list= ['gold','silver','bronze']
I would like to replace every row in the 'third column' with a list if it does not contain none value, like this :
desired output:
first column second column third column
0 she is my ['gold','silver','bronze']
1 they are her ['gold','silver','bronze']
2 NaN NaN NaN
3 we are his ['gold','silver','bronze']
4 NaN NaN NaN
I have tried np.where, but it does not select the desired rows
np.where(df.loc[df['third column'] != 'NaN', [','.join(my_list)], df['third column']