3
$\begingroup$

Does anyone know how to get EntityProperty "Date" and "DateRange" qualifiers to return data?

It seems reasonable that you should be able to use the DateRange function parameters on the "DateRange" qualifier. Sadly that does not seem to be the case.

CountryData["UnitedStates", 
  EntityProperty["Country", "InflationRate", 
   {"DateRange" -> {DateObject@{1980, 12, 31}, DateObject@{2017, 12, 31}, "Year"}, 
    "Frequency" -> "Annual"}]]

It also seems reasonable that you should be able to pass a list of DateObjects to a "Date" qualifier but sadly that too does not seem to be the case.

CountryData["UnitedStates", 
  EntityProperty["Country", "InflationRate", 
   {"Date" -> DateRange[DateObject@{1980, 12, 31}, DateObject@{2017, 12, 31}, "Year"], 
    "Frequency" -> "Annual"}]]

So how are these qualifiers specified. No hints are given in the "QualifierValues" entity property either.


I have since tried a few additional methods with no luck.

The very inefficient mapping over each date which produces multiple internet calls to WRI entity server. This produces a large jumble of an error without an error message.

CountryData["UnitedStates",
   EntityProperty["Country", 
    "InflationRate", {"Date" -> #, "Frequency" -> "Annual"}]] & /@ 
 DateRange[DateObject@{1980, 12, 31}, DateObject@{2017, 12, 31}, "Year"]

Mathematica graphics

Also tried using Dated to see if it would avoid this error. All calls fail with this method.

CountryData["UnitedStates",
   Dated[EntityProperty["Country", 
     "InflationRate", {"Frequency" -> "Annual"}], #]] & /@ 
 DateRange[DateObject@{1980, 12, 31}, DateObject@{2017, 12, 31}, "Year"]

Mathematica graphics

I think these two may be bugs. Well, definitely the first one. I might be using Dated wrong in the second but the syntax seems to conform.

$\endgroup$
9
  • $\begingroup$ Did you try Ctrl-= "US inflation rate from 1999 to 2010"? $\endgroup$
    – Jason B.
    Commented Sep 18, 2017 at 18:29
  • $\begingroup$ That doesn't give a useful result for me. $\endgroup$
    – chuy
    Commented Sep 18, 2017 at 18:30
  • $\begingroup$ @chuy - it doesn't return an EntityValue expression for you? $\endgroup$
    – Jason B.
    Commented Sep 18, 2017 at 18:34
  • $\begingroup$ @JasonB. it does, but the result is a single number. I strongly suspect Edmund is looking ti get back a time series or something like it. $\endgroup$
    – chuy
    Commented Sep 18, 2017 at 18:36
  • $\begingroup$ @chuy Yes. I would like it to return the TimeSeries object with the rates at the end of each year. $\endgroup$
    – Edmund
    Commented Sep 18, 2017 at 18:37

1 Answer 1

2
$\begingroup$

Interval seems to be the right way to specify a date range for an EntityValue call on a "Country" entity. Using Ctrl-="US inflation rate from 1999 to 2010" to query for the linguistics, gives a returned expression,

Entity["Country", "UnitedStates"][
 EntityProperty["Country", "Inflation", 
     {"Date" -> Interval[{DateObject[{1999}], DateObject[{2010}]}], 
       "Frequency" -> "Monthly", 
   "SeasonalAdjustment" -> "NotSeasonallyAdjusted"}]]

This shows the syntax for a date range for this property is Interval[{__DateObject}]

This is a good use case for EntityInstance,

entity = 
 EntityInstance[
  Entity["Country", 
   "UnitedStates"], {"Date" -> 
    Interval[{DateObject[{1978}], DateObject[{2010}]}]}]

Then query for properties,

entity["InflationRate"]
(* Quantity[250.686, "Percent"] *)

entity["Inflation"]

enter image description here

DateListPlot@%

enter image description here

$\endgroup$
6
  • $\begingroup$ What is very odd is that CountryData["UnitedStates", EntityProperty["Country", "InflationRate", {"Date" -> All, "Frequency" -> "Annual"}]] returns a TimeSeries object. However there appears to be no method to specify a subset of this data with either the "Date" or the "DateRange" qualifier. Seems to be a broken framework. $\endgroup$
    – Edmund
    Commented Sep 18, 2017 at 19:02
  • $\begingroup$ For me Ctrl+= for "US inflation rate from 1999 to 2010" returns the EntitiyProperty "InfationRate" rather than "Inflation". $\endgroup$
    – chuy
    Commented Sep 18, 2017 at 19:07
  • $\begingroup$ Oh, yes. Interesting work around with EntityInstance (+1). I don't like that the property is not holding the date range and don't want to change all my code for it. Currently use a list of entities and can just use EntityValue[list, property,"EntityAssociation"] on this list to get the information needed. $\endgroup$
    – Edmund
    Commented Sep 18, 2017 at 19:09
  • $\begingroup$ @Edmund - it isn't necessary to put the modifiers on the entity, you can give them to the property. [here] is a snippet doing that. $\endgroup$
    – Jason B.
    Commented Sep 18, 2017 at 19:34
  • 1
    $\begingroup$ d'oh! pastebin.com/raw/JGE2ScGc $\endgroup$
    – Jason B.
    Commented Sep 18, 2017 at 19:39

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.