I have the following dataset
Chr Position Name AD
1 866511 A 13,21
1 881627 A 28,33
2 1599812 B 67,25
I need to split the column AD into three columns [REF, ALT1, ALT2].
When for every row the AD has only two values I still need the ALT2 column filled in with NaN value.
The following code works if AD contains rows with three values
df['REF'], df['ALT1'], df['ALT2'] = df['AD'].str.split(',', 2).str
However, in some cases for each row, the dataset contains only two values in column AD and when I run the same line I get the following error message:
ValueError: not enough values to unpack (expected 3, got 2)
In this case, I would like to still have the third column ALT2 and fill it in with NaN values. Any suggestion? Thank you, anyone, who is willing to help.