Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Python package to reconcile DataFrames

License

NotificationsYou must be signed in to change notification settings

jvfe/reconciler

Repository files navigation

licensepytest statusdocumentation statusDOI

reconciler is a python package to reconcile tabular data with various reconciliation services, such asWikidata, working similarly to whatOpenRefinedoes, but entirely within Python, using Pandas.

Quickstart

You can install the latest version of reconciler from PyPI with:

pip install reconciler

Then to use it:

fromreconcilerimportreconcileimportpandasaspd# A DataFrame with a column you want to reconcile.test_df=pd.DataFrame(    {"City": ["Rio de Janeiro","São Paulo","São Paulo","Natal"],"Country": ["Q155","Q155","Q155","Q155"]    })# Reconcile against type city (Q515), getting the best match for each item.reconciled=reconcile(test_df["City"],type_id="Q515")

The resulting dataframe would look like this:

idmatchnamescoretypetype_idinput_value
Q8678TrueRio de Janeiro100cityQ515Rio de Janeiro
Q174TrueSão Paulo100cityQ515São Paulo
Q131620TrueNatal100municipality of BrazilQ3184121Natal

In case you want to ensure the results are cities from Brazil, you can specify the property_mapping argument witha specific property-value pair:

# Reconcile against type city (Q515) and items have the country (P17) property equals to Brazil (Q155)reconciled=reconcile(test_df["City"],type_id="Q515",property_mapping={"P17":test_df["Country"]})

Options

Thereconcile() function accepts several options.

  • type_id - The type of items to reconcile against per theAPI specification.
  • top_res - Either the number of results to return per entry or the string 'all' to return all results.
  • property_mapping - A list of properties to filter results on per theAPI specification.
  • reconciliation_endpoint - The reconciliation service to connect to. Defaults tohttps://wikidata.reconci.link/en/api.

Other very useful packages

Although my opinion may be biased, I thinkreconciler is a pretty nice package.But the thing is, it probably won't fulfill all your Wikidata-related needs.Here are other packages that could help with that:

  • WikidataIntegrator has a lot of very nice, low-level, functionsfor dealing with various wikidata-related activities, such as item acquisition and programmatic editing.

  • wikidata2df is a very simple utility package for quickly and easilyturning wikidata SPARQL queries into Pandas DataFrames.


[8]ページ先頭

©2009-2025 Movatter.jp