Function commenting

PHOTO EMBED

Wed Feb 09 2022 05:29:22 GMT+0000 (Coordinated Universal Time)

Saved by @Milados

def find_ratio(df):
    """
    Calculates the ratio of the sepal length range to the petal length range for a pandas dataframe.
    
    Arguments:
    ----------
        df (pandas dataframe): a dataframe to calculate the ratio over
        
    Returns:
    --------
        ratio (numpy float): the calculated ratio
    """
    ratio = (df['sepal length (cm)'].max() - df['sepal length (cm)'].min())/(df['petal length (cm)'].max() - df['petal length (cm)'].min())
    
    return(ratio)
content_copyCOPY

A great example for knowing how to define a function

http://localhost:8888/notebooks/Untitled.ipynb