Home > database >  Column name repetition in pandas data frame
Column name repetition in pandas data frame

Time:10-21

I am trying to read some data but the column names are repeatedly coming.

Here is a sample code:

for i in range(1, len(df_A2C), 1):
    A2C_TT= df_A2C.loc[(df_A2C['TO_ID'] == i)].sort_values('DURATION_H').head(1)
    if A2C_TT.size > 0:
        print (A2C_TT)

Output:

enter image description here

I do not need column names. What should I do?

CodePudding user response:

You may simply call the values method after head:

for i in range(1, len(df_A2C), 1):
    A2C_TT= df_A2C.loc[(df_A2C['TO_ID'] == i)].sort_values('DURATION_H').head(1).values
    if A2C_TT.size > 0:
        print (A2C_TT)
  • Related