Question: # 1 2 . ( * Code ) ic _ long = ic _ wide.melt ( id _ vars = [ ' ID ' ,

# 12.(*Code) ic_long = ic_wide.melt(id_vars=['ID','address'],value_name='count',var_name='day')
ic_long
# Write the code to create a heatmap (or copy-paste from item 9).
# Instead of using data=ic_wide, make data be the line of code from item 10.
# We can use this temporary copy of a dataframe instead of saving it as another
# dataframe.
# Your answer:
# 13.(*Response)
# Uh-oh! Why is this heat map useless? (look carefully at the x-axis and color
# scale; compare to the dataframe)
# I.e. why are all the blocks on the days of the week the same color? (Please be
# as specific as possible.)
# Your answer:
# 15. We can string together these two commands by putting the ".drop" command
# followed by the ".set_index" command. Run this code.
# We'll save it as a DataFrame for clarity.
ic_reformatted = ic_wide.drop(columns='address').set_index('ID')
ic_reformatted
# 16.(*Code)
# Use the ic_reformatted to create a heat map.
# Title and label as needed.
# Your answer:
# 17.(*Code and Response)
# From the heat map, we can see that one ice cream shop is in a business district
# where people do not spend time on the weekend. Let's practice filtering rows
# by filtering out the data.
# Use the original dataframe ic_wide for this part.
# a.(*Response) What is the ID number of this ice cream shop?
# b.(*Code) Use logical indexing to print True for the row with that shop and False for the others.
# c.(*Code) We want to get rid of that row. We therefore want to flip this to get False for
# that row and True for the others. Use negation in the logical indexing to produce
# the opposite result of part b.
# d.(*Code) Use row selection combined with your answer to part c to print all the rows that
# are not that row.
# e.(*Code) Save your answer from part d into a dataframe called ic.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!