Using pandas and the diamonds data set from class - what is


Homework - Homework is to be completed in Python 3.

1. Using pandas and the diamonds data set from class

a. Create a new column price_01 that for each observation (row) applies a linear scaling of the price where 0 corresponds to the minimum price in the data set and 1 corresponds to the maximum price

b. Create a new column size that contains 'small', 'medium', or 'large' depending if it is in the bottom quartile, one of the two middle quartiles, or the largest quartile respectively

c. Create a new data frame exp_diamonds that only includes prices >1000 and ideal or premium cuts

d. What is the average size of each color diamond? (add an inline comment, #1d, to the line of code that creates the table)

2. Using pandas and the diamonds data set from class

a. Plot the density of the prices

b. Log10 transform the prices and plot the density

c. Make a scatter plot of transformed prices vs carat for diamonds with ideal cut and E color

d. Groupy all diamonds less than 1 carat by cut and make a boxplot of their log transformed prices

3. Graphs like the one above can be coded as a dictionary in python. Each node is a key and values consist of all nodes that are connected to the key node. {1:[2,3,4],2:[1,5,6],3:[1,7,8],4:[1,9],5:[2],6: [2],7:[3],8:[3],9:[4]} would represent the above graph. Write a function called shortest_path(start_node, end_node, graph) that accepts a starting node, ending node, and a graph dictionary as input and returns a list of nodes (including starting and ending node) of the shortest path between the two.

1481_figure.png

4. A cycle in a graph theory is a path of vertices connected by edges that forms a closed loop without repeating any edges or vertices. Using the same concept of graph dictionary from the previous problem write a function called cycle(node, graph) that accepts a starting node and a graph dictionary. The function prints no cycle and returns an empty list if there does not exist a cycle that begins and ends at that node, otherwise it prints cycle exists and returns a list that contains a cycle with the starting node in the first and last position. Note that the cycle does not have to contain every vertex (which would be a Hamiltonian cycle).

Attachment:- Assignment Files.rar

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Using pandas and the diamonds data set from class - what is
Reference No:- TGS02656173

Expected delivery within 24 Hours