How do you get the value of an "instance" property?
michaelmendoza42 opened this issue · comments
Hi, I'm new to wikidata in general.
I can't figure out how to get the start/end dates of someone who held office.
For example, president George Washington (Q23), there is a property P39 (offices held) and within that I can get that he was a president (Q11696). But that item itself has no start/end date property (P580, P582). However, on the wikidata page there is definitely those properties for each office held.
In my code I'm doing something like:
p39 = client.get('P39')
george = client.get('Q23')
george.get(p39)
which returns <wikidata.entity.Entity Q11696 'President of the United States'>
which is my dead end. this is the same object you'd get if i just did
client.get('Q11696')
because the item has no relation to the original item Q23.
Even the SPARQL to figure out the dates for a held office is kinda crazy. You have to do something like:
?pres p:P39 ?position_held_statement .
?position_held_statement ps:P39 wd:Q11696 .
?position_held_statement pq:P580 ?start .
any help is appreciated. thanks.