-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountries.py
75 lines (68 loc) · 2.27 KB
/
countries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 26 14:25:39 2024
@author: shanewhite
"""
########################################################################################
#
# Module: countries.py
#
# Description:
# Functions that perform country name lookups and modifications.
#
########################################################################################
########################################################################################
#
# Function: iea_country_name()
#
# Description:
# Converts country name to version compliant with IEA JSON dataset.
#
########################################################################################
def iea_country_name(country_in):
country = "'" + country_in.upper() + "'"
if country == "'AUSTRALIA'":
return "'AUSTRALI'"
if country == "'UNITED ARAB EMIRATES'":
return "'UAE'"
if country == "'UNITED KINGDOM'":
return "'UK'"
if country == "'US'":
return "'USA'"
if country == "'RUSSIAN FEDERATION'":
return "'RUSSIA'"
if country == "'SAUDI ARABIA'":
return "'SAUDIARABI'"
if country == "'UNITED ARAB EMIRATES'":
return "'UAE'"
if country == "'NEW ZEALAND'":
return "'NZ'"
if country == "'SOUTH KOREA'":
return "'KOREA'"
if country == "'TOTAL EU'":
return "'EU28'"
if country == "'SOUTH AFRICA'":
return "'SOUTHAFRIC'"
if country == "'SOUTH KOREA'":
return "'KOREA'"
if country == "'TURKIYE'":
return "'TURKEY'"
else:
return country
########################################################################################
#
# Function: ffprod_shorten_country()
#
# Description:
# Shortens country name for chart.treemap().
#
########################################################################################
def ffprod_shorten_country(df1, df2, df3):
df1.replace("Russian Federation", "Russia", inplace=True)
df2.replace("Russian Federation", "Russia", inplace=True)
df3.replace("Russian Federation", "Russia", inplace=True)
df1.replace("United Arab Emirates", "UAE", inplace=True)
df2.replace("United Arab Emirates", "UAE", inplace=True)
df3.replace("United Arab Emirates", "UAE", inplace=True)
return df1, df2, df3