LSMS_Library 0.2.7__py3-none-any.whl → 0.2.9.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lsms_library/__init__.py +1 -2
- lsms_library/countries/.dvc/.gitignore +3 -0
- lsms_library/countries/.dvc/config +13 -0
- lsms_library/countries/.dvc/plots/confusion.json +30 -0
- lsms_library/countries/.dvc/plots/default.json +29 -0
- lsms_library/countries/.dvc/plots/scatter.json +27 -0
- lsms_library/countries/.dvc/plots/smooth.json +39 -0
- lsms_library/countries/.dvc/s3_config +2 -0
- lsms_library/countries/.dvc/s3_reader_creds.gpg +0 -0
- lsms_library/countries/Uganda/2005-06/_/data_info.yml +1 -1
- lsms_library/countries/Uganda/_/Makefile +2 -2
- lsms_library/countries/Uganda/_/data_scheme.yml +3 -0
- lsms_library/countries/Uganda/_/household_characteristics.py +2 -4
- lsms_library/countries/Uganda/_/unitlabels.csv +290 -0
- lsms_library/country.py +6 -7
- lsms_library/dvc_permissions.py +68 -0
- lsms_library/local_tools.py +3 -3
- {lsms_library-0.2.7.dist-info → lsms_library-0.2.9.dev0.dist-info}/METADATA +1 -1
- {lsms_library-0.2.7.dist-info → lsms_library-0.2.9.dev0.dist-info}/RECORD +21 -11
- {lsms_library-0.2.7.dist-info → lsms_library-0.2.9.dev0.dist-info}/LICENSE.txt +0 -0
- {lsms_library-0.2.7.dist-info → lsms_library-0.2.9.dev0.dist-info}/WHEEL +0 -0
lsms_library/__init__.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from . import country
|
|
2
2
|
from . country import Country, Wave
|
|
3
3
|
from . import local_tools as tools
|
|
4
|
-
#from . import countries
|
|
5
|
-
#from .countries import GhanaLSS
|
|
6
4
|
from .categorical_mapping import ai_agent
|
|
7
5
|
from . import transformations
|
|
6
|
+
from .dvc_permissions import authenticate
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[core]
|
|
2
|
+
remote = ligonresearch_s3
|
|
3
|
+
autostage = true
|
|
4
|
+
[cache]
|
|
5
|
+
type = reflink
|
|
6
|
+
['remote "ligonresearch"']
|
|
7
|
+
url = gdrive://1oVOdo2-oeM_LYBSe1lKSr-pm08syczdu/LSMS
|
|
8
|
+
gdrive_use_service_account = true
|
|
9
|
+
gdrive_service_account_json_file_path = gdrive_creds.json
|
|
10
|
+
['remote "ligonresearch_s3"']
|
|
11
|
+
url = s3://dvcbucket0/LSMS
|
|
12
|
+
credentialpath = s3_creds
|
|
13
|
+
configpath = s3_config
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
|
|
3
|
+
"data": {
|
|
4
|
+
"values": "<DVC_METRIC_DATA>"
|
|
5
|
+
},
|
|
6
|
+
"title": "<DVC_METRIC_TITLE>",
|
|
7
|
+
"mark": "rect",
|
|
8
|
+
"encoding": {
|
|
9
|
+
"x": {
|
|
10
|
+
"field": "<DVC_METRIC_X>",
|
|
11
|
+
"type": "nominal",
|
|
12
|
+
"sort": "ascending",
|
|
13
|
+
"title": "<DVC_METRIC_X_LABEL>"
|
|
14
|
+
},
|
|
15
|
+
"y": {
|
|
16
|
+
"field": "<DVC_METRIC_Y>",
|
|
17
|
+
"type": "nominal",
|
|
18
|
+
"sort": "ascending",
|
|
19
|
+
"title": "<DVC_METRIC_Y_LABEL>"
|
|
20
|
+
},
|
|
21
|
+
"color": {
|
|
22
|
+
"aggregate": "count",
|
|
23
|
+
"type": "quantitative"
|
|
24
|
+
},
|
|
25
|
+
"facet": {
|
|
26
|
+
"field": "rev",
|
|
27
|
+
"type": "nominal"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
|
|
3
|
+
"data": {
|
|
4
|
+
"values": "<DVC_METRIC_DATA>"
|
|
5
|
+
},
|
|
6
|
+
"title": "<DVC_METRIC_TITLE>",
|
|
7
|
+
"mark": {
|
|
8
|
+
"type": "line"
|
|
9
|
+
},
|
|
10
|
+
"encoding": {
|
|
11
|
+
"x": {
|
|
12
|
+
"field": "<DVC_METRIC_X>",
|
|
13
|
+
"type": "quantitative",
|
|
14
|
+
"title": "<DVC_METRIC_X_LABEL>"
|
|
15
|
+
},
|
|
16
|
+
"y": {
|
|
17
|
+
"field": "<DVC_METRIC_Y>",
|
|
18
|
+
"type": "quantitative",
|
|
19
|
+
"title": "<DVC_METRIC_Y_LABEL>",
|
|
20
|
+
"scale": {
|
|
21
|
+
"zero": false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"color": {
|
|
25
|
+
"field": "rev",
|
|
26
|
+
"type": "nominal"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
|
|
3
|
+
"data": {
|
|
4
|
+
"values": "<DVC_METRIC_DATA>"
|
|
5
|
+
},
|
|
6
|
+
"title": "<DVC_METRIC_TITLE>",
|
|
7
|
+
"mark": "point",
|
|
8
|
+
"encoding": {
|
|
9
|
+
"x": {
|
|
10
|
+
"field": "<DVC_METRIC_X>",
|
|
11
|
+
"type": "quantitative",
|
|
12
|
+
"title": "<DVC_METRIC_X_LABEL>"
|
|
13
|
+
},
|
|
14
|
+
"y": {
|
|
15
|
+
"field": "<DVC_METRIC_Y>",
|
|
16
|
+
"type": "quantitative",
|
|
17
|
+
"title": "<DVC_METRIC_Y_LABEL>",
|
|
18
|
+
"scale": {
|
|
19
|
+
"zero": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"color": {
|
|
23
|
+
"field": "rev",
|
|
24
|
+
"type": "nominal"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
|
|
3
|
+
"data": {
|
|
4
|
+
"values": "<DVC_METRIC_DATA>"
|
|
5
|
+
},
|
|
6
|
+
"title": "<DVC_METRIC_TITLE>",
|
|
7
|
+
"mark": {
|
|
8
|
+
"type": "line"
|
|
9
|
+
},
|
|
10
|
+
"encoding": {
|
|
11
|
+
"x": {
|
|
12
|
+
"field": "<DVC_METRIC_X>",
|
|
13
|
+
"type": "quantitative",
|
|
14
|
+
"title": "<DVC_METRIC_X_LABEL>"
|
|
15
|
+
},
|
|
16
|
+
"y": {
|
|
17
|
+
"field": "<DVC_METRIC_Y>",
|
|
18
|
+
"type": "quantitative",
|
|
19
|
+
"title": "<DVC_METRIC_Y_LABEL>",
|
|
20
|
+
"scale": {
|
|
21
|
+
"zero": false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"color": {
|
|
25
|
+
"field": "rev",
|
|
26
|
+
"type": "nominal"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"transform": [
|
|
30
|
+
{
|
|
31
|
+
"loess": "<DVC_METRIC_Y>",
|
|
32
|
+
"on": "<DVC_METRIC_X>",
|
|
33
|
+
"groupby": [
|
|
34
|
+
"rev"
|
|
35
|
+
],
|
|
36
|
+
"bandwidth": 0.3
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
Binary file
|
|
@@ -28,7 +28,7 @@ interview_date_parquet := $(interview_date:.py=.parquet)
|
|
|
28
28
|
enterprise_income = $(shell find $(rounds) -name enterprise_income.py)
|
|
29
29
|
enterprise_income_parquet := $(enterprise_income:.py=.parquet)
|
|
30
30
|
|
|
31
|
-
../var/enterprise_income.parquet: enterprise_income.py $(enterprise_income_parquet)
|
|
31
|
+
../var/enterprise_income.parquet: enterprise_income.py $(enterprise_income_parquet) ../var/other_features.parquet
|
|
32
32
|
python enterprise_income.py
|
|
33
33
|
|
|
34
34
|
assets = $(shell find $(rounds) -name assets.py)
|
|
@@ -40,7 +40,7 @@ assets_parquet := $(assets:.py=.parquet)
|
|
|
40
40
|
earnings = $(shell find $(rounds) -name earnings.py)
|
|
41
41
|
earnings_parquet := $(earnings:.py=.parquet)
|
|
42
42
|
|
|
43
|
-
../var/earnings.parquet: earnings.py $(earnings_parquet)
|
|
43
|
+
../var/earnings.parquet: earnings.py $(earnings_parquet) ../var/other_features.parquet
|
|
44
44
|
python earnings.py
|
|
45
45
|
|
|
46
46
|
shocks = $(shell find $(rounds) -name shocks.py)
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
from lsms_library.local_tools import to_parquet
|
|
3
|
-
from lsms_library.local_tools import get_dataframe
|
|
4
2
|
"""
|
|
5
3
|
Concatenate data on other household features across rounds.
|
|
6
4
|
"""
|
|
7
|
-
|
|
5
|
+
import json
|
|
8
6
|
import pandas as pd
|
|
7
|
+
from lsms_library.local_tools import to_parquet, get_dataframe
|
|
9
8
|
from uganda import Waves, id_walk
|
|
10
|
-
import json
|
|
11
9
|
|
|
12
10
|
x = {}
|
|
13
11
|
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
Code,Preferred Label
|
|
2
|
+
0,---
|
|
3
|
+
1,Kg
|
|
4
|
+
2,Gram
|
|
5
|
+
3,Litre
|
|
6
|
+
4,Akendo (Small)
|
|
7
|
+
5,Metre
|
|
8
|
+
6,Square metre
|
|
9
|
+
7,Yard
|
|
10
|
+
8,Millilitre
|
|
11
|
+
9,Sack (120 kgs)
|
|
12
|
+
10,Sack (100 kgs)
|
|
13
|
+
11,Sack (80 kgs)
|
|
14
|
+
12,Sack (50 kgs)
|
|
15
|
+
13,Sack (unspecified)
|
|
16
|
+
14,Jerrican (20 lts)
|
|
17
|
+
15,Jerrican (10 lts)
|
|
18
|
+
16,Jerrican (5 lts)
|
|
19
|
+
17,Jerrican (3 lts)
|
|
20
|
+
18,Jerrican (2 lts)
|
|
21
|
+
19,Jerrican (1 lt)
|
|
22
|
+
20,Tin (Debe) (20 lts)
|
|
23
|
+
21,Tin (5 lts)
|
|
24
|
+
22,Plastic Basin (15 lts)
|
|
25
|
+
23,Bottle(750ml)
|
|
26
|
+
24,Bottle(500ml)
|
|
27
|
+
25,Bottle(350ml)
|
|
28
|
+
26,Bottle(300ml)
|
|
29
|
+
27,Bottle(250ml)
|
|
30
|
+
28,Bottle(150ml)
|
|
31
|
+
29,Kimbo/Cowboy/Blueband Tin (2kg)
|
|
32
|
+
30,Kimbo/Cowboy/Blueband Tin (1kg)
|
|
33
|
+
31,Kimbo/Cowboy/Blueband Tin (0.5kg)
|
|
34
|
+
32,Cup/Mug(0.5lt)
|
|
35
|
+
33,Glass(0.25lt)
|
|
36
|
+
34,Ladle(100g)
|
|
37
|
+
35,Table spoon
|
|
38
|
+
36,Tea spoon
|
|
39
|
+
37,Basket (20 kg)
|
|
40
|
+
38,Basket (10 kg)
|
|
41
|
+
39,Basket (5 kg)
|
|
42
|
+
40,Basket (2 kg)
|
|
43
|
+
41,Loaf (1kg)
|
|
44
|
+
42,Loaf (500g)
|
|
45
|
+
43,Buns (200 g)
|
|
46
|
+
44,Buns (100 g)
|
|
47
|
+
45,Buns (50 g)
|
|
48
|
+
46,Bathing soap (Tablet)
|
|
49
|
+
47,Washing soap (Bar)
|
|
50
|
+
48,Washing soap (Tablet)
|
|
51
|
+
49,Packet (2 kg)
|
|
52
|
+
50,Packet (1 kg)
|
|
53
|
+
51,Packet (500 g)
|
|
54
|
+
52,Packet (250 g)
|
|
55
|
+
53,Packet (100 g)
|
|
56
|
+
54,Packet(125g)
|
|
57
|
+
55,Fish Whole (Small)
|
|
58
|
+
56,Fish Whole (Medium)
|
|
59
|
+
57,Fish Whole (Large)
|
|
60
|
+
58,Fish Cut piece (up to 1kg)
|
|
61
|
+
59,Fish Cut piece (1 - 2 kg)
|
|
62
|
+
60,Fish Cut piece(Above 2 kg)
|
|
63
|
+
61,Tray of 30 eggs
|
|
64
|
+
62,Ream
|
|
65
|
+
63,Crate
|
|
66
|
+
64,Heap (unspecified)
|
|
67
|
+
65,Dozen
|
|
68
|
+
66,Bundle (Unspecified)
|
|
69
|
+
67,Bunch (Big)
|
|
70
|
+
68,Bunch (Medium)
|
|
71
|
+
69,Bunch (Small)
|
|
72
|
+
70,Bunch (Big)
|
|
73
|
+
71,Bunch (Medium)
|
|
74
|
+
72,Bunch (Small)
|
|
75
|
+
73,Cluster (Unspecified)
|
|
76
|
+
74,Gourd (1-5lts)
|
|
77
|
+
75,Gourd (5-10lts)
|
|
78
|
+
76,Gourd (Above 10 lts)
|
|
79
|
+
77,Jug (2 lts)
|
|
80
|
+
78,Jug (1.5 lts)
|
|
81
|
+
79,Jug (1 lt)
|
|
82
|
+
80,Tot (50 ml)
|
|
83
|
+
81,Tot (sachet)
|
|
84
|
+
82,Tot (Unspecified)
|
|
85
|
+
83,Tobacco leaf (Number)
|
|
86
|
+
84,Pair
|
|
87
|
+
85,Number of Units (General)
|
|
88
|
+
86,Acre
|
|
89
|
+
87,Piece (Big)
|
|
90
|
+
88,Piece (Medium)
|
|
91
|
+
89,Piece (Small)
|
|
92
|
+
90,Heap (Big)
|
|
93
|
+
91,Heap (Medium)
|
|
94
|
+
92,Heap (Small)
|
|
95
|
+
93,Cluster (Big)
|
|
96
|
+
94,Cluster (Medium)
|
|
97
|
+
95,Cluster (Small)
|
|
98
|
+
96,Bundle (Big)
|
|
99
|
+
97,Bundle (Medium)
|
|
100
|
+
98,Bundle (Small)
|
|
101
|
+
99,Others specify
|
|
102
|
+
100,Fish Whole (Large)
|
|
103
|
+
101,Fish Whole (Medium)
|
|
104
|
+
102,Fish Whole (Small)
|
|
105
|
+
103,Plastic Basin (5 ltrs)
|
|
106
|
+
104,Glass (500ml)
|
|
107
|
+
105,Glass (125ml)
|
|
108
|
+
106,Jug (2.5ltrs)
|
|
109
|
+
107,Nice cup (100g) - Large
|
|
110
|
+
108,Nice cup (60g) - Medium
|
|
111
|
+
109,Nice cup (50g) - Small
|
|
112
|
+
110,Metallic tumbler (100g) - Big
|
|
113
|
+
111,Metallic tumbler (50g) - Small
|
|
114
|
+
112,Plastic tumbler (50g) - Big
|
|
115
|
+
113,Plastic tumbler (30g) - Small
|
|
116
|
+
114,Plastic plate (60g) - Large
|
|
117
|
+
115,Plastic plate (30g) - Small
|
|
118
|
+
116,Metallic plate (100g) - Large
|
|
119
|
+
117,Metallic plate (80g) - Small
|
|
120
|
+
118,Plastic bowl (40g)
|
|
121
|
+
119,Nomi Tin (1kg)
|
|
122
|
+
120,Nomi Tin (500g)
|
|
123
|
+
121,Nomi Tin (250g)
|
|
124
|
+
122,Nido Tin (400g)
|
|
125
|
+
123,Akendo (Big)
|
|
126
|
+
124,Akendo (Medium)
|
|
127
|
+
125,Akendo (Small)
|
|
128
|
+
126,Jerrican (500 ml)
|
|
129
|
+
127,Container (Big)
|
|
130
|
+
128,Container (Medium)
|
|
131
|
+
129,Container (Small)
|
|
132
|
+
130,Container (Smallest)
|
|
133
|
+
131,Bottle (500g)
|
|
134
|
+
132,Bottle (350g)
|
|
135
|
+
133,Sadolin Tin (3ltrs)
|
|
136
|
+
134,Loaf (1kg)
|
|
137
|
+
135,Loaf (500g)
|
|
138
|
+
137,Bottle (1ltr)
|
|
139
|
+
138,Bottle (1.5ltr)
|
|
140
|
+
139,Bottle (2ltr)
|
|
141
|
+
140,Sacket (10g)
|
|
142
|
+
141,Sacket (15g)
|
|
143
|
+
142,Sacket (20g)
|
|
144
|
+
143,Sacket (25g)
|
|
145
|
+
144,Sacket (30g)
|
|
146
|
+
145,Sacket (50g)
|
|
147
|
+
146,Sacket (100g)
|
|
148
|
+
147,Sacket (150g)
|
|
149
|
+
104002,---
|
|
150
|
+
104003,---
|
|
151
|
+
104087,---
|
|
152
|
+
104088,---
|
|
153
|
+
104089,---
|
|
154
|
+
105091,---
|
|
155
|
+
105092,---
|
|
156
|
+
107087,---
|
|
157
|
+
107088,---
|
|
158
|
+
107089,---
|
|
159
|
+
107090,---
|
|
160
|
+
107091,---
|
|
161
|
+
107092,---
|
|
162
|
+
109087,---
|
|
163
|
+
109088,---
|
|
164
|
+
109089,---
|
|
165
|
+
109090,---
|
|
166
|
+
109092,---
|
|
167
|
+
111087,---
|
|
168
|
+
111088,---
|
|
169
|
+
111089,---
|
|
170
|
+
111090,---
|
|
171
|
+
113087,---
|
|
172
|
+
113088,---
|
|
173
|
+
113089,---
|
|
174
|
+
114087,---
|
|
175
|
+
114089,---
|
|
176
|
+
121087,---
|
|
177
|
+
121089,---
|
|
178
|
+
122055,---
|
|
179
|
+
122056,---
|
|
180
|
+
122057,---
|
|
181
|
+
123055,---
|
|
182
|
+
123056,---
|
|
183
|
+
123057,---
|
|
184
|
+
123058,---
|
|
185
|
+
123059,---
|
|
186
|
+
123060,---
|
|
187
|
+
123090,---
|
|
188
|
+
123091,---
|
|
189
|
+
123092,---
|
|
190
|
+
124088,---
|
|
191
|
+
125050,---
|
|
192
|
+
125051,---
|
|
193
|
+
125052,---
|
|
194
|
+
128004,---
|
|
195
|
+
128005,---
|
|
196
|
+
128051,---
|
|
197
|
+
128052,---
|
|
198
|
+
128053,---
|
|
199
|
+
129001,---
|
|
200
|
+
129002,---
|
|
201
|
+
129003,---
|
|
202
|
+
129004,---
|
|
203
|
+
130090,---
|
|
204
|
+
130091,---
|
|
205
|
+
130092,---
|
|
206
|
+
131093,---
|
|
207
|
+
131094,---
|
|
208
|
+
131095,---
|
|
209
|
+
132087,---
|
|
210
|
+
132088,---
|
|
211
|
+
132089,---
|
|
212
|
+
133087,---
|
|
213
|
+
133088,---
|
|
214
|
+
133089,---
|
|
215
|
+
133090,---
|
|
216
|
+
133092,---
|
|
217
|
+
135087,---
|
|
218
|
+
135088,---
|
|
219
|
+
135089,---
|
|
220
|
+
135090,---
|
|
221
|
+
135091,---
|
|
222
|
+
135092,---
|
|
223
|
+
135096,---
|
|
224
|
+
135097,---
|
|
225
|
+
135098,---
|
|
226
|
+
136087,---
|
|
227
|
+
136088,---
|
|
228
|
+
136089,---
|
|
229
|
+
136090,---
|
|
230
|
+
136091,---
|
|
231
|
+
136092,---
|
|
232
|
+
137087,---
|
|
233
|
+
137088,---
|
|
234
|
+
137089,---
|
|
235
|
+
138096,---
|
|
236
|
+
138097,---
|
|
237
|
+
138098,---
|
|
238
|
+
151024,---
|
|
239
|
+
151026,---
|
|
240
|
+
152024,---
|
|
241
|
+
153001,---
|
|
242
|
+
154001,---
|
|
243
|
+
155054,---
|
|
244
|
+
155099,---
|
|
245
|
+
157001,---
|
|
246
|
+
158024,---
|
|
247
|
+
158026,---
|
|
248
|
+
159024,---
|
|
249
|
+
160001,---
|
|
250
|
+
161001,---
|
|
251
|
+
164087,---
|
|
252
|
+
164088,---
|
|
253
|
+
164089,---
|
|
254
|
+
165087,---
|
|
255
|
+
165088,---
|
|
256
|
+
165089,---
|
|
257
|
+
166087,---
|
|
258
|
+
166088,---
|
|
259
|
+
166089,---
|
|
260
|
+
167087,---
|
|
261
|
+
167088,---
|
|
262
|
+
167089,---
|
|
263
|
+
167090,---
|
|
264
|
+
167091,---
|
|
265
|
+
167092,---
|
|
266
|
+
168087,---
|
|
267
|
+
168088,---
|
|
268
|
+
168089,---
|
|
269
|
+
168090,---
|
|
270
|
+
168091,---
|
|
271
|
+
168092,---
|
|
272
|
+
169087,---
|
|
273
|
+
169088,---
|
|
274
|
+
169089,---
|
|
275
|
+
170087,---
|
|
276
|
+
170088,---
|
|
277
|
+
170089,---
|
|
278
|
+
171087,---
|
|
279
|
+
171088,---
|
|
280
|
+
171089,---
|
|
281
|
+
807087,---
|
|
282
|
+
807089,---
|
|
283
|
+
136,---
|
|
284
|
+
156087,---
|
|
285
|
+
139093,---
|
|
286
|
+
142092,---
|
|
287
|
+
156096,---
|
|
288
|
+
156090,---
|
|
289
|
+
181087,---
|
|
290
|
+
142090,---
|
lsms_library/country.py
CHANGED
|
@@ -43,9 +43,8 @@ class Wave:
|
|
|
43
43
|
|
|
44
44
|
@property
|
|
45
45
|
def file_path(self):
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
return files("lsms_library") / "countries" / self.folder
|
|
47
|
+
|
|
49
48
|
@property
|
|
50
49
|
def resources(self):
|
|
51
50
|
"""Load the data_info.yml that describes table structure, merges, etc."""
|
|
@@ -212,7 +211,7 @@ class Wave:
|
|
|
212
211
|
df_edit_function = mapping_info.pop('df_edit')
|
|
213
212
|
dfs = []
|
|
214
213
|
for file, mappings in mapping_info.items():
|
|
215
|
-
df = df_data_grabber(f'
|
|
214
|
+
df = df_data_grabber(f'./{self.folder}/Data/{file}', mappings['idxvars'], **mappings['myvars'], convert_categoricals=convert_cat)
|
|
216
215
|
df = check_adding_t(df)
|
|
217
216
|
# Oddity with large number for missing code
|
|
218
217
|
na = df.select_dtypes(exclude=['object', 'datetime64[ns]']).max().max()
|
|
@@ -266,7 +265,7 @@ class Wave:
|
|
|
266
265
|
|
|
267
266
|
cwd_path = self.file_path.parent / "_"
|
|
268
267
|
relative_parquet_path = parquet_fn.relative_to(cwd_path.parent) # Convert to relative path
|
|
269
|
-
subprocess.run(["make", '../' + str(relative_parquet_path)], cwd=cwd_path, check=True)
|
|
268
|
+
subprocess.run(["make", "-s", '../' + str(relative_parquet_path)], cwd=cwd_path, check=True)
|
|
270
269
|
print(f"Makefile executed successfully for {self.name}. Rechecking for parquet file...",file=stderr)
|
|
271
270
|
|
|
272
271
|
if not parquet_fn.exists():
|
|
@@ -331,7 +330,7 @@ class Country:
|
|
|
331
330
|
# 'nonfood_expenditures.parquet', 'enterprise_income.parquet', 'assets.parquet',
|
|
332
331
|
# 'earnings.parquet', 'housing.parquet', 'income.parquet', 'fct.parquet', 'nutrition.parquet']
|
|
333
332
|
|
|
334
|
-
def __init__(self,country_name, preload_panel_ids =
|
|
333
|
+
def __init__(self, country_name, preload_panel_ids=True, verbose=False):
|
|
335
334
|
self.name = country_name
|
|
336
335
|
self._panel_ids_cache = None
|
|
337
336
|
self._updated_ids_cache = None
|
|
@@ -510,7 +509,7 @@ class Country:
|
|
|
510
509
|
relative_path = target_path.relative_to(cwd_path.parent)
|
|
511
510
|
make_target = '../' + str(relative_path)
|
|
512
511
|
|
|
513
|
-
subprocess.run(["make", make_target], cwd=cwd_path, check=True)
|
|
512
|
+
subprocess.run(["make", "-s", make_target], cwd=cwd_path, check=True)
|
|
514
513
|
print(f"Makefile executed successfully for {self.name}. Rechecking for {target_path.name}...",file=stderr)
|
|
515
514
|
|
|
516
515
|
if not target_path.exists():
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import git
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import getpass
|
|
5
|
+
import pkgutil
|
|
6
|
+
import gnupg
|
|
7
|
+
|
|
8
|
+
def is_git_repo(path='.'):
|
|
9
|
+
"""
|
|
10
|
+
Check if the specified path is a Git repository.
|
|
11
|
+
|
|
12
|
+
Parameters:
|
|
13
|
+
path (str): The path to check. Default is the current directory.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
bool: True if the path is a valid Git repository, False otherwise.
|
|
17
|
+
"""
|
|
18
|
+
try:
|
|
19
|
+
_ = git.Repo(path).git_dir
|
|
20
|
+
return True
|
|
21
|
+
except git.exc.InvalidGitRepositoryError:
|
|
22
|
+
return False
|
|
23
|
+
|
|
24
|
+
def authenticate(gpg_key_file='s3_reader_creds.gpg'):
|
|
25
|
+
"""
|
|
26
|
+
Decrypt the specified GPG file and store the decrypted credentials securely.
|
|
27
|
+
|
|
28
|
+
This function prompts the user for a passphrase to decrypt the provided GPG
|
|
29
|
+
file.
|
|
30
|
+
|
|
31
|
+
Parameters:
|
|
32
|
+
gpg_key_file (str): The name of the GPG file containing the encrypted credentials.
|
|
33
|
+
Default is 's3_reader_creds.gpg'.
|
|
34
|
+
|
|
35
|
+
Raises:
|
|
36
|
+
ValueError: If decryption fails due to an incorrect passphrase or other issues.
|
|
37
|
+
"""
|
|
38
|
+
# Construct the path to the encrypted file relative to this function’s location
|
|
39
|
+
gpg_path = Path(__file__).resolve().parent / 'countries' / '.dvc'
|
|
40
|
+
encrypted_file = gpg_path / gpg_key_file
|
|
41
|
+
|
|
42
|
+
# Load the encrypted data
|
|
43
|
+
encrypted_data = encrypted_file.read_bytes()
|
|
44
|
+
|
|
45
|
+
# Initialize GPG
|
|
46
|
+
gpg = gnupg.GPG()
|
|
47
|
+
|
|
48
|
+
# Prompt the user for the passphrase securely
|
|
49
|
+
passphrase = getpass.getpass(prompt='Enter passphrase for decryption: ')
|
|
50
|
+
|
|
51
|
+
# Decrypt the data
|
|
52
|
+
decrypted_data = gpg.decrypt(encrypted_data, passphrase=passphrase)
|
|
53
|
+
|
|
54
|
+
if decrypted_data.ok:
|
|
55
|
+
# Write the decrypted data to a temporary file securely
|
|
56
|
+
creds_file = gpg_path / 's3_creds'
|
|
57
|
+
|
|
58
|
+
if creds_file.exists():
|
|
59
|
+
user_input = input(f"The file {creds_file} already exists. Overwrite? (yes/no): ").strip().lower()
|
|
60
|
+
if user_input not in ['yes', 'y']:
|
|
61
|
+
print("Operation aborted. Credentials were not written.")
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
with open(creds_file, 'w') as f:
|
|
65
|
+
f.write(str(decrypted_data))
|
|
66
|
+
print(f"Decryption successful; credentials written to {creds_file}")
|
|
67
|
+
else:
|
|
68
|
+
raise ValueError("Decryption failed: check the passphrase and try again")
|
lsms_library/local_tools.py
CHANGED
|
@@ -696,11 +696,11 @@ def panel_ids(Waves):
|
|
|
696
696
|
if isinstance(wave_info[1], list): #tanzania
|
|
697
697
|
df = wave_info[2](df, wave_info[1])
|
|
698
698
|
else:
|
|
699
|
-
df[wave_info[1]] = df[wave_info[1]].apply(format_id)
|
|
700
|
-
df[wave_info[2]] = df[wave_info[2]].apply(format_id)
|
|
699
|
+
df.loc[:,wave_info[1]] = df[wave_info[1]].apply(format_id)
|
|
700
|
+
df.loc[:,wave_info[2]] = df[wave_info[2]].apply(format_id)
|
|
701
701
|
# If a transformation function is provided (tuple length 4), apply it to the old_id column
|
|
702
702
|
if len(wave_info) == 4:
|
|
703
|
-
df[wave_info[2]] = df[wave_info[2]].apply(wave_info[3])
|
|
703
|
+
df.loc[:,wave_info[2]] = df[wave_info[2]].apply(wave_info[3])
|
|
704
704
|
df['t'] = wave_year
|
|
705
705
|
df = df.rename(columns={wave_info[1]: 'i', wave_info[2]: 'previous_i'})
|
|
706
706
|
df = df.set_index(['t', 'i'])[['previous_i']]
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
lsms_library/Makefile,sha256=5iTMKOlMuK29OtDrqIrjGztt-ivnIw0l8UWI8UR0alU,607
|
|
2
2
|
lsms_library/README.org,sha256=Nm5shD0nZnG_CyFXrJRK78RQJ6bNbHKL3UyVf4tK0rI,810
|
|
3
|
-
lsms_library/__init__.py,sha256=
|
|
3
|
+
lsms_library/__init__.py,sha256=BXz5Xm1FW_0Ebo9NCa05QBhg4-LyntFUx1vI78ILn-E,207
|
|
4
4
|
lsms_library/categorical_mapping/ai_agent.py,sha256=uN4DZmpeLyl3E03AS-50Acb4bjNhL5BByHIZwbxtwfw,6268
|
|
5
5
|
lsms_library/categorical_mapping/categorical_mapping_helper.py,sha256=P6vHZf2vdXPmIr-FcidikaJZFtp025cRAMA2lBG_nMo,5310
|
|
6
6
|
lsms_library/categorical_mapping/spelling.yml,sha256=c5n0WudZZ3DHzG9dhi6-jzfUt9f29op6jvHyYavPPCI,20
|
|
7
7
|
lsms_library/contributing.org,sha256=KkW9ioEh6snUP5sEbSl42nhjfc-pr2rcd0F4NAd7tkU,7564
|
|
8
|
+
lsms_library/countries/.dvc/.gitignore,sha256=zaP8GkzpZZyxmBi7Bl7ujFJxeVSE9J8xTKA1e02uxu8,26
|
|
9
|
+
lsms_library/countries/.dvc/config,sha256=oWXrcncknTjZRLXS0XcHmaJB0FX6DZNgkRdgY6dOVqc,388
|
|
10
|
+
lsms_library/countries/.dvc/plots/confusion.json,sha256=jUW3NJJZlg4e-CFa4s8hEEvqnsWpLVGt_3cgBwt9iqE,740
|
|
11
|
+
lsms_library/countries/.dvc/plots/default.json,sha256=beLplVC3KKggxiinNrnAS74ghDY4ZgWU0lGiFVuzfzU,677
|
|
12
|
+
lsms_library/countries/.dvc/plots/scatter.json,sha256=FH0wazql-iIxd8eYZlQdwRtC9vR7wqe-lZw2lDtAYXg,654
|
|
13
|
+
lsms_library/countries/.dvc/plots/smooth.json,sha256=iAPend4RhPDoss8CkcbWBsyi92p4g_22A6gBQHxe8R4,889
|
|
14
|
+
lsms_library/countries/.dvc/s3_config,sha256=1qRklwYbm44Pq66ym8JL_2xaIKpmLN4BG14bru8lRXI,27
|
|
15
|
+
lsms_library/countries/.dvc/s3_reader_creds.gpg,sha256=GinaLcABIAWwiUIPXV5UACUOCKsqIi4b4GZFSyRXubg,187
|
|
8
16
|
lsms_library/countries/Afghanistan/2016-17/Data/Core household.dta.dvc,sha256=V3mHw_cBEqnugIWNKaO0JuInEfogtWBbr7qneySOsCw,88
|
|
9
17
|
lsms_library/countries/Afghanistan/2016-17/Data/Core individual.dta.dvc,sha256=U3uCKcKyNEwd_qucQS7LWaj4KZRtnKDGD2tGfcn02Sk,91
|
|
10
18
|
lsms_library/countries/Afghanistan/2016-17/Data/H_01.dta.dvc,sha256=A5iLTGccuRUsgfFfIjArEjMZpZaR1hxAlGEoSNJX05w,78
|
|
@@ -9479,7 +9487,7 @@ lsms_library/countries/Uganda/2005-06/Documentation/UNHS.2005-06.CommQuest_final
|
|
|
9479
9487
|
lsms_library/countries/Uganda/2005-06/Documentation/UNHS.2005-06.Household.Questionnaire.FINAL.pdf.dvc,sha256=NuESUFEsMG10Gm0poidecd3lTFVwh4-2j22ayosZtkY,129
|
|
9480
9488
|
lsms_library/countries/Uganda/2005-06/Documentation/UNHS.2005-06.Interviewer.Manual.FINAL.pdf.dvc,sha256=6urVSwN3_57SkfWcieq6NzlTbbVm9gxt0WHg5ywuXXs,123
|
|
9481
9489
|
lsms_library/countries/Uganda/2005-06/_/assets.py,sha256=Lh9BVYNv4DRRgjC6h1S2HK_JMmjLzn8LQYaUpv8yH9w,417
|
|
9482
|
-
lsms_library/countries/Uganda/2005-06/_/data_info.yml,sha256=
|
|
9490
|
+
lsms_library/countries/Uganda/2005-06/_/data_info.yml,sha256=y_k8aZuoQFBn-FVIg6fySwzIAHkpJGi8MeuBMZyFGQk,849
|
|
9483
9491
|
lsms_library/countries/Uganda/2005-06/_/earnings.py,sha256=HVM6pmh6_KuKVN_Cl9MQQ2GhbZxpWsztSoXw9jlE5oE,559
|
|
9484
9492
|
lsms_library/countries/Uganda/2005-06/_/education_expenses.py,sha256=HaBLCZfr8RRlfj9rDEvPg51KOK6uxii8D7M4Lk_LbuU,1466
|
|
9485
9493
|
lsms_library/countries/Uganda/2005-06/_/enterprise_income.py,sha256=dwJvipFBT9O7rjTAqZNfjSTCNp8aKeqEWLGeonzSmfc,932
|
|
@@ -10492,11 +10500,11 @@ lsms_library/countries/Uganda/2019-20/_/nonfood_expenditures.py,sha256=CRO6B7Fk0
|
|
|
10492
10500
|
lsms_library/countries/Uganda/2019-20/_/other_features.py,sha256=Tvevvw888c0NKnHB5EJ4AZko-XIzT6SbGLdkUvB6wT8,1012
|
|
10493
10501
|
lsms_library/countries/Uganda/2019-20/_/plots.py,sha256=mbqRPKeK5Z-phCZy1zIxbsPXXZiFAvu7Dq-oMtsrPTM,880
|
|
10494
10502
|
lsms_library/countries/Uganda/2019-20/_/shocks.py,sha256=L5nYYT82m_ACGGSaUtnpGmm7Bn7q-rdqDGvGEc0jcYA,2627
|
|
10495
|
-
lsms_library/countries/Uganda/_/Makefile,sha256=
|
|
10503
|
+
lsms_library/countries/Uganda/_/Makefile,sha256=9fuxU6l7SCjkL7tPNBo58u0Y42H1RKkfE6XDrWUqf2E,3649
|
|
10496
10504
|
lsms_library/countries/Uganda/_/assets.py,sha256=jfwV44k96WZ7bANodoZ8BAMO-baQy1FKuCDRKPoqFwA,665
|
|
10497
10505
|
lsms_library/countries/Uganda/_/categorical_mapping.org,sha256=XD4QBTKwdIEjScBEElpQ0BijfscmbnXfLS8dLQtDpR0,11822
|
|
10498
10506
|
lsms_library/countries/Uganda/_/conversion_to_kgs.json,sha256=K7uEX1YERdMTgVCpZ_9Fol2xSbRd90Obf9WuPocJJ98,2650
|
|
10499
|
-
lsms_library/countries/Uganda/_/data_scheme.yml,sha256=
|
|
10507
|
+
lsms_library/countries/Uganda/_/data_scheme.yml,sha256=98XKJaHdrPQj2xwfgkZ_P-uDPATWVByayFWuoj1jQnQ,450
|
|
10500
10508
|
lsms_library/countries/Uganda/_/earnings.py,sha256=ela9bgSbY1S-vvOnQM48WV0XOjCl6d5FNlpqmzAlINo,814
|
|
10501
10509
|
lsms_library/countries/Uganda/_/enterprise_income.py,sha256=MLx1mxjPym_r1KTNudDxRVY0t6Kezn4F4CwqJV1Li7M,851
|
|
10502
10510
|
lsms_library/countries/Uganda/_/fct_addition.py,sha256=d_TEoxFQ4yjd6D1ghMOT507sCc8T7RvOqKjVKl-RGHM,2679
|
|
@@ -10505,7 +10513,7 @@ lsms_library/countries/Uganda/_/fct_uganda.csv,sha256=Gc1M3vwIeo2DVEoHsVxanBYyP6
|
|
|
10505
10513
|
lsms_library/countries/Uganda/_/food_acquired.py,sha256=OqIpjJZV3DDwu8352FslIiwsz3-zBnrnmeCNCvG7RO0,1017
|
|
10506
10514
|
lsms_library/countries/Uganda/_/food_items.org,sha256=utpfHLa6oDsF52dFWI7z3-PQyZPgxb2-7F2bILqW-24,16896
|
|
10507
10515
|
lsms_library/countries/Uganda/_/food_prices_quantities_and_expenditures.py,sha256=ixtX8WlGlGUbKNCqtR8TPYEm6NhyapMxbw-g6_fwmyY,1493
|
|
10508
|
-
lsms_library/countries/Uganda/_/household_characteristics.py,sha256=
|
|
10516
|
+
lsms_library/countries/Uganda/_/household_characteristics.py,sha256=QyD2-Ma_m5VmVKhjlJ5zdNhsXaSA0MVXc2vcDN1Eg_A,877
|
|
10509
10517
|
lsms_library/countries/Uganda/_/housing.py,sha256=YY9ofu9YTTyz29E4UbpQPB32m3KiQFkc9Qomq73BbNg,802
|
|
10510
10518
|
lsms_library/countries/Uganda/_/income.py,sha256=1E0vimt_5Yyxf2KH7AyUYiUdwA8Hyeae_bzyaE0yq7w,584
|
|
10511
10519
|
lsms_library/countries/Uganda/_/interview_date.py,sha256=gYgueLpNwuI8a2EOOpeOzKTtH3LAN7YkaKz5H7hDvxo,825
|
|
@@ -10523,19 +10531,21 @@ lsms_library/countries/Uganda/_/panel_ids.py,sha256=lKXBBI-iVzPgDV0kOfq9iA3FUolP
|
|
|
10523
10531
|
lsms_library/countries/Uganda/_/regions_are_markets.py,sha256=SCO_yvRTaC8B8QiJASnPrLsTHq_x57fyC15a79LjhXY,1107
|
|
10524
10532
|
lsms_library/countries/Uganda/_/shocks.py,sha256=ZxpyJFwKwX02imDI15MxWCf4q-ehWzVb3ar8yfi3Zow,746
|
|
10525
10533
|
lsms_library/countries/Uganda/_/uganda.py,sha256=NtH1wllwPOwOObhYrxpgedGo5fkCfD6aJx8euxSppbg,9248
|
|
10534
|
+
lsms_library/countries/Uganda/_/unitlabels.csv,sha256=UCO_geSRyI6iJDsfeWrTJ5HSafBjMDG__nX5MT-4MZ4,4433
|
|
10526
10535
|
lsms_library/countries/Uganda/_/unitlabels.py,sha256=ZegaWAArOeRNKL9O1wpCeQL0QjUCsZkMg2zXqmXgMuM,36329
|
|
10527
10536
|
lsms_library/countries/Uganda/_/units.org,sha256=5wU9027ikC_yCneE-uqJGTwlrmJ5Pys9AF1iTUNX3So,98391
|
|
10528
10537
|
lsms_library/countries/Uganda/_/unitvalues.py,sha256=-pY-4OYLJQ-SrCv6xB1FRLevO7yF_KejlL5YV-yp9WY,565
|
|
10529
10538
|
lsms_library/countries/Uganda/_/updated_ids.json,sha256=pgkwK6gcYKufkWt0GS9G39WPF9w7_rxW_bIO-lSwJW4,462159
|
|
10530
10539
|
lsms_library/countries/Uganda/var/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10531
10540
|
lsms_library/countries/Uganda/var/README,sha256=pOIlG6aObxWzUedoWjt9Z5-FG28UXrtws6ktD6GhWn0,116
|
|
10532
|
-
lsms_library/country.py,sha256=
|
|
10541
|
+
lsms_library/country.py,sha256=G7QksqvSWET378pxcOCQ8hQ2dflf9AAaSGSQ1nmHobE,33835
|
|
10533
10542
|
lsms_library/data_info.yml,sha256=Y5GaP52AzJsIvXtioSJP4R63opZcqhjQFsGLjad-2U4,478
|
|
10534
10543
|
lsms_library/demands.py,sha256=UCnUTjoE6FHt32XvRm4hZdIBryOj_YQU4im0-Wu9y7U,749
|
|
10544
|
+
lsms_library/dvc_permissions.py,sha256=Igs04aJAmHbTiKmitNGh4uMI3mFFctUEebF99IMX3VY,2226
|
|
10535
10545
|
lsms_library/harmony.py,sha256=hEGLJUnWBXdyGeAAr7qgCFZ0Q-KsiqjBxHrtYbZ8Ngs,2742
|
|
10536
|
-
lsms_library/local_tools.py,sha256=
|
|
10546
|
+
lsms_library/local_tools.py,sha256=UJvressIwYCBdmq8TJ3fHUowUKzlmiHjlGTTRY-S2Kk,40734
|
|
10537
10547
|
lsms_library/transformations.py,sha256=uBSGfUAjWMrqSOmxdYYzi9csf8WvjaGCC7lzflJObtU,3661
|
|
10538
|
-
lsms_library-0.2.
|
|
10539
|
-
lsms_library-0.2.
|
|
10540
|
-
lsms_library-0.2.
|
|
10541
|
-
lsms_library-0.2.
|
|
10548
|
+
lsms_library-0.2.9.dev0.dist-info/LICENSE.txt,sha256=qImFXcRJwxIHS80FE7uOx6FhmLY8apd4Y12aR54QU7w,282
|
|
10549
|
+
lsms_library-0.2.9.dev0.dist-info/METADATA,sha256=1tt2IG9-RzVPRBr7V0eQSP6V-2NOtjWZlh_EBeBZ434,5219
|
|
10550
|
+
lsms_library-0.2.9.dev0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
10551
|
+
lsms_library-0.2.9.dev0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|