0

I find a strange thing. Suppose I have a data frame df1

     Children       Father   Mother  Address
  0  Alice|Bob        Tom     Mary    abc
  1   Cathy           Jack    Helen   ddd

When I use split("|") and df1.explode("Children")

  it will look like 
         Children       Father   Mother  Address
      0   Alice          Tom     Mary    abc
      0    Bob           Tom     Mary    abc
      1   Cathy          Jack    Helen   ddd

The index in Alice and Bob are same, however, if I ran print df1.iloc[0, ]

it will only print(not "Bob" line)
         Children       Father   Mother  Address
      0   Alice          Tom     Mary    abc

if I print df1.iloc[1, ]

it will only print
             Children       Father   Mother  Address
          0    Bob           Tom     Mary    abc

if I print df1.iloc[2, ]

it will print
             Children       Father   Mother  Address
          1   Cathy          Jack    Helen   ddd

    

It is really strange, so I have following questions: (1).I am confused what is data frame's index meaning here, why I use iloc, it doesn't using the index to choose it (2). is it possible to make the index(001) to be the normal order like(012)? (3) I notice the df.append(new_df), the index will look like(0123012), but using iloc, it has same thing with the example I did above.

Thank you in advance!

0 Answers0