unction which takes in a list of integers and returns a dictionary of the five number summary.. 1

unction which takes in a list of integers and returns a dictionary of the five number summary..

def fivenum(x):
    series=pd.Series(x)
    mi = series.min()
    q1 = series.quantile(q=0.25, interpolation='nearest')
    me = series.median()
    q3 = series.quantile(q=0.75, interpolation='nearest')
    ma = series.max()
    return pd.Series([mi, q1, me, q3, ma], index=['min', 'q1', 'median', 'q3', 'max'])

Here is what the above code is Doing:
1. Create a pandas Series from the input array
2. Calculate the min, q1, median, q3, and max
3. Return a pandas Series with the calculated values

Similar Posts