wikidata2df package¶
Submodules¶
wikidata2df.cli module¶
Console script for wikidata2df.
wikidata2df.wikidata2df module¶
Main module.
-
wikidata2df.wikidata2df.
parse_query_results
(query_result)[source]¶ Parse wikidata query json into a nice dataframe
Parameters: query_result (dict) – A json dict with the results from the query Returns: A Pandas DataFrame with the query results.
-
wikidata2df.wikidata2df.
perform_query
(query)[source]¶ Perform a SPARQL query to the wikidata endpoint.
A simple request with the header ‘Accept’ pointing to a json result.
Parameters: query (str) – A string containing a functional sparql query Returns: A json (dict) with the response content. Raises: requests.exceptions.HTTPError
-
wikidata2df.wikidata2df.
wikidata2df
[source]¶ Transform a wikidata SPARQL query into a Pandas DataFrame
Wrapper function that performs a request to the wikidata endpoint and returns a dataframe. If there is no result found, it will raise an exception. If there were optional fields in your query, the result will have rows with value “None”, corresponding to values that were not found.
Parameters: query (str) – A string containing a valid SPARQL query. Returns: A Pandas DataFrame with the results of the query.
Module contents¶
Top-level package for wikidata2df.