0

I'm looking for a solution to this: 2 columns in pandas dataframe with first name and surname. I'd like to shuffle name column but if the user has multiple entries (multiple rows with same name and surname) I want to keep the same rearragement. Example:

Name   surname new name
John   Bisham  Rick
Arthur Lefer   Mark
Arthur Lefer   Mark
Mike   Loner   Peter
Allen Qin
  • 19,507
  • 8
  • 51
  • 67
istwine
  • 41
  • 5
  • 1
    I think simpliest is `df.reindex(np.random.permutation(df.index))` – jezrael Jun 10 '21 at 06:00
  • No you didn't get the point, the issue isn't simply reshuffle the row, but keep the name or surname column fixed and then reshuffled the other column with the point that same entries keep the same reshuffled value – istwine Jun 10 '21 at 08:53
  • Can you explain more? Because hard to know problem with data posted in question. The best is add some 2 new columns and expected ouput to question. – jezrael Jun 10 '21 at 09:03

0 Answers0