Practice Problems

Lecture 9

Answer each number in a separate cell

Rename the notebook with your lastName and the lecture

ex. CychB_09

Turn this notebook into TritonEd by the end of class

1. Pandas: methods and filters

  • Import the file 'Datasets/minutes_velocity.csv' into a Pandas DataFrame.
  • Find the median velocity from this DataFrame (use the function Series.median( )). Print the median value
  • Find the mean velocity (use the function Series.mean( )). Print the mean value
  • Filter your DataFrame to select all the velocities that fall between the median and mean using the 'and' conditional syntax.
  • Check your work: find the maximum and minimum velocities in the filtered data frame. Print the maximum and minimum values and compare them to the median and mean.

2. functions

  • write a function that takes latitudes (in degrees) and converts them to colatitudes (in radians)
  • write a function, that takes two longitudes and returns the difference
  • re-write the function great_circle( ) that calls the two other functions and returns the latitudinal separation in degrees. (Hint: remember that NumPy assumes that the units are in radians)

3. Great circles

  • Use your new funciton to find the angular difference between where you were born and Pinyon Flat (PF_lat = 33.3,PF_lon = -115.7).
  • There are roughly 111 km in one degree, how many kilometers is the distance between your birthplace and Pinyon Flat? Print the distance

4. Formatting strings

  • set a variable, pi, to the value of np.pi
  • print the value of pi
  • format the value to have four significant digits.
  • print out a sentence with the formatted value of $\pi$ in it.
  • multiply $\pi$ by 50 and use the exponential form of string formatting to print out 4 significant digits.
In [ ]: