# Run this cell to import the data and create the dictionaries

# Run this cell to import the data and create the dictionaries

import pandas as pd
df = pd.read_csv(‘./IowaLiquorSales2018-1.csv’)
sales_amounts = df[‘SaleAmount’].tolist()

dictCounts = {}
for i in range(1,10):
dictCounts[i] = 0

for x in sales_amounts:
first_digit = int(str(x)[0])
dictCounts[first_digit] += 1

dictPercents = {}
for i in range(1,10):
dictPercents[i] = dictCounts[i] / len(sales_amounts)

Problem 1a:

Write the code to create the appropriate data visualization with the Bokeh package in Python.

This visualization should show the distribution of the raw counts (in other words, the values in the dictCounts dictionary). Each value in dictCounts should be a separate column.

Make sure that your visualization has the following features:

Relevant title and axis labels
Size should be 600 pixels wide by 600 pixels tall
The x-axis should be the keys in the dictionary
The y-axis should be the values in the dictionary
You can get a list with just the keys in a dictionary by using the dict.keys() method (more information available at https://www.tutorialspoint.com/python/dictionary_keys.htm). You can also get a list with just the values in a dictionary by using the dict.values()method (more information available at https://www.tutorialspoint.com/python/dictionary_values.htm). Both of these are already written for you in the code cell below.

code:

digits = list(dictCounts.keys())
counts = list(dictCounts.values())

#your code here

Problem 1b:

Write the code to create the appropriate data visualization with the Bokeh package in Python.

This visualization should show the distribution of the percents (in other words, the values in the dictPercents dictionary). Each value in dictPercents should be a different column.

Make sure that your visualization has the following features:

Relevant title and axis labels
Size should be 600 pixels wide by 600 pixels tall
The x-axis should be the keys in the dictionary
The y-axis should be the values in the dictionary
You can get a list with just the keys in a dictionary by using the dict.keys() method (more information available at https://www.tutorialspoint.com/python/dictionary_keys.htm). You can also get a list with just the values in a dictionary by using the dict.values()method (more information available at https://www.tutorialspoint.com/python/dictionary_values.htm). Both of these are already written for you in the code cell below.

code:

digits = list(dictPercents.keys())
percents = list(dictPercents.values())

#your code here

Problem 1c:

The shape of the graphs in problems 1a and 1b are identical. Why? Is it a coincidence or can you explain this?

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?