I have the following dataframe:
>>>name breakfast lunch dinner
0 Zoey apple egg noodels
1 Rena pear pasta
2 Shila tomato potatoes
3 Daphni coffee soup
4 Dufi
I would like to create new column which will have all the food values that each name ate on the same day. I have tried to do it using '+' and seperate between the words with ',' as following:
df['food']=df['breakfast']+','+df['lunch']+','+df['dinner']
but then if I have null values I have ',' in the middle:
>>>name breakfast lunch dinner food
0 Zoey apple egg noodels apple,egg,noodels
1 Rena pear pasta pear,,pasta
2 Shila tomato potatoes ,tmatoe,potatoes
3 Daphni coffee soup coffee,,soupp
4. Dufi ,,
and I would like to get it clean with ',' in the right places, e.g not to put , if there is null:
>>>name breakfast lunch dinner food
0 Zoey apple egg noodels apple,egg,noodels
1 Rena pear pasta pear,pasta
2 Shila tomato potatoes tmatoe,potatoes
3 Daphni coffee soup coffee,soup
4 Dufi
is there any way to do this ? to define that if there is null cell do not add it/ don't put , in wrong places