0

I have a dataframe which looks like below

name|age|city
Tom |20 |Newyork
Tom |30 |Kansas
Ruby|16 |Venice
Hari|34 |Mumbai
Hari|65 | Delhi

I want to split this dataframe into "n" dataframes based on same name value.

So the above should become -

df1

name|age|city
Tom |20 |Newyork
Tom |30 |Kansas

df2

name|age|city
Ruby|16 |Venice

df3

name|age|city
Hari|34 |Mumbai
Hari|65 | Delhi

The number of rows in the initial dataframe is not fixed. So the number of new smaller dataframes has to be dynamic.

Naxi
  • 960
  • 1
  • 14
  • 49

0 Answers0