Class 10 – Start Pandas

Today we are going to start using Pandas (pdf=Pandas_Well_Data).

We are using part of a data set that looks at arsenic concentrations in Bangladesh.

VIDEO

MAKE SURE TO TAKE THE QUIZ!

Homework

Due Next Class (Monday February 26, 2024).

  1. Take the data from class today and plot depth on the y-axis and arsenic on the x-axis. I would use ax.scatter() and I would also use the fig,ax=plt.subplots() notation.  Because when you plot something versus depth you always want depth in reverse order or inverted so the 0 is at the top and the maximum is at the bottom.    Use ax. and some google searching to find out how to do it. But if you stop and think about setting ranges you can change your start and stop intervals.  Then the next step is to put the x-axis ticks on top and to put the label position on top.  then you can set the x limits (xlim) to get the plot so it starts at 0.  Also xlim could go from high to low. If something takes a list you add a [] inside the ().   luckily to make this plot there is more than one way to alter all the parts.  When searching for answers I would google something like “matplotlib switch axes direction”.  I usually add pandas or matplotlib to the search and it should show you options.

arsenic-depth

 

3.  Now the second graph is fancier.  Take the first graph and color the points as shown below.  Do this by calling scatter three times but only selecting the data you want to plot each time you call scatter.  Think about the boolean calls we did in class.  These are the arsenic concentrations I am coloring.  Get the first graph nice and this second graph becomes easier.    Do not copy my colors.  These are good colors for representing the points.  Choose three colors and three symbols of your own and see how they work. As a hint I would first do the less than 10 and then greater than 50.   Then you can do the 10-50 which needs an “and” of some kind.
arsenic-depth-color