Home > Net >  How to join two columns (one is list other is integer id column ) in pandas python in one dataframe?
How to join two columns (one is list other is integer id column ) in pandas python in one dataframe?

Time:10-15

https://i.stack.imgur.com/ptVi1.png

enter image description here

I want to join these two columns in a new Dataframe like this:

enter image description here

CodePudding user response:

join and explode:

out = (df_id.join(df_cast['Cast'].str.split(',\s*'))
        .explode('Cast')
     )

Or explode and join:

out = df_id.join(df_cast['Cast'].str.split(',\s*').explode('Cast'))
  • Related