我有一個(gè)由以下生成的數(shù)據(jù)的數(shù)據(jù)框:df2 = df.groupby(['City','Address','date_time'])['house_price'].mean().pct_change()City Address Date Pct ChWashington, D.C. 111 S Street Appletown 2018-08-03 0.298077 2018-08-11 0.000000 2018-08-17 0.000000 2018-09-07 0.000000 2018-09-17 0.000000 2018-09-20 0.000000 222 S Street Appletown 2018-08-07 0.125926 2018-08-11 0.000000 2018-08-17 0.000000 2018-09-07 0.000000 2018-09-17 0.000000 2018-09-20 0.000000我想刪除每個(gè)組中的最短日期(111 S Street Appletown 為 2018-08-03;222 S Street 為 2018-08-07)。我試過(guò)了df2 = df.groupby(['City','Address','date_time'])['house_price'].mean().pct_change().filter(lambda x: x['date_time']> x['date_time'].min())但這會(huì)引發(fā)錯(cuò)誤。有沒(méi)有好的方法可以做到這一點(diǎn)?
根據(jù)組標(biāo)準(zhǔn)熊貓刪除組中的值
動(dòng)漫人物
2021-06-21 12:10:05