Wolfram Data Repository
Immediate Computable Access to Curated Contributed Data
A dataset containing the prices and other attributes of almost 54,000 diamonds
| In[1]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/168c63fec8a91493.png) | 
| Out[1]= |  | 
Dimensions:
| In[2]:= | ![Dimensions[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)]]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/6e66eea00bc9b014.png) | 
| Out[2]= |  | 
Column keys and column descriptions:
| In[3]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\), "ColumnKeys"]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/34988b672d80ecec.png) | 
| Out[3]= |  | 
| In[4]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\), "ColumnDescriptions"] // Dataset](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/17a5eb03fff395ac.png) | 
| Out[4]= |  | 
Column types:
| In[5]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\), "ColumnTypes"]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/5deabfdaa630398a.png) | 
| Out[5]= |  | 
Find the heaviest diamond in the data:
| In[6]:= | ![MaximalBy[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)], "carat"]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/41db9bd5aac3f6c6.png) | 
| Out[6]= |  | 
Find the most expensive diamond in the data:
| In[7]:= | ![MaximalBy[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)], "price"]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/6b1b1e5ff401c1a7.png) | 
| Out[7]= |  | 
| In[8]:= | ![SortBy[AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)], {"price" -> Function[Mean[#price/#carat]]}, "color"], "color"]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/7a43621e266196ee.png) | 
| Out[8]= |  | 
Compute the average price per carat in the data depending on all four 'C's - color, cut, clarity, and carat and sort by price:
| In[9]:= | ![ReverseSortBy[AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)], {"price" -> Function[Mean[#price/#carat]]}, {"color", "cut", "clarity", "carat"}], "price"]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/70bd79be0abf7735.png) | 
| Out[9]= |  | 
Create a pivot table for the average price per carat depending on color and clarity:
| In[10]:= | ![PivotTable[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)], {"price" -> Function[Mean[#price/#carat]]}, {"clarity"}, {"color"}]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/3bae148b6cb92503.png) | 
| Out[10]= |  | 
Visualize the price as a function of weight:
| In[11]:= | ![ListPlot[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)] -> {"carat", "price"}, AxesLabel -> {"carat", "price"}]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/5307c8bfc055d7fe.png) | 
| Out[11]= |  | 
Assuming carat-price space, analyze the color distribution:
| In[12]:= | ![colorSorted = SortBy[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Diamonds\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Diamonds-Input",
AutoDelete->True]\)], "color"];](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/66bfd1dc031c44c3.png) | 
| In[13]:= | ![pts = QuantityMagnitude@
   FromTabular[colorSorted[[All, {"carat", "price"}]], "Matrix"];](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/5db2f6195552bc97.png) | 
To make the plot more readable take a random sample from the data:
| In[14]:= | ![pos = Partition[Sort@RandomSample[Range[Length[pts]], 500], 1];](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/5003eb8a83e7a49c.png) | 
| In[15]:= | ![points = Extract[pts, pos];](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/260c00af2c2c6f54.png) | 
| In[16]:= | ![colors = Extract[Normal[colorSorted[[All, "color"]]], pos];](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/1489eb14ab383e74.png) | 
The bounding rectangle for carat-price points:
| In[17]:= | ![reg = Rectangle[Min /@ {pts[[All, 1]], pts[[All, 2]]}, Max /@ {pts[[All, 1]], pts[[All, 2]]}];](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/256c1ed80ea332da.png) | 
Create SpatialPointData object with "color" annotation:
| In[18]:= | ![spd = SpatialPointData[points -> {"color" -> colors}, reg]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/6d8a0a5ded3e2632.png) | 
| Out[18]= |  | 
Use PointValuePlot to visualize the diamond colors across carat-price space:
| In[19]:= | ![PointValuePlot[spd, PlotStyle -> "StarryNightColors", PlotLegends -> Automatic]](https://www.wolframcloud.com/obj/resourcesystem/images/1f9/1f9ef345-c18c-4df5-8e29-e0ec7836fe1f/2be8cbb58c471602.png) | 
| Out[19]= |  | 
Gosia Konwerska, "Sample Tabular Data: Diamonds" from the Wolfram Data Repository (2025)