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"]
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"]
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.
Answer
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"]
DateListPlot@%
Comments
Post a Comment