keeganskeate
commited on
Commit
•
6a105a7
1
Parent(s):
a01fb05
pr/1 (#1)
Browse files- Curating cannabis licenses📜 | Completed CA + OR ✅ (14c4eafb52dcf9c57c7f00051cfd9c52641749c0)
- .gitattributes +1 -0
- .gitignore +11 -0
- LICENSE +395 -0
- README.md +257 -1
- algorithms/get_licenses_az.py +100 -0
- algorithms/get_licenses_ca.py +103 -0
- algorithms/get_licenses_mt.py +138 -0
- algorithms/get_licenses_or.py +192 -0
- analysis/figures/cannabis-licenses-map.html +0 -0
- analysis/license_map.py +284 -0
- requirements.txt +13 -0
.gitattributes
CHANGED
@@ -49,3 +49,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
49 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
50 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
51 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
49 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
50 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
51 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
52 |
+
*.xlsx filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ignore environment variables.
|
2 |
+
*.env
|
3 |
+
|
4 |
+
# Ignore temporary files.
|
5 |
+
*tmp
|
6 |
+
|
7 |
+
# Ignore PDFs.
|
8 |
+
*pdfs
|
9 |
+
|
10 |
+
# Ignore external datasets.
|
11 |
+
*.datasets
|
LICENSE
ADDED
@@ -0,0 +1,395 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Attribution 4.0 International
|
2 |
+
|
3 |
+
=======================================================================
|
4 |
+
|
5 |
+
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
6 |
+
does not provide legal services or legal advice. Distribution of
|
7 |
+
Creative Commons public licenses does not create a lawyer-client or
|
8 |
+
other relationship. Creative Commons makes its licenses and related
|
9 |
+
information available on an "as-is" basis. Creative Commons gives no
|
10 |
+
warranties regarding its licenses, any material licensed under their
|
11 |
+
terms and conditions, or any related information. Creative Commons
|
12 |
+
disclaims all liability for damages resulting from their use to the
|
13 |
+
fullest extent possible.
|
14 |
+
|
15 |
+
Using Creative Commons Public Licenses
|
16 |
+
|
17 |
+
Creative Commons public licenses provide a standard set of terms and
|
18 |
+
conditions that creators and other rights holders may use to share
|
19 |
+
original works of authorship and other material subject to copyright
|
20 |
+
and certain other rights specified in the public license below. The
|
21 |
+
following considerations are for informational purposes only, are not
|
22 |
+
exhaustive, and do not form part of our licenses.
|
23 |
+
|
24 |
+
Considerations for licensors: Our public licenses are
|
25 |
+
intended for use by those authorized to give the public
|
26 |
+
permission to use material in ways otherwise restricted by
|
27 |
+
copyright and certain other rights. Our licenses are
|
28 |
+
irrevocable. Licensors should read and understand the terms
|
29 |
+
and conditions of the license they choose before applying it.
|
30 |
+
Licensors should also secure all rights necessary before
|
31 |
+
applying our licenses so that the public can reuse the
|
32 |
+
material as expected. Licensors should clearly mark any
|
33 |
+
material not subject to the license. This includes other CC-
|
34 |
+
licensed material, or material used under an exception or
|
35 |
+
limitation to copyright. More considerations for licensors:
|
36 |
+
wiki.creativecommons.org/Considerations_for_licensors
|
37 |
+
|
38 |
+
Considerations for the public: By using one of our public
|
39 |
+
licenses, a licensor grants the public permission to use the
|
40 |
+
licensed material under specified terms and conditions. If
|
41 |
+
the licensor's permission is not necessary for any reason--for
|
42 |
+
example, because of any applicable exception or limitation to
|
43 |
+
copyright--then that use is not regulated by the license. Our
|
44 |
+
licenses grant only permissions under copyright and certain
|
45 |
+
other rights that a licensor has authority to grant. Use of
|
46 |
+
the licensed material may still be restricted for other
|
47 |
+
reasons, including because others have copyright or other
|
48 |
+
rights in the material. A licensor may make special requests,
|
49 |
+
such as asking that all changes be marked or described.
|
50 |
+
Although not required by our licenses, you are encouraged to
|
51 |
+
respect those requests where reasonable. More considerations
|
52 |
+
for the public:
|
53 |
+
wiki.creativecommons.org/Considerations_for_licensees
|
54 |
+
|
55 |
+
=======================================================================
|
56 |
+
|
57 |
+
Creative Commons Attribution 4.0 International Public License
|
58 |
+
|
59 |
+
By exercising the Licensed Rights (defined below), You accept and agree
|
60 |
+
to be bound by the terms and conditions of this Creative Commons
|
61 |
+
Attribution 4.0 International Public License ("Public License"). To the
|
62 |
+
extent this Public License may be interpreted as a contract, You are
|
63 |
+
granted the Licensed Rights in consideration of Your acceptance of
|
64 |
+
these terms and conditions, and the Licensor grants You such rights in
|
65 |
+
consideration of benefits the Licensor receives from making the
|
66 |
+
Licensed Material available under these terms and conditions.
|
67 |
+
|
68 |
+
|
69 |
+
Section 1 -- Definitions.
|
70 |
+
|
71 |
+
a. Adapted Material means material subject to Copyright and Similar
|
72 |
+
Rights that is derived from or based upon the Licensed Material
|
73 |
+
and in which the Licensed Material is translated, altered,
|
74 |
+
arranged, transformed, or otherwise modified in a manner requiring
|
75 |
+
permission under the Copyright and Similar Rights held by the
|
76 |
+
Licensor. For purposes of this Public License, where the Licensed
|
77 |
+
Material is a musical work, performance, or sound recording,
|
78 |
+
Adapted Material is always produced where the Licensed Material is
|
79 |
+
synched in timed relation with a moving image.
|
80 |
+
|
81 |
+
b. Adapter's License means the license You apply to Your Copyright
|
82 |
+
and Similar Rights in Your contributions to Adapted Material in
|
83 |
+
accordance with the terms and conditions of this Public License.
|
84 |
+
|
85 |
+
c. Copyright and Similar Rights means copyright and/or similar rights
|
86 |
+
closely related to copyright including, without limitation,
|
87 |
+
performance, broadcast, sound recording, and Sui Generis Database
|
88 |
+
Rights, without regard to how the rights are labeled or
|
89 |
+
categorized. For purposes of this Public License, the rights
|
90 |
+
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
91 |
+
Rights.
|
92 |
+
|
93 |
+
d. Effective Technological Measures means those measures that, in the
|
94 |
+
absence of proper authority, may not be circumvented under laws
|
95 |
+
fulfilling obligations under Article 11 of the WIPO Copyright
|
96 |
+
Treaty adopted on December 20, 1996, and/or similar international
|
97 |
+
agreements.
|
98 |
+
|
99 |
+
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
100 |
+
any other exception or limitation to Copyright and Similar Rights
|
101 |
+
that applies to Your use of the Licensed Material.
|
102 |
+
|
103 |
+
f. Licensed Material means the artistic or literary work, database,
|
104 |
+
or other material to which the Licensor applied this Public
|
105 |
+
License.
|
106 |
+
|
107 |
+
g. Licensed Rights means the rights granted to You subject to the
|
108 |
+
terms and conditions of this Public License, which are limited to
|
109 |
+
all Copyright and Similar Rights that apply to Your use of the
|
110 |
+
Licensed Material and that the Licensor has authority to license.
|
111 |
+
|
112 |
+
h. Licensor means the individual(s) or entity(ies) granting rights
|
113 |
+
under this Public License.
|
114 |
+
|
115 |
+
i. Share means to provide material to the public by any means or
|
116 |
+
process that requires permission under the Licensed Rights, such
|
117 |
+
as reproduction, public display, public performance, distribution,
|
118 |
+
dissemination, communication, or importation, and to make material
|
119 |
+
available to the public including in ways that members of the
|
120 |
+
public may access the material from a place and at a time
|
121 |
+
individually chosen by them.
|
122 |
+
|
123 |
+
j. Sui Generis Database Rights means rights other than copyright
|
124 |
+
resulting from Directive 96/9/EC of the European Parliament and of
|
125 |
+
the Council of 11 March 1996 on the legal protection of databases,
|
126 |
+
as amended and/or succeeded, as well as other essentially
|
127 |
+
equivalent rights anywhere in the world.
|
128 |
+
|
129 |
+
k. You means the individual or entity exercising the Licensed Rights
|
130 |
+
under this Public License. Your has a corresponding meaning.
|
131 |
+
|
132 |
+
|
133 |
+
Section 2 -- Scope.
|
134 |
+
|
135 |
+
a. License grant.
|
136 |
+
|
137 |
+
1. Subject to the terms and conditions of this Public License,
|
138 |
+
the Licensor hereby grants You a worldwide, royalty-free,
|
139 |
+
non-sublicensable, non-exclusive, irrevocable license to
|
140 |
+
exercise the Licensed Rights in the Licensed Material to:
|
141 |
+
|
142 |
+
a. reproduce and Share the Licensed Material, in whole or
|
143 |
+
in part; and
|
144 |
+
|
145 |
+
b. produce, reproduce, and Share Adapted Material.
|
146 |
+
|
147 |
+
2. Exceptions and Limitations. For the avoidance of doubt, where
|
148 |
+
Exceptions and Limitations apply to Your use, this Public
|
149 |
+
License does not apply, and You do not need to comply with
|
150 |
+
its terms and conditions.
|
151 |
+
|
152 |
+
3. Term. The term of this Public License is specified in Section
|
153 |
+
6(a).
|
154 |
+
|
155 |
+
4. Media and formats; technical modifications allowed. The
|
156 |
+
Licensor authorizes You to exercise the Licensed Rights in
|
157 |
+
all media and formats whether now known or hereafter created,
|
158 |
+
and to make technical modifications necessary to do so. The
|
159 |
+
Licensor waives and/or agrees not to assert any right or
|
160 |
+
authority to forbid You from making technical modifications
|
161 |
+
necessary to exercise the Licensed Rights, including
|
162 |
+
technical modifications necessary to circumvent Effective
|
163 |
+
Technological Measures. For purposes of this Public License,
|
164 |
+
simply making modifications authorized by this Section 2(a)
|
165 |
+
(4) never produces Adapted Material.
|
166 |
+
|
167 |
+
5. Downstream recipients.
|
168 |
+
|
169 |
+
a. Offer from the Licensor -- Licensed Material. Every
|
170 |
+
recipient of the Licensed Material automatically
|
171 |
+
receives an offer from the Licensor to exercise the
|
172 |
+
Licensed Rights under the terms and conditions of this
|
173 |
+
Public License.
|
174 |
+
|
175 |
+
b. No downstream restrictions. You may not offer or impose
|
176 |
+
any additional or different terms or conditions on, or
|
177 |
+
apply any Effective Technological Measures to, the
|
178 |
+
Licensed Material if doing so restricts exercise of the
|
179 |
+
Licensed Rights by any recipient of the Licensed
|
180 |
+
Material.
|
181 |
+
|
182 |
+
6. No endorsement. Nothing in this Public License constitutes or
|
183 |
+
may be construed as permission to assert or imply that You
|
184 |
+
are, or that Your use of the Licensed Material is, connected
|
185 |
+
with, or sponsored, endorsed, or granted official status by,
|
186 |
+
the Licensor or others designated to receive attribution as
|
187 |
+
provided in Section 3(a)(1)(A)(i).
|
188 |
+
|
189 |
+
b. Other rights.
|
190 |
+
|
191 |
+
1. Moral rights, such as the right of integrity, are not
|
192 |
+
licensed under this Public License, nor are publicity,
|
193 |
+
privacy, and/or other similar personality rights; however, to
|
194 |
+
the extent possible, the Licensor waives and/or agrees not to
|
195 |
+
assert any such rights held by the Licensor to the limited
|
196 |
+
extent necessary to allow You to exercise the Licensed
|
197 |
+
Rights, but not otherwise.
|
198 |
+
|
199 |
+
2. Patent and trademark rights are not licensed under this
|
200 |
+
Public License.
|
201 |
+
|
202 |
+
3. To the extent possible, the Licensor waives any right to
|
203 |
+
collect royalties from You for the exercise of the Licensed
|
204 |
+
Rights, whether directly or through a collecting society
|
205 |
+
under any voluntary or waivable statutory or compulsory
|
206 |
+
licensing scheme. In all other cases the Licensor expressly
|
207 |
+
reserves any right to collect such royalties.
|
208 |
+
|
209 |
+
|
210 |
+
Section 3 -- License Conditions.
|
211 |
+
|
212 |
+
Your exercise of the Licensed Rights is expressly made subject to the
|
213 |
+
following conditions.
|
214 |
+
|
215 |
+
a. Attribution.
|
216 |
+
|
217 |
+
1. If You Share the Licensed Material (including in modified
|
218 |
+
form), You must:
|
219 |
+
|
220 |
+
a. retain the following if it is supplied by the Licensor
|
221 |
+
with the Licensed Material:
|
222 |
+
|
223 |
+
i. identification of the creator(s) of the Licensed
|
224 |
+
Material and any others designated to receive
|
225 |
+
attribution, in any reasonable manner requested by
|
226 |
+
the Licensor (including by pseudonym if
|
227 |
+
designated);
|
228 |
+
|
229 |
+
ii. a copyright notice;
|
230 |
+
|
231 |
+
iii. a notice that refers to this Public License;
|
232 |
+
|
233 |
+
iv. a notice that refers to the disclaimer of
|
234 |
+
warranties;
|
235 |
+
|
236 |
+
v. a URI or hyperlink to the Licensed Material to the
|
237 |
+
extent reasonably practicable;
|
238 |
+
|
239 |
+
b. indicate if You modified the Licensed Material and
|
240 |
+
retain an indication of any previous modifications; and
|
241 |
+
|
242 |
+
c. indicate the Licensed Material is licensed under this
|
243 |
+
Public License, and include the text of, or the URI or
|
244 |
+
hyperlink to, this Public License.
|
245 |
+
|
246 |
+
2. You may satisfy the conditions in Section 3(a)(1) in any
|
247 |
+
reasonable manner based on the medium, means, and context in
|
248 |
+
which You Share the Licensed Material. For example, it may be
|
249 |
+
reasonable to satisfy the conditions by providing a URI or
|
250 |
+
hyperlink to a resource that includes the required
|
251 |
+
information.
|
252 |
+
|
253 |
+
3. If requested by the Licensor, You must remove any of the
|
254 |
+
information required by Section 3(a)(1)(A) to the extent
|
255 |
+
reasonably practicable.
|
256 |
+
|
257 |
+
4. If You Share Adapted Material You produce, the Adapter's
|
258 |
+
License You apply must not prevent recipients of the Adapted
|
259 |
+
Material from complying with this Public License.
|
260 |
+
|
261 |
+
|
262 |
+
Section 4 -- Sui Generis Database Rights.
|
263 |
+
|
264 |
+
Where the Licensed Rights include Sui Generis Database Rights that
|
265 |
+
apply to Your use of the Licensed Material:
|
266 |
+
|
267 |
+
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
268 |
+
to extract, reuse, reproduce, and Share all or a substantial
|
269 |
+
portion of the contents of the database;
|
270 |
+
|
271 |
+
b. if You include all or a substantial portion of the database
|
272 |
+
contents in a database in which You have Sui Generis Database
|
273 |
+
Rights, then the database in which You have Sui Generis Database
|
274 |
+
Rights (but not its individual contents) is Adapted Material; and
|
275 |
+
|
276 |
+
c. You must comply with the conditions in Section 3(a) if You Share
|
277 |
+
all or a substantial portion of the contents of the database.
|
278 |
+
|
279 |
+
For the avoidance of doubt, this Section 4 supplements and does not
|
280 |
+
replace Your obligations under this Public License where the Licensed
|
281 |
+
Rights include other Copyright and Similar Rights.
|
282 |
+
|
283 |
+
|
284 |
+
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
285 |
+
|
286 |
+
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
287 |
+
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
288 |
+
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
289 |
+
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
290 |
+
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
291 |
+
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
292 |
+
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
293 |
+
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
294 |
+
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
295 |
+
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
296 |
+
|
297 |
+
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
298 |
+
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
299 |
+
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
300 |
+
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
301 |
+
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
302 |
+
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
303 |
+
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
304 |
+
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
305 |
+
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
306 |
+
|
307 |
+
c. The disclaimer of warranties and limitation of liability provided
|
308 |
+
above shall be interpreted in a manner that, to the extent
|
309 |
+
possible, most closely approximates an absolute disclaimer and
|
310 |
+
waiver of all liability.
|
311 |
+
|
312 |
+
|
313 |
+
Section 6 -- Term and Termination.
|
314 |
+
|
315 |
+
a. This Public License applies for the term of the Copyright and
|
316 |
+
Similar Rights licensed here. However, if You fail to comply with
|
317 |
+
this Public License, then Your rights under this Public License
|
318 |
+
terminate automatically.
|
319 |
+
|
320 |
+
b. Where Your right to use the Licensed Material has terminated under
|
321 |
+
Section 6(a), it reinstates:
|
322 |
+
|
323 |
+
1. automatically as of the date the violation is cured, provided
|
324 |
+
it is cured within 30 days of Your discovery of the
|
325 |
+
violation; or
|
326 |
+
|
327 |
+
2. upon express reinstatement by the Licensor.
|
328 |
+
|
329 |
+
For the avoidance of doubt, this Section 6(b) does not affect any
|
330 |
+
right the Licensor may have to seek remedies for Your violations
|
331 |
+
of this Public License.
|
332 |
+
|
333 |
+
c. For the avoidance of doubt, the Licensor may also offer the
|
334 |
+
Licensed Material under separate terms or conditions or stop
|
335 |
+
distributing the Licensed Material at any time; however, doing so
|
336 |
+
will not terminate this Public License.
|
337 |
+
|
338 |
+
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
339 |
+
License.
|
340 |
+
|
341 |
+
|
342 |
+
Section 7 -- Other Terms and Conditions.
|
343 |
+
|
344 |
+
a. The Licensor shall not be bound by any additional or different
|
345 |
+
terms or conditions communicated by You unless expressly agreed.
|
346 |
+
|
347 |
+
b. Any arrangements, understandings, or agreements regarding the
|
348 |
+
Licensed Material not stated herein are separate from and
|
349 |
+
independent of the terms and conditions of this Public License.
|
350 |
+
|
351 |
+
|
352 |
+
Section 8 -- Interpretation.
|
353 |
+
|
354 |
+
a. For the avoidance of doubt, this Public License does not, and
|
355 |
+
shall not be interpreted to, reduce, limit, restrict, or impose
|
356 |
+
conditions on any use of the Licensed Material that could lawfully
|
357 |
+
be made without permission under this Public License.
|
358 |
+
|
359 |
+
b. To the extent possible, if any provision of this Public License is
|
360 |
+
deemed unenforceable, it shall be automatically reformed to the
|
361 |
+
minimum extent necessary to make it enforceable. If the provision
|
362 |
+
cannot be reformed, it shall be severed from this Public License
|
363 |
+
without affecting the enforceability of the remaining terms and
|
364 |
+
conditions.
|
365 |
+
|
366 |
+
c. No term or condition of this Public License will be waived and no
|
367 |
+
failure to comply consented to unless expressly agreed to by the
|
368 |
+
Licensor.
|
369 |
+
|
370 |
+
d. Nothing in this Public License constitutes or may be interpreted
|
371 |
+
as a limitation upon, or waiver of, any privileges and immunities
|
372 |
+
that apply to the Licensor or You, including from the legal
|
373 |
+
processes of any jurisdiction or authority.
|
374 |
+
|
375 |
+
|
376 |
+
=======================================================================
|
377 |
+
|
378 |
+
Creative Commons is not a party to its public
|
379 |
+
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
380 |
+
its public licenses to material it publishes and in those instances
|
381 |
+
will be considered the “Licensor.” The text of the Creative Commons
|
382 |
+
public licenses is dedicated to the public domain under the CC0 Public
|
383 |
+
Domain Dedication. Except for the limited purpose of indicating that
|
384 |
+
material is shared under a Creative Commons public license or as
|
385 |
+
otherwise permitted by the Creative Commons policies published at
|
386 |
+
creativecommons.org/policies, Creative Commons does not authorize the
|
387 |
+
use of the trademark "Creative Commons" or any other trademark or logo
|
388 |
+
of Creative Commons without its prior written consent including,
|
389 |
+
without limitation, in connection with any unauthorized modifications
|
390 |
+
to any of its public licenses or any other arrangements,
|
391 |
+
understandings, or agreements concerning use of licensed material. For
|
392 |
+
the avoidance of doubt, this paragraph does not form part of the
|
393 |
+
public licenses.
|
394 |
+
|
395 |
+
Creative Commons may be contacted at creativecommons.org.
|
README.md
CHANGED
@@ -1,3 +1,259 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language_creators:
|
5 |
+
- expert-generated
|
6 |
+
license:
|
7 |
+
- cc-by-4.0
|
8 |
+
pretty_name: cannabis_licenses
|
9 |
+
size_categories:
|
10 |
+
- 10K<n<100K
|
11 |
+
source_datasets:
|
12 |
+
- original
|
13 |
+
tags:
|
14 |
+
- cannabis
|
15 |
+
- licenses
|
16 |
+
- licensees
|
17 |
---
|
18 |
+
|
19 |
+
# Cannabis Licenses, Curated by Cannlytics
|
20 |
+
|
21 |
+
## Table of Contents
|
22 |
+
- [Table of Contents](#table-of-contents)
|
23 |
+
- [Dataset Description](#dataset-description)
|
24 |
+
- [Dataset Summary](#dataset-summary)
|
25 |
+
- [Dataset Structure](#dataset-structure)
|
26 |
+
- [Data Instances](#data-instances)
|
27 |
+
- [Data Fields](#data-fields)
|
28 |
+
- [Data Splits](#data-splits)
|
29 |
+
- [Dataset Creation](#dataset-creation)
|
30 |
+
- [Curation Rationale](#curation-rationale)
|
31 |
+
- [Source Data](#source-data)
|
32 |
+
- [Data Collection and Normalization](#data-collection-and-normalization)
|
33 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
34 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
35 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
36 |
+
- [Discussion of Biases](#discussion-of-biases)
|
37 |
+
- [Other Known Limitations](#other-known-limitations)
|
38 |
+
- [Additional Information](#additional-information)
|
39 |
+
- [Dataset Curators](#dataset-curators)
|
40 |
+
- [License](#license)
|
41 |
+
- [Citation](#citation)
|
42 |
+
- [Contributions](#contributions)
|
43 |
+
|
44 |
+
## Dataset Description
|
45 |
+
|
46 |
+
- **Homepage:** <https://github.com/cannlytics/cannlytics>
|
47 |
+
- **Repository:** <https://huggingface.co/datasets/cannlytics/cannabis_licenses>
|
48 |
+
- **Point of Contact:** <dev@cannlytics.com>
|
49 |
+
|
50 |
+
### Dataset Summary
|
51 |
+
|
52 |
+
This dataset is a collection of cannabis license data for the licensees that have been permitted in the United States.
|
53 |
+
|
54 |
+
## Dataset Structure
|
55 |
+
|
56 |
+
The dataset is partitioned into subsets for each state.
|
57 |
+
|
58 |
+
|
59 |
+
| State | Licenses |
|
60 |
+
|-------|----------|
|
61 |
+
| [Alaska](#) | |
|
62 |
+
| [Arizona](#) | |
|
63 |
+
| [California](#) | ✅ |
|
64 |
+
| [Colorado](#) | |
|
65 |
+
| [Connecticut](#) | |
|
66 |
+
| [District of Columbia](#) | |
|
67 |
+
| [Illinois](#) | |
|
68 |
+
| [Maine](#) | |
|
69 |
+
| [Massachusetts](#) | |
|
70 |
+
| [Michigan](#) | |
|
71 |
+
| [Montana](#) | |
|
72 |
+
| [Nevada](#) | |
|
73 |
+
| [New Hampshire](#) | |
|
74 |
+
| [New Jersey](#) | |
|
75 |
+
| [New Mexico](#) | |
|
76 |
+
| [New York](#) | |
|
77 |
+
| [Oregon](#) | ✅ |
|
78 |
+
| [Rhode Island](#) | |
|
79 |
+
| [Vermont](#) | |
|
80 |
+
| [Washington](#) | |
|
81 |
+
|
82 |
+
|
83 |
+
### Data Instances
|
84 |
+
|
85 |
+
You can load the licenses for each state. For example:
|
86 |
+
|
87 |
+
```py
|
88 |
+
from datasets import load_dataset
|
89 |
+
|
90 |
+
# Get the licenses for a specific state.
|
91 |
+
dataset = load_dataset('cannlytics/cannabis_licenses', 'ca')
|
92 |
+
data = dataset['data']
|
93 |
+
assert len(data) > 0
|
94 |
+
print('%i licenses.' % len(data))
|
95 |
+
```
|
96 |
+
|
97 |
+
### Data Fields
|
98 |
+
|
99 |
+
Below is a non-exhaustive list of fields, used to standardize the various data that are encountered, that you may expect encounter in the parsed COA data.
|
100 |
+
|
101 |
+
| Field | Example | Description |
|
102 |
+
|-------|-----|-------------|
|
103 |
+
| `id` | `"1046"` | |
|
104 |
+
| `license_number` | `"C10-0000423-LIC"` | |
|
105 |
+
| `license_status` | `"Active"` | |
|
106 |
+
| `license_status_date` | `""` | |
|
107 |
+
| `license_term` | `"Provisional"` | |
|
108 |
+
| `license_type` | `"Commercial - Retailer"` | |
|
109 |
+
| `license_designation` | `"Adult-Use and Medicinal"` | |
|
110 |
+
| `issue_date` | `"2019-07-15T00:00:00"` | |
|
111 |
+
| `expiration_date` | `"2023-07-14T00:00:00"` | |
|
112 |
+
| `licensing_authority_id` | `"BCC"` | |
|
113 |
+
| `licensing_authority` | `"Bureau of Cannabis Control (BCC)"` | |
|
114 |
+
| `business_legal_name` | `"Movocan"` | |
|
115 |
+
| `business_dba_name` | `"Movocan"` | |
|
116 |
+
| `business_owner_name` | `"redacted"` | |
|
117 |
+
| `business_structure` | `"Corporation"` | |
|
118 |
+
| `activity` | `""` | |
|
119 |
+
| `premise_street_address` | `"1632 Gateway Rd"` | |
|
120 |
+
| `premise_city` | `"Calexico"` | |
|
121 |
+
| `premise_state` | `"CA"` | |
|
122 |
+
| `premise_county` | `"Imperial"` | |
|
123 |
+
| `premise_zip_code` | `"92231"` | |
|
124 |
+
| `business_email` | `"redacted@gmail.com"` | |
|
125 |
+
| `business_phone` | `"(555) 555-5555"` | |
|
126 |
+
| `parcel_number` | `""` | |
|
127 |
+
| `premise_latitude` | `32.69035693` | |
|
128 |
+
| `premise_longitude` | `-115.38987552` | |
|
129 |
+
| `data_refreshed_date` | `"2022-09-21T12:16:33.3866667"` | |
|
130 |
+
|
131 |
+
### Data Splits
|
132 |
+
|
133 |
+
The data is split into subsets by state. You can retrieve all licenses by requesting the `all` subset.
|
134 |
+
|
135 |
+
```py
|
136 |
+
from datasets import load_dataset
|
137 |
+
|
138 |
+
# Get all cannabis licenses.
|
139 |
+
repo = 'cannlytics/cannabis_licenses'
|
140 |
+
dataset = load_dataset(repo, 'all')
|
141 |
+
data = dataset['data']
|
142 |
+
```
|
143 |
+
|
144 |
+
## Dataset Creation
|
145 |
+
|
146 |
+
### Curation Rationale
|
147 |
+
|
148 |
+
Data about organizations operating in the cannabis industry for each state is valuable for research.
|
149 |
+
|
150 |
+
### Source Data
|
151 |
+
|
152 |
+
| State | Data Source URL |
|
153 |
+
|-------|-----------------|
|
154 |
+
| [Alaska](#) | |
|
155 |
+
| [Arizona](https://azcarecheck.azdhs.gov/s/?licenseType=null) | <https://azcarecheck.azdhs.gov/s/?licenseType=null> |
|
156 |
+
| [California](https://search.cannabis.ca.gov/) | <https://search.cannabis.ca.gov/> |
|
157 |
+
| [Colorado](#) | |
|
158 |
+
| [Connecticut](#) | |
|
159 |
+
| [District of Columbia](#) | |
|
160 |
+
| [Illinois](#) | |
|
161 |
+
| [Maine](#) | |
|
162 |
+
| [Massachusetts](#) | |
|
163 |
+
| [Michigan](#) | |
|
164 |
+
| [Montana](https://mtrevenue.gov/cannabis/#CannabisLicenses) | <https://mtrevenue.gov/cannabis/#CannabisLicenses> |
|
165 |
+
| [Nevada](https://ccb.nv.gov/list-of-licensees/) | <https://ccb.nv.gov/list-of-licensees/> |
|
166 |
+
| [New Hampshire](#) | |
|
167 |
+
| [New Jersey](#) | |
|
168 |
+
| [New Mexico](https://nmrldlpi.force.com/bcd/s/public-search-license?division=CCD&language=en_US) | <https://nmrldlpi.force.com/bcd/s/public-search-license?division=CCD&language=en_US> |
|
169 |
+
| [New York](#) | |
|
170 |
+
| [Oregon](https://www.oregon.gov/olcc/marijuana/pages/recreational-marijuana-licensing.aspx) | <https://www.oregon.gov/olcc/marijuana/pages/recreational-marijuana-licensing.aspx> |
|
171 |
+
| [Rhode Island](#) | |
|
172 |
+
| [Vermont](#) | |
|
173 |
+
| [Washington](https://lcb.wa.gov/records/frequently-requested-lists) | <https://lcb.wa.gov/records/frequently-requested-lists> |
|
174 |
+
|
175 |
+
#### Data Collection and Normalization
|
176 |
+
|
177 |
+
In the `algorithms` directory, you can find the algorithms used for data collection. You can use these algorithms to recreate the dataset. First, you will need to clone the repository:
|
178 |
+
|
179 |
+
```
|
180 |
+
git clone https://huggingface.co/datasets/cannlytics/cannabis_licenses
|
181 |
+
```
|
182 |
+
|
183 |
+
You can then install the algorithm Python (3.9+) requirements:
|
184 |
+
|
185 |
+
```
|
186 |
+
cd cannabis_licenses
|
187 |
+
pip install -r requirements.txt
|
188 |
+
```
|
189 |
+
|
190 |
+
Then you can run all of the data-collection algorithms:
|
191 |
+
|
192 |
+
```
|
193 |
+
python algorithms/main.py
|
194 |
+
```
|
195 |
+
|
196 |
+
Or you can run each algorithm individually. For example:
|
197 |
+
|
198 |
+
```
|
199 |
+
python algorithms/get_licenses_ca.py
|
200 |
+
```
|
201 |
+
|
202 |
+
### Personal and Sensitive Information
|
203 |
+
|
204 |
+
This dataset includes names of individuals, public addresses, and contact information for cannabis licensees. It is important to take care to use these data points in a legal manner.
|
205 |
+
|
206 |
+
## Considerations for Using the Data
|
207 |
+
|
208 |
+
### Social Impact of Dataset
|
209 |
+
|
210 |
+
Arguably, there is substantial social impact that could result from the study of permitted adult-use cannabis, therefore, researchers and data consumers alike should take the utmost care in the use of this dataset.
|
211 |
+
|
212 |
+
### Discussion of Biases
|
213 |
+
|
214 |
+
Cannlytics is a for-profit data and analytics company that primarily serves cannabis businesses. The data are not randomly collected and thus sampling bias should be taken into consideration.
|
215 |
+
|
216 |
+
### Other Known Limitations
|
217 |
+
|
218 |
+
The data is for adult-use cannabis licenses. It would be valuable to include medical cannabis licenses too.
|
219 |
+
|
220 |
+
## Additional Information
|
221 |
+
|
222 |
+
### Dataset Curators
|
223 |
+
|
224 |
+
Curated by [🔥Cannlytics](https://cannlytics.com)<br>
|
225 |
+
<dev@cannlytics.com>
|
226 |
+
|
227 |
+
### License
|
228 |
+
|
229 |
+
```
|
230 |
+
Copyright (c) 2022 Cannlytics and the Cannabis Data Science Team
|
231 |
+
|
232 |
+
The files associated with this dataset are licensed under a
|
233 |
+
Creative Commons Attribution 4.0 International license.
|
234 |
+
|
235 |
+
You can share, copy and modify this dataset so long as you give
|
236 |
+
appropriate credit, provide a link to the CC BY license, and
|
237 |
+
indicate if changes were made, but you may not do so in a way
|
238 |
+
that suggests the rights holder has endorsed you or your use of
|
239 |
+
the dataset. Note that further permission may be required for
|
240 |
+
any content within the dataset that is identified as belonging
|
241 |
+
to a third party.
|
242 |
+
```
|
243 |
+
|
244 |
+
### Citation
|
245 |
+
|
246 |
+
Please cite the following if you use the code examples in your research:
|
247 |
+
|
248 |
+
```bibtex
|
249 |
+
@misc{cannlytics2022,
|
250 |
+
title={Cannabis Data Science},
|
251 |
+
author={Skeate, Keegan},
|
252 |
+
journal={https://github.com/cannlytics/cannabis-data-science},
|
253 |
+
year={2022}
|
254 |
+
}
|
255 |
+
```
|
256 |
+
|
257 |
+
### Contributions
|
258 |
+
|
259 |
+
Thanks to [🔥Cannlytics](https://cannlytics.com), [@candy-o](https://github.com/candy-o), [@keeganskeate](https://github.com/keeganskeate), and the entire [Cannabis Data Science Team](https://meetup.com/cannabis-data-science/members) for their contributions.
|
algorithms/get_licenses_az.py
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Cannabis Licenses | Get Arizona Licenses
|
3 |
+
Copyright (c) 2022 Cannlytics
|
4 |
+
|
5 |
+
Authors:
|
6 |
+
Keegan Skeate <https://github.com/keeganskeate>
|
7 |
+
Created: 9/27/2022
|
8 |
+
Updated: 9/27/2022
|
9 |
+
License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
|
10 |
+
|
11 |
+
Description:
|
12 |
+
|
13 |
+
Collect Arizona cannabis license data.
|
14 |
+
|
15 |
+
Data Source:
|
16 |
+
|
17 |
+
- Arizona Department of Health Services | Division of Licensing
|
18 |
+
URL: <https://azcarecheck.azdhs.gov/s/?licenseType=null>
|
19 |
+
|
20 |
+
"""
|
21 |
+
# Standard imports.
|
22 |
+
from datetime import datetime
|
23 |
+
import os
|
24 |
+
from time import sleep
|
25 |
+
|
26 |
+
# External imports.
|
27 |
+
from cannlytics.utils import camel_to_snake
|
28 |
+
from cannlytics.utils.constants import DEFAULT_HEADERS
|
29 |
+
import matplotlib.pyplot as plt
|
30 |
+
import pandas as pd
|
31 |
+
import requests
|
32 |
+
import seaborn as sns
|
33 |
+
|
34 |
+
|
35 |
+
# Specify where your data lives.
|
36 |
+
DATA_DIR = '../data/az'
|
37 |
+
PDF_DIR = '../data/mt/pdfs'
|
38 |
+
|
39 |
+
# Create directories if necessary.
|
40 |
+
if not os.path.exists(DATA_DIR): os.makedirs(DATA_DIR)
|
41 |
+
if not os.path.exists(PDF_DIR): os.makedirs(PDF_DIR)
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
# # Define the license data API.
|
46 |
+
# base = 'https://as-cdt-pub-vip-cannabis-ww-p-002.azurewebsites.net'
|
47 |
+
# endpoint = '/licenses/filteredSearch'
|
48 |
+
# query = f'{base}{endpoint}'
|
49 |
+
# params = {'pageSize': 50, 'searchQuery': ''}
|
50 |
+
|
51 |
+
# # Iterate over all of the pages to get all of the data.
|
52 |
+
# iterate = True
|
53 |
+
# page = 1
|
54 |
+
# licenses = []
|
55 |
+
# verbose = True
|
56 |
+
# while(iterate):
|
57 |
+
# params['pageNumber'] = page
|
58 |
+
# response = requests.get(query, headers=DEFAULT_HEADERS, params=params)
|
59 |
+
# body = response.json()
|
60 |
+
# data = body['data']
|
61 |
+
# licenses.extend(data)
|
62 |
+
# if not body['metadata']['hasNext']:
|
63 |
+
# iterate = False
|
64 |
+
# if verbose:
|
65 |
+
# print('Recorded %i/%i pages.' % (page, body['metadata']['totalPages']))
|
66 |
+
# page += 1
|
67 |
+
# sleep(0.2)
|
68 |
+
|
69 |
+
# # Standardize the licensee data.
|
70 |
+
# license_data = pd.DataFrame(licenses)
|
71 |
+
# columns = list(license_data.columns)
|
72 |
+
# columns = [camel_to_snake(x) for x in columns]
|
73 |
+
# license_data.columns = columns
|
74 |
+
|
75 |
+
# # Save the data locally.
|
76 |
+
# timestamp = datetime.now().isoformat()[:19].replace(':', '-')
|
77 |
+
# license_data.to_excel(f'{DATA_DIR}/licenses-ca-{timestamp}.xlsx')
|
78 |
+
|
79 |
+
# # Optional: Archive the licensee data in Firebase.
|
80 |
+
# from cannlytics.firebase import initialize_firebase, update_documents
|
81 |
+
# n = 420
|
82 |
+
# database = initialize_firebase()
|
83 |
+
# collection = 'public/data/licenses'
|
84 |
+
# shards = [df[i:i + n] for i in range(0, df.shape[0], n)]
|
85 |
+
# for shard in shards:
|
86 |
+
# refs = shard['license_number'].apply(lambda x: f'{collection}/{x}')
|
87 |
+
# docs = shard.to_dict('records')
|
88 |
+
# update_documents(refs, docs, database=database)
|
89 |
+
|
90 |
+
# # Create a scatterplot of latitude and longitude with hue as license type.
|
91 |
+
# sns.scatterplot(
|
92 |
+
# data=license_data.loc[
|
93 |
+
# (~license_data['premise_longitude'].isnull()) &
|
94 |
+
# (~license_data['premise_latitude'].isnull())
|
95 |
+
# ],
|
96 |
+
# x='premise_longitude',
|
97 |
+
# y='premise_latitude',
|
98 |
+
# hue='license_type',
|
99 |
+
# )
|
100 |
+
# plt.show()
|
algorithms/get_licenses_ca.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Cannabis Licenses | Get California Licenses
|
3 |
+
Copyright (c) 2022 Cannlytics
|
4 |
+
|
5 |
+
Authors:
|
6 |
+
Keegan Skeate <https://github.com/keeganskeate>
|
7 |
+
Created: 9/16/2022
|
8 |
+
Updated: 9/27/2022
|
9 |
+
License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
|
10 |
+
|
11 |
+
Description:
|
12 |
+
|
13 |
+
Collect California cannabis license data.
|
14 |
+
|
15 |
+
Data Source:
|
16 |
+
|
17 |
+
- California Department of Cannabis Control Cannabis Unified License Search
|
18 |
+
URL: <https://search.cannabis.ca.gov/>
|
19 |
+
|
20 |
+
"""
|
21 |
+
# Standard imports.
|
22 |
+
from datetime import datetime
|
23 |
+
import os
|
24 |
+
from time import sleep
|
25 |
+
from typing import Optional
|
26 |
+
|
27 |
+
# External imports.
|
28 |
+
from cannlytics.utils import camel_to_snake
|
29 |
+
from cannlytics.utils.constants import DEFAULT_HEADERS
|
30 |
+
import pandas as pd
|
31 |
+
import requests
|
32 |
+
|
33 |
+
|
34 |
+
# Specify where your data lives.
|
35 |
+
DATA_DIR = '../data/ca'
|
36 |
+
|
37 |
+
|
38 |
+
def get_licenses_ca(
|
39 |
+
data_dir: Optional[str] = None,
|
40 |
+
page_size: Optional[int] = 50,
|
41 |
+
pause: Optional[float] = 0.2,
|
42 |
+
starting_page: Optional[int] = 1,
|
43 |
+
ending_page: Optional[int] = None,
|
44 |
+
verbose: Optional[bool] = False,
|
45 |
+
search: Optional[str] = '',
|
46 |
+
):
|
47 |
+
"""Get California cannabis license data."""
|
48 |
+
|
49 |
+
# Define the license data API.
|
50 |
+
base = 'https://as-cdt-pub-vip-cannabis-ww-p-002.azurewebsites.net'
|
51 |
+
endpoint = '/licenses/filteredSearch'
|
52 |
+
query = f'{base}{endpoint}'
|
53 |
+
params = {'pageSize': page_size, 'searchQuery': search}
|
54 |
+
|
55 |
+
# Iterate over all of the pages to get all of the data.
|
56 |
+
page = int(starting_page)
|
57 |
+
licenses = []
|
58 |
+
iterate = True
|
59 |
+
while(iterate):
|
60 |
+
params['pageNumber'] = page
|
61 |
+
response = requests.get(query, headers=DEFAULT_HEADERS, params=params)
|
62 |
+
body = response.json()
|
63 |
+
data = body['data']
|
64 |
+
licenses.extend(data)
|
65 |
+
if not body['metadata']['hasNext']:
|
66 |
+
iterate = False
|
67 |
+
if verbose:
|
68 |
+
print('Recorded %i/%i pages.' % (page, body['metadata']['totalPages']))
|
69 |
+
if ending_page is not None:
|
70 |
+
if page == ending_page:
|
71 |
+
iterate = False
|
72 |
+
page += 1
|
73 |
+
sleep(pause)
|
74 |
+
|
75 |
+
# Standardize the licensee data.
|
76 |
+
license_data = pd.DataFrame(licenses)
|
77 |
+
columns = list(license_data.columns)
|
78 |
+
columns = [camel_to_snake(x) for x in columns]
|
79 |
+
license_data.columns = columns
|
80 |
+
|
81 |
+
# Save and return the data.
|
82 |
+
if data_dir is not None:
|
83 |
+
if not os.path.exists(data_dir): os.makedirs(data_dir)
|
84 |
+
timestamp = datetime.now().isoformat()[:19].replace(':', '-')
|
85 |
+
license_data.to_excel(f'{data_dir}/licenses-ca-{timestamp}.xlsx')
|
86 |
+
return license_data
|
87 |
+
|
88 |
+
if __name__ == '__main__':
|
89 |
+
|
90 |
+
# Support command line usage.
|
91 |
+
import argparse
|
92 |
+
try:
|
93 |
+
arg_parser = argparse.ArgumentParser()
|
94 |
+
arg_parser.add_argument('--d', dest='data_dir', type=str)
|
95 |
+
arg_parser.add_argument('--data_dir', dest='data_dir', type=str)
|
96 |
+
# Future work: Support the rest of the arguments from the CL.
|
97 |
+
args = arg_parser.parse_args()
|
98 |
+
except SystemExit:
|
99 |
+
args = {'d': DATA_DIR}
|
100 |
+
|
101 |
+
# Get California licenses, saving them to the specified directory.
|
102 |
+
data_dir = args.get('d', args.get('data_dir'))
|
103 |
+
get_licenses_ca(data_dir)
|
algorithms/get_licenses_mt.py
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Cannabis Licenses | Get Montana Licenses
|
3 |
+
Copyright (c) 2022 Cannlytics
|
4 |
+
|
5 |
+
Authors:
|
6 |
+
Keegan Skeate <https://github.com/keeganskeate>
|
7 |
+
Created: 9/27/2022
|
8 |
+
Updated: 9/28/2022
|
9 |
+
License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
|
10 |
+
|
11 |
+
Description:
|
12 |
+
|
13 |
+
Collect Montana cannabis license data.
|
14 |
+
|
15 |
+
Data Source:
|
16 |
+
|
17 |
+
- Montana Department of Revenue | Cannabis Control Division
|
18 |
+
URL: <https://mtrevenue.gov/cannabis/#CannabisLicenses>
|
19 |
+
|
20 |
+
"""
|
21 |
+
# Standard imports.
|
22 |
+
from datetime import datetime
|
23 |
+
import os
|
24 |
+
from time import sleep
|
25 |
+
|
26 |
+
# External imports.
|
27 |
+
from bs4 import BeautifulSoup
|
28 |
+
from cannlytics.utils import camel_to_snake
|
29 |
+
from cannlytics.utils.constants import DEFAULT_HEADERS
|
30 |
+
import pdfplumber
|
31 |
+
import requests
|
32 |
+
|
33 |
+
|
34 |
+
# Specify where your data lives.
|
35 |
+
DATA_DIR = '../data/mt'
|
36 |
+
PDF_DIR = '../data/mt/pdfs'
|
37 |
+
|
38 |
+
MONTANA = {
|
39 |
+
'retailers': {
|
40 |
+
'url': 'https://mtrevenue.gov/?mdocs-file=60245',
|
41 |
+
'columns': ['city', 'dba', 'license_type', 'phone']
|
42 |
+
},
|
43 |
+
'processors': {'url': 'https://mtrevenue.gov/?mdocs-file=60250'},
|
44 |
+
'cultivators': {'url': 'https://mtrevenue.gov/?mdocs-file=60252'},
|
45 |
+
'labs': {'url': 'https://mtrevenue.gov/?mdocs-file=60248'},
|
46 |
+
'transporters': {'url': 'https://mtrevenue.gov/?mdocs-file=72489'},
|
47 |
+
}
|
48 |
+
|
49 |
+
# Create directories if necessary.
|
50 |
+
if not os.path.exists(DATA_DIR): os.makedirs(DATA_DIR)
|
51 |
+
if not os.path.exists(PDF_DIR): os.makedirs(PDF_DIR)
|
52 |
+
|
53 |
+
|
54 |
+
# Download the retailers PDF.
|
55 |
+
timestamp = datetime.now().isoformat()[:19].replace(':', '-')
|
56 |
+
outfile = f'{PDF_DIR}/mt-retailers-{timestamp}.pdf'
|
57 |
+
response = requests.get(MONTANA['retailers']['url'], headers=DEFAULT_HEADERS)
|
58 |
+
with open(outfile, 'wb') as pdf:
|
59 |
+
pdf.write(response.content)
|
60 |
+
|
61 |
+
# Extract the data from the PDF.
|
62 |
+
rows = []
|
63 |
+
skip_lines = ['GOVERNOR ', 'DIRECTOR ', 'Cannabis Control Division',
|
64 |
+
'Licensed Dispensary locations', 'Please note', 'registered ',
|
65 |
+
'City Location Name Sales Type Phone Number', 'Page ']
|
66 |
+
doc = pdfplumber.open(outfile)
|
67 |
+
for page in doc.pages:
|
68 |
+
text = page.extract_text()
|
69 |
+
lines = text.split('\n')
|
70 |
+
for line in lines:
|
71 |
+
skip = False
|
72 |
+
for skip_line in skip_lines:
|
73 |
+
if line.startswith(skip_line):
|
74 |
+
skip = True
|
75 |
+
break
|
76 |
+
if skip:
|
77 |
+
continue
|
78 |
+
rows.append(line)
|
79 |
+
|
80 |
+
# Collect licensee data.
|
81 |
+
licensees = []
|
82 |
+
for row in rows:
|
83 |
+
|
84 |
+
# FIXME: Rows with double-line text get cut-off.
|
85 |
+
if '(' not in row:
|
86 |
+
continue
|
87 |
+
|
88 |
+
obs = {}
|
89 |
+
if 'Adult Use' in row:
|
90 |
+
parts = row.split('Adult Use')
|
91 |
+
obs['license_type'] = 'Adult Use'
|
92 |
+
else:
|
93 |
+
parts = row.split('Medical Only')
|
94 |
+
obs['license_type'] = 'Medical Only'
|
95 |
+
obs['dba'] = parts[0].strip()
|
96 |
+
obs['phone'] = parts[-1].strip()
|
97 |
+
licensees.append(obs)
|
98 |
+
|
99 |
+
# Get a list of Montana cities.
|
100 |
+
cities = []
|
101 |
+
# response = requests.get('http://www.mlct.org/', headers=DEFAULT_HEADERS)
|
102 |
+
# soup = BeautifulSoup(response.content, 'html.parser')
|
103 |
+
# table = soup.find('table')
|
104 |
+
# for tr in table.findAll('tr'):
|
105 |
+
# if not tr.text.strip().replace('\n', ''):
|
106 |
+
# continue
|
107 |
+
# city = tr.find('td').text
|
108 |
+
# if '©' in city or ',' in city or '\n' in city or city == 'Home' or city == 'City':
|
109 |
+
# continue
|
110 |
+
# cities.append(city)
|
111 |
+
|
112 |
+
# remove_lines = ['RESOURCES', 'Official State Website', 'State Legislature',
|
113 |
+
# 'Chamber of Commerce', 'Contact Us']
|
114 |
+
# for ele in remove_lines:
|
115 |
+
# cities.remove(ele)
|
116 |
+
|
117 |
+
# FIXME:
|
118 |
+
url = 'https://dojmt.gov/wp-content/uploads/2011/05/mvmtcitiescountieszips.pdf'
|
119 |
+
|
120 |
+
# TODO: Separate `city` from `dba` using list of Montana cities.
|
121 |
+
for i, licensee in enumerate(licensees):
|
122 |
+
dba = licensee['dba']
|
123 |
+
city_found = False
|
124 |
+
for city in cities:
|
125 |
+
city_name = city.upper()
|
126 |
+
if city_name in dba:
|
127 |
+
licensees[i]['dba'] = dba.replace(city_name, '').strip()
|
128 |
+
licensees[i]['city'] = city
|
129 |
+
city_found = True
|
130 |
+
break
|
131 |
+
if not city_found:
|
132 |
+
print("Couldn't identify city:", dba)
|
133 |
+
|
134 |
+
|
135 |
+
# TODO: Remove duplicates.
|
136 |
+
|
137 |
+
|
138 |
+
# TODO: Lookup the address of the licenses?
|
algorithms/get_licenses_or.py
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Cannabis Licenses | Get Oregon Licenses
|
3 |
+
Copyright (c) 2022 Cannlytics
|
4 |
+
|
5 |
+
Authors:
|
6 |
+
Keegan Skeate <https://github.com/keeganskeate>
|
7 |
+
Created: 9/28/2022
|
8 |
+
Updated: 9/28/2022
|
9 |
+
License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
|
10 |
+
|
11 |
+
Description:
|
12 |
+
|
13 |
+
Collect Oregon cannabis license data.
|
14 |
+
|
15 |
+
Data Source:
|
16 |
+
|
17 |
+
- Oregon Liquor and Cannabis Commission
|
18 |
+
URL: <https://www.oregon.gov/olcc/marijuana/pages/recreational-marijuana-licensing.aspx>
|
19 |
+
|
20 |
+
"""
|
21 |
+
# Standard imports.
|
22 |
+
from datetime import datetime
|
23 |
+
import os
|
24 |
+
from typing import Optional
|
25 |
+
|
26 |
+
# External imports.
|
27 |
+
from dotenv import dotenv_values
|
28 |
+
import pandas as pd
|
29 |
+
import requests
|
30 |
+
from cannlytics.data.gis import geocode_addresses
|
31 |
+
|
32 |
+
|
33 |
+
# Specify where your data lives.
|
34 |
+
DATA_DIR = '../data/or'
|
35 |
+
|
36 |
+
# Specify state-specific constants.
|
37 |
+
OREGON = {
|
38 |
+
'licensing_authority_id': 'OLCC',
|
39 |
+
'licensing_authority': 'Oregon Liquor and Cannabis Commission',
|
40 |
+
'licenses': {
|
41 |
+
'url': 'https://www.oregon.gov/olcc/marijuana/Documents/MarijuanaLicenses_Approved.xlsx',
|
42 |
+
},
|
43 |
+
'retailers': {
|
44 |
+
'url': 'https://www.oregon.gov/olcc/marijuana/Documents/Approved_Retail_Licenses.xlsx',
|
45 |
+
'columns': {
|
46 |
+
'TRADE NAME': 'business_dba_name',
|
47 |
+
'POSTAL CITY': 'premise_city',
|
48 |
+
'COUNTY': 'premise_county',
|
49 |
+
'STREET ADDRESS': 'premise_street_address',
|
50 |
+
'ZIP': 'premise_zip_code',
|
51 |
+
'Med Grade': 'medicinal',
|
52 |
+
'Delivery': 'delivery',
|
53 |
+
},
|
54 |
+
},
|
55 |
+
}
|
56 |
+
|
57 |
+
def get_licenses_or(
|
58 |
+
data_dir: Optional[str] = None,
|
59 |
+
env_file: Optional[str] = '.env',
|
60 |
+
# Optional: Add print statements.
|
61 |
+
# verbose: Optional[bool] = False,
|
62 |
+
):
|
63 |
+
"""Get California cannabis license data."""
|
64 |
+
|
65 |
+
# Create the necessary directories.
|
66 |
+
file_dir = f'{data_dir}/.datasets'
|
67 |
+
if not os.path.exists(data_dir): os.makedirs(data_dir)
|
68 |
+
if not os.path.exists(file_dir): os.makedirs(file_dir)
|
69 |
+
|
70 |
+
# Download the data workbooks.
|
71 |
+
timestamp = datetime.now().isoformat()[:19].replace(':', '-')
|
72 |
+
outfile = f'{file_dir}/retailers-or-{timestamp}.xlsx'
|
73 |
+
response = requests.get(OREGON['retailers']['url'])
|
74 |
+
with open(outfile, 'wb') as doc:
|
75 |
+
doc.write(response.content)
|
76 |
+
|
77 |
+
# Extract data from the workbooks, removing the footnote.
|
78 |
+
data = pd.read_excel(outfile, skiprows=3)
|
79 |
+
data = data[:-1]
|
80 |
+
data.rename(columns=OREGON['retailers']['columns'], inplace=True)
|
81 |
+
|
82 |
+
# Optional: Remove licenses with an asterisk (*).
|
83 |
+
|
84 |
+
# Curate the data.
|
85 |
+
data['licensing_authority_id'] = OREGON['licensing_authority_id']
|
86 |
+
data['licensing_authority'] = OREGON['licensing_authority']
|
87 |
+
data['license_status'] = 'Active'
|
88 |
+
data['license_designation'] = 'Adult-Use'
|
89 |
+
data['premise_state'] = 'OR'
|
90 |
+
data.loc[data['medicinal'] == 'Yes', 'license_designation'] = 'Adult-Use and Medicinal'
|
91 |
+
|
92 |
+
# Convert `medicinal` and `delivery` columns to boolean.
|
93 |
+
data['medicinal'] = data['medicinal'].map(dict(Yes=1))
|
94 |
+
data['delivery'] = data['delivery'].map(dict(Yes=1))
|
95 |
+
data['medicinal'].fillna(0, inplace=True)
|
96 |
+
data['delivery'].fillna(0, inplace=True)
|
97 |
+
|
98 |
+
# Convert certain columns from upper case title case.
|
99 |
+
cols = ['business_dba_name', 'premise_city', 'premise_county',
|
100 |
+
'premise_street_address']
|
101 |
+
for col in cols:
|
102 |
+
data[col] = data[col].apply(lambda x: x.title().strip())
|
103 |
+
|
104 |
+
# Convert zip code to a string.
|
105 |
+
data.loc[:, 'premise_zip_code'] = data['premise_zip_code'].apply(lambda x: str(int(x)))
|
106 |
+
|
107 |
+
# Get the `data_refreshed_date`.
|
108 |
+
df = pd.read_excel(outfile, index_col=None, usecols='C', header=1, nrows=0)
|
109 |
+
header = df.columns.values[0]
|
110 |
+
date = pd.to_datetime(header.split(' ')[-1])
|
111 |
+
data['data_refreshed_date'] = date.isoformat()
|
112 |
+
|
113 |
+
# Get the `license_number` and `license_type` from license list.
|
114 |
+
license_file = f'{file_dir}/licenses-or-{timestamp}.xlsx'
|
115 |
+
response = requests.get(OREGON['licenses']['url'])
|
116 |
+
with open(license_file, 'wb') as doc:
|
117 |
+
doc.write(response.content)
|
118 |
+
licenses = pd.read_excel(license_file, skiprows=2)
|
119 |
+
licenses['BUSINESS NAME'] = licenses['BUSINESS NAME'].apply(
|
120 |
+
lambda x: str(x).title().strip(),
|
121 |
+
)
|
122 |
+
licenses = licenses.loc[licenses['LICENSE TYPE'] == 'Recreational Retailer']
|
123 |
+
data = pd.merge(
|
124 |
+
data,
|
125 |
+
licenses[['BUSINESS NAME', 'COUNTY', 'LICENSE NUMBER', 'LICENSE TYPE']],
|
126 |
+
left_on=['business_dba_name', 'premise_county'],
|
127 |
+
right_on=['BUSINESS NAME', 'COUNTY'],
|
128 |
+
how='left',
|
129 |
+
)
|
130 |
+
|
131 |
+
# Clean the merged columns.
|
132 |
+
data.drop_duplicates(subset='premise_street_address', inplace=True)
|
133 |
+
columns = {
|
134 |
+
'LICENSE NUMBER': 'license_number',
|
135 |
+
'LICENSE TYPE': 'license_type',
|
136 |
+
}
|
137 |
+
data.rename(columns=columns, inplace=True)
|
138 |
+
data.drop(columns=['BUSINESS NAME', 'COUNTY'], inplace=True)
|
139 |
+
|
140 |
+
# Geocode licenses to get `premise_latitude` and `premise_longitude`.
|
141 |
+
config = dotenv_values(env_file)
|
142 |
+
google_maps_api_key = config['GOOGLE_MAPS_API_KEY']
|
143 |
+
cols = ['premise_street_address', 'premise_city', 'premise_state',
|
144 |
+
'premise_zip_code']
|
145 |
+
data['address'] = data[cols].apply(
|
146 |
+
lambda row: ', '.join(row.values.astype(str)),
|
147 |
+
axis=1,
|
148 |
+
)
|
149 |
+
data = geocode_addresses(
|
150 |
+
data,
|
151 |
+
api_key=google_maps_api_key,
|
152 |
+
address_field='address',
|
153 |
+
)
|
154 |
+
drop_cols = ['state', 'state_name', 'county', 'address']
|
155 |
+
data.drop(columns=drop_cols, inplace=True)
|
156 |
+
gis_cols = {
|
157 |
+
'latitude': 'premise_latitude',
|
158 |
+
'longitude': 'premise_longitude'
|
159 |
+
}
|
160 |
+
data.rename(columns=gis_cols, inplace=True)
|
161 |
+
|
162 |
+
# Optional: Lookup details by searching for business' websites.
|
163 |
+
# - business_email
|
164 |
+
# - business_phone
|
165 |
+
|
166 |
+
# Optional: Create fields for standardization:
|
167 |
+
# - id
|
168 |
+
|
169 |
+
# Save the license data.
|
170 |
+
if data_dir is not None:
|
171 |
+
timestamp = datetime.now().isoformat()[:19].replace(':', '-')
|
172 |
+
data.to_excel(f'{data_dir}/licenses-or-{timestamp}.xlsx')
|
173 |
+
return data
|
174 |
+
|
175 |
+
|
176 |
+
if __name__ == '__main__':
|
177 |
+
|
178 |
+
# Support command line usage.
|
179 |
+
import argparse
|
180 |
+
try:
|
181 |
+
arg_parser = argparse.ArgumentParser()
|
182 |
+
arg_parser.add_argument('--d', dest='data_dir', type=str)
|
183 |
+
arg_parser.add_argument('--data_dir', dest='data_dir', type=str)
|
184 |
+
arg_parser.add_argument('--env', dest='env_file', type=str)
|
185 |
+
args = arg_parser.parse_args()
|
186 |
+
except SystemExit:
|
187 |
+
args = {'d': DATA_DIR, 'env_file': '../.env'}
|
188 |
+
|
189 |
+
# Get California licenses, saving them to the specified directory.
|
190 |
+
data_dir = args.get('d', args.get('data_dir'))
|
191 |
+
env_file = args.get('env_file')
|
192 |
+
get_licenses_or(data_dir, env_file=env_file)
|
analysis/figures/cannabis-licenses-map.html
ADDED
The diff for this file is too large to render.
See raw diff
|
|
analysis/license_map.py
ADDED
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Interstate Cannabis Commerce
|
3 |
+
Copyright (c) 2022 Cannlytics
|
4 |
+
|
5 |
+
Authors:
|
6 |
+
Keegan Skeate <https://github.com/keeganskeate>
|
7 |
+
Created: 9/22/2022
|
8 |
+
Updated: 9/28/2022
|
9 |
+
License: <https://github.com/cannlytics/cannabis-data-science/blob/main/LICENSE>
|
10 |
+
|
11 |
+
Description:
|
12 |
+
|
13 |
+
Map the adult-use cannabis retailers permitted in the United States.
|
14 |
+
|
15 |
+
Data Sources (16):
|
16 |
+
|
17 |
+
- Alaska
|
18 |
+
URL: <>
|
19 |
+
|
20 |
+
- Arizona Department of Health Services | Division of Licensing
|
21 |
+
URL: <https://azcarecheck.azdhs.gov/s/?licenseType=null>
|
22 |
+
|
23 |
+
- Colorado
|
24 |
+
URL: <>
|
25 |
+
|
26 |
+
- Connecticut
|
27 |
+
URL: <>
|
28 |
+
|
29 |
+
- Illinois
|
30 |
+
URL: <>
|
31 |
+
|
32 |
+
- Maine
|
33 |
+
URL: <>
|
34 |
+
|
35 |
+
- Massachusetts
|
36 |
+
URL: <>
|
37 |
+
|
38 |
+
- Michigan
|
39 |
+
URL: <>
|
40 |
+
|
41 |
+
- Montana Department of Revenue | Cannabis Control Division
|
42 |
+
URL: <https://mtrevenue.gov/cannabis/#CannabisLicenses>
|
43 |
+
|
44 |
+
- New Mexico
|
45 |
+
URL: <https://nmrldlpi.force.com/bcd/s/public-search-license?division=CCD&language=en_US>
|
46 |
+
|
47 |
+
- Nevada Cannabis Compliance Board | Nevada Cannabis Licensees
|
48 |
+
URL: <https://ccb.nv.gov/list-of-licensees/>
|
49 |
+
|
50 |
+
- New Jersey
|
51 |
+
URL: <>
|
52 |
+
|
53 |
+
- Oregon Liquor and Cannabis Commission
|
54 |
+
URL: <https://www.oregon.gov/olcc/marijuana/pages/recreational-marijuana-licensing.aspx>
|
55 |
+
|
56 |
+
- Rhode Island
|
57 |
+
URL: <>
|
58 |
+
|
59 |
+
- Vermont
|
60 |
+
URL: <>
|
61 |
+
|
62 |
+
- Washington
|
63 |
+
URL: <https://lcb.wa.gov/records/frequently-requested-lists>
|
64 |
+
|
65 |
+
Coming Soon (3):
|
66 |
+
|
67 |
+
- New York
|
68 |
+
- Virginia
|
69 |
+
- D.C.
|
70 |
+
|
71 |
+
Medical (17):
|
72 |
+
|
73 |
+
- Utah
|
74 |
+
- Oklahoma
|
75 |
+
- North Dakota
|
76 |
+
- South Dakota
|
77 |
+
- Minnesota
|
78 |
+
- Missouri
|
79 |
+
- Arkansas
|
80 |
+
- Louisiana
|
81 |
+
- Mississippi
|
82 |
+
- Alabama
|
83 |
+
- Florida
|
84 |
+
- Ohio
|
85 |
+
- West Virginia
|
86 |
+
- Pennsylvania
|
87 |
+
- Maryland
|
88 |
+
- Delaware
|
89 |
+
- New Hampshire
|
90 |
+
|
91 |
+
"""
|
92 |
+
# Standard imports.
|
93 |
+
|
94 |
+
# External imports.
|
95 |
+
import folium
|
96 |
+
import matplotlib.pyplot as plt
|
97 |
+
import pandas as pd
|
98 |
+
import seaborn as sns
|
99 |
+
|
100 |
+
|
101 |
+
# Specify where your data lives.
|
102 |
+
DATA_DIR = '../data'
|
103 |
+
|
104 |
+
#-----------------------------------------------------------------------
|
105 |
+
# Get the data.
|
106 |
+
#-----------------------------------------------------------------------
|
107 |
+
|
108 |
+
# California retailers.
|
109 |
+
filename = f'{DATA_DIR}/ca/licenses-ca-2022-09-21T19-02-29.xlsx'
|
110 |
+
ca_licenses = pd.read_excel(filename, index_col=0)
|
111 |
+
|
112 |
+
# Alaska retailers.
|
113 |
+
|
114 |
+
# Arizona retailers.
|
115 |
+
|
116 |
+
# Colorado retailers.
|
117 |
+
|
118 |
+
# Connecticut retailers.
|
119 |
+
|
120 |
+
# Illinois retailers.
|
121 |
+
|
122 |
+
# Maine retailers.
|
123 |
+
|
124 |
+
# Massachusetts retailers.
|
125 |
+
|
126 |
+
# Michigan retailers.
|
127 |
+
|
128 |
+
# Montana retailers.
|
129 |
+
|
130 |
+
# New Mexico retailers.
|
131 |
+
|
132 |
+
# Nevada retailers.
|
133 |
+
|
134 |
+
# New Jersey retailers.
|
135 |
+
|
136 |
+
# Oregon retailers.
|
137 |
+
filename = f'{DATA_DIR}/or/licenses-or-2022-09-28T10-11-12.xlsx'
|
138 |
+
or_licenses = pd.read_excel(filename, index_col=0)
|
139 |
+
|
140 |
+
# Rhode Island retailers.
|
141 |
+
|
142 |
+
# Vermont retailers.
|
143 |
+
|
144 |
+
# Washington retailers.
|
145 |
+
|
146 |
+
|
147 |
+
#-----------------------------------------------------------------------
|
148 |
+
# Look at the data!
|
149 |
+
#-----------------------------------------------------------------------
|
150 |
+
|
151 |
+
# Aggregate all of the retailer data.
|
152 |
+
retailers = pd.concat([
|
153 |
+
ca_licenses,
|
154 |
+
or_licenses,
|
155 |
+
])
|
156 |
+
retailers = retailers.loc[
|
157 |
+
(~retailers['premise_longitude'].isnull()) &
|
158 |
+
(~retailers['premise_latitude'].isnull())
|
159 |
+
]
|
160 |
+
|
161 |
+
# Create a scatterplot of latitude and longitude with hue as license type.
|
162 |
+
sns.scatterplot(
|
163 |
+
data=retailers,
|
164 |
+
x='premise_longitude',
|
165 |
+
y='premise_latitude',
|
166 |
+
hue='license_type',
|
167 |
+
)
|
168 |
+
plt.show()
|
169 |
+
|
170 |
+
# Optional: Create a nice static map.
|
171 |
+
|
172 |
+
# Create an interactive map.
|
173 |
+
locations = retailers[['premise_latitude', 'premise_longitude']].to_numpy()
|
174 |
+
m = folium.Map(
|
175 |
+
location=[45.5236, -122.6750],
|
176 |
+
zoom_start=4,
|
177 |
+
control_scale=True,
|
178 |
+
)
|
179 |
+
for index, row in retailers.iterrows():
|
180 |
+
folium.Circle(
|
181 |
+
radius=10,
|
182 |
+
location=[row['premise_latitude'], row['premise_longitude']],
|
183 |
+
color='crimson',
|
184 |
+
).add_to(m)
|
185 |
+
m.save('figures/cannabis-licenses-map.html')
|
186 |
+
|
187 |
+
|
188 |
+
#-----------------------------------------------------------------------
|
189 |
+
# Get supplementary data.
|
190 |
+
#-----------------------------------------------------------------------
|
191 |
+
|
192 |
+
from bs4 import BeautifulSoup
|
193 |
+
from cannlytics.data.gis import get_state_population
|
194 |
+
from cannlytics.utils.constants import state_names
|
195 |
+
from dotenv import dotenv_values
|
196 |
+
from fredapi import Fred
|
197 |
+
import requests
|
198 |
+
|
199 |
+
# Read your FRED API key.
|
200 |
+
config = dotenv_values('../.env')
|
201 |
+
fred_api_key = config['FRED_API_KEY']
|
202 |
+
|
203 |
+
# Get the population for each state (in 2021).
|
204 |
+
state_data = {}
|
205 |
+
for state, abbv in state_names.items():
|
206 |
+
population = get_state_population(
|
207 |
+
abbv,
|
208 |
+
fred_api_key=fred_api_key,
|
209 |
+
obs_start='2021-01-01',
|
210 |
+
)
|
211 |
+
state_data[state] = {'population': population['population']}
|
212 |
+
|
213 |
+
# Get the square miles of land for each state.
|
214 |
+
url = 'https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_area'
|
215 |
+
response = requests.get(url).text
|
216 |
+
soup = BeautifulSoup(response, 'lxml')
|
217 |
+
table = soup.find('table', class_='wikitable')
|
218 |
+
for items in table.find_all('tr'):
|
219 |
+
data = items.find_all(['th', 'td'])
|
220 |
+
if data:
|
221 |
+
try:
|
222 |
+
rank = int(data[1].text)
|
223 |
+
except:
|
224 |
+
continue
|
225 |
+
state = data[0].text.replace('\n', '')
|
226 |
+
land_area = float(data[5].text.replace('\n', '').replace(',', ''))
|
227 |
+
state_data[state]['land_area_sq_mi']
|
228 |
+
|
229 |
+
# Get the change in GDP for each state in 2022 Q1.
|
230 |
+
code = 'NQGSP'
|
231 |
+
fred = Fred(api_key=fred_api_key)
|
232 |
+
for state, abbv in state_names.items():
|
233 |
+
try:
|
234 |
+
series = fred.get_series(abbv + code, '2021-10-01')
|
235 |
+
except ValueError:
|
236 |
+
continue
|
237 |
+
current, past = series[-1], series[-2]
|
238 |
+
change_gdp = ((current - past) / past) * 100
|
239 |
+
state_data[state]['change_gdp_2022_q1'] = change_gdp
|
240 |
+
|
241 |
+
|
242 |
+
#-----------------------------------------------------------------------
|
243 |
+
# Analyze the data.
|
244 |
+
#-----------------------------------------------------------------------
|
245 |
+
|
246 |
+
import statsmodels.api as sm
|
247 |
+
|
248 |
+
# FIXME: Compile all of the state statistics.
|
249 |
+
stats = pd.DataFrame()
|
250 |
+
|
251 |
+
# TODO: Count the number of retailers by state.
|
252 |
+
|
253 |
+
|
254 |
+
# TODO: Calculate retailers per capita (100,000) by state.
|
255 |
+
|
256 |
+
|
257 |
+
# TODO: Calculate retailers per 100 square miles by state.
|
258 |
+
|
259 |
+
|
260 |
+
# TODO: Create `adult_use` dummy variable. Assign 0 `retailers_per_capita`.
|
261 |
+
|
262 |
+
|
263 |
+
# Regress GDP on adult-use status and retailers per capita.
|
264 |
+
Y = stats['change_gdp_2022_q1']
|
265 |
+
X = stats[['adult_use', 'retailers_per_capita']]
|
266 |
+
X = sm.add_constant(X)
|
267 |
+
regression = sm.OLS(Y, X).fit()
|
268 |
+
print(regression.summary())
|
269 |
+
|
270 |
+
# Interpret the relationships.
|
271 |
+
beta = regression.params.adult_use
|
272 |
+
statement = """If a state permitted adult-use at the start of 2022,
|
273 |
+
then everything else held constant one would expect
|
274 |
+
GDP in 2022 Q1 to change by {}.
|
275 |
+
""".format(beta)
|
276 |
+
print(statement)
|
277 |
+
|
278 |
+
# Interpret the relationships.
|
279 |
+
beta = regression.params.retailers_per_capita
|
280 |
+
statement = """If retailers per 100,000 adults increases by 1,
|
281 |
+
then everything else held constant one would expect
|
282 |
+
GDP in 2022 Q1 to change by {}.
|
283 |
+
""".format(beta)
|
284 |
+
print(statement)
|
requirements.txt
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Cannabis Licenses | Python Requirements
|
2 |
+
# Created: 9/28/2022
|
3 |
+
# Updated: 9/28/2022
|
4 |
+
beautifulsoup4==4.11.1
|
5 |
+
cannlytics==0.0.12
|
6 |
+
firebase_admin==5.3.0
|
7 |
+
folium==0.12.1.post1
|
8 |
+
fredapi==0.5.0
|
9 |
+
matplotlib==3.6.0
|
10 |
+
pandas==1.4.4
|
11 |
+
pdfplumber==0.7.4
|
12 |
+
python-dotenv==0.21.0
|
13 |
+
seaborn==0.12.0
|