Exercise 3.7: Computing things!


[1]:
import pandas as pd

We have looked at a data set from Harvey and Orbidans on the cross-sectional area of C. elegans eggs. Recall, we loaded the data and converted everything to Numpy arrays like this:

[2]:
df = pd.read_csv('data/c_elegans_egg_xa.csv', comment='#')

xa_high = df.loc[df['food']=='high', 'area (sq. um)'].values
xa_low = df.loc[df['food']=='low', 'area (sq. um)'].values

Now we would like to compute the diameter of the egg from the cross-sectional area. Write a function that takes in an array of cross-sectional areas and returns an array of diameters. Recall that the diameter \(d\) and cross-sectional area \(A\) are related by \(A = \pi d^2/4\). There should be no for loops in your function! The call signature is

xa_to_diameter(xa)

Use your function to compute the diameters of the eggs.