1

Create a new dataframe based on the data in the other dataframe

I was looking for an efficient method to populate new dataframe. I don't want to use for, iterrows etc if possible

Do not want to opt for:

for index, row in Df1.interrows():

Input Df1: Source 

Index    set
A      {aa, dd}
B      {cc}
C      {dd,bb}
D      {aa,cc,dd,bb}
E      {cc}

Output Df: 

Index  aa  bb  cc  dd
A      1   0    0   1
B      0   0    1   0
C      0   1    0   1
D      1   1    1   1
E      0   0    1   0

1 Answers1

0

You could just copy it. If we call your initial dataframe dframe1 , you could create a new object with the same data via:

newDframe = dframe1.copy(deep=True)
Nikos H.
  • 110
  • 9