I have a Dataframe with thousands of lines:
Column1 Column2
someString String1;String2;String3
someString String4;String5
I want to split column 2 in new columns by using ";" as a separator.
Column1 Column2 Column3 Column4 Column5
someString String1 String3 String2
someString String4 String5
While looking in the documentation, I tried a method:
df[['Subcolumn1','Subcolumn2','Subcolumn3','Subcolumn4']] = df.Column2.str.split(";",expand=True)
I had the ValueError: Columns must be same length as key
I can't predict how many columns will be created because I have thousands of lines and each line contains a different number of strings to be separated.
So I'm looking for a more "dynamic" way to generate these columns in order to avoid these value errors.