I have a problem with splitting two columns into new rows.
My dataframe looks like this
"involved" and "team_player_formation" each have 15 strings, that needs to be assigned into each their row. With the first string of "involved" matching first string of "team_player_formation"
I have tried to follow this: Split (explode) pandas dataframe string entry to separate rows and searching for ways to split multiple columns, but without success
I have been able to split one of my columns with the following at the moment
df = pd.read_csv('Hello.csv', delimiter=';')
df = df.assign(involved=df['involved'].str.split(',')).explode('involved')
Which gives me something like this:
matchId contestantId periodId typeId involved team_formation team_player_formation
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 b2492j7qzdo7g3ysxz6gq4g5x 4 1
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 b2492j7qzdo7g3ysxz6gq4g5x 4 1
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 b2492j7qzdo7g3ysxz6gq4g5x 4 1
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 b2492j7qzdo7g3ysxz6gq4g5x 4 1
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 b2492j7qzdo7g3ysxz6gq4g5x 4 1
..................
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 am3509ake84cde1xhb9264i22 4 0
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 am3509ake84cde1xhb9264i22 4 0
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 am3509ake84cde1xhb9264i22 4 0
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 am3509ake84cde1xhb9264i22 4 0
0 d5321qxmnyf9004i049uf4pre 77tfx9me4aaqhzv78bmgsy9bg 2 40 am3509ake84cde1xhb9264i22 4 0
But that only split "involed" into a new column.
The output should be something like this, where I have only showed the first 3 rows.
Thank you! I hope you can help, and that I explained it well enough.