1
$\begingroup$

Looking to see how to extract out just the length for this search:

formerSovietUnion = {"Armenia", "Azerbaijan", "Belarus", "Estonia", 
"Georgia", "Kazakhstan", "Kyrgyzstan", "Latvia", "Lithuania", 
"Moldova", "Russia", "Tajikistan", "Turkmenistan", "Ukraine", 
"Uzbekistan"};
totalKilometers = CountryData[#, "RailwayGaugeLengths"][[1, All]] & 
/@ formerSovietUnion
$\endgroup$
  • 1
    $\begingroup$ CountryData[#, "RailwayGaugeLengths"][[1, -1]] & /@ formerSovietUnion? $\endgroup$ – kglr Nov 18 '18 at 13:44
  • 1
    $\begingroup$ Use Values on the result list. $\endgroup$ – Szabolcs Nov 18 '18 at 13:50
4
$\begingroup$

Mapping over entities for properties is less efficient than calling EntityValue with a list of entities.

Create the country entities.

fsu = Thread[Entity["Country", formerSovietUnion]]

Mathematica graphics

There are several metrics available

EntityValue[fsu, "RailwayGaugeLengths"]
{TotalKilometers->845.,BroadGaugeKilometers->845.}
{TotalKilometers->2122.,BroadGaugeKilometers->2122.}
{TotalKilometers->5538.,BroadGaugeKilometers->5512.,StandardGaugeKilometers->25.}
{TotalKilometers->919.,BroadGaugeKilometers->919.}
{TotalKilometers->1612.,BroadGaugeKilometers->1575.,NarrowGaugeKilometers->37.}
{TotalKilometers->13700.,BroadGaugeKilometers->13700.}
{TotalKilometers->470.,BroadGaugeKilometers->470.}
{TotalKilometers->2298.,BroadGaugeKilometers->2265.,NarrowGaugeKilometers->33.}
{TotalKilometers->1765.,BroadGaugeKilometers->1743.,StandardGaugeKilometers->22.}
{TotalKilometers->1138.,BroadGaugeKilometers->1124.,StandardGaugeKilometers->14.}
{TotalKilometers->87157.,BroadGaugeKilometers->86200.,NarrowGaugeKilometers->957.}
{TotalKilometers->680.,BroadGaugeKilometers->680.}
{TotalKilometers->2980.,BroadGaugeKilometers->2980.}
{TotalKilometers->21655.,BroadGaugeKilometers->21655.}
{TotalKilometers->3645.,BroadGaugeKilometers->3645.}

and although its in the name you can check the units directly.

EntityValue[EntityProperty["Country", "RailwayGaugeLengths"], "Unit"]
Kilometers

You may use Query to access the values.

Total per country

Query[All, "TotalKilometers"]@res
{845., 2122., 5538., 919., 1612., 13700., 470., 2298., 1765., 1138., 87157., 680., 2980., 21655., 3645.}

Grand Total

Query[Total, "TotalKilometers"]@res
146524.

Other summary functions

Query[{Min, Max, Mean, Median, StandardDeviation}, "TotalKilometers"]@res
{470., 87157., 9768.27, 2122., 22190.}

Including visualisations like BoxWhiskerChart

Query[BoxWhiskerChart[#, "Outliers", BarOrigin -> Left] &, "TotalKilometers"]@res

Mathematica graphics

and so on.

Hope this helps.

$\endgroup$
  • $\begingroup$ This might be cleaner as you're able to ditch the List, even: EntityValue[EntityClass["Country", "FormerSovietUnionMembers"], EntityProperty["Country", "RailwayGaugeLengths"] ]~Lookup~"TotalKilometers". On the other hand I was expecting there to be a qualifier to specify the track gauge but it doesn't look like there is. $\endgroup$ – b3m2a1 Nov 18 '18 at 20:50
0
$\begingroup$

The result from your code is: Result from code

Applying the function Values gives

totalKilometers // Values

result from applying Values

Finding the total length is then computed through applying Total

totalKilometers // Values // Total

total length

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.