简体   繁体   English

如何删除 nlargest 元素?

[英]How to can I remove the nlargest element?

Hi I am triying to delete the nlargest examples of a dataset but I don't know how do it.嗨,我正在尝试删除数据集的最大示例,但我不知道该怎么做。

I get the data with the following code:我使用以下代码获取数据:

df_ae.nlargest(30, 'minimum_nights')

And I want to delete because this are the outliers in the dataset, I don't want to use the formula that drops the particular percentage.我想删除,因为这是数据集中的异常值,我不想使用降低特定百分比的公式。

How can do delete this data?如何删除这些数据?

Thanks谢谢

One possible approach:一种可能的方法:


df_ae.drop(index=df_ae.nlargest(30, 'mininimum_nights').index, inplace=True)

Note that it's probably good to add option keep='all' to your nlargest .请注意,将选项keep='all'添加到您的nlargest可能会很好。

I did with the following code:我用下面的代码做了:

df_ae.drop(df_ae.index[df_ae.nlargest(30, 'minimum_nights').index], inplace=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM