I have the following dataframe 'df' based on which I'd like to create a new df 'new_df'. I have some troubles getting the new df.
Cust-id Sex Country Orders Products
0 'Cu1' 'F' 'FR' 'ord1 + ord2' 'A+G'
1 'Cu2' 'M' 'US' 'ord3' 'C'
2 'Cu3' 'M' 'UK' 'ord4 + ord5' 'H+Z'
3 'Cu4' 'F' 'RU' 'ord6' 'K'
4 'Cu5' 'M' 'US' 'ord7' 'T'
5 NaN 'M' 'UK' 'ord#' 'K'
6 'Cu6' 'F' 'US' 'ord8+ord9+ord10' 'R+D+S'
7 'Cu7' 'M' 'UK' 'ord11' 'A'
I'd like the 'new_df' to contain a row for each 'order' with corresponding 'product'. All other columns keep their contents. Also, if a row in the 'Cust-id' column is NaN that complete row should be deleted (i.e. not present in the new df). This would give the following new_df:
Cust-id Sex Country Orders Products
0 'Cu1' 'F' 'FR' 'ord1' 'A'
1 'Cu1' 'F' 'FR' 'ord2' 'G'
2 'Cu2' 'M' 'US' 'ord3' 'C'
3 'Cu3' 'M' 'UK' 'ord4' 'H'
4 'Cu3' 'M' 'UK' 'ord5' 'Z'
5 'Cu4' 'F' 'RU' 'ord6' 'K'
6 'Cu5' 'M' 'US' 'ord7' 'T'
7 'Cu6' 'F' 'US' 'ord8' 'R'
8 'Cu6' 'F' 'US' 'ord9' 'D'
9 'Cu6' 'F' 'US' 'ord10' 'S'
10 'Cu7' 'M' 'UK' 'ord11' 'A'
Any help/guidance is appreciated.