Skip to content Skip to sidebar Skip to footer

Drop Duplicate In Multiindex Dataframe In Pandas

I am looking to an efficient method to drop duplicate columns in a multiindex dataframe with Pandas. My data : TypePoint TIME Test ... T1 T1 -

Solution 1:

I think you can use double T:

print df
  TypePoint   TIME  Test      T1        
          -      S Unit1    unit    unit
0     24001     90   100  303.15  303.15
1     24002    390   101  303.15  303.15
2     24801  10000   102  303.15  303.15
3     24802  10500   103  303.15  303.15

print df.T.drop_duplicates().T
  TypePoint   TIME  Test      T1
          -      S Unit1    unit
0     24001     90   100  303.15
1     24002    390   101  303.15
2     24801  10000   102  303.15
3     24802  10500   103  303.15

Post a Comment for "Drop Duplicate In Multiindex Dataframe In Pandas"