Wikidata powered comparisons
Project description
Wikidata powered comparisons
howmany is a Python package that uses Wikidata entity properties to easily compare the dimensions of any object. The package leverages the Wikidata REST API to easily derive amount values and then compare them given unit ratios.
You can use howmany to find the answers to questions including:
- How many association football pitches would fit inside Germany?
- How many Germanys would fit inside an association football pitch?
- And eventually anything else that Wikidata has dimensions for!
Contents
Installation ⇧
howmany can be downloaded from PyPI via pip or sourced directly from this repository:
pip install howmany
git clone https://github.com/andrewtavis/howmany.git
cd howmany
python setup.py install
import howmany
Environment Setup ⇧
The development environment for howmany can be installed via the following steps:
- Fork the howmany repo, clone your fork, and configure the remotes:
[!NOTE]
Consider using SSH
Alternatively to using HTTPS as in the instructions below, consider SSH to interact with GitHub from the terminal. SSH allows you to connect without a user-pass authentication flow.
To run git commands with SSH, remember then to substitute the HTTPS URL,
https://github.com/...
, with the SSH one,git@github.com:...
.
- e.g. Cloning now becomes
git clone git@github.com:<your-username>/howmany.git
GitHub also has their documentation on how to Generate a new SSH key 🔑
# Clone your fork of the repo into the current directory.
git clone https://github.com/<your-username>/howmany.git
# Navigate to the newly cloned directory.
cd howmany
# Assign the original repo to a remote called "upstream".
git remote add upstream https://github.com/andrewtavis/howmany.git
- Now, if you run
git remote -v
you should see two remote repositories named:origin
(forked repository)upstream
(howmany repository)
-
Use Anaconda to create the local development environment within your howmany directory:
conda env create -f environment.yml
Examples ⇧
See the examples directory for example Jupyter notebooks.
A basic howmany workflow is:
import howmany
from howmany.utils import float_to_str
soccer_fields_in_germany_dict = howmany.compare(
containers="Q183", entities="Q8524", pid="P2046", iso="en"
)
for k in soccer_fields_in_germany_dict.keys():
amount = round(soccer_fields_in_germany_dict[k]["amount"], 2)
print(
f"You could fit {amount:,} {soccer_fields_in_germany_dict[k]['entity']}es inside {k}."
)
# You could fit 50,453,300.88 association football pitches inside Germany.
germanies_in_soccer_fields_dict = howmany.compare(
containers="Q8524", entities="Q183", pid="P2046", iso="en"
)
for k in germanies_in_soccer_fields_dict.keys():
amount = float_to_str(germanies_in_soccer_fields_dict[k]["amount"])
print(
f"You could fit {amount} {germanies_in_soccer_fields_dict[k]['entity']}s inside an {k}."
)
# You could fit 0.000000019820308731475912 Germanys inside an association football pitch.
To-Do ⇧
Please see the contribution guidelines if you are interested in contributing to this project. Work that is in progress or could be implemented includes:
- Work to be done is a work in progress, but suggestions welcome!
Powered By
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.