| A | B
| a;b;c | 1;2;3
| a;b;c;d | 1
In order to split the column , I am using
new = df["A"].str.split(";", n=5, expand=True).
df['A1'] = new[0]
df['A2'] = new[1]
df['A3'] = new[2]
df['A4'] = new[3]
df.drop(columns=["A"], inplace=True)
df['B1'] = new[0]
df['B2'] = new[1]
df['B3'] = new[2]
df.drop(columns=["B"], inplace=True)
Is there any other alternatives such that I do not need to count the number of data in each column?? I still need the output to be something like :
| A1| A2| A3| A4| B1| B2| B3
| a | b | c | | 1 | 2 | 3
| a | b | c | d | 1 | |
Thanks!