keeganskeate commited on
Commit
124701c
1 Parent(s): 6a105a7

- Added `xlsx` files (433ed2b87f11f8fed28111336705d1b94d59280d)
- 🍅NJ + 🎴NV + 🦞ME + 🌲WA licenses | Updated 🗺️ (825c643f2f82dd00d39e5c7721d01bf2919754e6)

.gitignore CHANGED
@@ -9,3 +9,6 @@
9
 
10
  # Ignore external datasets.
11
  *.datasets
 
 
 
 
9
 
10
  # Ignore external datasets.
11
  *.datasets
12
+
13
+ # Ignore VS Code settings.
14
+ *.vscode
README.md CHANGED
@@ -58,27 +58,49 @@ The dataset is partitioned into subsets for each state.
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
 
@@ -151,26 +173,23 @@ Data about organizations operating in the cannabis industry for each state is va
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
 
 
58
 
59
  | State | Licenses |
60
  |-------|----------|
61
+ | [Alaska](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ak) | |
62
+ | [Arizona](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/az) | |
63
+ | [California](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ca) | ✅ |
64
+ | [Colorado](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/co) | |
65
+ | [Connecticut](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ct) | |
66
+ | [Illinois](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/il) | |
67
+ | [Maine](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/me) ||
68
+ | [Massachusetts](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ma) | |
69
+ | [Michigan](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/mi) | |
70
+ | [Montana](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/mt) | |
71
+ | [Nevada](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/nv) ||
72
+ | [New Jersey](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/nj) ||
73
+ | [New Mexico](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/nm) | |
74
+ | [Oregon](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/or) | |
75
+ | [Rhode Island](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ri) | |
76
+ | [Vermont](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/vt) | |
77
+ | [Washington](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/wa) | ✅ |
78
+
79
+ Coming Soon (2):
80
+
81
+ - New York
82
+ - Virginia
83
+
84
+ Medical (18):
85
+
86
+ - District of Columbia (D.C.)
87
+ - Utah
88
+ - Oklahoma
89
+ - North Dakota
90
+ - South Dakota
91
+ - Minnesota
92
+ - Missouri
93
+ - Arkansas
94
+ - Louisiana
95
+ - Mississippi
96
+ - Alabama
97
+ - Florida
98
+ - Ohio
99
+ - West Virginia
100
+ - Pennsylvania
101
+ - Maryland
102
+ - Delaware
103
+ - New Hampshire
104
 
105
  ### Data Instances
106
 
 
173
 
174
  | State | Data Source URL |
175
  |-------|-----------------|
176
+ | Alaska | <https://www.commerce.alaska.gov/abc/marijuana/Home/licensesearch> |
177
+ | Arizona | <https://azcarecheck.azdhs.gov/s/?licenseType=null> |
178
+ | California | <https://search.cannabis.ca.gov/> |
179
+ | Colorado | |
180
+ | Connecticut | <https://portal.ct.gov/DCP/Medical-Marijuana-Program/Connecticut-Medical-Marijuana-Dispensary-Facilities> |
181
+ | Illinois | |
182
+ | Maine | <https://www.maine.gov/dafs/ocp/open-data/adult-use> |
183
+ | Massachusetts | |
184
+ | Michigan | |
185
+ | Montana | <https://mtrevenue.gov/cannabis/#CannabisLicenses> |
186
+ | Nevada | <https://ccb.nv.gov/list-of-licensees/> |
187
+ | New Jersey | <https://data.nj.gov/stories/s/ggm4-mprw> |
188
+ | New Mexico | <https://nmrldlpi.force.com/bcd/s/public-search-license?division=CCD&language=en_US> |
189
+ | Oregon | <https://www.oregon.gov/olcc/marijuana/pages/recreational-marijuana-licensing.aspx> |
190
+ | Rhode Island | <https://dbr.ri.gov/office-cannabis-regulation/compassion-centers/licensed-compassion-centers> |
191
+ | Vermont | <https://ccb.vermont.gov/licenses> |
192
+ | Washington | <https://lcb.wa.gov/records/frequently-requested-lists> |
 
 
 
193
 
194
  #### Data Collection and Normalization
195
 
algorithms/__init__.py ADDED
File without changes
algorithms/get_licenses_ak.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Alaska Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Alaska cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Alaska
19
+ URL: <https://www.commerce.alaska.gov/abc/marijuana/Home/licensesearch>
20
+
21
+ """
algorithms/get_licenses_az.py CHANGED
@@ -4,8 +4,9 @@ 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:
@@ -20,10 +21,14 @@ Data Source:
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
@@ -31,70 +36,211 @@ 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()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  Authors:
6
  Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
  Created: 9/27/2022
9
+ Updated: 9/30/2022
10
  License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
 
12
  Description:
 
21
  """
22
  # Standard imports.
23
  from datetime import datetime
24
+ from dotenv import dotenv_values
25
  import os
26
  from time import sleep
27
+ from typing import Optional
28
 
29
  # External imports.
30
+ from bs4 import BeautifulSoup
31
+ from cannlytics.data.gis import geocode_addresses
32
  from cannlytics.utils import camel_to_snake
33
  from cannlytics.utils.constants import DEFAULT_HEADERS
34
  import matplotlib.pyplot as plt
 
36
  import requests
37
  import seaborn as sns
38
 
39
+ # Selenium imports.
40
+ from selenium import webdriver
41
+ from selenium.webdriver.chrome.options import Options
42
+ from selenium.webdriver.common.by import By
43
+ from selenium.webdriver.chrome.service import Service
44
+ from selenium.common.exceptions import (
45
+ TimeoutException,
46
+ )
47
+ from selenium.webdriver.support import expected_conditions as EC
48
+ from selenium.webdriver.support.ui import WebDriverWait
49
+ try:
50
+ import chromedriver_binary # Adds chromedriver binary to path.
51
+ except ImportError:
52
+ pass # Otherwise, ChromeDriver should be in your path.
53
+
54
 
55
  # Specify where your data lives.
56
  DATA_DIR = '../data/az'
57
+
58
+ # Specify state-specific constants.
59
+ STATE = 'AZ'
60
+ ARIZONA = {
61
+ 'licensing_authority_id': 'ADHS',
62
+ 'licensing_authority': 'Arizona Department of Health Services',
63
+ 'retailers': {
64
+ 'url': 'https://azcarecheck.azdhs.gov/s/?licenseType=null',
65
+ },
66
+ }
67
+
68
+ # def get_licenses_az(
69
+ # data_dir: Optional[str] = None,
70
+ # env_file: Optional[str] = '.env',
71
+ # ):
72
+ # """Get Arizona cannabis license data."""
73
+
74
+
75
+ # DEV:
76
+ data_dir = DATA_DIR
77
+ env_file = '../.env'
78
+
79
 
80
  # Create directories if necessary.
81
+ if not os.path.exists(data_dir): os.makedirs(data_dir)
82
+
83
+ # Initialize Selenium.
84
+ service = Service()
85
+ options = Options()
86
+ options.add_argument('--window-size=1920,1200')
87
+ # DEV:
88
+ options.headless = False
89
+ # options.add_argument('--headless')
90
+ options.add_argument('--disable-gpu')
91
+ options.add_argument('--no-sandbox')
92
+ driver = webdriver.Chrome(options=options, service=service)
93
+
94
+ # Load the license page.
95
+ url = ARIZONA['retailers']['url']
96
+ driver.get(url)
97
+
98
+ # Wait for the page to load by waiting to detect the image.
99
+ try:
100
+ el = (By.CLASS_NAME, 'slds-container_center')
101
+ detect = EC.presence_of_element_located(el)
102
+ WebDriverWait(driver, timeout=30).until(detect)
103
+ except TimeoutException:
104
+ print('Failed to load page within %i seconds.' % (30))
105
+
106
+ # Get the map container.
107
+ container = driver.find_element(by=By.CLASS_NAME, value='slds-container_center')
108
+
109
+ # Click "Load more" until all of the licenses are visible.
110
+ more = True
111
+ while(more):
112
+ button = container.find_element(by=By.TAG_NAME, value='button')
113
+ driver.execute_script('arguments[0].scrollIntoView(true);', button)
114
+ button.click()
115
+ counter = container.find_element(by=By.CLASS_NAME, value='count-text')
116
+ more = int(counter.text.replace(' more', ''))
117
+
118
+ # Get license data for each retailer.
119
+ retailers = []
120
+ els = container.find_elements(by=By.CLASS_NAME, value='map-list__item')
121
+ for i, el in enumerate(els):
122
+
123
+ # Get a retailer's data.
124
+ count = i + 1
125
+ xpath = f'/html/body/div[3]/div[2]/div/div[2]/div[2]/div/div/c-azcc-portal-home/c-azcc-map/div/div[2]/div[2]/div[2]/div[{count}]/c-azcc-map-list-item/div'
126
+ list_item = el.find_element(by=By.XPATH, value=xpath)
127
+ body = list_item.find_element(by=By.CLASS_NAME, value='slds-media__body')
128
+ divs = body.find_elements(by=By.TAG_NAME, value='div')
129
+ name = divs[0].text
130
+ legal_name = divs[1].text
131
+ if not name:
132
+ name = legal_name
133
+ address = divs[3].text
134
+ address_parts = address.split(',')
135
+ parts = divs[2].text.split(' · ')
136
+
137
+ # Get the retailer's link to get more details.
138
+ link = divs[-1].find_element(by=By.TAG_NAME, value='a')
139
+ href = link.get_attribute('href')
140
+
141
+ # Record the retailer's data.
142
+ obs = {
143
+ 'address': address,
144
+ 'details_url': href,
145
+ 'business_legal_name': legal_name,
146
+ 'business_dba_name': name,
147
+ 'business_phone': parts[-1],
148
+ 'license_status': parts[0],
149
+ 'license_type': parts[1],
150
+ 'premise_street_address': address_parts[0],
151
+ 'premise_city': address_parts[1],
152
+ 'premise_zip_code': address_parts[-1].replace('AZ ', ''),
153
+ }
154
+ retailers.append(obs)
155
+
156
+ # Standardize the retailer data.
157
+ retailers = pd.DataFrame(retailers)
158
+ retailers['licensing_authority_id'] = ARIZONA['licensing_authority_id']
159
+ retailers['licensing_authority'] = ARIZONA['licensing_authority']
160
+ retailers['license_designation'] = 'Adult-Use'
161
+ retailers['premise_state'] = STATE
162
+ retailers['license_status_date'] = None
163
+ retailers['license_term'] = None
164
+ retailers['business_structure'] = None
165
+ retailers['activity'] = None
166
+ retailers['parcel_number'] = None
167
+
168
+ # TODO: Get each retailer's details.
169
+ for index, row in retailers.iterrows():
170
+
171
+ # Load the retailer's details webpage.
172
+ driver.get(row['details_url'])
173
+ # https://azcarecheck.azdhs.gov/s/facility-details?facilityId=001t000000L0TAaAAN&activeTab=details
174
+
175
+ # TODO: Get the `business_email`.
176
+ # lightning-formatted-email
177
+
178
+
179
+ # TODO: Get the `license_number`
180
+
181
+
182
+ # TODO: Get `issue_date` and `expiration_date`
183
+
184
+
185
+ # TODO: Get `business_owner_name`
186
+
187
+
188
+ # TODO: Get `license_designation` ("Services").
189
+
190
+
191
+ # TODO: Create entries for cultivations!
192
+
193
+
194
+ # TODO: Get the `premise_latitude` and `premise_longitude`.
195
+ # https://maps.google.com/maps?daddr=33.447334955594650,-111.991646657827630&amp;ll=
196
+
197
+
198
+
199
+ # TODO: Lookup counties for the retailers.
200
+
201
+
202
+ # TODO: Geocode-cultivations.
203
+
204
+ # Geocode licenses to get `premise_latitude` and `premise_longitude`.
205
+ # config = dotenv_values(env_file)
206
+ # google_maps_api_key = config['GOOGLE_MAPS_API_KEY']
207
+ # retailers = geocode_addresses(
208
+ # retailers,
209
+ # api_key=google_maps_api_key,
210
+ # address_field='address',
211
  # )
212
+ # drop_cols = ['state', 'state_name', 'address', 'formatted_address']
213
+ # retailers.drop(columns=drop_cols, inplace=True)
214
+ # gis_cols = {
215
+ # 'county': 'premise_county',
216
+ # 'latitude': 'premise_latitude',
217
+ # 'longitude': 'premise_longitude',
218
+ # }
219
+ # retailers.rename(columns=gis_cols, inplace=True)
220
+
221
+ # TODO: Save and return the data.
222
+ # if data_dir is not None:
223
+ # timestamp = datetime.now().isoformat()[:19].replace(':', '-')
224
+ # retailers.to_excel(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.xlsx')
225
+ # return retailers
226
+
227
+
228
+ # === Test ===
229
+ # if __name__ == '__main__':
230
+
231
+ # # Support command line usage.
232
+ # import argparse
233
+ # try:
234
+ # arg_parser = argparse.ArgumentParser()
235
+ # arg_parser.add_argument('--d', dest='data_dir', type=str)
236
+ # arg_parser.add_argument('--data_dir', dest='data_dir', type=str)
237
+ # arg_parser.add_argument('--env', dest='env_file', type=str)
238
+ # args = arg_parser.parse_args()
239
+ # except SystemExit:
240
+ # args = {'d': DATA_DIR, 'env_file': ENV_FILE}
241
+
242
+ # # Get licenses, saving them to the specified directory.
243
+ # data_dir = args.get('d', args.get('data_dir'))
244
+ # env_file = args.get('env_file')
245
+ # data = get_licenses_az(data_dir, env_file=env_file)
246
+
algorithms/get_licenses_ca.py CHANGED
@@ -4,6 +4,7 @@ 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>
@@ -43,6 +44,7 @@ def get_licenses_ca(
43
  ending_page: Optional[int] = None,
44
  verbose: Optional[bool] = False,
45
  search: Optional[str] = '',
 
46
  ):
47
  """Get California cannabis license data."""
48
 
 
4
 
5
  Authors:
6
  Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
  Created: 9/16/2022
9
  Updated: 9/27/2022
10
  License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
 
44
  ending_page: Optional[int] = None,
45
  verbose: Optional[bool] = False,
46
  search: Optional[str] = '',
47
+ **kwargs,
48
  ):
49
  """Get California cannabis license data."""
50
 
algorithms/get_licenses_co.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Colorado Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Colorado cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Colorado
19
+ URL: <>
20
+
21
+ """
algorithms/get_licenses_ct.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Connecticut Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Connecticut cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Connecticut
19
+ URL: <https://portal.ct.gov/DCP/Medical-Marijuana-Program/Connecticut-Medical-Marijuana-Dispensary-Facilities>
20
+
21
+ """
algorithms/get_licenses_il.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Illinois Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Illinois cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Illinois
19
+ URL: <>
20
+
21
+ """
algorithms/get_licenses_ma.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Massachusetts Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Massachusetts cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Massachusetts
19
+ URL: <>
20
+
21
+ """
22
+
23
+
algorithms/get_licenses_me.py ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Maine Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/30/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Maine cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Maine Office of Cannabis Policy
19
+ URL: <https://www.maine.gov/dafs/ocp/open-data/adult-use>
20
+
21
+ """
22
+ # Standard imports.
23
+ from datetime import datetime
24
+ import os
25
+ from typing import Optional
26
+
27
+ # External imports.
28
+ from bs4 import BeautifulSoup
29
+ from cannlytics.data.gis import geocode_addresses
30
+ from dotenv import dotenv_values
31
+ import pandas as pd
32
+ import requests
33
+
34
+
35
+ # Specify where your data lives.
36
+ DATA_DIR = '../data/me'
37
+ ENV_FILE = '../.env'
38
+
39
+ # Specify state-specific constants.
40
+ STATE = 'ME'
41
+ MAINE = {
42
+ 'licensing_authority_id': 'MEOCP',
43
+ 'licensing_authority': 'Maine Office of Cannabis Policy',
44
+ 'licenses': {
45
+ 'url': 'https://www.maine.gov/dafs/ocp/open-data/adult-use',
46
+ 'key': 'Adult_Use_Establishments_And_Contacts',
47
+ 'columns': {
48
+ 'LICENSE': 'license_number',
49
+ 'LICENSE_CATEGORY': 'license_type',
50
+ 'LICENSE_TYPE': 'license_designation',
51
+ 'LICENSE_NAME': 'business_legal_name',
52
+ 'DBA': 'business_dba_name',
53
+ 'LICENSE_STATUS': 'license_status',
54
+ 'LICENSE_CITY': 'premise_city',
55
+ 'WEBSITE': 'business_website',
56
+ 'CONTACT_NAME': 'business_owner_name',
57
+ 'CONTACT_TYPE': 'contact_type',
58
+ 'CONTACT_CITY': 'contact_city',
59
+ 'CONTACT_DESCRIPTION': 'contact_description',
60
+ },
61
+ }
62
+ }
63
+
64
+
65
+ def get_licenses_me(
66
+ data_dir: Optional[str] = None,
67
+ env_file: Optional[str] = '.env',
68
+ ):
69
+ """Get Maine cannabis license data."""
70
+
71
+ # Create the necessary directories.
72
+ file_dir = f'{data_dir}/.datasets'
73
+ if not os.path.exists(data_dir): os.makedirs(data_dir)
74
+ if not os.path.exists(file_dir): os.makedirs(file_dir)
75
+
76
+ # Get the download link.
77
+ licenses_url = None
78
+ licenses_key = MAINE['licenses']['key']
79
+ url = MAINE['licenses']['url']
80
+ response = requests.get(url)
81
+ soup = BeautifulSoup(response.content, 'html.parser')
82
+ links = soup.find_all('a')
83
+ for link in links:
84
+ try:
85
+ href = link['href']
86
+ except KeyError:
87
+ continue
88
+ if licenses_key in href:
89
+ licenses_url = href
90
+ break
91
+
92
+ # Download the licenses workbook.
93
+ filename = licenses_url.split('/')[-1]
94
+ licenses_source_file = os.path.join(file_dir, filename)
95
+ response = requests.get(licenses_url)
96
+ with open(licenses_source_file, 'wb') as doc:
97
+ doc.write(response.content)
98
+
99
+ # Extract the data from the license workbook.
100
+ licenses = pd.read_excel(licenses_source_file)
101
+ licenses.rename(columns=MAINE['licenses']['columns'], inplace=True)
102
+ licenses['licensing_authority_id'] = MAINE['licensing_authority_id']
103
+ licenses['licensing_authority'] = MAINE['licensing_authority']
104
+ licenses['license_designation'] = 'Adult-Use'
105
+ licenses['premise_state'] = STATE
106
+ licenses['license_status_date'] = None
107
+ licenses['license_term'] = None
108
+ licenses['issue_date'] = None
109
+ licenses['expiration_date'] = None
110
+ licenses['business_structure'] = None
111
+ licenses['business_email'] = None
112
+ licenses['business_phone'] = None
113
+ licenses['activity'] = None
114
+ licenses['parcel_number'] = None
115
+ licenses['premise_street_address'] = None
116
+ licenses['id'] = licenses['license_number']
117
+
118
+ # Remove duplicates.
119
+ licenses.drop_duplicates(subset='license_number', inplace=True)
120
+
121
+ # Replace null DBA with legal name.
122
+ criterion = licenses['business_dba_name'].isnull()
123
+ licenses.loc[criterion,'business_dba_name'] = licenses['business_legal_name']
124
+
125
+ # Convert certain columns from upper case title case.
126
+ cols = ['business_legal_name', 'business_dba_name', 'business_owner_name']
127
+ for col in cols:
128
+ licenses[col] = licenses[col].apply(
129
+ lambda x: x.title().strip() if isinstance(x, str) else x
130
+ )
131
+
132
+ # Get the refreshed date.
133
+ date = licenses_source_file.split('\\')[-1].split('.')[0].replace(licenses_key, '')
134
+ date = date.replace('%20', '')
135
+ date = '-'.join([date[:2], date[2:4], date[4:]])
136
+ licenses['data_refreshed_date'] = pd.to_datetime(date).isoformat()
137
+
138
+ # Geocode licenses to get `premise_latitude` and `premise_longitude`.
139
+ config = dotenv_values(env_file)
140
+ google_maps_api_key = config['GOOGLE_MAPS_API_KEY']
141
+ cols = ['premise_city', 'premise_state']
142
+ licenses['address'] = licenses[cols].apply(
143
+ lambda row: ', '.join(row.values.astype(str)),
144
+ axis=1,
145
+ )
146
+ licenses = geocode_addresses(
147
+ licenses,
148
+ api_key=google_maps_api_key,
149
+ address_field='address',
150
+ )
151
+ drop_cols = ['state', 'state_name', 'address', 'formatted_address',
152
+ 'contact_type', 'contact_city', 'contact_description']
153
+ licenses.drop(columns=drop_cols, inplace=True)
154
+ gis_cols = {
155
+ 'county': 'premise_county',
156
+ 'latitude': 'premise_latitude',
157
+ 'longitude': 'premise_longitude',
158
+ }
159
+ licenses.rename(columns=gis_cols, inplace=True)
160
+
161
+ # Save and return the data.
162
+ if data_dir is not None:
163
+ timestamp = datetime.now().isoformat()[:19].replace(':', '-')
164
+ licenses.to_excel(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.xlsx')
165
+ return licenses
166
+
167
+
168
+ # === Test ===
169
+ if __name__ == '__main__':
170
+
171
+ # Support command line usage.
172
+ import argparse
173
+ try:
174
+ arg_parser = argparse.ArgumentParser()
175
+ arg_parser.add_argument('--d', dest='data_dir', type=str)
176
+ arg_parser.add_argument('--data_dir', dest='data_dir', type=str)
177
+ arg_parser.add_argument('--env', dest='env_file', type=str)
178
+ args = arg_parser.parse_args()
179
+ except SystemExit:
180
+ args = {'d': DATA_DIR, 'env_file': ENV_FILE}
181
+
182
+ # Get licenses, saving them to the specified directory.
183
+ data_dir = args.get('d', args.get('data_dir'))
184
+ env_file = args.get('env_file')
185
+ data = get_licenses_me(data_dir, env_file=env_file)
algorithms/get_licenses_mi.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Michigan Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Michigan cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Michigan
19
+ URL: <>
20
+
21
+ """
algorithms/get_licenses_mt.py CHANGED
@@ -4,8 +4,9 @@ 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:
@@ -33,8 +34,10 @@ import requests
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',
@@ -46,18 +49,30 @@ MONTANA = {
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',
@@ -131,7 +146,6 @@ for i, licensee in enumerate(licensees):
131
  if not city_found:
132
  print("Couldn't identify city:", dba)
133
 
134
-
135
  # TODO: Remove duplicates.
136
 
137
 
 
4
 
5
  Authors:
6
  Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
  Created: 9/27/2022
9
+ Updated: 9/30/2022
10
  License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
 
12
  Description:
 
34
 
35
  # Specify where your data lives.
36
  DATA_DIR = '../data/mt'
37
+ ENV_FILE = '../.env'
38
 
39
+ # Specify state-specific constants.
40
+ STATE = 'MT'
41
  MONTANA = {
42
  'retailers': {
43
  'url': 'https://mtrevenue.gov/?mdocs-file=60245',
 
49
  'transporters': {'url': 'https://mtrevenue.gov/?mdocs-file=72489'},
50
  }
51
 
52
+ # DEV:
53
+ data_dir = DATA_DIR
54
+ pdf_dir = f'{data_dir}/pdfs'
55
 
56
+ # Create directories if necessary.
57
+ if not os.path.exists(data_dir): os.makedirs(data_dir)
58
+ if not os.path.exists(pdf_dir): os.makedirs(pdf_dir)
59
 
60
  # Download the retailers PDF.
61
  timestamp = datetime.now().isoformat()[:19].replace(':', '-')
62
+ outfile = f'{pdf_dir}/mt-retailers-{timestamp}.pdf'
63
  response = requests.get(MONTANA['retailers']['url'], headers=DEFAULT_HEADERS)
64
  with open(outfile, 'wb') as pdf:
65
  pdf.write(response.content)
66
 
67
+ # FIXME: Extract text by section!
68
+ # E.g.
69
+ # doc = pdfplumber.open(outfile)
70
+ # page = doc.pages[0]
71
+ # img = page.to_image(resolution=150)
72
+ # img.draw_rects(
73
+ # [[0, 0.25 * page.height, 0.2 * page.width, 0.95 * page.height]]
74
+ # )
75
+
76
  # Extract the data from the PDF.
77
  rows = []
78
  skip_lines = ['GOVERNOR ', 'DIRECTOR ', 'Cannabis Control Division',
 
146
  if not city_found:
147
  print("Couldn't identify city:", dba)
148
 
 
149
  # TODO: Remove duplicates.
150
 
151
 
algorithms/get_licenses_nj.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get New Jersey Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect New Jersey cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - New Jersey Cannabis Regulatory Commission
19
+ URL: <https://data.nj.gov/stories/s/ggm4-mprw>
20
+
21
+ """
22
+ # Standard imports.
23
+ from datetime import datetime
24
+ import os
25
+ from typing import Optional
26
+
27
+ # External imports.
28
+ import pandas as pd
29
+ import requests
30
+
31
+
32
+ # Specify where your data lives.
33
+ DATA_DIR = '../data/nj'
34
+
35
+ # Specify state-specific constants.
36
+ STATE = 'NJ'
37
+ NEW_JERSEY = {
38
+ 'licensing_authority_id': 'NJCRC',
39
+ 'licensing_authority': 'New Jersey Cannabis Regulatory Commission',
40
+ 'retailers': {
41
+ 'columns': {
42
+ 'name': 'business_dba_name',
43
+ 'address': 'premise_street_address',
44
+ 'town': 'premise_city',
45
+ 'state': 'premise_state',
46
+ 'zip_code': 'premise_zip_code',
47
+ 'county': 'premise_county',
48
+ 'phone_number': 'business_phone',
49
+ 'type': 'license_type',
50
+ }
51
+ }
52
+ }
53
+
54
+
55
+ def get_licenses_nj(
56
+ data_dir: Optional[str] = None,
57
+ **kwargs,
58
+ ):
59
+ """Get New Jersey cannabis license data."""
60
+
61
+ # Get retailer data.
62
+ url = 'https://data.nj.gov/resource/nv37-s2zn.json'
63
+ response = requests.get(url)
64
+ data = pd.DataFrame(response.json())
65
+
66
+ # Parse the website.
67
+ data['business_website'] = data['website'].apply(lambda x: x['url'])
68
+
69
+ # Parse the GIS coordinates.
70
+ data['premise_longitude'] = data['dispensary_location'].apply(
71
+ lambda x: x['coordinates'][0]
72
+ )
73
+ data['premise_latitude'] = data['dispensary_location'].apply(
74
+ lambda x: x['coordinates'][1]
75
+ )
76
+
77
+ # Standardize the data.
78
+ drop_cols = ['dispensary_location', 'location', 'website']
79
+ data.drop(columns=drop_cols, inplace=True)
80
+ data.rename(columns=NEW_JERSEY['retailers']['columns'], inplace=True)
81
+ data['business_legal_name'] = data['business_dba_name']
82
+ data['licensing_authority_id'] = NEW_JERSEY['licensing_authority_id']
83
+ data['licensing_authority'] = NEW_JERSEY['licensing_authority']
84
+ data['license_designation'] = 'Adult-Use'
85
+ data['premise_state'] = STATE
86
+ data['license_status_date'] = None
87
+ data['license_term'] = None
88
+ data['issue_date'] = None
89
+ data['expiration_date'] = None
90
+ data['business_owner_name'] = None
91
+ data['business_structure'] = None
92
+ data['business_email'] = None
93
+ data['activity'] = None
94
+ data['parcel_number'] = None
95
+
96
+ # Convert certain columns from upper case title case.
97
+ cols = ['premise_city', 'premise_county', 'premise_street_address']
98
+ for col in cols:
99
+ data[col] = data[col].apply(lambda x: x.title().strip())
100
+
101
+ # Save and return the data.
102
+ if data_dir is not None:
103
+ if not os.path.exists(data_dir): os.makedirs(data_dir)
104
+ timestamp = datetime.now().isoformat()[:19].replace(':', '-')
105
+ data.to_excel(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.xlsx')
106
+ return data
107
+
108
+
109
+ # === Test ===
110
+ if __name__ == '__main__':
111
+
112
+ # Support command line usage.
113
+ import argparse
114
+ try:
115
+ arg_parser = argparse.ArgumentParser()
116
+ arg_parser.add_argument('--d', '--data_dir', dest='data_dir', type=str)
117
+ args = arg_parser.parse_args()
118
+ except SystemExit:
119
+ args = {'d': DATA_DIR}
120
+
121
+ # Get licenses, saving them to the specified directory.
122
+ data_dir = args.get('d', args.get('data_dir'))
123
+ data = get_licenses_nj(data_dir)
algorithms/get_licenses_nm.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get New Mexico Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect New Mexico cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - New Mexico
19
+ URL: <>
20
+
21
+ """
algorithms/get_licenses_nv.py ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Nevada Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Nevada cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Nevada
19
+ URL: <https://ccb.nv.gov/list-of-licensees/>
20
+
21
+ """
22
+ # Standard imports.
23
+ from datetime import datetime
24
+ import os
25
+ from typing import Optional
26
+
27
+ # External imports.
28
+ from bs4 import BeautifulSoup
29
+ from cannlytics.data.gis import geocode_addresses
30
+ from cannlytics.utils.constants import DEFAULT_HEADERS
31
+ from dotenv import dotenv_values
32
+ import pandas as pd
33
+ import requests
34
+
35
+ # Specify where your data lives.
36
+ DATA_DIR = '../data/nv'
37
+ ENV_FILE = '../.env'
38
+
39
+ # Specify state-specific constants.
40
+ STATE = 'NV'
41
+ NEVADA = {
42
+ 'licensing_authority_id': 'NVCCB',
43
+ 'licensing_authority': 'Nevada Cannabis Compliance Board',
44
+ 'licenses': {
45
+ 'key': 'Active-License-List',
46
+ 'columns': {
47
+ 'LicenseNumber': 'license_number',
48
+ 'LicenseName': 'business_dba_name',
49
+ 'CE ID': 'id',
50
+ 'LicenseType': 'license_type',
51
+ 'County': 'premise_county',
52
+ },
53
+ 'url': 'https://ccb.nv.gov/list-of-licensees/',
54
+ }
55
+ }
56
+
57
+
58
+ def get_licenses_nv(
59
+ data_dir: Optional[str] = None,
60
+ env_file: Optional[str] = '.env',
61
+ ):
62
+ """Get Nevada cannabis license data."""
63
+
64
+ # Create the necessary directories.
65
+ file_dir = f'{data_dir}/.datasets'
66
+ if not os.path.exists(data_dir): os.makedirs(data_dir)
67
+ if not os.path.exists(file_dir): os.makedirs(file_dir)
68
+
69
+ #--------------------------------------------------------------------------
70
+ # Get all license data.
71
+ #--------------------------------------------------------------------------
72
+
73
+ # Find the latest licenses workbook.
74
+ licenses_url = ''
75
+ retailer_key = NEVADA['licenses']['key']
76
+ url = NEVADA['licenses']['url']
77
+ response = requests.get(url, headers=DEFAULT_HEADERS)
78
+ soup = BeautifulSoup(response.content, 'html.parser')
79
+ links = soup.find_all('a')
80
+ for link in links:
81
+ href = link['href']
82
+ if retailer_key in href:
83
+ licenses_url = href
84
+ break
85
+
86
+ # Download the workbook.
87
+ filename = licenses_url.split('/')[-1]
88
+ licenses_source_file = os.path.join(file_dir, filename)
89
+ response = requests.get(licenses_url, headers=DEFAULT_HEADERS)
90
+ with open(licenses_source_file, 'wb') as doc:
91
+ doc.write(response.content)
92
+
93
+ # Extract and standardize the data from the workbook.
94
+ licenses = pd.read_excel(licenses_source_file, skiprows=1)
95
+ licenses.rename(columns=NEVADA['licenses']['columns'], inplace=True)
96
+ licenses['licensing_authority_id'] = NEVADA['licensing_authority_id']
97
+ licenses['licensing_authority'] = NEVADA['licensing_authority']
98
+ licenses['license_designation'] = 'Adult-Use'
99
+ licenses['premise_state'] = STATE
100
+ licenses['license_status_date'] = None
101
+ licenses['license_term'] = None
102
+ licenses['issue_date'] = None
103
+ licenses['expiration_date'] = None
104
+ licenses['business_legal_name'] = licenses['business_dba_name']
105
+ licenses['business_owner_name'] = None
106
+ licenses['business_structure'] = None
107
+ licenses['business_email'] = None
108
+ licenses['activity'] = None
109
+ licenses['parcel_number'] = None
110
+
111
+ # Convert certain columns from upper case title case.
112
+ cols = ['business_dba_name', 'premise_county']
113
+ for col in cols:
114
+ licenses[col] = licenses[col].apply(lambda x: x.title().strip())
115
+
116
+ # Get the refreshed date.
117
+ date = filename.split('.')[0].replace(retailer_key, '').lstrip('-')
118
+ date = '-'.join([date[:2], date[2:4], date[4:]])
119
+ licenses['data_refreshed_date'] = pd.to_datetime(date)
120
+
121
+ # Wish: Geocode licenses to get `premise_latitude` and `premise_longitude`.
122
+
123
+ # Save the licenses
124
+ if data_dir is not None:
125
+ timestamp = datetime.now().isoformat()[:19].replace(':', '-')
126
+ licenses.to_excel(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.xlsx')
127
+
128
+ #--------------------------------------------------------------------------
129
+ # Get retailer data
130
+ #--------------------------------------------------------------------------
131
+
132
+ # Get the retailer data.
133
+ retailers = []
134
+ tables = soup.find_all('table', attrs={'class': 'customTable'})
135
+ for table in tables:
136
+ try:
137
+ city = table.find('span').text
138
+ except AttributeError:
139
+ continue
140
+ rows = table.find_all('td')
141
+ for row in rows:
142
+ cells = row.text.split(' – ')
143
+ name = cells[0]
144
+ street = cells[1]
145
+ designation = cells[-1]
146
+ retailers.append({
147
+ 'business_legal_name': name,
148
+ 'business_dba_name': name,
149
+ 'license_designation': designation,
150
+ 'premise_city': city,
151
+ 'premise_street_address': street,
152
+ })
153
+
154
+ # Standardize the retailers.
155
+ retailers = pd.DataFrame(retailers)
156
+ retailers['licensing_authority_id'] = NEVADA['licensing_authority_id']
157
+ retailers['licensing_authority'] = NEVADA['licensing_authority']
158
+ retailers['license_type'] = 'Commercial - Retailer'
159
+ retailers['license_status'] = 'Active'
160
+ retailers['license_designation'] = 'Adult-Use'
161
+ retailers['premise_state'] = STATE
162
+ retailers['license_status_date'] = None
163
+ retailers['license_term'] = None
164
+ retailers['issue_date'] = None
165
+ retailers['expiration_date'] = None
166
+ retailers['business_owner_name'] = None
167
+ retailers['business_structure'] = None
168
+ retailers['business_email'] = None
169
+ retailers['activity'] = None
170
+ retailers['parcel_number'] = None
171
+
172
+ # Geocode the retailers.
173
+ config = dotenv_values(env_file)
174
+ google_maps_api_key = config['GOOGLE_MAPS_API_KEY']
175
+ cols = ['premise_street_address', 'premise_city', 'premise_state']
176
+ retailers['address'] = retailers[cols].apply(
177
+ lambda row: ', '.join(row.values.astype(str)),
178
+ axis=1,
179
+ )
180
+ retailers = geocode_addresses(
181
+ retailers,
182
+ api_key=google_maps_api_key,
183
+ address_field='address',
184
+ )
185
+ drop_cols = ['state', 'state_name', 'county', 'address', 'formatted_address']
186
+ retailers.drop(columns=drop_cols, inplace=True)
187
+ gis_cols = {
188
+ 'latitude': 'premise_latitude',
189
+ 'longitude': 'premise_longitude'
190
+ }
191
+ retailers.rename(columns=gis_cols, inplace=True)
192
+
193
+ # Future work: Merge the retailers with the licenses data?
194
+
195
+ # Save the retailers
196
+ if data_dir is not None:
197
+ timestamp = datetime.now().isoformat()[:19].replace(':', '-')
198
+ retailers.to_excel(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.xlsx')
199
+
200
+ # Return all of the data.
201
+ return pd.concat([licenses, retailers])
202
+
203
+
204
+ if __name__ == '__main__':
205
+
206
+ # Support command line usage.
207
+ import argparse
208
+ try:
209
+ arg_parser = argparse.ArgumentParser()
210
+ arg_parser.add_argument('--d', dest='data_dir', type=str)
211
+ arg_parser.add_argument('--data_dir', dest='data_dir', type=str)
212
+ arg_parser.add_argument('--env', dest='env_file', type=str)
213
+ args = arg_parser.parse_args()
214
+ except SystemExit:
215
+ args = {'d': DATA_DIR, 'env_file': ENV_FILE}
216
+
217
+ # Get licenses, saving them to the specified directory.
218
+ data_dir = args.get('d', args.get('data_dir'))
219
+ env_file = args.get('env_file')
220
+ data = get_licenses_nv(data_dir, env_file=env_file)
algorithms/get_licenses_or.py CHANGED
@@ -4,6 +4,7 @@ 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>
@@ -32,6 +33,7 @@ from cannlytics.data.gis import geocode_addresses
32
 
33
  # Specify where your data lives.
34
  DATA_DIR = '../data/or'
 
35
 
36
  # Specify state-specific constants.
37
  OREGON = {
@@ -151,7 +153,7 @@ def get_licenses_or(
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',
@@ -184,7 +186,7 @@ if __name__ == '__main__':
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'))
 
4
 
5
  Authors:
6
  Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
  Created: 9/28/2022
9
  Updated: 9/28/2022
10
  License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
 
33
 
34
  # Specify where your data lives.
35
  DATA_DIR = '../data/or'
36
+ ENV_FILE = '../.env'
37
 
38
  # Specify state-specific constants.
39
  OREGON = {
 
153
  api_key=google_maps_api_key,
154
  address_field='address',
155
  )
156
+ drop_cols = ['state', 'state_name', 'county', 'address', 'formatted_address']
157
  data.drop(columns=drop_cols, inplace=True)
158
  gis_cols = {
159
  'latitude': 'premise_latitude',
 
186
  arg_parser.add_argument('--env', dest='env_file', type=str)
187
  args = arg_parser.parse_args()
188
  except SystemExit:
189
+ args = {'d': DATA_DIR, 'env_file': ENV_FILE}
190
 
191
  # Get California licenses, saving them to the specified directory.
192
  data_dir = args.get('d', args.get('data_dir'))
algorithms/get_licenses_ri.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Rhode Island Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Rhode Island cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Rhode Island
19
+ URL: <https://dbr.ri.gov/office-cannabis-regulation/compassion-centers/licensed-compassion-centers>
20
+
21
+ """
algorithms/get_licenses_vt.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Vermont Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Vermont cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Vermont
19
+ URL: <https://ccb.vermont.gov/licenses>
20
+
21
+ """
algorithms/get_licenses_wa.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get Washington Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect Washington cannabis license data.
15
+
16
+ Data Source:
17
+
18
+ - Washington State Liquor and Cannabis Board | Frequently Requested Lists
19
+ URL: <https://lcb.wa.gov/records/frequently-requested-lists>
20
+
21
+ """
22
+ # Standard imports.
23
+ from datetime import datetime
24
+ import os
25
+ from typing import Optional
26
+
27
+ # External imports.
28
+ from bs4 import BeautifulSoup
29
+ from cannlytics.data.gis import geocode_addresses
30
+ from dotenv import dotenv_values
31
+ import pandas as pd
32
+ import requests
33
+
34
+
35
+ # Specify where your data lives.
36
+ DATA_DIR = '../data/wa'
37
+ ENV_FILE = '../.env'
38
+
39
+ # Specify state-specific constants.
40
+ STATE = 'WA'
41
+ WASHINGTON = {
42
+ 'licensing_authority_id': 'WSLCB',
43
+ 'licensing_authority': 'Washington State Liquor and Cannabis Board',
44
+ 'retailers': {
45
+ 'key': 'CannabisApplicants',
46
+ 'columns': {
47
+ 'Tradename': 'business_dba_name',
48
+ 'License ': 'license_number',
49
+ 'UBI': 'id',
50
+ 'Street Address': 'premise_street_address',
51
+ 'Suite Rm': 'premise_street_address_2',
52
+ 'City': 'premise_city',
53
+ 'State': 'premise_state',
54
+ 'county': 'premise_county',
55
+ 'Zip Code': 'premise_zip_code',
56
+ 'Priv Desc': 'license_type',
57
+ 'Privilege Status': 'license_status',
58
+ 'Day Phone': 'business_phone',
59
+ },
60
+ }
61
+ }
62
+
63
+
64
+ def get_licenses_wa(
65
+ data_dir: Optional[str] = None,
66
+ env_file: Optional[str] = '.env',
67
+ ):
68
+ """Get Washington cannabis license data."""
69
+
70
+ # Create the necessary directories.
71
+ file_dir = f'{data_dir}/.datasets'
72
+ if not os.path.exists(data_dir): os.makedirs(data_dir)
73
+ if not os.path.exists(file_dir): os.makedirs(file_dir)
74
+
75
+ # Get the URLs for the license workbooks.
76
+ labs_url, medical_url, retailers_url = None, None, None
77
+ url = 'https://lcb.wa.gov/records/frequently-requested-lists'
78
+ response = requests.get(url)
79
+ soup = BeautifulSoup(response.content, 'html.parser')
80
+ links = soup.find_all('a')
81
+ for link in links:
82
+ href = link['href']
83
+ if 'Lab-List' in href:
84
+ labs_url = href
85
+ elif 'CannabisApplicants' in href:
86
+ retailers_url = href
87
+ elif 'MedicalCannabisEndorsements' in href:
88
+ medical_url = href
89
+ break
90
+
91
+ # TODO: Also download and collect lab + medical dispensary data.
92
+
93
+ # Download the licenses workbook.
94
+ filename = retailers_url.split('/')[-1]
95
+ retailers_source_file = os.path.join(file_dir, filename)
96
+ response = requests.get(retailers_url)
97
+ with open(retailers_source_file, 'wb') as doc:
98
+ doc.write(response.content)
99
+
100
+ # Extract and standardize the data from the workbook.
101
+ retailers = pd.read_excel(retailers_source_file)
102
+ retailers.rename(columns=WASHINGTON['retailers']['columns'], inplace=True)
103
+ retailers['licensing_authority_id'] = WASHINGTON['licensing_authority_id']
104
+ retailers['licensing_authority'] = WASHINGTON['licensing_authority']
105
+ retailers['license_designation'] = 'Adult-Use'
106
+ retailers['premise_state'] = STATE
107
+ retailers['license_status_date'] = None
108
+ retailers['license_term'] = None
109
+ retailers['issue_date'] = None
110
+ retailers['expiration_date'] = None
111
+ retailers['business_legal_name'] = retailers['business_dba_name']
112
+ retailers['business_owner_name'] = None
113
+ retailers['business_structure'] = None
114
+ retailers['business_email'] = None
115
+ retailers['activity'] = None
116
+ retailers['parcel_number'] = None
117
+
118
+ # Keep only active licenses.
119
+ retailers = retailers.loc[
120
+ (retailers['license_status'] == 'ACTIVE (ISSUED)') |
121
+ (retailers['license_status'] == 'ACTIVE TITLE CERTIFICATE')
122
+ ]
123
+
124
+ # Convert certain columns from upper case title case.
125
+ cols = ['business_dba_name', 'premise_city', 'premise_county',
126
+ 'premise_street_address', 'license_type', 'license_status']
127
+ for col in cols:
128
+ retailers[col] = retailers[col].apply(lambda x: x.title().strip())
129
+
130
+ # Get the refreshed date.
131
+ date = retailers_source_file.split('\\')[-1].split('.')[0]
132
+ date = date.replace('CannabisApplicants', '')
133
+ date = date[:2] + '-' + date[2:4] + '-' + date[4:]
134
+ retailers['data_refreshed_date'] = pd.to_datetime(date).isoformat()
135
+
136
+ # FIXME: Append `premise_street_address_2` to `premise_street_address`.
137
+
138
+
139
+ # Geocode licenses to get `premise_latitude` and `premise_longitude`.
140
+ config = dotenv_values(env_file)
141
+ google_maps_api_key = config['GOOGLE_MAPS_API_KEY']
142
+ cols = ['premise_street_address', 'premise_city', 'premise_state',
143
+ 'premise_zip_code']
144
+ retailers['address'] = retailers[cols].apply(
145
+ lambda row: ', '.join(row.values.astype(str)),
146
+ axis=1,
147
+ )
148
+ retailers = geocode_addresses(
149
+ retailers,
150
+ api_key=google_maps_api_key,
151
+ address_field='address',
152
+ )
153
+ drop_cols = ['state', 'state_name', 'county', 'address', 'formatted_address']
154
+ retailers.drop(columns=drop_cols, inplace=True)
155
+ gis_cols = {
156
+ 'latitude': 'premise_latitude',
157
+ 'longitude': 'premise_longitude'
158
+ }
159
+ retailers.rename(columns=gis_cols, inplace=True)
160
+
161
+ # Save and return the data.
162
+ if data_dir is not None:
163
+ timestamp = datetime.now().isoformat()[:19].replace(':', '-')
164
+ retailers.to_excel(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.xlsx')
165
+ return retailers
166
+
167
+
168
+ if __name__ == '__main__':
169
+
170
+ # Support command line usage.
171
+ import argparse
172
+ try:
173
+ arg_parser = argparse.ArgumentParser()
174
+ arg_parser.add_argument('--d', dest='data_dir', type=str)
175
+ arg_parser.add_argument('--data_dir', dest='data_dir', type=str)
176
+ arg_parser.add_argument('--env', dest='env_file', type=str)
177
+ args = arg_parser.parse_args()
178
+ except SystemExit:
179
+ args = {'d': DATA_DIR, 'env_file': ENV_FILE}
180
+
181
+ # Get licenses, saving them to the specified directory.
182
+ data_dir = args.get('d', args.get('data_dir'))
183
+ env_file = args.get('env_file')
184
+ data = get_licenses_wa(data_dir, env_file=env_file)
algorithms/main.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Get All Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/30/2022
10
+ License: <https://github.com/cannlytics/cannlytics/blob/main/LICENSE>
11
+
12
+ Description:
13
+
14
+ Collect all cannabis license data from all states with permitted adult-use:
15
+
16
+ - Alaska
17
+ - Arizona
18
+ ✓ California
19
+ - Colorado
20
+ - Connecticut
21
+ - Illinois
22
+ ✓ Maine
23
+ - Massachusetts
24
+ - Michigan
25
+ - Montana
26
+ ✓ Nevada
27
+ ✓ New Jersey
28
+ - New Mexico
29
+ - New York
30
+ ✓ Oregon
31
+ - Rhode Island
32
+ - Vermont
33
+ ✓ Washington
34
+
35
+ """
36
+ from .get_licenses_ca import get_licenses_ca
37
+ from .get_licenses_me import get_licenses_me
38
+ from .get_licenses_nj import get_licenses_nj
39
+ from .get_licenses_nv import get_licenses_nv
40
+ from .get_licenses_or import get_licenses_or
41
+ from .get_licenses_wa import get_licenses_wa
42
+
43
+
44
+ # === Test ===
45
+ if __name__ == '__main':
46
+
47
+ # Support command line usage.
48
+ import argparse
49
+ try:
50
+ arg_parser = argparse.ArgumentParser()
51
+ arg_parser.add_argument('--d', dest='data_dir', type=str)
52
+ arg_parser.add_argument('--data_dir', dest='data_dir', type=str)
53
+ arg_parser.add_argument('--env', dest='env_file', type=str)
54
+ args = arg_parser.parse_args()
55
+ except SystemExit:
56
+ args = {'d': '../data/all', 'env_file': '../.env'}
57
+
58
+ # Get arguments.
59
+ data_dir = args.get('d', args.get('data_dir'))
60
+ env_file = args.get('env_file')
61
+
62
+ # Get licenses for each state.
63
+ get_licenses_ca(data_dir, env_file=env_file)
64
+ get_licenses_me(data_dir, env_file=env_file)
65
+ get_licenses_nj(data_dir, env_file=env_file)
66
+ get_licenses_nv(data_dir, env_file=env_file)
67
+ get_licenses_or(data_dir, env_file=env_file)
68
+ get_licenses_wa(data_dir, env_file=env_file)
analysis/figures/cannabis-licenses-map.html CHANGED
The diff for this file is too large to render. See raw diff
 
analysis/license_map.py CHANGED
@@ -1,284 +1,91 @@
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)
 
1
  """
2
+ Cannabis Licenses | License Mao
3
  Copyright (c) 2022 Cannlytics
4
 
5
  Authors:
6
  Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
  Created: 9/22/2022
9
+ Updated: 9/30/2022
10
  License: <https://github.com/cannlytics/cannabis-data-science/blob/main/LICENSE>
11
 
12
  Description:
13
 
14
+ Map the adult-use cannabis retailers permitted in the United States:
15
+
16
+ - Alaska
17
+ - Arizona
18
+ California
19
+ - Colorado
20
+ - Connecticut
21
+ - Illinois
22
+ Maine
23
+ - Massachusetts
24
+ - Michigan
25
+ - Montana
26
+ ✓ Nevada
27
+ New Jersey
28
+ - New Mexico
29
+ - New York
30
+ Oregon
31
+ - Rhode Island
32
+ - Vermont
33
+ Washington
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  """
36
  # Standard imports.
37
+ import os
38
 
39
  # External imports.
40
  import folium
 
41
  import pandas as pd
 
42
 
43
 
44
  # Specify where your data lives.
45
  DATA_DIR = '../data'
46
+ DATA_FILES = {
47
+ 'ca': 'ca/licenses-ca-2022-09-21T19-02-29.xlsx',
48
+ 'me': 'me/licenses-me-2022-09-30T16-44-03.xlsx',
49
+ 'nj': 'nj/licenses-nj-2022-09-29T16-17-38.xlsx',
50
+ 'nv': 'nv/retailers-nv-2022-09-30T07-41-59.xlsx',
51
+ 'or': 'or/licenses-or-2022-09-28T10-11-12.xlsx',
52
+ 'wa': 'wa/licenses-wa-2022-09-29T14-44-25.xlsx',
53
+ }
54
 
55
  #-----------------------------------------------------------------------
56
  # Get the data.
57
  #-----------------------------------------------------------------------
58
 
59
+ # Read license data for each state.
60
+ data = []
61
+ for state, data_file in DATA_FILES.items():
62
+ filename = os.path.join(DATA_DIR, DATA_FILES[state])
63
+ licenses = pd.read_excel(filename, index_col=0)
64
+ data.append(licenses)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
+ # Aggregate all retailers and keep only those with latitude and longitude.
67
+ retailers = pd.concat(data)
 
 
 
 
 
 
 
 
68
  retailers = retailers.loc[
69
  (~retailers['premise_longitude'].isnull()) &
70
  (~retailers['premise_latitude'].isnull())
71
  ]
72
 
 
 
 
 
 
 
 
 
73
 
74
+ #-----------------------------------------------------------------------
75
+ # Look at the data!
76
+ #-----------------------------------------------------------------------
77
 
78
  # Create an interactive map.
79
  locations = retailers[['premise_latitude', 'premise_longitude']].to_numpy()
80
  m = folium.Map(
81
+ location=[39.8283, -98.5795],
82
+ zoom_start=3,
83
  control_scale=True,
84
  )
85
  for index, row in retailers.iterrows():
86
  folium.Circle(
87
+ radius=5,
88
  location=[row['premise_latitude'], row['premise_longitude']],
89
  color='crimson',
90
  ).add_to(m)
91
+ m.save('../analysis/figures/cannabis-licenses-map.html')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cannabis_licenses.py ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Candace O'Sullivan-Sutherland <https://github.com/candy-o>
8
+ Created: 9/29/2022
9
+ Updated: 9/29/2022
10
+ License: <https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/LICENSE>
11
+ """
12
+ # Standard imports.
13
+ import json
14
+
15
+ # External imports.
16
+ import datasets
17
+ import pandas as pd
18
+
19
+
20
+ # Constants.
21
+ _VERSION = '1.0.0'
22
+ _HOMEPAGE = 'https://huggingface.co/datasets/cannlytics/cannabis_licenses'
23
+ _LICENSE = "https://opendatacommons.org/licenses/by/4-0/"
24
+ _DESCRIPTION = """\
25
+ Cannabis Licenses (https://cannlytics.com/data/licenses) is a
26
+ dataset of curated cannabis license data. The dataset consists of 16
27
+ sub-datasets for each state with permitted adult-use cannabis, as well
28
+ as a sub-dataset that includes all licenses.
29
+ """
30
+ _CITATION = """\
31
+ @inproceedings{cannlytics2022cannabis_licenses,
32
+ author = {Skeate, Keegan and O'Sullivan-Sutherland, Candace},
33
+ title = {Cannabis Licenses},
34
+ booktitle = {Cannabis Data Science},
35
+ month = {September},
36
+ year = {2022},
37
+ address = {United States of America},
38
+ publisher = {Cannlytics}
39
+ }
40
+ """
41
+
42
+ # Dataset fields.
43
+ FIELDS = datasets.Features({
44
+ 'id': datasets.Value(dtype='string'),
45
+ 'license_number': datasets.Value(dtype='string'),
46
+ 'license_status': datasets.Value(dtype='string'),
47
+ 'license_status_date': datasets.Value(dtype='string'),
48
+ 'license_term': datasets.Value(dtype='string'),
49
+ 'license_type': datasets.Value(dtype='string'),
50
+ 'issue_date': datasets.Value(dtype='string'),
51
+ 'expiration_date': datasets.Value(dtype='string'),
52
+ 'licensing_authority_id': datasets.Value(dtype='string'),
53
+ 'licensing_authority': datasets.Value(dtype='string'),
54
+ 'business_legal_name': datasets.Value(dtype='string'),
55
+ 'business_dba_name': datasets.Value(dtype='string'),
56
+ 'business_owner_name': datasets.Value(dtype='string'),
57
+ 'business_structure': datasets.Value(dtype='string'),
58
+ 'activity': datasets.Value(dtype='string'),
59
+ 'premise_street_address': datasets.Value(dtype='string'),
60
+ 'premise_city': datasets.Value(dtype='string'),
61
+ 'premise_state': datasets.Value(dtype='string'),
62
+ 'premise_county': datasets.Value(dtype='string'),
63
+ 'premise_zip_code': datasets.Value(dtype='string'),
64
+ 'business_email': datasets.Value(dtype='string'),
65
+ 'business_phone': datasets.Value(dtype='string'),
66
+ 'parcel_number': datasets.Value(dtype='string'),
67
+ 'premise_latitude': datasets.Value(dtype='float'),
68
+ 'premise_longitude': datasets.Value(dtype='float'),
69
+ 'data_refreshed_date': datasets.Value(dtype='string'),
70
+ })
71
+
72
+ # Read dataset subsets.
73
+ with open('subsets.json', 'r') as f:
74
+ SUBSETS = json.loads(f.read())
75
+
76
+
77
+ class CannabisLicensesConfig(datasets.BuilderConfig):
78
+ """BuilderConfig for Cannabis Licenses."""
79
+
80
+ def __init__(self, name, **kwargs):
81
+ """BuilderConfig for Cannabis Licenses.
82
+ Args:
83
+ name (str): Configuration name that determines setup.
84
+ **kwargs: Keyword arguments forwarded to super.
85
+ """
86
+ description = _DESCRIPTION
87
+ description += f'This configuration is for the `{name}` subset.'
88
+ super().__init__(name=name, description=description, **kwargs)
89
+
90
+
91
+ class CannabisLicenses(datasets.GeneratorBasedBuilder):
92
+ """The Cannabis Licenses dataset."""
93
+
94
+ VERSION = datasets.Version(_VERSION)
95
+ BUILDER_CONFIG_CLASS = CannabisLicensesConfig
96
+ BUILDER_CONFIGS = [CannabisLicensesConfig(s) for s in SUBSETS.keys()]
97
+ DEFAULT_CONFIG_NAME = 'ca'
98
+
99
+ def _info(self):
100
+ """Returns the dataset metadata."""
101
+ return datasets.DatasetInfo(
102
+ features=FIELDS,
103
+ supervised_keys=None,
104
+ homepage=_HOMEPAGE,
105
+ citation=_CITATION,
106
+ description=_DESCRIPTION,
107
+ license=_LICENSE,
108
+ version=_VERSION,
109
+ )
110
+
111
+ def _split_generators(self, dl_manager):
112
+ """Returns SplitGenerators."""
113
+ config_name = self.config.name
114
+ data_url = SUBSETS[config_name]['data_url']
115
+ urls = {config_name: data_url}
116
+ downloaded_files = dl_manager.download_and_extract(urls)
117
+ filepath = downloaded_files[config_name]
118
+ params = {'filepath': filepath}
119
+ return [datasets.SplitGenerator(name='data', gen_kwargs=params)]
120
+
121
+ def _generate_examples(self, filepath):
122
+ """Returns the examples in raw text form."""
123
+ with open(filepath) as f:
124
+ df = pd.read_csv(filepath)
125
+ for index, row in df.iterrows():
126
+ obs = row.to_dict()
127
+ yield index, obs
128
+
129
+
130
+ # === Test ===
131
+ if __name__ == '__main__':
132
+
133
+ from datasets import load_dataset
134
+
135
+ # Load the dataset.
136
+ dataset = load_dataset('cannabis_licenses.py', 'ca')
137
+ data = dataset['data']
138
+ assert len(data) > 0
139
+ print('Read %i licenses.' % len(data))
data/ca/licenses-ca-2022-09-21T19-02-29.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:043cbc637b350900dd8e443ee69f5af22ccfa5fa352591c9afbc3c3ddf70e130
3
+ size 2224034
data/me/licenses-me-2022-09-30T16-44-03.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40e2cbc9ae9ce900ad49c95dbfaec38be6934ce501db2d8c8c3df5434741683b
3
+ size 58428
data/nj/licenses-nj-2022-09-29T16-17-38.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43f813dd02efc1c62b8a8752dad76a4678ecde70f340d5346219a567d75f4b73
3
+ size 9238
data/nv/licenses-nv-2022-09-30T07-37-45.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:389815eb373420e86e2b33e5826404a0f7e258f9e0f3f98fc6e576cfb4cca5ed
3
+ size 60579
data/nv/retailers-nv-2022-09-30T07-41-59.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b347ca54b3859673360348cf81a24c09ba5e75e957caa39d756b398390c7d0f0
3
+ size 13816
data/or/licenses-or-2022-09-28T10-11-12.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb2221a123a531a5376cb4e8c27bc0d736e19a0dad75b868d33aa91f23e02c74
3
+ size 103522
data/wa/licenses-wa-2022-09-29T14-44-25.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af8a143d93b5ffb055b56d5632d43bfd0e3c68b8637fb34886adb0e7798ef925
3
+ size 87330
env.example ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ FRED_API_KEY=abc
2
+ GOOGLE_MAPS_API_KEY=xyz
manage.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Cannabis Licenses | Management
3
+ Copyright (c) 2022 Cannlytics
4
+
5
+ Authors:
6
+ Keegan Skeate <https://github.com/keeganskeate>
7
+ Created: 9/29/2022
8
+ Updated: 9/29/2022
9
+ License: <https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/LICENSE>
10
+ """
11
+ # Standard imports.
12
+ import argparse
13
+
14
+
15
+ def aggregate():
16
+ """Aggregate all subsets into a single data file."""
17
+ # TODO: Implement!
18
+
19
+ raise NotImplementedError
20
+
21
+
22
+ def upload():
23
+ """Upload all data files and create dynamic links."""
24
+ # TODO: Implement!
25
+
26
+ raise NotImplementedError
27
+
28
+
29
+ # === Support command line usage. ===
30
+ if __name__ == '__main__':
31
+
32
+ # Get command line arguments.
33
+ try:
34
+ arg_parser = argparse.ArgumentParser()
35
+ arg_parser.add_argument(
36
+ '--aggregate',
37
+ dest='aggregate',
38
+ action=argparse.BooleanOptionalAction,
39
+ )
40
+ arg_parser.add_argument(
41
+ '--upload',
42
+ dest='upload',
43
+ action=argparse.BooleanOptionalAction,
44
+ )
45
+ args = arg_parser.parse_args()
46
+ except SystemExit:
47
+ args = {}
48
+
49
+ # Perform specified action, otherwise aggregate and upload.
50
+ if args.get('aggregate'):
51
+ aggregate()
52
+ elif args.get('upload'):
53
+ upload()
54
+ else:
55
+ aggregate()
56
+ upload()
requirements.txt CHANGED
@@ -11,3 +11,4 @@ pandas==1.4.4
11
  pdfplumber==0.7.4
12
  python-dotenv==0.21.0
13
  seaborn==0.12.0
 
 
11
  pdfplumber==0.7.4
12
  python-dotenv==0.21.0
13
  seaborn==0.12.0
14
+ xlrd==2.0.1
subsets.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ak": {
3
+ "name": "ak",
4
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ak.py",
5
+ "data_source": "https://www.commerce.alaska.gov/abc/marijuana/Home/licensesearch",
6
+ "data_url": ""
7
+ },
8
+ "az": {
9
+ "name": "az",
10
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_az.py",
11
+ "data_source": "https://azcarecheck.azdhs.gov/s/?licenseType=null",
12
+ "data_url": ""
13
+ },
14
+ "ca": {
15
+ "name": "ca",
16
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ca.py",
17
+ "data_source": "https://search.cannabis.ca.gov/",
18
+ "data_url": "https://cannlytics.page.link/?link=https://firebasestorage.googleapis.com/v0/b/cannlytics.appspot.com/o/data%252Flicenses%252Fca%252Flicenses-ca-2022-09-21T19-02-29.xlsx?alt%3Dmedia%26token%3Dbde64ea0-4cd0-46b4-be01-155bf06f949a"
19
+ },
20
+ "co": {
21
+ "name": "co",
22
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_co.py",
23
+ "data_source": "",
24
+ "data_url": ""
25
+ },
26
+ "ct": {
27
+ "name": "ct",
28
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ct.py",
29
+ "data_source": "https://portal.ct.gov/DCP/Medical-Marijuana-Program/Connecticut-Medical-Marijuana-Dispensary-Facilities",
30
+ "data_url": ""
31
+ },
32
+ "il": {
33
+ "name": "il",
34
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_il.py",
35
+ "data_source": "",
36
+ "data_url": ""
37
+ },
38
+ "ma": {
39
+ "name": "ma",
40
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ma.py",
41
+ "data_source": "",
42
+ "data_url": ""
43
+ },
44
+ "me": {
45
+ "name": "me",
46
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_me.py",
47
+ "data_source": "https://www.maine.gov/dafs/ocp/open-data/adult-use",
48
+ "data_url": ""
49
+ },
50
+ "mi": {
51
+ "name": "mi",
52
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_mi.py",
53
+ "data_source": "",
54
+ "data_url": ""
55
+ },
56
+ "mt": {
57
+ "name": "mt",
58
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_mt.py",
59
+ "data_source": "https://mtrevenue.gov/cannabis/#CannabisLicenses",
60
+ "data_url": ""
61
+ },
62
+ "nj": {
63
+ "name": "nj",
64
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_nj.py",
65
+ "data_source": "https://data.nj.gov/stories/s/ggm4-mprw",
66
+ "data_url": ""
67
+ },
68
+ "nm": {
69
+ "name": "nm",
70
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_nm.py",
71
+ "data_source": "https://nmrldlpi.force.com/bcd/s/public-search-license?division=CCD&language=en_US",
72
+ "data_url": ""
73
+ },
74
+ "nv": {
75
+ "name": "nv",
76
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_nv.py",
77
+ "data_source": "https://ccb.nv.gov/list-of-licensees/",
78
+ "data_url": ""
79
+ },
80
+ "or": {
81
+ "name": "or",
82
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ca.py",
83
+ "data_source": "https://www.oregon.gov/olcc/marijuana/pages/recreational-marijuana-licensing.aspx",
84
+ "data_url": "https://cannlytics.page.link/?link=https://firebasestorage.googleapis.com/v0/b/cannlytics.appspot.com/o/data%252Flicenses%252For%252Flicenses-or-2022-09-28T10-11-12.xlsx?alt%3Dmedia%26token%3Dabd5aa4d-2335-4ab1-bae7-b3bd533d2206"
85
+ },
86
+ "ri": {
87
+ "name": "ri",
88
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ri.py",
89
+ "data_source": "https://dbr.ri.gov/office-cannabis-regulation/compassion-centers/licensed-compassion-centers",
90
+ "data_url": ""
91
+ },
92
+ "vt": {
93
+ "name": "vt",
94
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_vt.py",
95
+ "data_source": "https://ccb.vermont.gov/licenses",
96
+ "data_url": ""
97
+ },
98
+ "wa": {
99
+ "name": "wa",
100
+ "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_wa.py",
101
+ "data_source": "https://lcb.wa.gov/records/frequently-requested-lists",
102
+ "data_url": ""
103
+ }
104
+ }