# Wolfram Mathematica

## World Nuclear Reactors

NuclearReactorData provides data on the known nuclear reactors all over the world. Some of them have already been shut down, like Chernobyl. You can select the reactors that are currently operational for the analysis of nuclear energy resources.

In:= `reactors = NuclearReactorData[];`
In:= ```active = Keys@ Select[EntityValue["NuclearReactor", "Status", "EntityAssociation"], # === "operational" &];```

Extract the annual energy production and the location country.

In:= ```annualproduction = NuclearReactorData[active, "AnnualEnergyProduction"]; countries = Map[First, NuclearReactorData[active, "Countries"]];```

Create a dataset and remove the data points that contain missing values. The number of running reactors is above 400.

In:= ```data = Transpose[{active, countries, annualproduction}]; data = DeleteMissing[data, 1, 2];```
In:= `data // Dimensions`
Out= The number of reactors per country.

In:= `percountry = GroupBy[data, #1[] &];`
In:= `numberpercountry = Map[Length, percountry];`
In:= ```BarChart[Sort[numberpercountry], ChartLabels -> Automatic, ChartStyle -> "DarkRainbow", BarOrigin -> Left, BarSpacing -> 1, LabelingFunction -> (Placed[#1, After] &), ImageSize -> Large]```
Out= The number of reactors corresponds to the total nuclear energy produced per country.

In:= `energytotals = Map[Total[#[[All, 3]]] &, percountry];`
In:= ```stats = {Min, Max, Mean, Median, Total}; TableForm[#[energytotals] & /@ stats, TableHeadings -> {stats}]```
Out//TableForm= The largest producers of nuclear energy are the United States and France.

In:= `TakeLargest[energytotals, 2]`
Out= show complete Wolfram Language input
In:= ```GeoRegionValuePlot[energytotals, GeoProjection -> "Mercator", GeoRange -> {{-70, 80}, {-170, 190}}, GeoLabels -> (Tooltip[#1, #2] &)]```
Out= The map looks different if you consider the total energy production per capita. Use CountryData to access population totals for each country on the list.

In:= ```populations = AssociationThread[Keys[energytotals], CountryData[#, "Population"] & /@ Keys[energytotals]];```

Calculate nuclear energy per capita.

In:= `energypercapita = energytotals/populations;`
In:= `TableForm[#[energypercapita] & /@ stats, TableHeadings -> {stats}]`
Out//TableForm= On the map, you can see that even though the USA has the largest absolute nuclear energy production, it is not the largest per person, where France and Sweden have the lead.

In:= `TakeLargest[energypercapita, 2]`
Out= show complete Wolfram Language input
In:= ```GeoRegionValuePlot[energypercapita, GeoProjection -> "Mercator", GeoRange -> {{-70, 80}, {-170, 190}}, GeoLabels -> (Tooltip[#1, #2] &)]```
Out= 