Skip to main content

Python library for JoshuaProject.net

Project description

Joshua Project Python Library

This is a Python library to help one use APIv2 to fetch the data from the database JoshuaProject.net web site.

This library uses Joshua Project's APIv2. You'll need an api_key to use API and the library. For details, see Documentation.

Install

pip install joshuaproject

How to use

Get your API key and set it in a variable or pass to functions.

Country Codes

Joshua Project uses FIPS codes (US Federal Information Processing Standard) for countries.

[FIPS 10-4](https: //www.wikiwand.com/en/FIPS_10-4) (April 1995) -- Countries, Dependencies, Areas of Special Sovereignty, and TheirPrincipal Administrative Divisions.

However, FIPS 10-4 was withdrawn by NIST on September 2, 2008 in favor of the international ISO 3166 standard.

In the meantime, as of Jan 2020 Joshua Project has no plans to switch onto ISO codes, I was notified. sigh

Sadly, FIPS in 60% cases differs from the ISO.

cc = CountryCodes()
diff = cc.data[cc.data.FIPS != cc.data.ISO]
len(diff)/len(cc)
0.6024096385542169
diff.head()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
cname FIPS ISO
1 Aland Islands NaN AX
3 Algeria AG DZ
4 American Samoa AQ AS
5 Andorra AN AD
7 Anguilla AV AI

Solution

This library provides a CountryCodes() class to workaround this discrepancy.

Missing FIPS codes

Missing FIPS values:

cc.data[cc.data.FIPS.isna()]
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
cname FIPS ISO
1 Aland Islands NaN AX
27 Bonaire, Sint Eustatius and Saba NaN BQ
236 United States Minor Outlying Islands NaN UM
cc.like('French')
[{'cname': 'French Guiana', 'FIPS': 'FG', 'ISO': 'GF'},
 {'cname': 'French Polynesia', 'FIPS': 'FP', 'ISO': 'PF'},
 {'cname': 'French Southern Territories', 'FIPS': 'FS', 'ISO': 'TF'}]

URL Constricting finctions

2. Get all people groups in a specific country.

Build an URL to query all people groups in India:

url_pgs_cntry('IN',api_key=api_key)
'https://joshuaproject.net/api/v2/people_groups?ROG3=IN&api_key=your_api_key'

Development

All phases of development (coding, testing, documentation -- autogenerated) are being done completely inside Jupyter Notebooks, thanks to the excellent tool nbdev by Fast.ai team.

Testing

Tests are incorporated into the Jupyter Notebooks and are also a neat way to learn the function's expected behavior, since in case of incorrect behavior test_* functions will return an AssertionError.

Tests can also be launched from the console with nbdev_test_nbs.

Contributing

Ideas, issues and pull-requests are welcome! Please submit via GitHub.

Please share, like and upvote, too.

Copyright

Copyright 2020 onwards, Konstantin Dorichev. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project's files except in compliance with the License. A copy of the License is provided in the LICENSE file in this repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

joshuaproject-0.0.5.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

joshuaproject-0.0.5-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file joshuaproject-0.0.5.tar.gz.

File metadata

  • Download URL: joshuaproject-0.0.5.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for joshuaproject-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c810c096585fb905ec43c944dbb03da66d3d01e4ffae8a1b6472e78c32f34793
MD5 ce603c4e2a19539023eb1fff1a9b91aa
BLAKE2b-256 5c36c8b516e4b09faf8ba9b6ba56e48456237411f02958d93db1a1bea659ff66

See more details on using hashes here.

File details

Details for the file joshuaproject-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: joshuaproject-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for joshuaproject-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8cf7799129b075c3631633170a5bd9fd9a60da9e6edda259b61cba81a6119c27
MD5 c698552d23f50bfda2370bf7455ce86a
BLAKE2b-256 c46577bc11a5d795bdda50548829e15bad5951d8c394a2a1523409b8b55b0084

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page