Skip to content

Commit c5ed5dd

Browse files
authored
Release v2.1.4 (#610)
1 parent 0e4da98 commit c5ed5dd

26 files changed

+140
-63
lines changed

ckanext/querytool/commands/camstat.py

Lines changed: 64 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,42 @@
4242
sys.setdefaultencoding('utf-8')
4343

4444
DATASETS_URL = 'https://sdmx-faceted-search-camstat-live.officialstatistics.org/api/search'
45+
MAP_SORTING = {
46+
'Cambodia': 0,
47+
'Banteay Meanchey': 1,
48+
'Battambang': 2,
49+
'Kampong Cham': 3,
50+
'Kampong Chhnang': 4,
51+
'Kampong Speu': 5,
52+
'Kampong Thom': 6,
53+
'Kampot': 7,
54+
'Kandal': 8,
55+
'Koh Kong': 9,
56+
'Kratie': 10,
57+
'Mondul Kiri': 11,
58+
'Phnom Penh': 12,
59+
'Preah Vihear': 13,
60+
'Prey Veng': 14,
61+
'Pursat': 15,
62+
'Ratanak Kiri': 16,
63+
'Siem Reap': 17,
64+
'Preah Sihanouk': 18,
65+
'Stung Treng': 19,
66+
'Svay Rieng': 20,
67+
'Takeo': 21,
68+
'Otdar Meanchey': 22,
69+
'Kep': 23,
70+
'Pailin': 24,
71+
'Tboung Khmum': 25,
72+
'Battambang and Pailin': 31,
73+
'Kampot, Preah Sihanouk and Kep': 32,
74+
'Kratie, Preah Vihear and Stung Treng': 33,
75+
'Mondul Kiri and Ratanak Kiri': 34,
76+
'Otdar Meanchey and Siem Reap': 35,
77+
'Kampot and Kep': 36,
78+
'Koh Kong and Preah Sihanouk': 37,
79+
'Preah Vihear and Stung Treng': 38
80+
}
4581

4682

4783
class UpdateCamstat(CkanCommand):
@@ -281,6 +317,8 @@ def clean_csv(data, id_removal, dataflow_agency,
281317
data[i][j] = data[i][j].replace(
282318
to_be_removed, ''
283319
)
320+
if j == ref_area_index and id_removal[i][j] != 'REF_AREA':
321+
data[i][j] = '{}.{}'.format(str(MAP_SORTING[data[i][j]]), data[i][j])
284322
cleaned += 1
285323

286324
# Clean up NA values
@@ -326,34 +364,35 @@ def clean_csv(data, id_removal, dataflow_agency,
326364
else:
327365
print(' + Done. {} items to clean.\n'.format(cleaned))
328366

329-
data = pivot_data(data)
367+
# data = pivot_data(data)
330368

331369
return data
332370

333-
def pivot_data(data):
334-
'''
335-
Pivots the data from a wider and less usable format to a cleaner, vertical CSV, with one observation per row.
336-
The main issue with the original format is that the column headers we need for visualizations are in a single
337-
column themselves, instead of at the top as headers.
338-
'''
339-
print(' + Pivoting data...')
340-
341-
df = pd.DataFrame(data)
342-
header_row = df.iloc[0]
343-
df = df[1:]
344-
df.columns = header_row
345-
346-
df_melted = df.melt(id_vars=[u'Dataflow', u'Indicator', u'Reference area', u'Sex',
347-
u'Age group', u'Unit of measure', u'Frequency', u'Time period', u'Observation value', u'Unit multiplier',
348-
u'Responsible agency', u'Data source', u'REF_AREA'], var_name='Category', value_name='Group')
349-
350-
columns = df_melted.columns.tolist()
351-
columns = columns[:2] + columns[-2:] + columns[2:-2]
352-
df_melted = df_melted[columns]
353-
354-
print(' + Done.\n')
355-
356-
return [df_melted.columns.values.tolist()] + df_melted.values.tolist()
371+
# def pivot_data(data):
372+
# '''
373+
# Pivots the data from a wider and less usable format to a cleaner, vertical CSV, with one observation per row.
374+
# The main issue with the original format is that the column headers we need for visualizations are in a single
375+
# column themselves, instead of at the top as headers.
376+
# '''
377+
#
378+
# print(' + Pivoting data...')
379+
#
380+
# df = pd.DataFrame(data)
381+
# header_row = df.iloc[0]
382+
# df = df[1:]
383+
# df.columns = header_row
384+
#
385+
# df_melted = df.melt(id_vars=['Dataflow', 'Indicator', 'Reference area', 'Sex',
386+
# 'Age group', 'Unit of measure', 'Frequency', 'Time period', 'Observation value', 'Unit multiplier',
387+
# 'Responsible agency', 'Data source', 'REF_AREA'], var_name='Category', value_name='Group')
388+
#
389+
# columns = df_melted.columns.tolist()
390+
# columns = columns[:2] + columns[-2:] + columns[2:-2]
391+
# df_melted = df_melted[columns]
392+
#
393+
# print(' + Done.\n')
394+
#
395+
# return [df_melted.columns.values.tolist()] + df_melted.values.tolist()
357396

358397

359398
def compare_hashes(existing_hash, new_hash):

ckanext/querytool/fanstatic/javascript/dist/modules/civic_cookies.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ckanext/querytool/fanstatic/javascript/dist/modules/civic_cookies.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ckanext/querytool/fanstatic/javascript/dist/modules/export-to-png.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ckanext/querytool/fanstatic/javascript/dist/modules/export-to-png.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ckanext/querytool/fanstatic/javascript/dist/modules/fullscreen.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ckanext/querytool/fanstatic/javascript/dist/modules/fullscreen.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ckanext/querytool/fanstatic/javascript/dist/modules/map-module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ckanext/querytool/fanstatic/javascript/dist/modules/map-module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ckanext/querytool/fanstatic/javascript/dist/modules/table-module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)