Home > other >  How python group to find outliers and replace na?
How python group to find outliers and replace na?

Time:09-30

Two columns of data, a column is a type, a column is the consumption, consumption is divided into several groups according to different type, need according to the box figure method to identify the upper and lower bounds of the consumption data in each group, according to the upper and lower bounds of the each group to find outliers in each group (greater than the upper bound is less than the lower bound of values), and replaced with na
Now each group of the upper and lower bounds of the consumption data have been used dataframe groupby find out, but don't know how to write a statement to determine whether each data is greater than or less than the upper and lower bounds of the group it belongs to
Beginners, for help, thank you!!!!!

CodePudding user response:

In the apply such treatment can?
Col=group [' mycol]
Col [col< x]=na
Col col> y=na

CodePudding user response:

refer to the original poster Sylvia__ response:
two columns of data, a column is a type, a column is the consumption, consumption is divided into several groups according to different type, need according to the box figure method to find out the upper and lower bounds of the consumption data in each group, according to the upper and lower bounds of the each group to find outliers in each group (greater than the upper bound is less than the lower bound of values), and replaced with na
Now each group of the upper and lower bounds of the consumption data have been used dataframe groupby find out, but don't know how to write a statement to determine whether each data is greater than or less than the upper and lower bounds of the group it belongs to
Beginners, for help, thank you!!!!!

Can look at this article: https://blog.csdn.net/weixin_44013214/article/details/100176055
  • Related