Remove rows with duplicate indices (Pandas DataFrame and TimeSeries)

后端 未结 6 932
我寻月下人不归
我寻月下人不归 2020-11-22 14:31

I\'m reading some automated weather data from the web. The observations occur every 5 minutes and are compiled into monthly files for each weather station. Once I\'m done pa

6条回答
  •  礼貌的吻别
    2020-11-22 15:16

    If anyone like me likes chainable data manipulation using the pandas dot notation (like piping), then the following may be useful:

    df3 = df3.query('~index.duplicated()')
    

    This enables chaining statements like this:

    df3.assign(C=2).query('~index.duplicated()').mean()
    

提交回复
热议问题