Sample Tabular Data: Fuel Economy

Source Notebook

Fuel economy data for years 1999 and 2008 for 38 popular models of cars

Details

This dataset contains a subset of the fuel economy data that the EPA makes available on https: //fueleconomy.gov/. It contains only models which had a new release every year between 1999 and 2008 - this was used as a proxy for the popularity of the car.

Examples

Basic Examples (3) 

In[1]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Fuel Economy\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Fuel Economy-Input",
AutoDelete->True]\)]
Out[1]=

Dimensions:

In[2]:=
Dimensions[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Fuel Economy\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Fuel Economy-Input",
AutoDelete->True]\)]]
Out[2]=

Column keys and descriptions:

In[3]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Fuel Economy\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Fuel Economy-Input",
AutoDelete->True]\), "ColumnKeys"]
Out[3]=
In[4]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Fuel Economy\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Fuel Economy-Input",
AutoDelete->True]\), "ColumnDescriptions"] // Dataset
Out[4]=

Column types:

In[5]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Fuel Economy\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Fuel Economy-Input",
AutoDelete->True]\), "ColumnTypes"]
Out[5]=

Scope & Additional Elements (2) 

Tally each model per manufacturer:

In[6]:=
AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Fuel Economy\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Fuel Economy-Input",
AutoDelete->True]\)], "model_count" -> Function[Length[#model]], {"manufacturer", "model"}]
Out[6]=

Find the mean mileage for each class and year:

In[7]:=
AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Fuel Economy\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Fuel Economy-Input",
AutoDelete->True]\)], {"hwy_mean" -> Function[Mean[#"hwy"]], "city_mean" -> Function[Mean[#"city"]]}, {"class", "year"}]
Out[7]=

Visualizations (3) 

Compare displacement between the years:

In[8]:=
pivot = PivotToColumns[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Fuel Economy\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Fuel Economy-Input",
AutoDelete->True]\)][All, {"year", "displ"}], "year" -> "displ"]
Out[8]=

The new tabular has extended keys:

In[9]:=
ColumnKeys[pivot]
Out[9]=

Plot histogram for each year:

In[10]:=
Map[Histogram[pivot -> ExtendedKey["displ", #], PlotLabel -> #] &, {1999, 2008}]
Out[10]=

Gosia Konwerska, "Sample Tabular Data: Fuel Economy" from the Wolfram Data Repository (2024)  

Data Resource History

Source Metadata

See Also

Publisher Information