Home Practicum 1 Practicum 2 Practicum 3 Practicum 4 Practicum 5 Practicum 6 Practicum 7 Practicum 8 Practicum 9 Practicum 10 Practicum 11

Welcome to DS2000 CS Practicum 7!


Today we will practice reading data from CSV files as well learn how to make scatter plots and bar charts.

The data that we will be using comes from Copenhagen Networks Study and it describes communication patterns between pairs (dyads) of students. Remeber:

Exercise 1: Loading the data

  1. Download the practicum_07.py and the dyads.csv files.
  2. in your main() function implement loading the dyads.csv file into three lists, based on the value of the gender column. Do it using only one loop, reading through the file once, not with separate loops for each gender combination. > Show hint
  3. There should be 109 male dyads, 17 female dyads, and 38 mixed gender dyads. Make sure that your lists are of these lengths.

Exercise 2: Making a bar chart

In this exercise we will make a bar chart that shows the numbers of different genders of dyads with different colors: blue for men, green for women, and red for mixed dyads. This is what the final product will look somewhat like this:

We will build two functions to achieve this goal:

  1. rect(x, y, width, height, color) that draws just one rectangle with the lower left corner at the coordinates of x, y with the specified width and height and if fills it with specified color. Before going to the next function, make sure that this one works with different input arguments! > Show hint
  2. bar(data) that takes a list of values (in our case it's three values but make sure your code works with a different number of values too!), and draws one rectangle per value, side by side with the WIDTH of 10, SPACING between them of 5, and colors cycling through the COLORS list specified on top of the file (i.e. if there are four values, the fourth rect will be blue again).
  3. In your main() function make a list of counts of dyads and call the bar function with that list as an argument. Your plot should look like the one on the screen shot.

Exercise 3: Making a scatter plot

In this exercise we will make a scatter plot that shows the relation betweenthe time spent talking on the phone and the number of exchanged messages for each dyad, depending on the gender. The final result will look like this, with one dot per dyad and colors denoting gender combination of the dyad:

  1. Complete the scatter(points, color) function. that takes a list of points and for each leaves a stamp at point[0], point[1] with a given color. > Show hint
  2. In your main() function comment out the call to the bar function and instead call the scatter function three times with different colors, one for each gender combination (one for each list).
  3. In the comments leave your answers to these questions:
    1. what does it mean that one point is more to the right than another on this scatter plot?
    2. what does it mean that one point is higher than another on this scatter plot?
    3. what is the gender combination of a dyad that spent most time talking on the phone?
    4. what is the gender combination of the dyad that sent most messages? Is it the same dyad as with most time on the phone?
    5. if we see that a dyad mostly texts and hardly talks on the phone can we have a reasonable guess at their gender combination?
    6. if we see that a dyad talks on the phone and messages a lot, can we have a reasonable guess at their gender combination?