Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
wikidata-plain-sparql
Query WikiData in plain SPARQL and display the result as a map or data frame
Readme
This package allows to query the WikiData database. For example this package is intended for people who need to be able to query WikiData in plain SPARQL while staying whithin a Jupyter Notebook.
Currently data can be returned as a dataframe or as a map. See examples
pip install wikidata_plain_sparql
The module only has one function which is named query
which has two parameters:
view
is None
(see examples for map use)# import the module
import wikidata_plain_sparql as wikidata
wikidata.query(query, view=None)
The following examples are also available on Google Colab and can be executed without any additional setup: https://colab.research.google.com/github/jelleschutter/wikidata-plain-sparql/blob/assets/wikidata_plain_sparql_examples.ipynb
# query WikiData
wikidata.query('''
SELECT ?actor ?actorLabel
WHERE
{
# tv series "Person of Interest" has actor
wd:Q564345 wdt:P161 ?actor.
# actor has won a Golden Globe Award
?actor wdt:P166 wd:Q1011547.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
''')
Which will result in the following pandas data frame:
actor | actorLabel |
---|---|
http://www.wikidata.org/entity/Q3295000 | Sterling K. Brown |
The following query was copied from the offical WikiData Examples and shows all places within 1km of the Empire State Building:
# query WikiData
wikidata.query('''
#Places within 1km of the Empire State Building
SELECT ?place ?placeLabel ?location ?instanceLabel
WHERE
{
wd:Q9188 wdt:P625 ?loc .
SERVICE wikibase:around {
?place wdt:P625 ?location .
bd:serviceParam wikibase:center ?loc .
bd:serviceParam wikibase:radius "1" .
}
OPTIONAL { ?place wdt:P31 ?instance }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
BIND(geof:distance(?loc, ?location) as ?dist)
} ORDER BY ?dist
''', view='map')
Which will result in the following map:
FAQs
Query WikiData in plain SPARQL and display the result as a map or data frame
We found that wikidata-plain-sparql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.