Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to sort values of pandas dataframe for iqr

    def mod_outlier(df):
        df1 = df.copy()
        df = df._get_numeric_data()


        q1 = df.quantile(0.25)
        q3 = df.quantile(0.75)

        iqr = q3 - q1

        lower_bound = q1 -(1.5 * iqr) 
        upper_bound = q3 +(1.5 * iqr)


        for col in col_vals:
            for i in range(0,len(df[col])):
                if df[col][i] < lower_bound[col]:            
                    df[col][i] = lower_bound[col]

                if df[col][i] > upper_bound[col]:            
                    df[col][i] = upper_bound[col]    


        for col in col_vals:
            df1[col] = df[col]

        return(df1)
Comment

PREVIOUS NEXT
Code Example
Python :: how download youtube video in python 
Python :: how to get a number from a string in python 
Python :: flask flash not working 
Python :: pandas front fill 
Python :: python class variables make blobal 
Python :: pandas count the number of unique values in a column 
Python :: excel get unique values from column formula 
Python :: python remove consecutive spaces 
Python :: spyder - comment banch of codee 
Python :: python function to scale selected features in a dataframe pandas 
Python :: keras example 
Python :: rnadom number python 
Python :: get ContentType with django get_model 
Python :: how to store in parquet format using pandas 
Python :: import time in python 
Python :: generate list of consecutive numbers 
Python :: how to open application using python 
Python :: keyboard press pyautogui 
Python :: strip array of strings python 
Python :: how to calculate the sum of a list in python 
Python :: python list comprehension cartesian product 
Python :: delete columns pandas 
Python :: python 2 deprecated 
Python :: kafka get last offset of topic python 
Python :: pyramid pattern in python 
Python :: python package version 
Python :: python operators 
Python :: make a script run itself again python 
Python :: python vs c++ 
Python :: operator precedence in python 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =