Remove outliers in Pandas dataframe with groupby

前端 未结 2 516
生来不讨喜
生来不讨喜 2020-12-17 05:53

I have a dataframe of Report Date, Time Interval and Total Volume for a full year. I would like to be able to remove outliers within each Time Interval.

This is as f

2条回答
  •  鱼传尺愫
    2020-12-17 06:12

    df[df.groupby("ReportDate").TotalVolume.\
          transform(lambda x : (x(x.quantile(0.05)))).eq(1)]
    Out[1033]: 
          ReportDate  TimeInterval  TotalVolume
    5785  2016-03-01            25        580.0
    5786  2016-03-01            26        716.0
    5787  2016-03-01            27        803.0
    

提交回复
热议问题