Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 4 : Diamonds Data ( Part 2 ) We will continue working with the Diamonds dataset in this problem. We will start by using
Problem : Diamonds Data Part
We will continue working with the Diamonds dataset in this problem. We will start by using sorting to identify
the most expensive diamonds in the dataset.
Sort the contents of the diamonds DataFrame in descending order by price. Use show to display the first
rows of the sorted DataFrame.
New, we will identify the largest five diamonds in the dataset.
Sort the contents of the diamonds DataFrame in descending order by carat. Use show to display the first
rows of the sorted DataFrame.
In the next two cells, we will explore the price per carat for diamonds in the dataset.
Create a code cell to complete the following tasks:
Create a new DataFrame named diamondsppc This DataFrame should contain all columns from
diamonds but should also contain a column named pricepercarat. Values in this new column
should be equal to the price of the diamond divided by the carat size, rounded to decimal places.
Sort the contents of the diamondsppc DataFrame in descending order by pricepercarat. Use
show to display the first rows of the sorted DataFrame.
In the previous cell, we identified the diamonds with the highest price per carat. We will now identify the
diamonds with the lowest.
Sort the contents of the diamondsppc DataFrame in ascending order by pricepercarat. Use show
to display the first rows of the sorted DataFrame.
In the last part of this problem, we will graphically explore the relationship between pricepercarat and
carat.
Create a code cell to complete the following tasks:
Use the sample method to draw a sample from diamondsppc Use fraction and
seed Convert the sample to a Pandas DataFrame and store the result in ppcamplepdf
Use the data in the sample to create a scatter plot of pricepercarat versus carat. When
creating the scatter plot, set alpha and select a named color for the points. Label the xaxis
"Carat" and label the yaxis "Price per Carat". Use pltshow to display the plot.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started