Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: IndEcol/country_converter
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2
Choose a base ref
...
head repository: IndEcol/country_converter
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 4 commits
  • 10 files changed
  • 2 contributors

Commits on Feb 27, 2024

  1. fix spelling

    konstantinstadler committed Feb 27, 2024
    Copy the full SHA
    d0454b7 View commit details

Commits on Nov 15, 2024

  1. Bonsai (#159)

    * add baci + unido
    
    * add GEOnumeric
    
    * force string
    
    * use 4 number string
    
    * do isort
    
    * string issue
    
    * tread GEOnumeric as int + fix float issue
    mabudz authored Nov 15, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2651d65 View commit details
  2. updated python versions

    konstantinstadler committed Nov 15, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9a57ccc View commit details
  3. pushed version

    konstantinstadler committed Nov 15, 2024
    Copy the full SHA
    1fa81f1 View commit details
4 changes: 2 additions & 2 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
@@ -11,10 +11,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
4 changes: 2 additions & 2 deletions .github/workflows/puplish_test_pypi.yml
Original file line number Diff line number Diff line change
@@ -11,10 +11,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
2 changes: 1 addition & 1 deletion .github/workflows/tests_and_coverage.yml
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Check out repository code
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 1.3 - 20241115

### Classifications

- added BACI - BACI: International Trade Database at the Product-Level (by @mabudz)
- added UNIDO - UNIDO INDSTAT database (by @mabudz)
- added EXIOBASE hybrid 3 classification (by @mabudz)
- added EXIOBASE hybrid 3 consequential classification (by @mabudz)
- added GEOnumeric GEO numerical codes (also used in Prodcom) (by @mabudz)
- fixed some spellings

### Development

- set minimum python version to 3.9
- added CI tests for up to 3.13

## 1.2 - 20231212

### Classifications
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ and the classification schemes available:
cc.valid_class
```

There is also a methdod for only getting country classifications (thus
There is also a method for only getting country classifications (thus
omitting any grouping of countries):

``` python
@@ -425,7 +425,11 @@ Data sources below for further information):
34. [GWcode](https://www.tandfonline.com/doi/abs/10.1080/03050629908434958) - Gledisch & Ward numerical codes as published in https://www.andybeger.com/states/articles/statelists.html
35. CC41 - common classification for MRIOs (list of countries found in all public MRIOs)
36. [IOC](https://en.wikipedia.org/wiki/List_of_IOC_country_codes) - International Olympic Committee (IOC) country codes

37. [BACI](https://www.cepii.fr/CEPII/en/bdd_modele/bdd_modele_item.asp?id=37) - BACI: International Trade Database at the Product-Level
38. [UNIDO](https://stat.unido.org/portal/dataset/getDataset/COUNTRY_PROFILE) - UNIDO INDSTAT database
39. [EXIOBASE hybrid 3](https://zenodo.org/records/10148587) classification
40. [EXIOBASE hybrid 3 consequential](https://zenodo.org/records/13926939) classification
41. [GEOnumeric](https://ec.europa.eu/eurostat/comext/newxtweb/openNom.do) GEO numerical codes (also used in Prodcom)

Coco contains official recognised codes as well as non-standard codes
for disputed or dissolved countries. To restrict the set to only the
35 changes: 32 additions & 3 deletions country_converter/country_converter.py
Original file line number Diff line number Diff line change
@@ -7,9 +7,11 @@
import pprint
import re
import sys
from collections import OrderedDict
from collections import OrderedDict, defaultdict

import numpy as np
import pandas as pd
from pandas._libs.parsers import STR_NA_VALUES

from country_converter.version import __version__

@@ -409,8 +411,29 @@ def __init__(

must_be_unique = ["name_short", "name_official", "regex"]
must_be_string = must_be_unique + (
["ISO2", "ISO3", "continent", "UNregion", "EXIO1", "EXIO2", "EXIO3", "WIOD"]
[
"ISO2",
"ISO3",
"continent",
"UNregion",
"EXIO1",
"EXIO2",
"EXIO3",
"WIOD",
]
)
must_be_int = [
"ISOnumeric",
"UNcode",
"FAOcode",
"GBDcode",
"EURO",
"UN",
"UNmember",
"obsolete",
"GEOnumeric",
]
accepted_na_values = STR_NA_VALUES - {"NA"}

def test_for_unique_names(
df, data_name="passed dataframe", report_fun=log.error
@@ -433,11 +456,16 @@ def data_loader(data):
sep="\t",
encoding="utf-8",
converters={str_col: str for str_col in must_be_string},
na_values=accepted_na_values,
)
ret = ret.astype(
{col: "Int64" for col in ret.columns if col in must_be_int}
)
test_for_unique_names(ret, data)
return ret

basic_df = data_loader(country_data)

if only_UNmember:
basic_df.dropna(subset=["UNmember"], inplace=True)

@@ -808,8 +836,9 @@ def _validate_input_para(self, para, column_names):
"name_short": ["short", "short_name", "name", "names"],
"name_official": ["official", "long_name", "long"],
"UNcode": ["un", "unnumeric", "M49"],
"ISOnumeric": ["isocode"],
"ISOnumeric": ["isocode", "baci", "unido"],
"FAOcode": ["fao", "faonumeric"],
"EXIO3": ["exio_hybrid_3", "exio_hybrid_3_cons"],
}

for item in alt_valid_names.items():
Loading