3
$\begingroup$

Running this command. Trying to get all cities more than 1 million people in US.

EntityClass["City", {"Country" -> Entity["Country", "UnitedStates"], 
   "Population" -> GreaterThan[1000000 people]}] // EntityList

Running for more than an hour. Can it speed up, if I was repeatedly running this?

$\endgroup$

1 Answer 1

3
$\begingroup$

You have incorrect syntax for Quantity "People". You must use natural language input by entering Ctrl+= and typing 1000000 People into the input box. Alternatively, you could explicitly type out a Quantity expression.

The following returns in less-than one second.

EntityClass["City", {"Country" -> Entity["Country", "UnitedStates"], 
   "Population" -> GreaterThan[Quantity[1000000, "People"]]}] // EntityList
{Entity["City", {"SanJose", "California", "UnitedStates"}], 
 Entity["City", {"Dallas", "Texas", "UnitedStates"}], 
 Entity["City", {"SanDiego", "California", "UnitedStates"}], 
 Entity["City", {"SanAntonio", "Texas", "UnitedStates"}], 
 Entity["City", {"Philadelphia", "Pennsylvania", "UnitedStates"}], 
 Entity["City", {"Phoenix", "Arizona", "UnitedStates"}], 
 Entity["City", {"Houston", "Texas", "UnitedStates"}], 
 Entity["City", {"Chicago", "Illinois", "UnitedStates"}], 
 Entity["City", {"LosAngeles", "California", "UnitedStates"}], 
 Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}

Hope this helps.

PS: You can copy as plain text when copying special forms like entities to get a more concise paste.

$\endgroup$
1
  • $\begingroup$ Thank you for the help. The MMA tutorials don't point everything out, I guess. CTRL-= is new to me. Thank you. $\endgroup$
    – prog9910
    May 25, 2020 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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