I am trying to separate the column values separated by "," separator of a panda dataframe.
The original data Original panda dataframe
The desired output Desired output
I have tried several ways.
Explode/stack a Series of strings
newdf['Month'] = newdf['Month'].apply(list)
using the above code I am getting [j,a,n,,f,e,b]
and then I have used
pd.Dataframe({'Month':np.concatenate(newdf['Month'].values), 'cust.no':newdf['cust.no'].repeat(newdf['cust no.'].apply(len))})
The output is each letter is coming in separate rows. As a result, the row numbers are not matching with "cust no." and I am getting error.
I know there are several functions available but I couldn't one that can efficiently break down the values.