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)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter