Unit 4

Data Analysis II

Conceptual Questions

[26.1] You are provided a one-dimensional data set. Based on the data type (ordinal, numerical, categorical), what visualization would you use?

[26.2] You are provided a two-dimensional data set. Based on the data type (ordinal, numerical, categorical), what visualization would you use?

[26.3] You are provided a three-dimensional data set. Based on the data type (ordinal, numerical, categorical), what visualization would you use?

[26.4] Fill in the blank for the type of chart that should be used with each scenario.

  1. To analyze how the size of the product affects the cost of shipping, use a _______.
  2. To analyze the weight of the animals that people own, by pet species use a _______ for averages or a __________ for ranges.
  3. It is difficult to analyze pet species and their names visually. Use a ______ instead.

[26.5] Fill in the blank for the type of chart that should be used with each scenario.

  1. To analyze how many of each product type are in a data set, use a _______.
  2. To analyze the proportion of people who have cats in a data use a _______ .
  3. To analyze the distribution of grades in an exam use a _______ .

[26.6] Fill in the blank for each type of chart that should be used with each three-dimensional relationship.

  1. To analyze numerical x numerical x numerical data, use a __________ to compare all three together or a __________ to compare all the pairs.
  2. To analyze numerical x numerical x ordinal/categorical data, use a _____________.

[26.7] For each of the following prompts, determine the number of dimensions, determine the data type, then pick the best visualization to use based on the dimensions and data types.

  1. Graph the relationship between students' study hours and their exam scores, grouped by whether they attended review sessions or not.
  2. Show the distribution of daily step counts recorded by users of a fitness app.
  3. Compare the salaries of employees across different departments in a company.
  4. Visualize the relationship between temperature, ice cream sales, and whether the day is a weekday or weekend.
  5. Compare the number of books checked out from a library by genre.

Code Writing

[26.8] In class we created the following code to find all the flavor categories in the dataset and create a list of all the #1 categories so we can find their counts easily.


data = readData("all-icecream.csv") 
firstCol = data[0].index("#1 category") 
numberOneData = [] 
flavors = [] 

for i in range(1, len(data)): 
    flavor = data[i][firstCol] 
    numberOneData.append(flavor) 

    if flavor not in flavors: # haven't seen this one yet   
        flavors.append(flavor) 

counts = [] 
for flavor in flavors: 
    counts.append(numberOneData.count(flavor)) # get each flavor's count
    

Using the above example as a starting point, and the matplotlib documentation on creating a bar chart, create a visualization that shows the different types of ice cream flavors and their counts from the column "#1 category".

[26.9] Using the "all-icecream.csv" dataset, use matplotlib to visualize a bar chart of the number of people who chose chocolate ice-cream as their #1 choice, #2 choice, and #3 choice of flavors.

[26.10] Using the code from the previous question, visualize the data so that each bar in the bar chart is a different color.