diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 9f48abdaf7e3d028226fcb8fbe20fa30ce79d5ab..0000000000000000000000000000000000000000 --- a/.gitattributes +++ /dev/null @@ -1,53 +0,0 @@ -*.7z filter=lfs diff=lfs merge=lfs -text -*.arrow filter=lfs diff=lfs merge=lfs -text -*.bin filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.ftz filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.h5 filter=lfs diff=lfs merge=lfs -text -*.joblib filter=lfs diff=lfs merge=lfs -text -*.lfs.* filter=lfs diff=lfs merge=lfs -text -*.lz4 filter=lfs diff=lfs merge=lfs -text -*.model filter=lfs diff=lfs merge=lfs -text -*.msgpack filter=lfs diff=lfs merge=lfs -text -*.npy filter=lfs diff=lfs merge=lfs -text -*.npz filter=lfs diff=lfs merge=lfs -text -*.onnx filter=lfs diff=lfs merge=lfs -text -*.ot filter=lfs diff=lfs merge=lfs -text -*.parquet filter=lfs diff=lfs merge=lfs -text -*.pb filter=lfs diff=lfs merge=lfs -text -*.pickle filter=lfs diff=lfs merge=lfs -text -*.pkl filter=lfs diff=lfs merge=lfs -text -*.pt filter=lfs diff=lfs merge=lfs -text -*.pth filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -saved_model/**/* filter=lfs diff=lfs merge=lfs -text -*.tar.* filter=lfs diff=lfs merge=lfs -text -*.tflite filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.wasm filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text -*.zst filter=lfs diff=lfs merge=lfs -text -*tfevents* filter=lfs diff=lfs merge=lfs -text -# Audio files - uncompressed -*.pcm filter=lfs diff=lfs merge=lfs -text -*.sam filter=lfs diff=lfs merge=lfs -text -*.raw filter=lfs diff=lfs merge=lfs -text -# Audio files - compressed -*.aac filter=lfs diff=lfs merge=lfs -text -*.flac filter=lfs diff=lfs merge=lfs -text -*.mp3 filter=lfs diff=lfs merge=lfs -text -*.ogg filter=lfs diff=lfs merge=lfs -text -*.wav filter=lfs diff=lfs merge=lfs -text -# Image files - uncompressed -*.bmp filter=lfs diff=lfs merge=lfs -text -*.gif filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text -*.tiff filter=lfs diff=lfs merge=lfs -text -# Image files - compressed -*.jpg filter=lfs diff=lfs merge=lfs -text -*.jpeg filter=lfs diff=lfs merge=lfs -text -*.webp filter=lfs diff=lfs merge=lfs -text -*.xlsx filter=lfs diff=lfs merge=lfs -text -*.csv filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 389c02685b4f9952536fcd38ee399108e895b80e..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# Ignore environment variables. -*.env - -# Ignore temporary files. -*tmp - -# Ignore PDFs. -*pdfs - -# Ignore external datasets. -*.datasets - -# Ignore VS Code settings. -*.vscode - -# Ignore PyCache -*__pycache__ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 4ea99c213c5c0c005ae4e80df8e52169d06896ec..0000000000000000000000000000000000000000 --- a/LICENSE +++ /dev/null @@ -1,395 +0,0 @@ -Attribution 4.0 International - -======================================================================= - -Creative Commons Corporation ("Creative Commons") is not a law firm and -does not provide legal services or legal advice. Distribution of -Creative Commons public licenses does not create a lawyer-client or -other relationship. Creative Commons makes its licenses and related -information available on an "as-is" basis. Creative Commons gives no -warranties regarding its licenses, any material licensed under their -terms and conditions, or any related information. Creative Commons -disclaims all liability for damages resulting from their use to the -fullest extent possible. - -Using Creative Commons Public Licenses - -Creative Commons public licenses provide a standard set of terms and -conditions that creators and other rights holders may use to share -original works of authorship and other material subject to copyright -and certain other rights specified in the public license below. The -following considerations are for informational purposes only, are not -exhaustive, and do not form part of our licenses. - - Considerations for licensors: Our public licenses are - intended for use by those authorized to give the public - permission to use material in ways otherwise restricted by - copyright and certain other rights. Our licenses are - irrevocable. Licensors should read and understand the terms - and conditions of the license they choose before applying it. - Licensors should also secure all rights necessary before - applying our licenses so that the public can reuse the - material as expected. Licensors should clearly mark any - material not subject to the license. This includes other CC- - licensed material, or material used under an exception or - limitation to copyright. More considerations for licensors: - wiki.creativecommons.org/Considerations_for_licensors - - Considerations for the public: By using one of our public - licenses, a licensor grants the public permission to use the - licensed material under specified terms and conditions. If - the licensor's permission is not necessary for any reason--for - example, because of any applicable exception or limitation to - copyright--then that use is not regulated by the license. Our - licenses grant only permissions under copyright and certain - other rights that a licensor has authority to grant. Use of - the licensed material may still be restricted for other - reasons, including because others have copyright or other - rights in the material. A licensor may make special requests, - such as asking that all changes be marked or described. - Although not required by our licenses, you are encouraged to - respect those requests where reasonable. More considerations - for the public: - wiki.creativecommons.org/Considerations_for_licensees - -======================================================================= - -Creative Commons Attribution 4.0 International Public License - -By exercising the Licensed Rights (defined below), You accept and agree -to be bound by the terms and conditions of this Creative Commons -Attribution 4.0 International Public License ("Public License"). To the -extent this Public License may be interpreted as a contract, You are -granted the Licensed Rights in consideration of Your acceptance of -these terms and conditions, and the Licensor grants You such rights in -consideration of benefits the Licensor receives from making the -Licensed Material available under these terms and conditions. - - -Section 1 -- Definitions. - - a. Adapted Material means material subject to Copyright and Similar - Rights that is derived from or based upon the Licensed Material - and in which the Licensed Material is translated, altered, - arranged, transformed, or otherwise modified in a manner requiring - permission under the Copyright and Similar Rights held by the - Licensor. For purposes of this Public License, where the Licensed - Material is a musical work, performance, or sound recording, - Adapted Material is always produced where the Licensed Material is - synched in timed relation with a moving image. - - b. Adapter's License means the license You apply to Your Copyright - and Similar Rights in Your contributions to Adapted Material in - accordance with the terms and conditions of this Public License. - - c. Copyright and Similar Rights means copyright and/or similar rights - closely related to copyright including, without limitation, - performance, broadcast, sound recording, and Sui Generis Database - Rights, without regard to how the rights are labeled or - categorized. For purposes of this Public License, the rights - specified in Section 2(b)(1)-(2) are not Copyright and Similar - Rights. - - d. Effective Technological Measures means those measures that, in the - absence of proper authority, may not be circumvented under laws - fulfilling obligations under Article 11 of the WIPO Copyright - Treaty adopted on December 20, 1996, and/or similar international - agreements. - - e. Exceptions and Limitations means fair use, fair dealing, and/or - any other exception or limitation to Copyright and Similar Rights - that applies to Your use of the Licensed Material. - - f. Licensed Material means the artistic or literary work, database, - or other material to which the Licensor applied this Public - License. - - g. Licensed Rights means the rights granted to You subject to the - terms and conditions of this Public License, which are limited to - all Copyright and Similar Rights that apply to Your use of the - Licensed Material and that the Licensor has authority to license. - - h. Licensor means the individual(s) or entity(ies) granting rights - under this Public License. - - i. Share means to provide material to the public by any means or - process that requires permission under the Licensed Rights, such - as reproduction, public display, public performance, distribution, - dissemination, communication, or importation, and to make material - available to the public including in ways that members of the - public may access the material from a place and at a time - individually chosen by them. - - j. Sui Generis Database Rights means rights other than copyright - resulting from Directive 96/9/EC of the European Parliament and of - the Council of 11 March 1996 on the legal protection of databases, - as amended and/or succeeded, as well as other essentially - equivalent rights anywhere in the world. - - k. You means the individual or entity exercising the Licensed Rights - under this Public License. Your has a corresponding meaning. - - -Section 2 -- Scope. - - a. License grant. - - 1. Subject to the terms and conditions of this Public License, - the Licensor hereby grants You a worldwide, royalty-free, - non-sublicensable, non-exclusive, irrevocable license to - exercise the Licensed Rights in the Licensed Material to: - - a. reproduce and Share the Licensed Material, in whole or - in part; and - - b. produce, reproduce, and Share Adapted Material. - - 2. Exceptions and Limitations. For the avoidance of doubt, where - Exceptions and Limitations apply to Your use, this Public - License does not apply, and You do not need to comply with - its terms and conditions. - - 3. Term. The term of this Public License is specified in Section - 6(a). - - 4. Media and formats; technical modifications allowed. The - Licensor authorizes You to exercise the Licensed Rights in - all media and formats whether now known or hereafter created, - and to make technical modifications necessary to do so. The - Licensor waives and/or agrees not to assert any right or - authority to forbid You from making technical modifications - necessary to exercise the Licensed Rights, including - technical modifications necessary to circumvent Effective - Technological Measures. For purposes of this Public License, - simply making modifications authorized by this Section 2(a) - (4) never produces Adapted Material. - - 5. Downstream recipients. - - a. Offer from the Licensor -- Licensed Material. Every - recipient of the Licensed Material automatically - receives an offer from the Licensor to exercise the - Licensed Rights under the terms and conditions of this - Public License. - - b. No downstream restrictions. You may not offer or impose - any additional or different terms or conditions on, or - apply any Effective Technological Measures to, the - Licensed Material if doing so restricts exercise of the - Licensed Rights by any recipient of the Licensed - Material. - - 6. No endorsement. Nothing in this Public License constitutes or - may be construed as permission to assert or imply that You - are, or that Your use of the Licensed Material is, connected - with, or sponsored, endorsed, or granted official status by, - the Licensor or others designated to receive attribution as - provided in Section 3(a)(1)(A)(i). - - b. Other rights. - - 1. Moral rights, such as the right of integrity, are not - licensed under this Public License, nor are publicity, - privacy, and/or other similar personality rights; however, to - the extent possible, the Licensor waives and/or agrees not to - assert any such rights held by the Licensor to the limited - extent necessary to allow You to exercise the Licensed - Rights, but not otherwise. - - 2. Patent and trademark rights are not licensed under this - Public License. - - 3. To the extent possible, the Licensor waives any right to - collect royalties from You for the exercise of the Licensed - Rights, whether directly or through a collecting society - under any voluntary or waivable statutory or compulsory - licensing scheme. In all other cases the Licensor expressly - reserves any right to collect such royalties. - - -Section 3 -- License Conditions. - -Your exercise of the Licensed Rights is expressly made subject to the -following conditions. - - a. Attribution. - - 1. If You Share the Licensed Material (including in modified - form), You must: - - a. retain the following if it is supplied by the Licensor - with the Licensed Material: - - i. identification of the creator(s) of the Licensed - Material and any others designated to receive - attribution, in any reasonable manner requested by - the Licensor (including by pseudonym if - designated); - - ii. a copyright notice; - - iii. a notice that refers to this Public License; - - iv. a notice that refers to the disclaimer of - warranties; - - v. a URI or hyperlink to the Licensed Material to the - extent reasonably practicable; - - b. indicate if You modified the Licensed Material and - retain an indication of any previous modifications; and - - c. indicate the Licensed Material is licensed under this - Public License, and include the text of, or the URI or - hyperlink to, this Public License. - - 2. You may satisfy the conditions in Section 3(a)(1) in any - reasonable manner based on the medium, means, and context in - which You Share the Licensed Material. For example, it may be - reasonable to satisfy the conditions by providing a URI or - hyperlink to a resource that includes the required - information. - - 3. If requested by the Licensor, You must remove any of the - information required by Section 3(a)(1)(A) to the extent - reasonably practicable. - - 4. If You Share Adapted Material You produce, the Adapter's - License You apply must not prevent recipients of the Adapted - Material from complying with this Public License. - - -Section 4 -- Sui Generis Database Rights. - -Where the Licensed Rights include Sui Generis Database Rights that -apply to Your use of the Licensed Material: - - a. for the avoidance of doubt, Section 2(a)(1) grants You the right - to extract, reuse, reproduce, and Share all or a substantial - portion of the contents of the database; - - b. if You include all or a substantial portion of the database - contents in a database in which You have Sui Generis Database - Rights, then the database in which You have Sui Generis Database - Rights (but not its individual contents) is Adapted Material; and - - c. You must comply with the conditions in Section 3(a) if You Share - all or a substantial portion of the contents of the database. - -For the avoidance of doubt, this Section 4 supplements and does not -replace Your obligations under this Public License where the Licensed -Rights include other Copyright and Similar Rights. - - -Section 5 -- Disclaimer of Warranties and Limitation of Liability. - - a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE - EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS - AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF - ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, - IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, - WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, - ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT - KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT - ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. - - b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE - TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, - NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, - INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, - COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR - USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR - DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR - IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. - - c. The disclaimer of warranties and limitation of liability provided - above shall be interpreted in a manner that, to the extent - possible, most closely approximates an absolute disclaimer and - waiver of all liability. - - -Section 6 -- Term and Termination. - - a. This Public License applies for the term of the Copyright and - Similar Rights licensed here. However, if You fail to comply with - this Public License, then Your rights under this Public License - terminate automatically. - - b. Where Your right to use the Licensed Material has terminated under - Section 6(a), it reinstates: - - 1. automatically as of the date the violation is cured, provided - it is cured within 30 days of Your discovery of the - violation; or - - 2. upon express reinstatement by the Licensor. - - For the avoidance of doubt, this Section 6(b) does not affect any - right the Licensor may have to seek remedies for Your violations - of this Public License. - - c. For the avoidance of doubt, the Licensor may also offer the - Licensed Material under separate terms or conditions or stop - distributing the Licensed Material at any time; however, doing so - will not terminate this Public License. - - d. Sections 1, 5, 6, 7, and 8 survive termination of this Public - License. - - -Section 7 -- Other Terms and Conditions. - - a. The Licensor shall not be bound by any additional or different - terms or conditions communicated by You unless expressly agreed. - - b. Any arrangements, understandings, or agreements regarding the - Licensed Material not stated herein are separate from and - independent of the terms and conditions of this Public License. - - -Section 8 -- Interpretation. - - a. For the avoidance of doubt, this Public License does not, and - shall not be interpreted to, reduce, limit, restrict, or impose - conditions on any use of the Licensed Material that could lawfully - be made without permission under this Public License. - - b. To the extent possible, if any provision of this Public License is - deemed unenforceable, it shall be automatically reformed to the - minimum extent necessary to make it enforceable. If the provision - cannot be reformed, it shall be severed from this Public License - without affecting the enforceability of the remaining terms and - conditions. - - c. No term or condition of this Public License will be waived and no - failure to comply consented to unless expressly agreed to by the - Licensor. - - d. Nothing in this Public License constitutes or may be interpreted - as a limitation upon, or waiver of, any privileges and immunities - that apply to the Licensor or You, including from the legal - processes of any jurisdiction or authority. - - -======================================================================= - -Creative Commons is not a party to its public -licenses. Notwithstanding, Creative Commons may elect to apply one of -its public licenses to material it publishes and in those instances -will be considered the “Licensor.” The text of the Creative Commons -public licenses is dedicated to the public domain under the CC0 Public -Domain Dedication. Except for the limited purpose of indicating that -material is shared under a Creative Commons public license or as -otherwise permitted by the Creative Commons policies published at -creativecommons.org/policies, Creative Commons does not authorize the -use of the trademark "Creative Commons" or any other trademark or logo -of Creative Commons without its prior written consent including, -without limitation, in connection with any unauthorized modifications -to any of its public licenses or any other arrangements, -understandings, or agreements concerning use of licensed material. For -the avoidance of doubt, this paragraph does not form part of the -public licenses. - -Creative Commons may be contacted at creativecommons.org. diff --git a/README.md b/README.md deleted file mode 100644 index 99d4ff227e17f8d76cfa9c5eefcfea2cf05a9487..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,281 +0,0 @@ ---- -annotations_creators: - - expert-generated -language_creators: - - expert-generated -license: - - cc-by-4.0 -pretty_name: cannabis_licenses -size_categories: - - 10K - - - -## Table of Contents -- [Table of Contents](#table-of-contents) -- [Dataset Description](#dataset-description) - - [Dataset Summary](#dataset-summary) -- [Dataset Structure](#dataset-structure) - - [Data Instances](#data-instances) - - [Data Fields](#data-fields) - - [Data Splits](#data-splits) -- [Dataset Creation](#dataset-creation) - - [Curation Rationale](#curation-rationale) - - [Source Data](#source-data) - - [Data Collection and Normalization](#data-collection-and-normalization) - - [Personal and Sensitive Information](#personal-and-sensitive-information) -- [Considerations for Using the Data](#considerations-for-using-the-data) - - [Social Impact of Dataset](#social-impact-of-dataset) - - [Discussion of Biases](#discussion-of-biases) - - [Other Known Limitations](#other-known-limitations) -- [Additional Information](#additional-information) - - [Dataset Curators](#dataset-curators) - - [License](#license) - - [Citation](#citation) - - [Contributions](#contributions) - -## Dataset Description - -- **Homepage:** -- **Repository:** -- **Point of Contact:** - -### Dataset Summary - -**Cannabis Licenses** is a collection of cannabis license data for each state with permitted adult-use cannabis. The dataset also includes a sub-dataset, `all`, that includes all licenses. - -## Dataset Structure - -The dataset is partitioned into 18 subsets for each state and the aggregate. - -| State | Code | Status | -|-------|------|--------| -| [All](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/all) | `all` | ✅ | -| [Alaska](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ak) | `ak` | ✅ | -| [Arizona](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/az) | `az` | ✅ | -| [California](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ca) | `ca` | ✅ | -| [Colorado](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/co) | `co` | ✅ | -| [Connecticut](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ct) | `ct` | ✅ | -| [Illinois](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/il) | `il` | ✅ | -| [Maine](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/me) | `me` | ✅ | -| [Massachusetts](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ma) | `ma` | ✅ | -| [Michigan](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/mi) | `mi` | ✅ | -| [Montana](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/mt) | `mt` | ✅ | -| [Nevada](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/nv) | `nv` | ✅ | -| [New Jersey](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/nj) | `nj` | ✅ | -| New York | `ny` | ⏳ Expected 2022 Q4 | -| [New Mexico](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/nm) | `nm` | ⚠️ Under development | -| [Oregon](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/or) | `or` | ✅ | -| [Rhode Island](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/ri) | `ri` | ✅ | -| [Vermont](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/vt) | `vt` | ✅ | -| Virginia | `va` | ⏳ Expected 2024 | -| [Washington](https://huggingface.co/datasets/cannlytics/cannabis_licenses/tree/main/data/wa) | `wa` | ✅ | - -The following (18) states have issued medical cannabis licenses, but are not (yet) included in the dataset: - -- Alabama -- Arkansas -- Delaware -- District of Columbia (D.C.) -- Florida -- Louisiana -- Maryland -- Minnesota -- Mississippi -- Missouri -- New Hampshire -- North Dakota -- Ohio -- Oklahoma -- Pennsylvania -- South Dakota -- Utah -- West Virginia - -### Data Instances - -You can load the licenses for each state. For example: - -```py -from datasets import load_dataset - -# Get the licenses for a specific state. -dataset = load_dataset('cannlytics/cannabis_licenses', 'ca') -data = dataset['data'] -assert len(data) > 0 -print('%i licenses.' % len(data)) -``` - -### Data Fields - -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. - -| Field | Example | Description | -|-------|-----|-------------| -| `id` | `"1046"` | A state-unique ID for the license. | -| `license_number` | `"C10-0000423-LIC"` | A unique license number. | -| `license_status` | `"Active"` | The status of the license. Only licenses that are active are included. | -| `license_status_date` | `"2022-04-20T00:00"` | The date the status was assigned, an ISO-formatted date if present. | -| `license_term` | `"Provisional"` | The term for the license. | -| `license_type` | `"Commercial - Retailer"` | The type of business license. | -| `license_designation` | `"Adult-Use and Medicinal"` | A state-specific classification for the license. | -| `issue_date` | `"2019-07-15T00:00:00"` | An issue date for the license, an ISO-formatted date if present. | -| `expiration_date` | `"2023-07-14T00:00:00"` | An expiration date for the license, an ISO-formatted date if present. | -| `licensing_authority_id` | `"BCC"` | A unique ID for the state licensing authority. | -| `licensing_authority` | `"Bureau of Cannabis Control (BCC)"` | The state licensing authority. | -| `business_legal_name` | `"Movocan"` | The legal name of the business that owns the license. | -| `business_dba_name` | `"Movocan"` | The name the license is doing business as. | -| `business_owner_name` | `"redacted"` | The name of the owner of the license. | -| `business_structure` | `"Corporation"` | The structure of the business that owns the license. | -| `activity` | `"Pending Inspection"` | Any relevant license activity. | -| `premise_street_address` | `"1632 Gateway Rd"` | The street address of the business. | -| `premise_city` | `"Calexico"` | The city of the business. | -| `premise_state` | `"CA"` | The state abbreviation of the business. | -| `premise_county` | `"Imperial"` | The county of the business. | -| `premise_zip_code` | `"92231"` | The zip code of the business. | -| `business_email` | `"redacted@gmail.com"` | The business email of the license. | -| `business_phone` | `"(555) 555-5555"` | The business phone of the license. | -| `business_website` | `"cannlytics.com"` | The business website of the license. | -| `parcel_number` | `"A42"` | An ID for the business location. | -| `premise_latitude` | `32.69035693` | The latitude of the business. | -| `premise_longitude` | `-115.38987552` | The longitude of the business. | -| `data_refreshed_date` | `"2022-09-21T12:16:33.3866667"` | An ISO-formatted time when the license data was updated. | - -### Data Splits - -The data is split into subsets by state. You can retrieve all licenses by requesting the `all` subset. - -```py -from datasets import load_dataset - -# Get all cannabis licenses. -repo = 'cannlytics/cannabis_licenses' -dataset = load_dataset(repo, 'all') -data = dataset['data'] -``` - -## Dataset Creation - -### Curation Rationale - -Data about organizations operating in the cannabis industry for each state is valuable for research. - -### Source Data - -| State | Data Source URL | -|-------|-----------------| -| Alaska | | -| Arizona | | -| California | | -| Colorado | | -| Connecticut | | -| Illinois | | -| Maine | | -| Massachusetts | | -| Michigan | | -| Montana | | -| Nevada | | -| New Jersey | | -| New Mexico | | -| Oregon | | -| Rhode Island | | -| Vermont | | -| Washington | | - -### Data Collection and Normalization - -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: - -``` -git clone https://huggingface.co/datasets/cannlytics/cannabis_licenses -``` - -You can then install the algorithm Python (3.9+) requirements: - -``` -cd cannabis_licenses -pip install -r requirements.txt -``` - -Then you can run all of the data-collection algorithms: - -``` -python algorithms/main.py -``` - -Or you can run each algorithm individually. For example: - -``` -python algorithms/get_licenses_ca.py -``` - -### Personal and Sensitive Information - -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. - -## Considerations for Using the Data - -### Social Impact of Dataset - -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. - -### Discussion of Biases - -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. - -### Other Known Limitations - -The data is for adult-use cannabis licenses. It would be valuable to include medical cannabis licenses too. - -## Additional Information - -### Dataset Curators - -Curated by [🔥Cannlytics](https://cannlytics.com)
- - -### License - -``` -Copyright (c) 2022 Cannlytics and the Cannabis Data Science Team - -The files associated with this dataset are licensed under a -Creative Commons Attribution 4.0 International license. - -You can share, copy and modify this dataset so long as you give -appropriate credit, provide a link to the CC BY license, and -indicate if changes were made, but you may not do so in a way -that suggests the rights holder has endorsed you or your use of -the dataset. Note that further permission may be required for -any content within the dataset that is identified as belonging -to a third party. -``` - -### Citation - -Please cite the following if you use the code examples in your research: - -```bibtex -@misc{cannlytics2022, - title={Cannabis Data Science}, - author={Skeate, Keegan and O'Sullivan-Sutherland, Candace}, - journal={https://github.com/cannlytics/cannabis-data-science}, - year={2022} -} -``` - -### Contributions - -Thanks to [🔥Cannlytics](https://cannlytics.com), [@candy-o](https://github.com/candy-o), [@hcadeaux](https://huggingface.co/hcadeaux), [@keeganskeate](https://github.com/keeganskeate), and the entire [Cannabis Data Science Team](https://meetup.com/cannabis-data-science/members) for their contributions. diff --git a/ak/cannabis_licenses-data.parquet b/ak/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..338b4831e83a71ba714caef712d7d12fc1a82523 --- /dev/null +++ b/ak/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b0f1da9b170ad51f59abbe6e00799b484a37dc66c655dcc9014841bf87c7792 +size 33684 diff --git a/algorithms/__init__.py b/algorithms/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/algorithms/get_licenses_ak.py b/algorithms/get_licenses_ak.py deleted file mode 100644 index 3a705233f7a62818e3b23f3517e00c118d56080d..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_ak.py +++ /dev/null @@ -1,244 +0,0 @@ -""" -Cannabis Licenses | Get Alaska Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/6/2022 -License: - -Description: - - Collect Alaska cannabis license data. - -Data Source: - - - Department of Commerce, Community, and Economic Development - Alcohol and Marijuana Control Office - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from time import sleep -from typing import Optional - -# External imports. -from cannlytics.data.gis import search_for_address -from dotenv import dotenv_values -import pandas as pd - -# Selenium imports. -from selenium import webdriver -from selenium.webdriver.chrome.options import Options -from selenium.webdriver.common.by import By -from selenium.webdriver.chrome.service import Service -try: - import chromedriver_binary # Adds chromedriver binary to path. -except ImportError: - pass # Otherwise, ChromeDriver should be in your path. - - -# Specify where your data lives. -DATA_DIR = '../data/ak' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'AK' -ALASKA = { - 'licensing_authority_id': 'AAMCO', - 'licensing_authority': 'Alaska Alcohol and Marijuana Control Office', - 'licenses_url': 'https://www.commerce.alaska.gov/abc/marijuana/Home/licensesearch', - 'licenses': { - 'columns': { - 'License #': 'license_number', - 'Business License #': 'id', - 'Doing Business As': 'business_dba_name', - 'License Type': 'license_type', - 'License Status': 'license_status', - 'Physical Address': 'address', - }, - }, -} - - -def get_licenses_ak( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Alaska cannabis license data.""" - - # Initialize Selenium and specify options. - service = Service() - options = Options() - options.add_argument('--window-size=1920,1200') - - # DEV: Run with the browser open. - # options.headless = False - - # PRODUCTION: Run with the browser closed. - options.add_argument('--headless') - options.add_argument('--disable-gpu') - options.add_argument('--no-sandbox') - - # Initiate a Selenium driver. - driver = webdriver.Chrome(options=options, service=service) - - # Load the license page. - driver.get(ALASKA['licenses_url']) - - # Get the license type select. - license_types = [] - options = driver.find_elements(by=By.TAG_NAME, value='option') - for option in options: - text = option.text - if text: - license_types.append(text) - - # Iterate over all of the license types. - data = [] - columns = list(ALASKA['licenses']['columns'].values()) - for license_type in license_types: - - # Set the text into the select. - select = driver.find_element(by=By.ID, value='SearchLicenseTypeID') - select.send_keys(license_type) - - # Click search. - # TODO: There is probably an elegant way to wait for the table to load. - search_button = driver.find_element(by=By.ID, value='mariSearchBtn') - search_button.click() - sleep(2) - - # Extract the table data. - table = driver.find_element(by=By.TAG_NAME, value='tbody') - rows = table.find_elements(by=By.TAG_NAME, value='tr') - for row in rows: - obs = {} - cells = row.find_elements(by=By.TAG_NAME, value='td') - for i, cell in enumerate(cells): - column = columns[i] - obs[column] = cell.text.replace('\n', ', ') - data.append(obs) - - # End the browser session. - service.stop() - - # Standardize the license data. - licenses = pd.DataFrame(data) - licenses = licenses.assign( - business_legal_name=licenses['business_dba_name'], - business_owner_name=None, - business_structure=None, - licensing_authority_id=ALASKA['licensing_authority_id'], - licensing_authority=ALASKA['licensing_authority'], - license_designation='Adult-Use', - license_status_date=None, - license_term=None, - premise_state=STATE, - parcel_number=None, - activity=None, - issue_date=None, - expiration_date=None, - ) - - # Restrict the license status to active. - active_license_types = [ - 'Active-Operating', - 'Active-Pending Inspection', - 'Delegated', - 'Complete', - ] - licenses = licenses.loc[licenses['license_status'].isin(active_license_types)] - - # Assign the city and zip code. - licenses['premise_city'] = licenses['address'].apply( - lambda x: x.split(', ')[1] - ) - licenses['premise_zip_code'] = licenses['address'].apply( - lambda x: x.split(', ')[2].replace(STATE, '').strip() - ) - - # Search for address for each retail license. - # Only search for a query once, then re-use the response. - # Note: There is probably a much, much more efficient way to do this!!! - config = dotenv_values(env_file) - api_key = config['GOOGLE_MAPS_API_KEY'] - queries = {} - fields = [ - 'formatted_address', - 'formatted_phone_number', - 'geometry/location/lat', - 'geometry/location/lng', - 'website', - ] - licenses = licenses.reset_index(drop=True) - licenses = licenses.assign( - premise_street_address=None, - premise_county=None, - premise_latitude=None, - premise_longitude=None, - business_phone=None, - business_website=None, - ) - for index, row in licenses.iterrows(): - - # Query Google Place API, if necessary. - query = ', '.join([row['business_dba_name'], row['address']]) - gis_data = queries.get(query) - if gis_data is None: - try: - gis_data = search_for_address(query, api_key=api_key, fields=fields) - except: - gis_data = {} - queries[query] = gis_data - - # Record the query. - licenses.iat[index, licenses.columns.get_loc('premise_street_address')] = gis_data.get('street') - licenses.iat[index, licenses.columns.get_loc('premise_county')] = gis_data.get('county') - licenses.iat[index, licenses.columns.get_loc('premise_latitude')] = gis_data.get('latitude') - licenses.iat[index, licenses.columns.get_loc('premise_longitude')] = gis_data.get('longitude') - licenses.iat[index, licenses.columns.get_loc('business_phone')] = gis_data.get('formatted_phone_number') - licenses.iat[index, licenses.columns.get_loc('business_website')] = gis_data.get('website') - - # Clean-up after GIS. - licenses.drop(columns=['address'], inplace=True) - - # Optional: Search for business website for email and a photo. - licenses['business_email'] = None - licenses['business_image_url'] = None - - # Get the refreshed date. - licenses['data_refreshed_date'] = datetime.now().isoformat() - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers = licenses.loc[licenses['license_type'] == 'Retail Marijuana Store'] - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - return licenses - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_ak(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_az.py b/algorithms/get_licenses_az.py deleted file mode 100644 index 45a35cdbd998087999cb72703345a3eeddb83581..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_az.py +++ /dev/null @@ -1,333 +0,0 @@ -""" -Cannabis Licenses | Get Arizona Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/27/2022 -Updated: 10/7/2022 -License: - -Description: - - Collect Arizona cannabis license data. - -Data Source: - - - Arizona Department of Health Services | Division of Licensing - URL: - -""" -# Standard imports. -from datetime import datetime -from dotenv import dotenv_values -import os -from time import sleep -from typing import Optional - -# External imports. -from cannlytics.data.gis import geocode_addresses -import pandas as pd -import zipcodes - -# Selenium imports. -from selenium import webdriver -from selenium.webdriver.chrome.options import Options -from selenium.webdriver.common.by import By -from selenium.webdriver.chrome.service import Service -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.ui import WebDriverWait -try: - import chromedriver_binary # Adds chromedriver binary to path. -except ImportError: - pass # Otherwise, ChromeDriver should be in your path. - - -# Specify where your data lives. -DATA_DIR = '../data/az' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'AZ' -ARIZONA = { - 'licensing_authority_id': 'ADHS', - 'licensing_authority': 'Arizona Department of Health Services', - 'licenses_url': 'https://azcarecheck.azdhs.gov/s/?licenseType=null', -} - - -def county_from_zip(x): - """Find a county given a zip code. Returns `None` if no match.""" - try: - return zipcodes.matching(x)[0]['county'] - except KeyError: - return None - - -def get_licenses_az( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Arizona cannabis license data.""" - - # Create directories if necessary. - if not os.path.exists(data_dir): os.makedirs(data_dir) - - # Initialize Selenium and specify options. - service = Service() - options = Options() - options.add_argument('--window-size=1920,1200') - - # DEV: Run with the browser open. - # options.headless = False - - # PRODUCTION: Run with the browser closed. - options.add_argument('--headless') - options.add_argument('--disable-gpu') - options.add_argument('--no-sandbox') - - # Initiate a Selenium driver. - driver = webdriver.Chrome(options=options, service=service) - - # Load the license page. - driver.get(ARIZONA['licenses_url']) - detect = (By.CLASS_NAME, 'slds-container_center') - WebDriverWait(driver, 30).until(EC.presence_of_element_located(detect)) - - # Get the map container. - container = driver.find_element(by=By.CLASS_NAME, value='slds-container_center') - - # Click "Load more" until all of the licenses are visible. - more = True - while(more): - button = container.find_element(by=By.TAG_NAME, value='button') - driver.execute_script('arguments[0].scrollIntoView(true);', button) - button.click() - counter = container.find_element(by=By.CLASS_NAME, value='count-text') - more = int(counter.text.replace(' more', '')) - - # Get license data for each retailer. - data = [] - els = container.find_elements(by=By.CLASS_NAME, value='map-list__item') - for i, el in enumerate(els): - - # Get a retailer's data. - count = i + 1 - 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' - list_item = el.find_element(by=By.XPATH, value=xpath) - body = list_item.find_element(by=By.CLASS_NAME, value='slds-media__body') - divs = body.find_elements(by=By.TAG_NAME, value='div') - name = divs[0].text - legal_name = divs[1].text - if not name: - name = legal_name - address = divs[3].text - address_parts = address.split(',') - parts = divs[2].text.split(' · ') - - # Get the retailer's link to get more details. - link = divs[-1].find_element(by=By.TAG_NAME, value='a') - href = link.get_attribute('href') - - # Record the retailer's data. - obs = { - 'address': address, - 'details_url': href, - 'business_legal_name': legal_name, - 'business_dba_name': name, - 'business_phone': parts[-1], - 'license_status': parts[0], - 'license_type': parts[1], - 'premise_street_address': address_parts[0].strip(), - 'premise_city': address_parts[1].strip(), - 'premise_zip_code': address_parts[-1].replace('AZ ', '').strip(), - } - data.append(obs) - - # Standardize the retailer data. - retailers = pd.DataFrame(data) - retailers = retailers.assign( - business_email=None, - business_owner_name=None, - business_structure=None, - business_image_url=None, - business_website=None, - id=retailers.index, - licensing_authority_id=ARIZONA['licensing_authority_id'], - licensing_authority=ARIZONA['licensing_authority'], - license_designation='Adult-Use', - license_number=None, - license_status_date=None, - license_term=None, - premise_latitude=None, - premise_longitude=None, - premise_state=STATE, - issue_date=None, - expiration_date=None, - parcel_number=None, - activity=None, - ) - - # Get each retailer's details. - cultivators = pd.DataFrame(columns=retailers.columns) - manufacturers = pd.DataFrame(columns=retailers.columns) - for index, row in retailers.iterrows(): - - # Load the licenses's details webpage. - driver.get(row['details_url']) - detect = (By.CLASS_NAME, 'slds-container_center') - WebDriverWait(driver, 30).until(EC.presence_of_element_located(detect)) - container = driver.find_element(by=By.CLASS_NAME, value='slds-container_center') - sleep(4) - - # Get the `business_email`. - links = container.find_elements(by=By.TAG_NAME, value='a') - for link in links: - href = link.get_attribute('href') - if href is None: continue - if href.startswith('mailto'): - business_email = href.replace('mailto:', '') - col = retailers.columns.get_loc('business_email') - retailers.iat[index, col] = business_email - break - - # Get the `license_number` - for link in links: - href = link.get_attribute('href') - if href is None: continue - if href.startswith('https://azdhs-licensing'): - col = retailers.columns.get_loc('license_number') - retailers.iat[index, col] = link.text - break - - # Get the `premise_latitude` and `premise_longitude`. - for link in links: - href = link.get_attribute('href') - if href is None: continue - if href.startswith('https://maps.google.com/'): - coords = href.split('=')[1].split('&')[0].split(',') - lat_col = retailers.columns.get_loc('premise_latitude') - long_col = retailers.columns.get_loc('premise_longitude') - retailers.iat[index, lat_col] = float(coords[0]) - retailers.iat[index, long_col] = float(coords[1]) - break - - # Get the `issue_date`. - key = 'License Effective' - el = container.find_element_by_xpath(f"//p[contains(text(),'{key}')]/following-sibling::lightning-formatted-text") - col = retailers.columns.get_loc('issue_date') - retailers.iat[index, col] = el.text - - # Get the `expiration_date`. - key = 'License Expires' - el = container.find_element_by_xpath(f"//p[contains(text(),'{key}')]/following-sibling::lightning-formatted-text") - col = retailers.columns.get_loc('expiration_date') - retailers.iat[index, col] = el.text - - # Get the `business_owner_name`. - key = 'Owner / License' - el = container.find_element_by_xpath(f"//p[contains(text(),'{key}')]/following-sibling::lightning-formatted-text") - col = retailers.columns.get_loc('expiration_date') - retailers.iat[index, col] = el.text - - # Get the `license_designation` ("Services"). - key = 'Services' - el = container.find_element_by_xpath(f"//p[contains(text(),'{key}')]/following-sibling::lightning-formatted-rich-text") - col = retailers.columns.get_loc('license_designation') - retailers.iat[index, col] = el.text - - # Create entries for cultivations. - cultivator = retailers.iloc[index].copy() - key = 'Offsite Cultivation Address' - el = container.find_element_by_xpath(f"//p[contains(text(),'{key}')]/following-sibling::lightning-formatted-text") - address = el.text - if address: - parts = address.split(',') - cultivator['address'] = address - cultivator['premise_street_address'] = parts[0] - cultivator['premise_city'] = parts[1].strip() - cultivator['premise_zip_code'] = parts[-1].replace(STATE, '').strip() - cultivator['license_type'] = 'Offsite Cultivation' - cultivators.append(cultivator, ignore_index=True) - - # Create entries for manufacturers. - manufacturer = retailers.iloc[index].copy() - key = 'Manufacture Address' - el = container.find_element_by_xpath(f"//p[contains(text(),'{key}')]/following-sibling::lightning-formatted-text") - address = el.text - if address: - parts = address.split(',') - manufacturer['address'] = address - manufacturer['premise_street_address'] = parts[0] - manufacturer['premise_city'] = parts[1].strip() - manufacturer['premise_zip_code'] = parts[-1].replace(STATE, '').strip() - manufacturer['license_type'] = 'Offsite Cultivation' - manufacturers.append(manufacturer, ignore_index=True) - - # End the browser session. - service.stop() - retailers.drop(column=['address', 'details_url'], inplace=True) - - # Lookup counties by zip code. - retailers['premise_county'] = retailers['premise_zip_code'].apply(county_from_zip) - cultivators['premise_county'] = cultivators['premise_zip_code'].apply(county_from_zip) - manufacturers['premise_county'] = manufacturers['premise_zip_code'].apply(county_from_zip) - - # Setup geocoding - config = dotenv_values(env_file) - api_key = config['GOOGLE_MAPS_API_KEY'] - drop_cols = ['state', 'state_name', 'county', 'address', 'formatted_address'] - gis_cols = {'latitude': 'premise_latitude', 'longitude': 'premise_longitude'} - - # # Geocode cultivators. - # cultivators = geocode_addresses(cultivators, api_key=api_key, address_field='address') - # cultivators.drop(columns=drop_cols, inplace=True) - # cultivators.rename(columns=gis_cols, inplace=True) - - # # Geocode manufacturers. - # manufacturers = geocode_addresses(manufacturers, api_key=api_key, address_field='address') - # manufacturers.drop(columns=drop_cols, inplace=True) - # manufacturers.rename(columns=gis_cols, inplace=True) - - # TODO: Lookup business website and image. - - # Aggregate all licenses. - licenses = pd.concat([retailers, cultivators, manufacturers]) - - # Get the refreshed date. - timestamp = datetime.now().isoformat() - licenses['data_refreshed_date'] = timestamp - retailers['data_refreshed_date'] = timestamp - # cultivators['data_refreshed_date'] = timestamp - # manufacturers['data_refreshed_date'] = timestamp - - # Save and return the data. - if data_dir is not None: - timestamp = timestamp[:19].replace(':', '-') - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - # cultivators.to_csv(f'{data_dir}/cultivators-{STATE.lower()}-{timestamp}.csv', index=False) - # manufacturers.to_csv(f'{data_dir}/manufacturers-{STATE.lower()}-{timestamp}.csv', index=False) - return licenses - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_az(data_dir, env_file=env_file) - diff --git a/algorithms/get_licenses_ca.py b/algorithms/get_licenses_ca.py deleted file mode 100644 index 92d8dcb1867cb15838c8a1766e99adbb12121ae2..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_ca.py +++ /dev/null @@ -1,112 +0,0 @@ -""" -Cannabis Licenses | Get California Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/16/2022 -Updated: 9/27/2022 -License: - -Description: - - Collect California cannabis license data. - -Data Source: - - - California Department of Cannabis Control Cannabis Unified License Search - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from time import sleep -from typing import Optional - -# External imports. -from cannlytics.utils import camel_to_snake -from cannlytics.utils.constants import DEFAULT_HEADERS -import pandas as pd -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/ca' - - -def get_licenses_ca( - data_dir: Optional[str] = None, - page_size: Optional[int] = 50, - pause: Optional[float] = 0.2, - starting_page: Optional[int] = 1, - ending_page: Optional[int] = None, - verbose: Optional[bool] = False, - search: Optional[str] = '', - **kwargs, - ): - """Get California cannabis license data.""" - - # Define the license data API. - base = 'https://as-cdt-pub-vip-cannabis-ww-p-002.azurewebsites.net' - endpoint = '/licenses/filteredSearch' - query = f'{base}{endpoint}' - params = {'pageSize': page_size, 'searchQuery': search} - - # Iterate over all of the pages to get all of the data. - page = int(starting_page) - licenses = [] - iterate = True - while(iterate): - params['pageNumber'] = page - response = requests.get(query, headers=DEFAULT_HEADERS, params=params) - body = response.json() - data = body['data'] - licenses.extend(data) - if not body['metadata']['hasNext']: - iterate = False - if verbose: - print('Recorded %i/%i pages.' % (page, body['metadata']['totalPages'])) - if ending_page is not None: - if page == ending_page: - iterate = False - page += 1 - sleep(pause) - - # Standardize the licensee data. - license_data = pd.DataFrame(licenses) - columns = list(license_data.columns) - columns = [camel_to_snake(x) for x in columns] - license_data.columns = columns - - # TODO: Lookup business website and image. - license_data['business_image_url'] = None - license_data['business_website'] = None - - # Restrict to only active licenses. - license_data = license_data.loc[license_data['license_status'] == 'Active'] - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - license_data.to_csv(f'{data_dir}/licenses-ca-{timestamp}.csv', index=False) - return license_data - -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - # Future work: Support the rest of the arguments from the CL. - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR} - - # Get California licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - get_licenses_ca(data_dir) diff --git a/algorithms/get_licenses_co.py b/algorithms/get_licenses_co.py deleted file mode 100644 index d54babcb5c229672f83b8149c49a2a623502ff37..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_co.py +++ /dev/null @@ -1,221 +0,0 @@ -""" -Cannabis Licenses | Get Colorado Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/4/2022 -License: - -Description: - - Collect Colorado cannabis license data. - -Data Source: - - - Colorado Department of Revenue | Marijuana Enforcement Division - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from time import sleep -from typing import Optional - -# External imports. -from bs4 import BeautifulSoup -from cannlytics.data.data import load_google_sheet -from cannlytics.data.gis import search_for_address -from dotenv import dotenv_values -import pandas as pd -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/co' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'CO' -COLORADO = { - 'licensing_authority_id': 'MED', - 'licensing_authority': 'Colorado Marijuana Enforcement Division', - 'licenses_url': 'https://sbg.colorado.gov/med/licensed-facilities', - 'licenses': { - 'columns': { - 'LicenseNumber': 'license_number', - 'FacilityName': 'business_legal_name', - 'DBA': 'business_dba_name', - 'City': 'premise_city', - 'ZipCode': 'premise_zip_code', - 'DateUpdated': 'data_refreshed_date', - 'Licensee Name ': 'business_legal_name', - 'License # ': 'license_number', - 'City ': 'premise_city', - 'Zip': 'premise_zip_code', - }, - 'drop_columns': [ - 'FacilityType', # This causes an error with `license_type`. - 'Potency', - 'Solvents', - 'Microbial', - 'Pesticides', - 'Mycotoxin', - 'Elemental Impurities', - 'Water Activity' - ] - } -} - - -def get_licenses_co( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Colorado cannabis license data.""" - - # Get the licenses webpage. - url = COLORADO['licenses_url'] - response = requests.get(url) - soup = BeautifulSoup(response.content, 'html.parser') - - # Get the Google Sheets for each license type. - docs = {} - links = soup.find_all('a') - for link in links: - try: - href = link['href'] - except KeyError: - pass - if 'docs.google' in href: - docs[link.text] = href - - # Download each "Medical" and "Retail" Google Sheet. - licenses = pd.DataFrame() - license_designations = ['Medical', 'Retail'] - columns=COLORADO['licenses']['columns'] - drop_columns=COLORADO['licenses']['drop_columns'] - for license_type, doc in docs.items(): - for license_designation in license_designations: - license_data = load_google_sheet(doc, license_designation) - license_data['license_type'] = license_type - license_data['license_designation'] = license_designation - license_data.rename(columns=columns, inplace=True) - license_data.drop(columns=drop_columns, inplace=True, errors='ignore') - licenses = pd.concat([licenses, license_data]) - sleep(0.22) - - # Standardize the license data. - licenses = licenses.assign( - id=licenses['license_number'], - license_status=None, - licensing_authority_id=COLORADO['licensing_authority_id'], - licensing_authority=COLORADO['licensing_authority'], - license_designation='Adult-Use', - premise_state=STATE, - license_status_date=None, - license_term=None, - issue_date=None, - expiration_date=None, - business_owner_name=None, - business_structure=None, - activity=None, - parcel_number=None, - business_phone=None, - business_email=None, - business_image_url=None, - ) - - # Fill empty DBA names and strip trailing whitespace. - licenses.loc[licenses['business_dba_name'] == '', 'business_dba_name'] = licenses['business_legal_name'] - licenses.business_dba_name.fillna(licenses.business_legal_name, inplace=True) - licenses.business_legal_name.fillna(licenses.business_dba_name, inplace=True) - licenses = licenses.loc[~licenses.business_dba_name.isna()] - licenses.business_dba_name = licenses.business_dba_name.apply(lambda x: x.strip()) - licenses.business_legal_name = licenses.business_legal_name.apply(lambda x: x.strip()) - - # Optional: Turn all capital case to title case. - - # Clean zip code column. - licenses['premise_zip_code'] = licenses['premise_zip_code'].apply( - lambda x: str(round(x)) if pd.notnull(x) else x - ) - licenses.loc[licenses['premise_zip_code'].isnull(), 'premise_zip_code'] = '' - - # Search for address for each retail license. - # Only search for a query once, then re-use the response. - # Note: There is probably a much, much more efficient way to do this!!! - config = dotenv_values(env_file) - api_key = config['GOOGLE_MAPS_API_KEY'] - cols = ['business_dba_name', 'premise_city', 'premise_state', 'premise_zip_code'] - retailers = licenses.loc[licenses['license_type'] == 'Stores'] - retailers['query'] = retailers[cols].apply( - lambda row: ', '.join(row.values.astype(str)), - axis=1, - ) - queries = {} - fields = [ - 'formatted_address', - 'formatted_phone_number', - 'geometry/location/lat', - 'geometry/location/lng', - 'website', - ] - retailers = retailers.reset_index(drop=True) - retailers = retailers.assign( - premise_street_address=None, - premise_county=None, - premise_latitude=None, - premise_longitude=None, - business_website=None, - business_phone=None, - ) - for index, row in retailers.iterrows(): - query = row['query'] - gis_data = queries.get(query) - if gis_data is None: - try: - gis_data = search_for_address(query, api_key=api_key, fields=fields) - except: - gis_data = {} - queries[query] = gis_data - retailers.iat[index, retailers.columns.get_loc('premise_street_address')] = gis_data.get('street') - retailers.iat[index, retailers.columns.get_loc('premise_county')] = gis_data.get('county') - retailers.iat[index, retailers.columns.get_loc('premise_latitude')] = gis_data.get('latitude') - retailers.iat[index, retailers.columns.get_loc('premise_longitude')] = gis_data.get('longitude') - retailers.iat[index, retailers.columns.get_loc('business_website')] = gis_data.get('website') - retailers.iat[index, retailers.columns.get_loc('business_phone')] = gis_data.get('formatted_phone_number') - - # Clean-up after getting GIS data. - retailers.drop(columns=['query'], inplace=True) - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - return licenses - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_co(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_ct.py b/algorithms/get_licenses_ct.py deleted file mode 100644 index 9a2cb48c5398e0c2e989b2bc8d24acbbf7d8be59..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_ct.py +++ /dev/null @@ -1,163 +0,0 @@ -""" -Cannabis Licenses | Get Connecticut Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/3/2022 -License: - -Description: - - Collect Connecticut cannabis license data. - -Data Source: - - - Connecticut State Department of Consumer Protection - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from bs4 import BeautifulSoup -from cannlytics.data.gis import geocode_addresses -from dotenv import dotenv_values -import pandas as pd -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/ct' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'CT' -CONNECTICUT = { - 'licensing_authority_id': 'CSDCP', - 'licensing_authority': 'Connecticut State Department of Consumer Protection', - 'licenses_url': 'https://portal.ct.gov/DCP/Medical-Marijuana-Program/Connecticut-Medical-Marijuana-Dispensary-Facilities', - 'retailers': { - 'columns': [ - 'business_legal_name', - 'address', - 'business_website', - 'business_email', - 'business_phone', - ] - } -} - - -def get_licenses_ct( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Connecticut cannabis license data.""" - - # Get the license webpage. - url = CONNECTICUT['licenses_url'] - response = requests.get(url) - soup = BeautifulSoup(response.content, 'html.parser') - - # Extract the license data. - data = [] - columns = CONNECTICUT['retailers']['columns'] - table = soup.find('table') - rows = table.find_all('tr') - for row in rows[1:]: - cells = row.find_all('td') - obs = {} - for i, cell in enumerate(cells): - column = columns[i] - obs[column] = cell.text - data.append(obs) - - # Standardize the license data. - retailers = pd.DataFrame(data) - retailers = retailers.assign( - id=retailers.index, - license_status=None, - business_dba_name=retailers['business_legal_name'], - license_number=None, - licensing_authority_id=CONNECTICUT['licensing_authority_id'], - licensing_authority=CONNECTICUT['licensing_authority'], - license_designation='Adult-Use', - premise_state=STATE, - license_status_date=None, - license_term=None, - issue_date=None, - expiration_date=None, - business_owner_name=None, - business_structure=None, - activity=None, - parcel_number=None, - business_image_url=None, - license_type=None, - ) - - # Get address parts. - retailers['premise_street_address'] = retailers['address'].apply( - lambda x: x.split(',')[0] - ) - retailers['premise_city'] = retailers['address'].apply( - lambda x: x.split('CT')[0].strip().split(',')[-2] - ) - retailers['premise_zip_code'] = retailers['address'].apply( - lambda x: x.split('CT')[-1].replace('\xa0', '').replace(',', '').strip() - ) - - # Geocode the licenses. - config = dotenv_values(env_file) - google_maps_api_key = config['GOOGLE_MAPS_API_KEY'] - retailers = geocode_addresses( - retailers, - api_key=google_maps_api_key, - address_field='address', - ) - retailers['premise_city'] = retailers['formatted_address'].apply( - lambda x: x.split(', ')[1].split(',')[0] if STATE in str(x) else x - ) - drop_cols = ['state', 'state_name', 'address', 'formatted_address'] - retailers.drop(columns=drop_cols, inplace=True) - gis_cols = { - 'county': 'premise_county', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude' - } - retailers.rename(columns=gis_cols, inplace=True) - - # Get the refreshed date. - retailers['data_refreshed_date'] = datetime.now().isoformat() - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - return retailers - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_ct(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_il.py b/algorithms/get_licenses_il.py deleted file mode 100644 index fbb2a4f8a14945253c1d4b7f04642e2002c7987d..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_il.py +++ /dev/null @@ -1,194 +0,0 @@ -""" -Cannabis Licenses | Get Illinois Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/3/2022 -License: - -Description: - - Collect Illinois cannabis license data. - -Data Source: - - - Illinois Department of Financial and Professional Regulation - Licensed Adult Use Cannabis Dispensaries - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from dotenv import dotenv_values -from cannlytics.data.gis import geocode_addresses -import pandas as pd -import pdfplumber -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/il' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'IL' -ILLINOIS = { - 'licensing_authority_id': 'IDFPR', - 'licensing_authority': 'Illinois Department of Financial and Professional Regulation', - 'retailers': { - 'url': 'https://www.idfpr.com/LicenseLookup/AdultUseDispensaries.pdf', - 'columns': [ - 'business_legal_name', - 'business_dba_name', - 'address', - 'medical', - 'issue_date', - 'license_number', - ], - }, -} - - -def get_licenses_il( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - **kwargs, - ): - """Get Illinois cannabis license data.""" - - # Create necessary directories. - pdf_dir = f'{data_dir}/pdfs' - if not os.path.exists(data_dir): os.makedirs(data_dir) - if not os.path.exists(pdf_dir): os.makedirs(pdf_dir) - - # Download the retailers PDF. - retailers_url = ILLINOIS['retailers']['url'] - filename = f'{pdf_dir}/illinois_retailers.pdf' - response = requests.get(retailers_url) - with open(filename, 'wb') as f: - f.write(response.content) - - # Read the retailers PDF. - pdf = pdfplumber.open(filename) - - # Get the table data, excluding the headers and removing empty cells. - table_data = [] - for i, page in enumerate(pdf.pages): - table = page.extract_table() - if i == 0: - table = table[4:] - table = [c for row in table - if (c := [elem for elem in row if elem is not None])] - table_data += table - - # Standardize the data. - licensee_columns = ILLINOIS['retailers']['columns'] - retailers = pd.DataFrame(table_data, columns=licensee_columns) - retailers = retailers.assign( - licensing_authority_id=ILLINOIS['licensing_authority_id'], - licensing_authority=ILLINOIS['licensing_authority'], - license_designation='Adult-Use', - premise_state=STATE, - license_status='Active', - license_status_date=None, - license_type='Commercial - Retailer', - license_term=None, - expiration_date=None, - business_legal_name=retailers['business_dba_name'], - business_owner_name=None, - business_structure=None, - business_email=None, - activity=None, - parcel_number=None, - id=retailers['license_number'], - business_image_url=None, - business_website=None, - ) - - # Apply `medical` to `license_designation` - retailers.loc[retailers['medical'] == 'Yes', 'license_designation'] = 'Adult-Use and Medicinal' - retailers.drop(columns=['medical'], inplace=True) - - # Clean the organization names. - retailers['business_legal_name'] = retailers['business_legal_name'].str.replace('\n', '', regex=False) - retailers['business_dba_name'] = retailers['business_dba_name'].str.replace('*', '', regex=False) - - # Separate address into 'street', 'city', 'state', 'zip_code', 'phone_number'. - streets, cities, states, zip_codes, phone_numbers = [], [], [], [], [] - for index, row in retailers.iterrows(): - parts = row.address.split(' \n') - streets.append(parts[0]) - phone_numbers.append(parts[-1]) - locales = parts[1] - city_locales = locales.split(', ') - state_locales = city_locales[-1].split(' ') - cities.append(city_locales[0]) - states.append(state_locales[0]) - zip_codes.append(state_locales[-1]) - retailers['premise_street_address'] = pd.Series(streets) - retailers['premise_city'] = pd.Series(cities) - retailers['premise_state'] = pd.Series(states) - retailers['premise_zip_code'] = pd.Series(zip_codes) - retailers['business_phone'] = pd.Series(phone_numbers) - - # Convert the issue date to ISO format. - retailers['issue_date'] = retailers['issue_date'].apply( - lambda x: pd.to_datetime(x).isoformat() - ) - - # Get the refreshed date. - date = pdf.metadata['ModDate'].replace('D:', '') - date = date[:4] + '-' + date[4:6] + '-' + date[6:8] + 'T' + date[8:10] + \ - ':' + date[10:12] + ':' + date[12:].replace("'", ':').rstrip(':') - retailers['data_refreshed_date'] = date - - # Geocode licenses to get `premise_latitude` and `premise_longitude`. - config = dotenv_values(env_file) - google_maps_api_key = config['GOOGLE_MAPS_API_KEY'] - retailers['address'] = retailers['address'].str.replace('*', '', regex=False) - retailers = geocode_addresses( - retailers, - api_key=google_maps_api_key, - address_field='address', - ) - drop_cols = ['state', 'state_name', 'address', 'formatted_address'] - retailers.drop(columns=drop_cols, inplace=True) - gis_cols = { - 'county': 'premise_county', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude' - } - retailers.rename(columns=gis_cols, inplace=True) - - # Save and return the data. - if data_dir is not None: - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - return retailers - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_il(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_ma.py b/algorithms/get_licenses_ma.py deleted file mode 100644 index 6d71672305226fa2d3e0bdb45cbd3be58313a294..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_ma.py +++ /dev/null @@ -1,146 +0,0 @@ -""" -Cannabis Licenses | Get Massachusetts Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/7/2022 -License: - -Description: - - Collect Massachusetts cannabis license data. - -Data Source: - - - Massachusetts Cannabis Control Commission Data Catalog - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from cannlytics.data.opendata import OpenData - - -# Specify where your data lives. -DATA_DIR = '../data/ma' - -# Specify state-specific constants. -STATE = 'MA' -MASSACHUSETTS = { - 'licensing_authority_id': 'MACCC', - 'licensing_authority': 'Massachusetts Cannabis Control Commission', - 'licenses': { - 'columns': { - 'license_number': 'license_number', - 'business_name': 'business_legal_name', - 'establishment_address_1': 'premise_street_address', - 'establishment_address_2': 'premise_street_address_2', - 'establishment_city': 'premise_city', - 'establishment_zipcode': 'premise_zip_code', - 'county': 'premise_county', - 'license_type': 'license_type', - 'application_status': 'license_status', - 'lic_status': 'license_term', - 'approved_license_type': 'license_designation', - 'commence_operations_date': 'license_status_date', - 'massachusetts_business': 'id', - 'dba_name': 'business_dba_name', - 'establishment_activities': 'activity', - 'cccupdatedate': 'data_refreshed_date', - 'establishment_state': 'premise_state', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude', - }, - 'drop': [ - 'square_footage_establishment', - 'cooperative_total_canopy', - 'cooperative_cultivation_environment', - 'establishment_cultivation_environment', - 'abutters_count', - 'is_abutters_notified', - 'business_zipcode', - 'dph_rmd_number', - 'geocoded_county', - 'geocoded_address', - 'name_of_rmd', - 'priority_applicant_type', - 'rmd_priority_certification', - 'dba_registration_city', - 'county_lat', - 'county_long', - ] - }, -} - - -def get_licenses_ma( - data_dir: Optional[str] = None, - **kwargs, - ): - """Get Massachusetts cannabis license data.""" - - # Get the licenses data. - ccc = OpenData() - licenses = ccc.get_licensees('approved') - - # Standardize the licenses data. - constants = MASSACHUSETTS['licenses'] - licenses.drop(columns=constants['drop'], inplace=True) - licenses.rename(columns=constants['columns'], inplace=True) - licenses = licenses.assign( - licensing_authority_id=MASSACHUSETTS['licensing_authority_id'], - licensing_authority=MASSACHUSETTS['licensing_authority'], - business_structure=None, - business_email=None, - business_owner_name=None, - parcel_number=None, - issue_date=None, - expiration_date=None, - business_image_url=None, - business_website=None, - business_phone=None, - ) - - # Append `premise_street_address_2` to `premise_street_address`. - cols = ['premise_street_address', 'premise_street_address_2'] - licenses['premise_street_address'] = licenses[cols].apply( - lambda x : '{} {}'.format(x[0].strip(), x[1]).replace('nan', '').strip().replace(' ', ' '), - axis=1, - ) - licenses.drop(columns=['premise_street_address_2'], inplace=True) - - # Optional: Look-up business websites for each license. - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers = licenses.loc[licenses['license_type'].str.contains('Retailer')] - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - return licenses - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - data = get_licenses_ma(data_dir) diff --git a/algorithms/get_licenses_me.py b/algorithms/get_licenses_me.py deleted file mode 100644 index 3d62714d5041864caeaa1ee1834622e941304ddc..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_me.py +++ /dev/null @@ -1,187 +0,0 @@ -""" -Cannabis Licenses | Get Maine Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/7/2022 -License: - -Description: - - Collect Maine cannabis license data. - -Data Source: - - - Maine Office of Cannabis Policy - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from bs4 import BeautifulSoup -from cannlytics.data.gis import geocode_addresses -from dotenv import dotenv_values -import pandas as pd -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/me' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'ME' -MAINE = { - 'licensing_authority_id': 'MEOCP', - 'licensing_authority': 'Maine Office of Cannabis Policy', - 'licenses': { - 'url': 'https://www.maine.gov/dafs/ocp/open-data/adult-use', - 'key': 'Adult_Use_Establishments_And_Contacts', - 'columns': { - 'LICENSE': 'license_number', - 'LICENSE_CATEGORY': 'license_type', - 'LICENSE_TYPE': 'license_designation', - 'LICENSE_NAME': 'business_legal_name', - 'DBA': 'business_dba_name', - 'LICENSE_STATUS': 'license_status', - 'LICENSE_CITY': 'premise_city', - 'WEBSITE': 'business_website', - 'CONTACT_NAME': 'business_owner_name', - 'CONTACT_TYPE': 'contact_type', - 'CONTACT_CITY': 'contact_city', - 'CONTACT_DESCRIPTION': 'contact_description', - }, - } -} - - -def get_licenses_me( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Maine cannabis license data.""" - - # Create the necessary directories. - file_dir = f'{data_dir}/.datasets' - if not os.path.exists(data_dir): os.makedirs(data_dir) - if not os.path.exists(file_dir): os.makedirs(file_dir) - - # Get the download link. - licenses_url = None - licenses_key = MAINE['licenses']['key'] - url = MAINE['licenses']['url'] - response = requests.get(url) - soup = BeautifulSoup(response.content, 'html.parser') - links = soup.find_all('a') - for link in links: - try: - href = link['href'] - except KeyError: - continue - if licenses_key in href: - licenses_url = href - break - - # Download the licenses workbook. - filename = licenses_url.split('/')[-1].split('?')[0] - licenses_source_file = os.path.join(file_dir, filename) - response = requests.get(licenses_url) - with open(licenses_source_file, 'wb') as doc: - doc.write(response.content) - - # Extract the data from the license workbook. - licenses = pd.read_excel(licenses_source_file) - licenses.rename(columns=MAINE['licenses']['columns'], inplace=True) - licenses = licenses.assign( - licensing_authority_id=MAINE['licensing_authority_id'], - licensing_authority=MAINE['licensing_authority'], - license_designation='Adult-Use', - premise_state=STATE, - license_status_date=None, - license_term=None, - issue_date=None, - expiration_date=None, - business_structure=None, - business_email=None, - business_phone=None, - activity=None, - parcel_number=None, - premise_street_address=None, - id=licenses['license_number'], - business_image_url=None, - ) - - # Remove duplicates. - licenses.drop_duplicates(subset='license_number', inplace=True) - - # Replace null DBA with legal name. - criterion = licenses['business_dba_name'].isnull() - licenses.loc[criterion,'business_dba_name'] = licenses['business_legal_name'] - - # Convert certain columns from upper case title case. - cols = ['business_legal_name', 'business_dba_name', 'business_owner_name'] - for col in cols: - licenses[col] = licenses[col].apply( - lambda x: x.title().strip() if isinstance(x, str) else x - ) - - # Get the refreshed date. - date = licenses_source_file.split('\\')[-1].split('.')[0].replace(licenses_key, '') - date = date.replace('%20', '') - date = '-'.join([date[:2], date[2:4], date[4:]]) - licenses['data_refreshed_date'] = pd.to_datetime(date).isoformat() - - # Geocode licenses to get `premise_latitude` and `premise_longitude`. - config = dotenv_values(env_file) - api_key = config['GOOGLE_MAPS_API_KEY'] - cols = ['premise_city', 'premise_state'] - licenses['address'] = licenses[cols].apply( - lambda row: ', '.join(row.values.astype(str)), - axis=1, - ) - licenses = geocode_addresses(licenses, address_field='address', api_key=api_key) - drop_cols = ['state', 'state_name', 'address', 'formatted_address', - 'contact_type', 'contact_city', 'contact_description'] - gis_cols = { - 'county': 'premise_county', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude', - } - licenses['premise_zip_code'] = licenses['formatted_address'].apply( - lambda x: x.split(', ')[2].split(',')[0].split(' ')[-1] if STATE in str(x) else x - ) - licenses.drop(columns=drop_cols, inplace=True) - licenses.rename(columns=gis_cols, inplace=True) - - # Save and return the data. - if data_dir is not None: - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - return licenses - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_me(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_mi.py b/algorithms/get_licenses_mi.py deleted file mode 100644 index 9e5f5748802bdf7d1af870e74cd973661681c2da..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_mi.py +++ /dev/null @@ -1,259 +0,0 @@ -""" -Cannabis Licenses | Get Michigan Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/8/2022 -License: - -Description: - - Collect Michigan cannabis license data. - -Data Source: - - - Michigan Cannabis Regulatory Agency - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from time import sleep -from typing import Optional - -# External imports. -from cannlytics.data.gis import geocode_addresses -from dotenv import dotenv_values -import pandas as pd - -# Selenium imports. -from selenium import webdriver -from selenium.webdriver.chrome.options import Options -from selenium.webdriver.common.by import By -from selenium.webdriver.chrome.service import Service -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support.ui import Select -try: - import chromedriver_binary # Adds chromedriver binary to path. -except ImportError: - pass # Otherwise, ChromeDriver should be in your path. - - -# Specify where your data lives. -DATA_DIR = '../data/mi' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'MI' -MICHIGAN = { - 'licensing_authority_id': 'CRA', - 'licensing_authority': 'Michigan Cannabis Regulatory Agency', - 'licenses_url': 'https://aca-prod.accela.com/MIMM/Cap/CapHome.aspx?module=Adult_Use&TabName=Adult_Use', - 'medicinal_url': 'https://aca-prod.accela.com/MIMM/Cap/CapHome.aspx?module=Licenses&TabName=Licenses&TabList=Home%7C0%7CLicenses%7C1%7CAdult_Use%7C2%7CEnforcement%7C3%7CRegistryCards%7C4%7CCurrentTabIndex%7C1', - 'licenses': { - 'columns': { - 'Record Number': 'license_number', - 'Record Type': 'license_type', - 'License Name': 'business_legal_name', - 'Address': 'address', - 'Expiration Date': 'expiration_date', - 'Status': 'license_status', - 'Action': 'activity', - 'Notes': 'license_designation', - 'Disciplinary Action': 'license_term', - }, - }, -} - - -def wait_for_id_invisible(driver, value, seconds=30): - """Wait for a given value to be invisible.""" - WebDriverWait(driver, seconds).until( - EC.invisibility_of_element((By.ID, value)) - ) - - -def get_licenses_mi( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Michigan cannabis license data.""" - - # Initialize Selenium and specify options. - service = Service() - options = Options() - options.add_argument('--window-size=1920,1200') - - # DEV: Run with the browser open. - options.headless = False - - # PRODUCTION: Run with the browser closed. - # options.add_argument('--headless') - # options.add_argument('--disable-gpu') - # options.add_argument('--no-sandbox') - - # Initiate a Selenium driver. - driver = webdriver.Chrome(options=options, service=service) - - # Load the license page. - url = MICHIGAN['licenses_url'] - driver.get(url) - - # Get the various license types, excluding certain types without addresses. - select = Select(driver.find_element(by=By.TAG_NAME, value='select')) - license_types = [] - options = driver.find_elements(by=By.TAG_NAME, value='option') - for option in options: - text = option.text - if text and '--' not in text: - license_types.append(text) - - # Restrict certain license types. - license_types = license_types[1:-2] - - # FIXME: Iterate over license types. - data = [] - columns = list(MICHIGAN['licenses']['columns'].values()) - for license_type in license_types: - - # Select the various license types. - try: - select.select_by_visible_text(license_type) - except: - pass - wait_for_id_invisible(driver, 'divGlobalLoading') - - # Click the search button. - search_button = driver.find_element(by=By.ID, value='ctl00_PlaceHolderMain_btnNewSearch') - search_button.click() - wait_for_id_invisible(driver, 'divGlobalLoading') - - # Iterate over all of the pages. - iterate = True - while iterate: - - # Get all of the license data. - grid = driver.find_element(by=By.ID, value='ctl00_PlaceHolderMain_dvSearchList') - rows = grid.find_elements(by=By.TAG_NAME, value='tr') - rows = [x.text for x in rows] - rows = [x for x in rows if 'Download results' not in x and not x.startswith('< Prev')] - cells = [] - for row in rows[1:]: # Skip the header. - obs = {} - cells = row.split('\n') - for i, cell in enumerate(cells): - column = columns[i] - obs[column] = cell - data.append(obs) - - # Keep clicking the next button until the next button is disabled. - next_button = driver.find_elements(by=By.CLASS_NAME, value='aca_pagination_PrevNext')[-1] - current_page = driver.find_element(by=By.CLASS_NAME, value='SelectedPageButton').text - next_button.click() - wait_for_id_invisible(driver, 'divGlobalLoading') - next_page = driver.find_element(by=By.CLASS_NAME, value='SelectedPageButton').text - if current_page == next_page: - iterate = False - - # TODO: Also get all of the medical licenses! - # https://aca-prod.accela.com/MIMM/Cap/CapHome.aspx?module=Licenses&TabName=Licenses&TabList=Home%7C0%7CLicenses%7C1%7CAdult_Use%7C2%7CEnforcement%7C3%7CRegistryCards%7C4%7CCurrentTabIndex%7C1 - - # End the browser session. - service.stop() - - # Standardize the data. - licenses = pd.DataFrame(data) - licenses = licenses.assign( - id=licenses.index, - licensing_authority_id=MICHIGAN['licensing_authority_id'], - licensing_authority=MICHIGAN['licensing_authority'], - premise_state=STATE, - license_status_date=None, - issue_date=None, - business_owner_name=None, - business_structure=None, - parcel_number=None, - business_phone=None, - business_email=None, - business_image_url=None, - license_designation=None, - business_website=None, - business_dba_name=licenses['business_legal_name'], - ) - - # Assign `license_term` if necessary. - try: - licenses['license_term'] - except KeyError: - licenses['license_term'] = None - - # Clean `license_type`. - licenses['license_type'] = licenses['license_type'].apply( - lambda x: x.replace(' - License', '') - ) - - # Format expiration date as an ISO formatted date. - licenses['expiration_date'] = licenses['expiration_date'].apply( - lambda x: pd.to_datetime(x).isoformat() - ) - - # Geocode the licenses. - config = dotenv_values(env_file) - google_maps_api_key = config['GOOGLE_MAPS_API_KEY'] - licenses = geocode_addresses( - licenses, - api_key=google_maps_api_key, - address_field='address', - ) - licenses['premise_street_address'] = licenses['formatted_address'].apply( - lambda x: x.split(',')[0] if STATE in str(x) else x - ) - licenses['premise_city'] = licenses['formatted_address'].apply( - lambda x: x.split(', ')[1].split(',')[0] if STATE in str(x) else x - ) - licenses['premise_zip_code'] = licenses['formatted_address'].apply( - lambda x: x.split(', ')[2].split(',')[0].split(' ')[-1] if STATE in str(x) else x - ) - drop_cols = ['state', 'state_name', 'address', 'formatted_address'] - gis_cols = { - 'county': 'premise_county', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude' - } - licenses.drop(columns=drop_cols, inplace=True) - licenses.rename(columns=gis_cols, inplace=True) - - # Get the refreshed date. - licenses['data_refreshed_date'] = datetime.now().isoformat() - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - return licenses - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_mi(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_mt.py b/algorithms/get_licenses_mt.py deleted file mode 100644 index 346ba8607e6205e6afec16ee5d030d8162f22892..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_mt.py +++ /dev/null @@ -1,278 +0,0 @@ -""" -Cannabis Licenses | Get Montana Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/27/2022 -Updated: 10/5/2022 -License: - -Description: - - Collect Montana cannabis license data. - -Data Source: - - - Montana Department of Revenue | Cannabis Control Division - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from cannlytics.data.gis import search_for_address -from cannlytics.utils.constants import DEFAULT_HEADERS -from dotenv import dotenv_values -import pandas as pd -import pdfplumber -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/mt' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'MT' -MONTANA = { - 'licensing_authority_id': 'MTCCD', - 'licensing_authority': 'Montana Cannabis Control Division', - 'licenses': { - 'columns': [ - { - 'key': 'premise_city', - 'name': 'City', - 'area': [0, 0.25, 0.2, 0.95], - }, - { - 'key': 'business_legal_name', - 'name': 'Location Name', - 'area': [0.2, 0.25, 0.6, 0.95], - }, - { - 'key': 'license_designation', - 'name': 'Sales Type', - 'area': [0.6, 0.25, 0.75, 0.95], - }, - { - 'key': 'business_phone', - 'name': 'Phone Number', - 'area': [0.75, 0.25, 1, 0.95], - }, - ] - }, - 'retailers': { - 'url': 'https://mtrevenue.gov/?mdocs-file=60245', - 'columns': ['city', 'dba', 'license_type', 'phone'] - }, - 'processors': {'url': 'https://mtrevenue.gov/?mdocs-file=60250'}, - 'cultivators': {'url': 'https://mtrevenue.gov/?mdocs-file=60252'}, - 'labs': {'url': 'https://mtrevenue.gov/?mdocs-file=60248'}, - 'transporters': {'url': 'https://mtrevenue.gov/?mdocs-file=72489'}, -} - - -def get_licenses_mt( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Montana cannabis license data.""" - - # Create directories if necessary. - pdf_dir = f'{data_dir}/pdfs' - if not os.path.exists(data_dir): os.makedirs(data_dir) - if not os.path.exists(pdf_dir): os.makedirs(pdf_dir) - - # Download the retailers PDF. - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - outfile = f'{pdf_dir}/mt-retailers-{timestamp}.pdf' - response = requests.get(MONTANA['retailers']['url'], headers=DEFAULT_HEADERS) - with open(outfile, 'wb') as pdf: - pdf.write(response.content) - - # Read the PDF. - doc = pdfplumber.open(outfile) - - # Get the table rows. - rows = [] - front_page = doc.pages[0] - width, height = front_page.width, front_page.height - x0, y0, x1, y1 = tuple([0, 0.25, 1, 0.95]) - page_area = (x0 * width, y0 * height, x1 * width, y1 * height) - for page in doc.pages: - crop = page.within_bbox(page_area) - text = crop.extract_text() - lines = text.split('\n') - for line in lines: - rows.append(line) - - # Get cities from the first column, used to identify the city for each line. - cities = [] - city_area = MONTANA['licenses']['columns'][0]['area'] - x0, y0, x1, y1 = tuple(city_area) - column_area = (x0 * width, y0 * height, x1 * width, y1 * height) - for page in doc.pages: - crop = page.within_bbox(column_area) - text = crop.extract_text() - lines = text.split('\n') - for line in lines: - cities.append(line) - - # Find all of the unique cities. - cities = list(set(cities)) - cities = [x for x in cities if x != 'City'] - - # Get all of the license data. - data = [] - rows = [x for x in rows if not x.startswith('City')] - for row in rows: - - # Get all of the license observation data. - obs = {} - text = str(row) - - # Identify the city and remove the city from the name (only once b/c of DBAs!). - for city in cities: - if city in row: - obs['premise_city'] = city.title() - text = text.replace(city, '', 1).strip() - break - - # Identify the license designation. - if 'Adult Use' in row: - parts = text.split('Adult Use') - obs['license_designation'] = 'Adult Use' - else: - parts = text.split('Medical Only') - obs['license_designation'] = 'Medical Only' - - # Skip rows with double-row text. - if len(row) == 1: continue - - # Record the name. - obs['business_legal_name'] = name = parts[0] - - # Record the phone number. - if '(' in text: - obs['business_phone'] = parts[-1].strip() - - # Record the observation. - data.append(obs) - - # Aggregate the data. - retailers = pd.DataFrame(data) - retailers = retailers.loc[~retailers['premise_city'].isna()] - - # Convert certain columns from upper case title case. - cols = ['business_legal_name', 'premise_city'] - for col in cols: - retailers[col] = retailers[col].apply( - lambda x: x.title().replace('Llc', 'LLC').replace("'S", "'s").strip() - ) - - # Standardize the data. - retailers['id'] = retailers.index - retailers['license_number'] = None # FIXME: It would be awesome to find these! - retailers['licensing_authority_id'] = MONTANA['licensing_authority_id'] - retailers['licensing_authority'] = MONTANA['licensing_authority'] - retailers['premise_state'] = STATE - retailers['license_status'] = 'Active' - retailers['license_status_date'] = None - retailers['license_type'] = 'Commercial - Retailer' - retailers['license_term'] = None - retailers['issue_date'] = None - retailers['expiration_date'] = None - retailers['business_owner_name'] = None - retailers['business_structure'] = None - retailers['activity'] = None - retailers['parcel_number'] = None - retailers['business_email'] = None - retailers['business_image_url'] = None - - # Separate any `business_dba_name` from `business_legal_name`. - retailers['business_dba_name'] = retailers['business_legal_name'] - criterion = retailers['business_legal_name'].str.contains('Dba') - retailers.loc[criterion, 'business_dba_name'] = retailers.loc[criterion] \ - ['business_legal_name'].apply(lambda x: x.split('Dba')[-1].strip()) - retailers.loc[criterion, 'business_legal_name'] = retailers.loc[criterion] \ - ['business_legal_name'].apply(lambda x: x.split('Dba')[0].strip()) - - # Search for address for each retail license. - # Only search for a query once, then re-use the response. - # Note: There is probably a much, much more efficient way to do this!!! - config = dotenv_values(env_file) - api_key = config['GOOGLE_MAPS_API_KEY'] - cols = ['business_dba_name', 'premise_city', 'premise_state'] - retailers['query'] = retailers[cols].apply( - lambda row: ', '.join(row.values.astype(str)), - axis=1, - ) - queries = {} - fields = [ - 'formatted_address', - 'geometry/location/lat', - 'geometry/location/lng', - 'website', - ] - retailers = retailers.reset_index(drop=True) - retailers = retailers.assign( - premise_street_address=None, - premise_county=None, - premise_zip_code=None, - premise_latitude=None, - premise_longitude=None, - business_website=None, - ) - for index, row in retailers.iterrows(): - query = row['query'] - gis_data = queries.get(query) - if gis_data is None: - try: - gis_data = search_for_address(query, api_key=api_key, fields=fields) - except: - gis_data = {} - queries[query] = gis_data - retailers.iat[index, retailers.columns.get_loc('premise_street_address')] = gis_data.get('street') - retailers.iat[index, retailers.columns.get_loc('premise_county')] = gis_data.get('county') - retailers.iat[index, retailers.columns.get_loc('premise_zip_code')] = gis_data.get('zipcode') - retailers.iat[index, retailers.columns.get_loc('premise_latitude')] = gis_data.get('latitude') - retailers.iat[index, retailers.columns.get_loc('premise_longitude')] = gis_data.get('longitude') - retailers.iat[index, retailers.columns.get_loc('business_website')] = gis_data.get('website') - - # Clean-up after getting GIS data. - retailers.drop(columns=['query'], inplace=True) - - # Get the refreshed date. - retailers['data_refreshed_date'] = datetime.now().isoformat() - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - return retailers - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_mt(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_nj.py b/algorithms/get_licenses_nj.py deleted file mode 100644 index 3023488cc65df8aff353fb8600bb3d0898fda510..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_nj.py +++ /dev/null @@ -1,128 +0,0 @@ -""" -Cannabis Licenses | Get New Jersey Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 9/29/2022 -License: - -Description: - - Collect New Jersey cannabis license data. - -Data Source: - - - New Jersey Cannabis Regulatory Commission - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -import pandas as pd -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/nj' - -# Specify state-specific constants. -STATE = 'NJ' -NEW_JERSEY = { - 'licensing_authority_id': 'NJCRC', - 'licensing_authority': 'New Jersey Cannabis Regulatory Commission', - 'retailers': { - 'columns': { - 'name': 'business_dba_name', - 'address': 'premise_street_address', - 'town': 'premise_city', - 'state': 'premise_state', - 'zip_code': 'premise_zip_code', - 'county': 'premise_county', - 'phone_number': 'business_phone', - 'type': 'license_type', - } - } -} - - -def get_licenses_nj( - data_dir: Optional[str] = None, - **kwargs, - ): - """Get New Jersey cannabis license data.""" - - # Get retailer data. - url = 'https://data.nj.gov/resource/nv37-s2zn.json' - response = requests.get(url) - data = pd.DataFrame(response.json()) - - # Parse the website. - data['business_website'] = data['website'].apply(lambda x: x['url']) - - # Parse the GIS coordinates. - data['premise_longitude'] = data['dispensary_location'].apply( - lambda x: x['coordinates'][0] - ) - data['premise_latitude'] = data['dispensary_location'].apply( - lambda x: x['coordinates'][1] - ) - - # Standardize the data. - drop_cols = ['dispensary_location', 'location', 'website'] - data.drop(columns=drop_cols, inplace=True) - data.rename(columns=NEW_JERSEY['retailers']['columns'], inplace=True) - data['business_legal_name'] = data['business_dba_name'] - data['licensing_authority_id'] = NEW_JERSEY['licensing_authority_id'] - data['licensing_authority'] = NEW_JERSEY['licensing_authority'] - data['license_designation'] = 'Adult-Use' - data['premise_state'] = STATE - data['license_status_date'] = None - data['license_term'] = None - data['issue_date'] = None - data['expiration_date'] = None - data['business_owner_name'] = None - data['business_structure'] = None - data['business_email'] = None - data['activity'] = None - data['parcel_number'] = None - data['business_image_url'] = None - data['id'] = None - data['license_number'] = None - data['license_status'] = None - data['data_refreshed_date'] = datetime.now().isoformat() - - # Convert certain columns from upper case title case. - cols = ['premise_city', 'premise_county', 'premise_street_address'] - for col in cols: - data[col] = data[col].apply(lambda x: x.title().strip()) - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - data.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - return data - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', '--data_dir', dest='data_dir', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - data = get_licenses_nj(data_dir) diff --git a/algorithms/get_licenses_nm.py b/algorithms/get_licenses_nm.py deleted file mode 100644 index 5b7d125b4d60574b089d65f2a50a2fca82822184..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_nm.py +++ /dev/null @@ -1,309 +0,0 @@ -""" -Cannabis Licenses | Get New Mexico Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/6/2022 -License: - -Description: - - Collect New Mexico cannabis license data. - -Data Source: - - - New Mexico Regulation and Licensing Department | Cannabis Control Division - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from time import sleep -from typing import Optional - -# External imports. -from cannlytics.data.gis import geocode_addresses, search_for_address -from dotenv import dotenv_values -import pandas as pd - -# Selenium imports. -from selenium import webdriver -from selenium.webdriver.chrome.options import Options -from selenium.webdriver.common.by import By -from selenium.webdriver.chrome.service import Service -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.ui import WebDriverWait -try: - import chromedriver_binary # Adds chromedriver binary to path. -except ImportError: - pass # Otherwise, ChromeDriver should be in your path. - - -# Specify where your data lives. -DATA_DIR = '../data/nm' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'NM' -NEW_MEXICO = { - 'licensing_authority_id': 'NMCCD', - 'licensing_authority': 'New Mexico Cannabis Control Division', - 'licenses_url': 'https://nmrldlpi.force.com/bcd/s/public-search-license?division=CCD&language=en_US', -} - - -def get_licenses_nm( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get New Mexico cannabis license data.""" - - # Create directories if necessary. - if not os.path.exists(data_dir): os.makedirs(data_dir) - - # Initialize Selenium and specify options. - service = Service() - options = Options() - options.add_argument('--window-size=1920,1200') - - # DEV: Run with the browser open. - options.headless = False - - # PRODUCTION: Run with the browser closed. - # options.add_argument('--headless') - # options.add_argument('--disable-gpu') - # options.add_argument('--no-sandbox') - - # Initiate a Selenium driver. - driver = webdriver.Chrome(options=options, service=service) - - # Load the license page. - driver.get(NEW_MEXICO['licenses_url']) - - # FIXME: Wait for the page to load by waiting to detect the image. - # try: - # el = (By.CLASS_NAME, 'slds-radio--faux') - # WebDriverWait(driver, 15).until(EC.presence_of_element_located(el)) - # except TimeoutException: - # print('Failed to load page within %i seconds.' % (30)) - sleep(5) - - # Get the main content and click "License Type" raido. - content = driver.find_element(by=By.CLASS_NAME, value='siteforceContentArea') - radio = content.find_element(by=By.CLASS_NAME, value='slds-radio--faux') - radio.click() - sleep(2) - - # Select retailers. - # TODO: Also get "Cannabis Manufacturer", "Cannabis Producer", and - # "Cannabis Producer Microbusiness". - search = content.find_element(by=By.ID, value='comboboxId-40') - search.click() - choices = content.find_elements(by=By.CLASS_NAME, value='slds-listbox__item') - for choice in choices: - if choice.text == 'Cannabis Retailer': - choice.click() - sleep(2) - break - - # Click the search button. - search = content.find_element(by=By.CLASS_NAME, value='vlocity-btn') - search.click() - sleep(2) - - # Iterate over all of the pages. - # Wait for the table to load, then iterate over the pages. - sleep(5) - data = [] - iterate = True - while(iterate): - - # Get all of the licenses. - items = content.find_elements(by=By.CLASS_NAME, value='block-container') - for item in items[3:]: - text = item.text - if not text: - continue - values = text.split('\n') - data.append({ - 'license_type': values[0], - 'license_status': values[1], - 'business_legal_name': values[2], - 'address': values[-1], - 'details_url': '', - }) - - # Get the page number and stop at the last page. - # FIXME: This doesn't correctly break! - par = content.find_elements(by=By.TAG_NAME, value='p')[-1].text - page_number = int(par.split(' ')[2]) - total_pages = int(par.split(' ')[-2]) - if page_number == total_pages: - iterate = False - - # Otherwise, click the next button. - buttons = content.find_elements(by=By.TAG_NAME, value='button') - for button in buttons: - if button.text == 'Next Page': - button.click() - sleep(5) - break - - # Search for each license name, 1 by 1, to get details. - retailers = pd.DataFrame(columns=['business_legal_name']) - for i, licensee in enumerate(data): - - # Skip recorded rows. - if len(retailers.loc[retailers['business_legal_name'] == licensee['business_legal_name']]): - continue - - # Click the "Business Name" search field. - content = driver.find_element(by=By.CLASS_NAME, value='siteforceContentArea') - radio = content.find_elements(by=By.CLASS_NAME, value='slds-radio--faux')[1] - radio.click() - sleep(1) - - # Enter the `business_legal_name` into the search. - search_field = content.find_element(by=By.CLASS_NAME, value='vlocity-input') - search_field.clear() - search_field.send_keys(licensee['business_legal_name']) - - # Click the search button. - search = content.find_element(by=By.CLASS_NAME, value='vlocity-btn') - search.click() - - # FIXME: Wait for the table to load. - # WebDriverWait(content, 5).until(EC.presence_of_element_located((By.CLASS_NAME, 'slds-button_icon'))) - sleep(1.5) - - # Click the "Action" button to get to the details page. - # FIXME: There can be multiple search candidates! - action = content.find_element(by=By.CLASS_NAME, value='slds-button_icon') - try: - action.click() - except: - continue # FIXME: Formally check if "No record found!". - - # FIXME: Wait for the details page to load. - el = (By.CLASS_NAME, 'body') - WebDriverWait(driver, 5).until(EC.presence_of_element_located(el)) - - # Get the page - page = driver.find_element(by=By.CLASS_NAME, value='body') - - # FIXME: Wait for the details to load! - # el = (By.TAG_NAME, 'vlocity_ins-omniscript-step') - # WebDriverWait(page, 5).until(EC.presence_of_element_located(el)) - sleep(1.5) - - # Get all of the details! - fields = [ - 'license_number', - 'license_status', - 'issue_date', - 'expiration_date', - 'business_owner_name', - ] - values = page.find_elements(by=By.CLASS_NAME, value='field-value') - if len(values) > 5: - for j, value in enumerate(values[:5]): - data[i][fields[j]] = value.text - for value in values[5:]: - data[i]['business_owner_name'] += f', {value.text}' - else: - for j, value in enumerate(values): - data[i][fields[j]] = value.text - - # Create multiple entries for each address!!! - premises = page.find_elements(by=By.CLASS_NAME, value='block-header') - for premise in premises: - values = premise.text.split('\n') - licensee['address'] = values[0].replace(',', ', ') - licensee['license_number'] = values[2] - retailers = pd.concat([retailers, pd.DataFrame([licensee])]) - - # Click the "Back to Search" button. - back_button = page.find_element(by=By.CLASS_NAME, value='vlocity-btn') - back_button.click() - sleep(1) - - # End the browser session. - service.stop() - - # Standardize the data, restricting to "Approved" retailers. - retailers = retailers.loc[retailers['license_status'] == 'Active'] - retailers = retailers.assign( - business_email=None, - business_structure=None, - licensing_authority_id=NEW_MEXICO['licensing_authority_id'], - licensing_authority=NEW_MEXICO['licensing_authority'], - license_designation='Adult-Use', - license_status_date=None, - license_term=None, - premise_state=STATE, - parcel_number=None, - activity=None, - business_image_url=None, - business_website=None, - business_phone=None, - id=retailers['license_number'], - business_dba_name=retailers['business_legal_name'], - ) - - # Get the refreshed date. - retailers['data_refreshed_date'] = datetime.now().isoformat() - - # Geocode licenses. - # FIXME: This is not working as intended. Perhaps try `search_for_address`? - config = dotenv_values(env_file) - api_key = config['GOOGLE_MAPS_API_KEY'] - retailers = geocode_addresses(retailers, api_key=api_key, address_field='address') - retailers['premise_street_address'] = retailers['formatted_address'].apply( - lambda x: x.split(',')[0] if STATE in str(x) else x - ) - retailers['premise_city'] = retailers['formatted_address'].apply( - lambda x: x.split(', ')[1].split(',')[0] if STATE in str(x) else x - ) - retailers['premise_zip_code'] = retailers['formatted_address'].apply( - lambda x: x.split(', ')[2].split(',')[0].split(' ')[-1] if STATE in str(x) else x - ) - drop_cols = ['state', 'state_name', 'address', 'formatted_address', - 'details_url'] - gis_cols = { - 'county': 'premise_county', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude' - } - retailers.drop(columns=drop_cols, inplace=True) - retailers.rename(columns=gis_cols, inplace=True) - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - return retailers - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_nm(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_nv.py b/algorithms/get_licenses_nv.py deleted file mode 100644 index 15f79ec3e0ff748fe4727331a2063df2815a8f27..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_nv.py +++ /dev/null @@ -1,235 +0,0 @@ -""" -Cannabis Licenses | Get Nevada Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 9/29/2022 -License: - -Description: - - Collect Nevada cannabis license data. - -Data Source: - - - Nevada - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from bs4 import BeautifulSoup -from cannlytics.data.gis import geocode_addresses -from cannlytics.utils.constants import DEFAULT_HEADERS -from dotenv import dotenv_values -import pandas as pd -import requests - -# Specify where your data lives. -DATA_DIR = '../data/nv' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'NV' -NEVADA = { - 'licensing_authority_id': 'NVCCB', - 'licensing_authority': 'Nevada Cannabis Compliance Board', - 'licenses': { - 'key': 'Active-License-List', - 'columns': { - 'LicenseNumber': 'license_number', - 'LicenseName': 'business_dba_name', - 'CE ID': 'id', - 'LicenseType': 'license_type', - 'County': 'premise_county', - }, - 'url': 'https://ccb.nv.gov/list-of-licensees/', - } -} - - -def get_licenses_nv( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Nevada cannabis license data.""" - - # Create the necessary directories. - file_dir = f'{data_dir}/.datasets' - if not os.path.exists(data_dir): os.makedirs(data_dir) - if not os.path.exists(file_dir): os.makedirs(file_dir) - - #-------------------------------------------------------------------------- - # Get all license data. - #-------------------------------------------------------------------------- - - # Find the latest licenses workbook. - licenses_url = '' - retailer_key = NEVADA['licenses']['key'] - url = NEVADA['licenses']['url'] - response = requests.get(url, headers=DEFAULT_HEADERS) - soup = BeautifulSoup(response.content, 'html.parser') - links = soup.find_all('a') - for link in links: - href = link['href'] - if retailer_key in href: - licenses_url = href - break - - # Download the workbook. - filename = licenses_url.split('/')[-1] - licenses_source_file = os.path.join(file_dir, filename) - response = requests.get(licenses_url, headers=DEFAULT_HEADERS) - with open(licenses_source_file, 'wb') as doc: - doc.write(response.content) - - # Extract and standardize the data from the workbook. - licenses = pd.read_excel(licenses_source_file, skiprows=1) - licenses.rename(columns=NEVADA['licenses']['columns'], inplace=True) - licenses['id'] = licenses['license_number'] - licenses['licensing_authority_id'] = NEVADA['licensing_authority_id'] - licenses['licensing_authority'] = NEVADA['licensing_authority'] - licenses['license_designation'] = 'Adult-Use' - licenses['premise_state'] = STATE - licenses['license_status_date'] = None - licenses['license_term'] = None - licenses['issue_date'] = None - licenses['expiration_date'] = None - licenses['business_legal_name'] = licenses['business_dba_name'] - licenses['business_owner_name'] = None - licenses['business_structure'] = None - licenses['business_email'] = None - licenses['activity'] = None - licenses['parcel_number'] = None - licenses['business_image_url'] = None - licenses['business_phone'] = None - licenses['business_website'] = None - - # Convert certain columns from upper case title case. - cols = ['business_dba_name', 'premise_county'] - for col in cols: - licenses[col] = licenses[col].apply(lambda x: x.title().strip()) - - # Get the refreshed date. - date = filename.split('.')[0].replace(retailer_key, '').lstrip('-') - date = '-'.join([date[:2], date[2:4], date[4:]]) - licenses['data_refreshed_date'] = pd.to_datetime(date) - - # Wish: Geocode licenses to get `premise_latitude` and `premise_longitude`. - - # Save the licenses - if data_dir is not None: - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - - #-------------------------------------------------------------------------- - # Get retailer data - #-------------------------------------------------------------------------- - - # Get the retailer data. - retailers = [] - tables = soup.find_all('table', attrs={'class': 'customTable'}) - for table in tables: - try: - city = table.find('span').text - except AttributeError: - continue - rows = table.find_all('td') - for row in rows: - cells = row.text.split(' – ') - name = cells[0] - street = cells[1] - designation = cells[-1] - retailers.append({ - 'business_legal_name': name, - 'business_dba_name': name, - 'license_designation': designation, - 'premise_city': city, - 'premise_street_address': street, - }) - - # Standardize the retailers. - retailers = pd.DataFrame(retailers) - retailers['licensing_authority_id'] = NEVADA['licensing_authority_id'] - retailers['licensing_authority'] = NEVADA['licensing_authority'] - retailers['license_type'] = 'Commercial - Retailer' - retailers['license_status'] = 'Active' - retailers['license_designation'] = 'Adult-Use' - retailers['premise_state'] = STATE - retailers['license_status_date'] = None - retailers['license_term'] = None - retailers['issue_date'] = None - retailers['expiration_date'] = None - retailers['business_owner_name'] = None - retailers['business_structure'] = None - retailers['business_email'] = None - retailers['activity'] = None - retailers['parcel_number'] = None - retailers['business_website'] = None - retailers['business_image_url'] = None - retailers['business_phone'] = None - - # FIXME: Merge `license_number`, `premise_county`, `data_refreshed_date` - # from licenses. - retailers['license_number'] = None - retailers['id'] = None - retailers['data_refreshed_date'] = datetime.now().isoformat() - - # Geocode the retailers. - config = dotenv_values(env_file) - google_maps_api_key = config['GOOGLE_MAPS_API_KEY'] - cols = ['premise_street_address', 'premise_city', 'premise_state'] - retailers['address'] = retailers[cols].apply( - lambda row: ', '.join(row.values.astype(str)), - axis=1, - ) - retailers = geocode_addresses( - retailers, - api_key=google_maps_api_key, - address_field='address', - ) - drop_cols = ['state', 'state_name', 'address', 'formatted_address'] - gis_cols = { - 'county': 'premise_county', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude' - } - licenses['premise_zip_code'] = licenses['formatted_address'].apply( - lambda x: x.split(', ')[2].split(',')[0].split(' ')[-1] if STATE in str(x) else x - ) - retailers.drop(columns=drop_cols, inplace=True) - retailers.rename(columns=gis_cols, inplace=True) - - # Save the retailers - if data_dir is not None: - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - - # Return all of the data. - return pd.concat([licenses, retailers]) - - -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_nv(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_or.py b/algorithms/get_licenses_or.py deleted file mode 100644 index 0d770ac72930271b71819daecdfd4db1fc4664b3..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_or.py +++ /dev/null @@ -1,213 +0,0 @@ -""" -Cannabis Licenses | Get Oregon Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/28/2022 -Updated: 10/7/2022 -License: - -Description: - - Collect Oregon cannabis license data. - -Data Source: - - - Oregon Liquor and Cannabis Commission - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from dotenv import dotenv_values -import pandas as pd -import requests -from cannlytics.data.gis import geocode_addresses - - -# Specify where your data lives. -DATA_DIR = '../data/or' -ENV_FILE = '../.env' - -# Specify state-specific constants. -OREGON = { - 'licensing_authority_id': 'OLCC', - 'licensing_authority': 'Oregon Liquor and Cannabis Commission', - 'licenses': { - 'url': 'https://www.oregon.gov/olcc/marijuana/Documents/MarijuanaLicenses_Approved.xlsx', - }, - 'retailers': { - 'url': 'https://www.oregon.gov/olcc/marijuana/Documents/Approved_Retail_Licenses.xlsx', - 'columns': { - 'TRADE NAME': 'business_dba_name', - 'POSTAL CITY': 'premise_city', - 'COUNTY': 'premise_county', - 'STREET ADDRESS': 'premise_street_address', - 'ZIP': 'premise_zip_code', - 'Med Grade': 'medicinal', - 'Delivery': 'delivery', - }, - 'drop_columns': [ - 'medicinal', - 'delivery', - ], - }, -} - -def get_licenses_or( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - # Optional: Add print statements. - # verbose: Optional[bool] = False, - ): - """Get California cannabis license data.""" - - # Create the necessary directories. - file_dir = f'{data_dir}/.datasets' - if not os.path.exists(data_dir): os.makedirs(data_dir) - if not os.path.exists(file_dir): os.makedirs(file_dir) - - # Download the data workbooks. - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - outfile = f'{file_dir}/retailers-or-{timestamp}.xlsx' - response = requests.get(OREGON['retailers']['url']) - with open(outfile, 'wb') as doc: - doc.write(response.content) - - # Extract data from the workbooks, removing the footnote. - data = pd.read_excel(outfile, skiprows=3) - data = data[:-1] - data.rename(columns=OREGON['retailers']['columns'], inplace=True) - - # Optional: Remove licenses with an asterisk (*). - - # Curate the data. - data['licensing_authority_id'] = OREGON['licensing_authority_id'] - data['licensing_authority'] = OREGON['licensing_authority'] - data['license_status'] = 'Active' - data['license_designation'] = 'Adult-Use' - data['premise_state'] = 'OR' - data.loc[data['medicinal'] == 'Yes', 'license_designation'] = 'Adult-Use and Medicinal' - data['business_image_url'] = None - data['license_status_date'] = None - data['license_term'] = None - data['issue_date'] = None - data['expiration_date'] = None - data['business_email'] = None - data['business_owner_name'] = None - data['business_structure'] = None - data['business_website'] = None - data['activity'] = None - data['business_phone'] = None - data['parcel_number'] = None - data['business_legal_name'] = data['business_dba_name'] - - # Optional: Convert `medicinal` and `delivery` columns to boolean. - # data['medicinal'] = data['medicinal'].map(dict(Yes=1)) - # data['delivery'] = data['delivery'].map(dict(Yes=1)) - # data['medicinal'].fillna(0, inplace=True) - # data['delivery'].fillna(0, inplace=True) - data.drop(columns=['medicinal', 'delivery'], inplace=True) - - # Convert certain columns from upper case title case. - cols = ['business_dba_name', 'premise_city', 'premise_county', - 'premise_street_address'] - for col in cols: - data[col] = data[col].apply(lambda x: x.title().strip()) - - # Convert zip code to a string. - data.loc[:, 'premise_zip_code'] = data['premise_zip_code'].apply(lambda x: str(int(x))) - - # Get the `data_refreshed_date`. - df = pd.read_excel(outfile, index_col=None, usecols='C', header=1, nrows=0) - header = df.columns.values[0] - date = pd.to_datetime(header.split(' ')[-1]) - data['data_refreshed_date'] = date.isoformat() - - # Get the `license_number` and `license_type` from license list. - license_file = f'{file_dir}/licenses-or-{timestamp}.xlsx' - response = requests.get(OREGON['licenses']['url']) - with open(license_file, 'wb') as doc: - doc.write(response.content) - licenses = pd.read_excel(license_file, skiprows=2) - licenses['BUSINESS NAME'] = licenses['BUSINESS NAME'].apply( - lambda x: str(x).title().strip(), - ) - licenses = licenses.loc[licenses['LICENSE TYPE'] == 'Recreational Retailer'] - data = pd.merge( - data, - licenses[['BUSINESS NAME', 'COUNTY', 'LICENSE NUMBER', 'LICENSE TYPE']], - left_on=['business_dba_name', 'premise_county'], - right_on=['BUSINESS NAME', 'COUNTY'], - how='left', - ) - - # Clean the merged columns. - data.drop_duplicates(subset='premise_street_address', inplace=True) - columns = { - 'LICENSE NUMBER': 'license_number', - 'LICENSE TYPE': 'license_type', - } - data.rename(columns=columns, inplace=True) - data.drop(columns=['BUSINESS NAME', 'COUNTY'], inplace=True) - data['id'] = data['license_number'] - - # Geocode licenses to get `premise_latitude` and `premise_longitude`. - config = dotenv_values(env_file) - google_maps_api_key = config['GOOGLE_MAPS_API_KEY'] - cols = ['premise_street_address', 'premise_city', 'premise_state', - 'premise_zip_code'] - data['address'] = data[cols].apply( - lambda row: ', '.join(row.values.astype(str)), - axis=1, - ) - data = geocode_addresses( - data, - api_key=google_maps_api_key, - address_field='address', - ) - drop_cols = ['state', 'state_name', 'county', 'address', 'formatted_address'] - data.drop(columns=drop_cols, inplace=True) - gis_cols = { - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude' - } - data.rename(columns=gis_cols, inplace=True) - - # Optional: Lookup details by searching for business' websites. - # - business_email - # - business_phone - - # Optional: Create fields for standardization: - # - id - - # Save the license data. - if data_dir is not None: - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - data.to_csv(f'{data_dir}/licenses-or-{timestamp}.csv', index=False) - return data - - -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get California licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - get_licenses_or(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_ri.py b/algorithms/get_licenses_ri.py deleted file mode 100644 index fea1ffa1517bab406884f04bbfe3083a824e0e93..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_ri.py +++ /dev/null @@ -1,179 +0,0 @@ -""" -Cannabis Licenses | Get Rhode Island Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/3/2022 -License: - -Description: - - Collect Rhode Island cannabis license data. - -Data Source: - - - Rhode Island - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from bs4 import BeautifulSoup -from cannlytics.data.gis import geocode_addresses -from dotenv import dotenv_values -import pandas as pd -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/ri' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'RI' -RHODE_ISLAND = { - 'licensing_authority_id': 'RIDBH', - 'licensing_authority': 'Rhode Island Department of Business Regulation', - 'retailers': { - 'url': 'https://dbr.ri.gov/office-cannabis-regulation/compassion-centers/licensed-compassion-centers', - 'columns': [ - 'license_number', - 'business_legal_name', - 'address', - 'business_phone', - 'license_designation', - ], - } -} - - -def get_licenses_ri( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Rhode Island cannabis license data.""" - - # Get the licenses webpage. - url = RHODE_ISLAND['retailers']['url'] - response = requests.get(url) - soup = BeautifulSoup(response.content, 'html.parser') - - # Parse the table data. - data = [] - columns = RHODE_ISLAND['retailers']['columns'] - table = soup.find('table') - rows = table.find_all('tr') - for row in rows[1:]: - cells = row.find_all('td') - obs = {} - for i, cell in enumerate(cells): - column = columns[i] - obs[column] = cell.text - data.append(obs) - - # Optional: It's possible to download the certificate to get it's `issue_date`. - - # Standardize the license data. - retailers = pd.DataFrame(data) - retailers['id'] = retailers['license_number'] - retailers['licensing_authority_id'] = RHODE_ISLAND['licensing_authority_id'] - retailers['licensing_authority'] = RHODE_ISLAND['licensing_authority'] - retailers['premise_state'] = STATE - retailers['license_type'] = 'Commercial - Retailer' - retailers['license_status'] = 'Active' - retailers['license_status_date'] = None - retailers['license_term'] = None - retailers['issue_date'] = None - retailers['expiration_date'] = None - retailers['business_owner_name'] = None - retailers['business_structure'] = None - retailers['business_email'] = None - retailers['activity'] = None - retailers['parcel_number'] = None - retailers['business_image_url'] = None - retailers['business_website'] = None - - # Correct `license_designation`. - coding = dict(Yes='Adult Use and Cultivation', No='Adult Use') - retailers['license_designation'] = retailers['license_designation'].map(coding) - - # Correct `business_dba_name`. - criterion = retailers['business_legal_name'].str.contains('D/B/A') - retailers['business_dba_name'] = retailers['business_legal_name'] - retailers.loc[criterion, 'business_dba_name'] = retailers['business_legal_name'].apply( - lambda x: x.split('D/B/A')[1].strip() if 'D/B/A' in x else x - ) - retailers.loc[criterion, 'business_legal_name'] = retailers['business_legal_name'].apply( - lambda x: x.split('D/B/A')[0].strip() - ) - criterion = retailers['business_legal_name'].str.contains('F/K/A') - retailers.loc[criterion, 'business_dba_name'] = retailers['business_legal_name'].apply( - lambda x: x.split('F/K/A')[1].strip() if 'D/B/A' in x else x - ) - retailers.loc[criterion, 'business_legal_name'] = retailers['business_legal_name'].apply( - lambda x: x.split('F/K/A')[0].strip() - ) - - # Get the refreshed date. - par = soup.find_all('p')[-1] - date = par.text.split('updated on ')[-1].split('.')[0] - retailers['data_refreshed_date'] = pd.to_datetime(date).isoformat() - - # Geocode the licenses. - config = dotenv_values(env_file) - google_maps_api_key = config['GOOGLE_MAPS_API_KEY'] - retailers = geocode_addresses( - retailers, - api_key=google_maps_api_key, - address_field='address', - ) - retailers['premise_street_address'] = retailers['formatted_address'].apply( - lambda x: x.split(',')[0] - ) - retailers['premise_city'] = retailers['formatted_address'].apply( - lambda x: x.split(', ')[1].split(',')[0] - ) - retailers['premise_zip_code'] = retailers['formatted_address'].apply( - lambda x: x.split(', ')[2].split(',')[0].split(' ')[-1] - ) - drop_cols = ['state', 'state_name', 'address', 'formatted_address'] - retailers.drop(columns=drop_cols, inplace=True) - gis_cols = { - 'county': 'premise_county', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude' - } - retailers.rename(columns=gis_cols, inplace=True) - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - return retailers - - -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_ri(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_vt.py b/algorithms/get_licenses_vt.py deleted file mode 100644 index 71e3142cb61270c123f0017a778208b031074706..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_vt.py +++ /dev/null @@ -1,253 +0,0 @@ -""" -Cannabis Licenses | Get Vermont Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/7/2022 -License: - -Description: - - Collect Vermont cannabis license data. - -Data Source: - - - Vermont - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from bs4 import BeautifulSoup -from cannlytics.data.gis import geocode_addresses -from dotenv import dotenv_values -import pandas as pd -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/vt' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'VT' -VERMONT = { - 'licensing_authority_id': 'VTCCB', - 'licensing_authority': 'Vermont Cannabis Control Board', - 'licenses_url': 'https://ccb.vermont.gov/licenses', - 'licenses': { - 'licensedcultivators': { - 'columns': [ - 'business_legal_name', - 'license_type', - 'address', - 'license_designation', - ], - }, - 'outdoorcultivators': { - 'columns': [ - 'business_legal_name', - 'license_type', - 'premise_city', - 'license_designation', - ], - }, - 'mixedcultivators': { - 'columns': [ - 'business_legal_name', - 'license_type', - 'premise_city', - 'license_designation', - ], - }, - 'testinglaboratories': { - 'columns': [ - 'business_legal_name', - 'license_type', - 'premise_city', - 'license_designation', - 'address' - ], - }, - 'integrated': { - 'columns': [ - 'business_legal_name', - 'license_type', - 'premise_city', - 'license_designation', - ], - }, - 'retailers': { - 'columns': [ - 'business_legal_name', - 'license_type', - 'address', - 'license_designation', - ], - }, - 'manufacturers': { - 'columns': [ - 'business_legal_name', - 'license_type', - 'premise_city', - 'license_designation', - ], - }, - 'wholesalers': { - 'columns': [ - 'business_legal_name', - 'license_type', - 'premise_city', - 'license_designation', - ], - }, - }, -} - - -def get_licenses_vt( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Vermont cannabis license data.""" - - # Get the licenses from the webpage. - url = VERMONT['licenses_url'] - response = requests.get(url) - soup = BeautifulSoup(response.content, 'html.parser') - - # Parse the various table types. - data = [] - for license_type, values in VERMONT['licenses'].items(): - columns = values['columns'] - table = block = soup.find(attrs={'id': f'block-{license_type}'}) - rows = table.find_all('tr') - for row in rows[1:]: - cells = row.find_all('td') - obs = {} - for i, cell in enumerate(cells): - column = columns[i] - obs[column] = cell.text - data.append(obs) - - # Standardize the licenses. - licenses = pd.DataFrame(data) - licenses['id'] = licenses.index - licenses['license_number'] = None # FIXME: It would be awesome to find these! - licenses['licensing_authority_id'] = VERMONT['licensing_authority_id'] - licenses['licensing_authority'] = VERMONT['licensing_authority'] - licenses['license_designation'] = 'Adult-Use' - licenses['premise_state'] = STATE - licenses['license_status'] = None - licenses['license_status_date'] = None - licenses['license_term'] = None - licenses['issue_date'] = None - licenses['expiration_date'] = None - licenses['business_owner_name'] = None - licenses['business_structure'] = None - licenses['activity'] = None - licenses['parcel_number'] = None - licenses['business_phone'] = None - licenses['business_email'] = None - licenses['business_image_url'] = None - licenses['business_website'] = None - - # Separate the `license_designation` from `license_type` if (Tier x). - criterion = licenses['license_type'].str.contains('Tier ') - licenses.loc[criterion, 'license_designation'] = licenses.loc[criterion]['license_type'].apply( - lambda x: 'Tier ' + x.split('(Tier ')[1].rstrip(')') - ) - licenses.loc[criterion, 'license_type'] = licenses.loc[criterion]['license_type'].apply( - lambda x: x.split('(Tier ')[0].strip() - ) - - # Separate labs' `business_email` and `business_phone` from the `address`. - criterion = licenses['license_type'] == 'Testing Lab' - licenses.loc[criterion, 'business_email'] = licenses.loc[criterion]['address'].apply( - lambda x: x.split('Email: ')[-1].rstrip('\n') if isinstance(x, str) else x - ) - licenses.loc[criterion, 'business_phone'] = licenses.loc[criterion]['address'].apply( - lambda x: x.split('Phone: ')[-1].split('Email: ')[0].rstrip('\n') if isinstance(x, str) else x - ) - licenses.loc[criterion, 'address'] = licenses.loc[criterion]['address'].apply( - lambda x: x.split('Phone: ')[0].replace('\n', ' ').strip() if isinstance(x, str) else x - ) - - # Split any DBA from the legal name. - splits = [';', 'DBA - ', '(DBA)', 'DBA ', 'dba '] - licenses['business_dba_name'] = licenses['business_legal_name'] - for split in splits: - criterion = licenses['business_legal_name'].str.contains(split) - licenses.loc[criterion, 'business_dba_name'] = licenses.loc[criterion]['business_legal_name'].apply( - lambda x: x.split(split)[1].replace(')', '').strip() if split in x else x - ) - licenses.loc[criterion, 'business_legal_name'] = licenses.loc[criterion]['business_legal_name'].apply( - lambda x: x.split(split)[0].replace('(', '').strip() - ) - licenses.loc[licenses['business_legal_name'] == '', 'business_legal_name'] = licenses['business_dba_name'] - - # Get the refreshed date. - licenses['data_refreshed_date'] = datetime.now().isoformat() - - # Geocode the licenses. - # FIXME: There are some wonky addresses that are output! - config = dotenv_values(env_file) - google_maps_api_key = config['GOOGLE_MAPS_API_KEY'] - licenses = geocode_addresses( - licenses, - api_key=google_maps_api_key, - address_field='address', - ) - licenses['premise_street_address'] = licenses['formatted_address'].apply( - lambda x: x.split(',')[0] if STATE in str(x) else x - ) - licenses['premise_city'] = licenses['formatted_address'].apply( - lambda x: x.split(', ')[1].split(',')[0] if STATE in str(x) else x - ) - licenses['premise_zip_code'] = licenses['formatted_address'].apply( - lambda x: x.split(', ')[2].split(',')[0].split(' ')[-1] if STATE in str(x) else x - ) - drop_cols = ['state', 'state_name', 'address', 'formatted_address'] - licenses.drop(columns=drop_cols, inplace=True) - gis_cols = { - 'county': 'premise_county', - 'latitude': 'premise_latitude', - 'longitude': 'premise_longitude' - } - licenses.rename(columns=gis_cols, inplace=True) - - # Save and return the data. - if data_dir is not None: - if not os.path.exists(data_dir): os.makedirs(data_dir) - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers = licenses.loc[licenses['license_type'] == 'Retail'] - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - return licenses - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_vt(data_dir, env_file=env_file) diff --git a/algorithms/get_licenses_wa.py b/algorithms/get_licenses_wa.py deleted file mode 100644 index 4ba2e75fb0111768c5e9b20f7ad720983d2cf716..0000000000000000000000000000000000000000 --- a/algorithms/get_licenses_wa.py +++ /dev/null @@ -1,271 +0,0 @@ -""" -Cannabis Licenses | Get Washington Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/7/2022 -License: - -Description: - - Collect Washington cannabis license data. - -Data Source: - - - Washington State Liquor and Cannabis Board | Frequently Requested Lists - URL: - -""" -# Standard imports. -from datetime import datetime -import os -from typing import Optional - -# External imports. -from bs4 import BeautifulSoup -from cannlytics.data.gis import geocode_addresses -from dotenv import dotenv_values -import pandas as pd -import requests - - -# Specify where your data lives. -DATA_DIR = '../data/wa' -ENV_FILE = '../.env' - -# Specify state-specific constants. -STATE = 'WA' -WASHINGTON = { - 'licensing_authority_id': 'WSLCB', - 'licensing_authority': 'Washington State Liquor and Cannabis Board', - 'licenses_urls': 'https://lcb.wa.gov/records/frequently-requested-lists', - 'labs': { - 'key': 'Lab-List', - 'columns': { - 'Lab Name': 'business_legal_name', - 'Lab #': 'license_number', - 'Address 1': 'premise_street_address', - 'Address 2': 'premise_street_address_2', - 'City': 'premise_city', - 'Zip': 'premise_zip_code', - 'Phone': 'business_phone', - 'Status': 'license_status', - 'Certification Date': 'issue_date', - }, - 'drop_columns': [ - 'Pesticides', - 'Heavy Metals', - 'Mycotoxins', - 'Water Activity', - 'Terpenes', - ], - }, - 'medical': { - 'key': 'MedicalCannabisEndorsements', - 'columns': { - 'License': 'license_number', - 'UBI': 'id', - 'Tradename': 'business_dba_name', - 'Privilege': 'license_type', - 'Status': 'license_status', - 'Med Privilege Code': 'license_designation', - 'Termination Code': 'license_term', - 'Street Adress': 'premise_street_address', - 'Suite Rm': 'premise_street_address_2', - 'City': 'premise_city', - 'State': 'premise_state', - 'County': 'premise_county', - 'Zip Code': 'premise_zip_code', - 'Date Created': 'issue_date', - 'Day Phone': 'business_phone', - 'Email': 'business_email', - }, - }, - 'retailers': { - 'key': 'CannabisApplicants', - 'columns': { - 'Tradename': 'business_dba_name', - 'License ': 'license_number', - 'UBI': 'id', - 'Street Address': 'premise_street_address', - 'Suite Rm': 'premise_street_address_2', - 'City': 'premise_city', - 'State': 'premise_state', - 'county': 'premise_county', - 'Zip Code': 'premise_zip_code', - 'Priv Desc': 'license_type', - 'Privilege Status': 'license_status', - 'Day Phone': 'business_phone', - }, - }, -} - - -def download_file(url, dest='./', headers=None): - """Download a file from a given URL to a local destination. - Args: - url (str): The URL of the data file. - dest (str): The destination for the data file, `./` by default (optional). - headers (dict): HTTP headers, `None` by default (optional). - Returns: - (str): The location for the data file. - """ - filename = url.split('/')[-1] - data_file = os.path.join(dest, filename) - response = requests.get(url, headers=headers) - with open(data_file, 'wb') as doc: - doc.write(response.content) - return data_file - - -def get_licenses_wa( - data_dir: Optional[str] = None, - env_file: Optional[str] = '.env', - ): - """Get Washington cannabis license data.""" - - # Create the necessary directories. - file_dir = f'{data_dir}/.datasets' - if not os.path.exists(data_dir): os.makedirs(data_dir) - if not os.path.exists(file_dir): os.makedirs(file_dir) - - # Get the URLs for the license workbooks. - labs_url, medical_url, retailers_url = None, None, None - labs_key = WASHINGTON['labs']['key'] - medical_key = WASHINGTON['medical']['key'] - retailers_key = WASHINGTON['retailers']['key'] - url = WASHINGTON['licenses_urls'] - response = requests.get(url) - soup = BeautifulSoup(response.content, 'html.parser') - links = soup.find_all('a') - for link in links: - href = link['href'] - if labs_key in href: - labs_url = href - elif retailers_key in href: - retailers_url = href - elif medical_key in href: - medical_url = href - break - - # Download the workbooks. - lab_source_file = download_file(labs_url, dest=file_dir) - medical_source_file = download_file(medical_url, dest=file_dir) - retailers_source_file = download_file(retailers_url, dest=file_dir) - - # Extract and standardize the data from the workbook. - retailers = pd.read_excel(retailers_source_file) - retailers.rename(columns=WASHINGTON['retailers']['columns'], inplace=True) - retailers['license_designation'] = 'Adult-Use' - retailers['license_type'] = 'Adult-Use Retailer' - - labs = pd.read_excel(lab_source_file) - labs.rename(columns=WASHINGTON['labs']['columns'], inplace=True) - labs.drop(columns=WASHINGTON['labs']['drop_columns'], inplace=True) - labs['license_type'] = 'Lab' - - medical = pd.read_excel(medical_source_file, skiprows=2) - medical.rename(columns=WASHINGTON['medical']['columns'], inplace=True) - medical['license_designation'] = 'Medicinal' - medical['license_type'] = 'Medical Retailer' - - # Aggregate the licenses. - licenses = pd.concat([retailers, medical, labs]) - - # Standardize all of the licenses at once! - licenses = licenses.assign( - licensing_authority_id=WASHINGTON['licensing_authority_id'], - licensing_authority=WASHINGTON['licensing_authority'], - premise_state=STATE, - license_status_date=None, - expiration_date=None, - activity=None, - parcel_number=None, - business_owner_name=None, - business_structure=None, - business_image_url=None, - business_website=None, - ) - - # Fill legal and DBA names. - licenses['id'].fillna(licenses['license_number'], inplace=True) - licenses['business_legal_name'].fillna(licenses['business_dba_name'], inplace=True) - licenses['business_dba_name'].fillna(licenses['business_legal_name'], inplace=True) - cols = ['business_legal_name', 'business_dba_name'] - for col in cols: - licenses[col] = licenses[col].apply( - lambda x: x.title().replace('Llc', 'LLC').replace("'S", "'s").strip() - ) - - # Keep only active licenses. - license_statuses = ['Active', 'ACTIVE (ISSUED)', 'ACTIVE TITLE CERTIFICATE',] - licenses = licenses.loc[licenses['license_status'].isin(license_statuses)] - - # Convert certain columns from upper case title case. - cols = ['business_dba_name', 'premise_city', 'premise_county', - 'premise_street_address', 'license_type', 'license_status'] - for col in cols: - retailers[col] = retailers[col].apply(lambda x: x.title().strip()) - - # Get the refreshed date. - date = retailers_source_file.split('\\')[-1].split('.')[0] - date = date.replace('CannabisApplicants', '') - date = date[:2] + '-' + date[2:4] + '-' + date[4:8] - licenses['data_refreshed_date'] = pd.to_datetime(date).isoformat() - - # Append `premise_street_address_2` to `premise_street_address`. - cols = ['premise_street_address', 'premise_street_address_2'] - licenses['premise_street_address'] = licenses[cols].apply( - lambda x : '{} {}'.format(x[0].strip(), x[1]).replace('nan', '').strip().replace(' ', ' '), - axis=1, - ) - licenses.drop(columns=['premise_street_address_2'], inplace=True) - - # Geocode licenses to get `premise_latitude` and `premise_longitude`. - config = dotenv_values(env_file) - api_key = config['GOOGLE_MAPS_API_KEY'] - cols = ['premise_street_address', 'premise_city', 'premise_state', - 'premise_zip_code'] - licenses['address'] = licenses[cols].apply( - lambda row: ', '.join(row.values.astype(str)), - axis=1, - ) - licenses = geocode_addresses(licenses, address_field='address', api_key=api_key) - drop_cols = ['state', 'state_name', 'county', 'address', 'formatted_address'] - gis_cols = {'latitude': 'premise_latitude', 'longitude': 'premise_longitude'} - licenses.drop(columns=drop_cols, inplace=True) - licenses.rename(columns=gis_cols, inplace=True) - - # TODO: Search for business website and image. - - # Save and return the data. - if data_dir is not None: - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - licenses.to_csv(f'{data_dir}/licenses-{STATE.lower()}-{timestamp}.csv', index=False) - retailers = licenses.loc[licenses['license_type'] == 'Adult-Use Retailer'] - retailers.to_csv(f'{data_dir}/retailers-{STATE.lower()}-{timestamp}.csv', index=False) - labs = licenses.loc[licenses['license_type'] == 'Lab'] - labs.to_csv(f'{data_dir}/labs-{STATE.lower()}-{timestamp}.csv', index=False) - return retailers - - -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': DATA_DIR, 'env_file': ENV_FILE} - - # Get licenses, saving them to the specified directory. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - data = get_licenses_wa(data_dir, env_file=env_file) diff --git a/algorithms/main.py b/algorithms/main.py deleted file mode 100644 index bada08779537690854f37596f69e3eacc6a8cbbb..0000000000000000000000000000000000000000 --- a/algorithms/main.py +++ /dev/null @@ -1,109 +0,0 @@ -""" -Cannabis Licenses | Get All Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/7/2022 -License: - -Description: - - Collect all cannabis license data from states with permitted adult-use: - - ✓ Alaska (Selenium) - ✓ Arizona (Selenium) - ✓ California - ✓ Colorado - ✓ Connecticut - ✓ Illinois - ✓ Maine - ✓ Massachusetts - ✓ Michigan (Selenium) - ✓ Montana - ✓ Nevada - ✓ New Jersey - x New Mexico (Selenium) (FIXME) - ✓ Oregon - ✓ Rhode Island - ✓ Vermont - ✓ Washington -""" -# Standard imports. -from datetime import datetime -import importlib -import os - -# External imports. -import pandas as pd - - -# Specify state-specific algorithms. -ALGORITHMS = { - 'ak': 'get_licenses_ak', - 'az': 'get_licenses_az', - 'ca': 'get_licenses_ca', - 'co': 'get_licenses_co', - 'ct': 'get_licenses_ct', - 'il': 'get_licenses_il', - 'ma': 'get_licenses_ma', - 'me': 'get_licenses_me', - 'mi': 'get_licenses_mi', - 'mt': 'get_licenses_mt', - 'nj': 'get_licenses_nj', - # 'nm': 'get_licenses_nm', - 'nv': 'get_licenses_nv', - 'or': 'get_licenses_or', - 'ri': 'get_licenses_ri', - 'vt': 'get_licenses_vt', - 'wa': 'get_licenses_wa', -} -DATA_DIR = '../data' - - -def main(data_dir, env_file): - """Collect all cannabis license data from states with permitted adult-use, - dynamically importing modules and finding the entry point for each of the - `ALGORITHMS`.""" - licenses = pd.DataFrame() - for state, algorithm in ALGORITHMS.items(): - module = importlib.import_module(f'{algorithm}') - entry_point = getattr(module, algorithm) - try: - print(f'Getting license data for {state.upper()}.') - data = entry_point(data_dir, env_file=env_file) - if not os.path.exists(f'{DATA_DIR}/{state}'): os.makedirs(f'{DATA_DIR}/{state}') - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - data.to_csv(f'{DATA_DIR}/{state}/licenses-{state}-{timestamp}.csv', index=False) - licenses = pd.concat([licenses, data]) - except: - print(f'Failed to collect {state.upper()} licenses.') - - # Save all of the retailers. - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - licenses.to_csv(f'{DATA_DIR}/all/licenses-{timestamp}.csv', index=False) - return licenses - - -# === Test === -if __name__ == '__main__': - - # Support command line usage. - import argparse - try: - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument('--d', dest='data_dir', type=str) - arg_parser.add_argument('--data_dir', dest='data_dir', type=str) - arg_parser.add_argument('--env', dest='env_file', type=str) - args = arg_parser.parse_args() - except SystemExit: - args = {'d': '../data/all', 'env_file': '../.env'} - - # Get arguments. - data_dir = args.get('d', args.get('data_dir')) - env_file = args.get('env_file') - - # Get licenses for each state. - all_licenses = main(data_dir, env_file) diff --git a/all/cannabis_licenses-data.parquet b/all/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..af5b82b6d6670f7cbaac36b151c8a1d54e4622a3 --- /dev/null +++ b/all/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9df1826899c75b4124866b6386ae346b5fecfbfbdf9305d39ea04f0ea85fab1 +size 972698 diff --git a/analysis/figures/cannabis-licenses-map.html b/analysis/figures/cannabis-licenses-map.html deleted file mode 100644 index 47bef60a28582300934dca01c07be65c65b0df9d..0000000000000000000000000000000000000000 --- a/analysis/figures/cannabis-licenses-map.html +++ /dev/null @@ -1,66424 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - \ No newline at end of file diff --git a/analysis/figures/cannabis-licenses-map.png b/analysis/figures/cannabis-licenses-map.png deleted file mode 100644 index 2019b85c44c7a1eb9bd1eb747089a9985dac3bde..0000000000000000000000000000000000000000 --- a/analysis/figures/cannabis-licenses-map.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b2664e0dd4284155fd74655fe94cd1e5eca805da1231276398887b8ac8f2811a -size 470396 diff --git a/analysis/license_map.py b/analysis/license_map.py deleted file mode 100644 index 916a319c5d491a27ed88e583644cb5f66b7d44d3..0000000000000000000000000000000000000000 --- a/analysis/license_map.py +++ /dev/null @@ -1,106 +0,0 @@ -""" -Cannabis Licenses | License Mao -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/22/2022 -Updated: 10/8/2022 -License: - -Description: - - Map the adult-use cannabis retailers permitted in the United States: - - ✓ Alaska - ✓ Arizona - ✓ California - ✓ Colorado - ✓ Connecticut - ✓ Illinois - ✓ Maine - ✓ Massachusetts - ✓ Michigan - ✓ Montana - ✓ Nevada - ✓ New Jersey - x New Mexico (FIXME) - ✓ Oregon - ✓ Rhode Island - ✓ Vermont - ✓ Washington - -""" -# Standard imports. -from datetime import datetime -import json -import os - -# External imports. -import folium -import pandas as pd - - -# Specify where your data lives. -DATA_DIR = '../' - -# Read data subsets. -with open('../subsets.json', 'r') as f: - SUBSETS = json.loads(f.read()) - - -def aggregate_retailers( - datafiles, - index_col=0, - lat='premise_latitude', - long='premise_longitude', - ): - """Aggregate retailer license data files, - keeping only those with latitude and longitude.""" - data = [] - for filename in datafiles: - data.append(pd.read_csv(filename, index_col=index_col)) - data = pd.concat(data) - return data.loc[(~data[lat].isnull()) & (~data[long].isnull())] - - -def create_retailer_map( - df, - color='crimson', - filename=None, - lat='premise_latitude', - long='premise_longitude', - ): - """Create a map of licensed retailers.""" - m = folium.Map( - location=[39.8283, -98.5795], - zoom_start=3, - control_scale=True, - ) - for _, row in df.iterrows(): - folium.Circle( - radius=5, - location=[row[lat], row[long]], - color=color, - ).add_to(m) - if filename: - m.save(filename) - return m - - -# === Test === -if __name__ == '__main__': - - # Aggregate retailers. - subsets = list(SUBSETS.values()) - datafiles = [DATA_DIR + x['data_url'] for x in subsets] - retailers = aggregate_retailers(datafiles) - - # Create the retailers map. - map_file = '../analysis/figures/cannabis-licenses-map.html' - m = create_retailer_map(retailers, filename=map_file) - - # Save all of the retailers. - timestamp = datetime.now().isoformat()[:19].replace(':', '-') - retailers.to_csv(f'{DATA_DIR}/data/all/licenses-{timestamp}.csv', index=False) diff --git a/az/cannabis_licenses-data.parquet b/az/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..be90f38119fe446943b495e5bd56896f83e3100d --- /dev/null +++ b/az/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a20ff11117c8b5eb7f3f60b26e8056e5eca447dbf02eca4e66f91ade6e5b8735 +size 38532 diff --git a/ca/cannabis_licenses-data.parquet b/ca/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..6c2f680396d5f86429c33982e9f6a226741f9916 --- /dev/null +++ b/ca/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5128e0a465672917e28d0902917abeb5c5b42911eeff4001603b2f99f1e1024 +size 1009853 diff --git a/cannabis_licenses.py b/cannabis_licenses.py deleted file mode 100644 index 779424b3744750012a43d6c900771467069bfe87..0000000000000000000000000000000000000000 --- a/cannabis_licenses.py +++ /dev/null @@ -1,152 +0,0 @@ -""" -Cannabis Licenses -Copyright (c) 2022 Cannlytics - -Authors: - Keegan Skeate - Candace O'Sullivan-Sutherland -Created: 9/29/2022 -Updated: 10/8/2022 -License: -""" -# Standard imports. -import json - -# External imports. -import datasets -import pandas as pd - - -# Constants. -_SCRIPT = 'cannabis_licenses.py' -_VERSION = '1.0.0' -_HOMEPAGE = 'https://huggingface.co/datasets/cannlytics/cannabis_licenses' -_LICENSE = "https://opendatacommons.org/licenses/by/4-0/" -_DESCRIPTION = """\ -Cannabis Licenses (https://cannlytics.com/data/licenses) is a -dataset of curated cannabis license data. The dataset consists of 18 -sub-datasets for each state with permitted adult-use cannabis, as well -as a sub-dataset that includes all licenses. -""" -_CITATION = """\ -@inproceedings{cannlytics2022cannabis_licenses, - author = {Skeate, Keegan and O'Sullivan-Sutherland, Candace}, - title = {Cannabis Licenses}, - booktitle = {Cannabis Data Science}, - month = {October}, - year = {2022}, - address = {United States of America}, - publisher = {Cannlytics} -} -""" - -# Dataset fields. -FIELDS = datasets.Features({ - 'id': datasets.Value(dtype='string'), - 'license_number': datasets.Value(dtype='string'), - 'license_status': datasets.Value(dtype='string'), - 'license_status_date': datasets.Value(dtype='string'), - 'license_term': datasets.Value(dtype='string'), - 'license_type': datasets.Value(dtype='string'), - 'license_designation': datasets.Value(dtype='string'), - 'issue_date': datasets.Value(dtype='string'), - 'expiration_date': datasets.Value(dtype='string'), - 'licensing_authority_id': datasets.Value(dtype='string'), - 'licensing_authority': datasets.Value(dtype='string'), - 'business_legal_name': datasets.Value(dtype='string'), - 'business_dba_name': datasets.Value(dtype='string'), - 'business_image_url': datasets.Value(dtype='string'), - 'business_owner_name': datasets.Value(dtype='string'), - 'business_structure': datasets.Value(dtype='string'), - 'business_website': datasets.Value(dtype='string'), - 'activity': datasets.Value(dtype='string'), - 'premise_street_address': datasets.Value(dtype='string'), - 'premise_city': datasets.Value(dtype='string'), - 'premise_state': datasets.Value(dtype='string'), - 'premise_county': datasets.Value(dtype='string'), - 'premise_zip_code': datasets.Value(dtype='string'), - 'business_email': datasets.Value(dtype='string'), - 'business_phone': datasets.Value(dtype='string'), - 'parcel_number': datasets.Value(dtype='string'), - 'premise_latitude': datasets.Value(dtype='float'), - 'premise_longitude': datasets.Value(dtype='float'), - 'data_refreshed_date': datasets.Value(dtype='string'), -}) - -# DEV: Read subsets from local source. -# with open('subsets.json', 'r') as f: -# SUBSETS = json.loads(f.read()) - -# PRODUCTION: Read subsets from the official source. -import urllib.request -with urllib.request.urlopen('https://huggingface.co/datasets/cannlytics/cannabis_licenses/raw/main/subsets.json') as url: - SUBSETS = json.load(url) - - -class CannabisLicensesConfig(datasets.BuilderConfig): - """BuilderConfig for Cannabis Licenses.""" - - def __init__(self, name, **kwargs): - """BuilderConfig for Cannabis Licenses. - Args: - name (str): Configuration name that determines setup. - **kwargs: Keyword arguments forwarded to super. - """ - description = _DESCRIPTION - description += f'This configuration is for the `{name}` subset.' - super().__init__(name=name, description=description, **kwargs) - - -class CannabisLicenses(datasets.GeneratorBasedBuilder): - """The Cannabis Licenses dataset.""" - - VERSION = datasets.Version(_VERSION) - BUILDER_CONFIG_CLASS = CannabisLicensesConfig - BUILDER_CONFIGS = [CannabisLicensesConfig(s) for s in SUBSETS.keys()] - DEFAULT_CONFIG_NAME = 'ca' - - def _info(self): - """Returns the dataset metadata.""" - return datasets.DatasetInfo( - features=FIELDS, - supervised_keys=None, - homepage=_HOMEPAGE, - citation=_CITATION, - description=_DESCRIPTION, - license=_LICENSE, - version=_VERSION, - ) - - def _split_generators(self, dl_manager): - """Returns SplitGenerators.""" - config_name = self.config.name - data_url = SUBSETS[config_name]['data_url'] - urls = {config_name: data_url} - downloaded_files = dl_manager.download_and_extract(urls) - filepath = downloaded_files[config_name] - params = {'filepath': filepath} - return [datasets.SplitGenerator(name='data', gen_kwargs=params)] - - def _generate_examples(self, filepath): - """Returns the examples in raw text form.""" - with open(filepath) as f: - df = pd.read_csv(filepath) - for index, row in df.iterrows(): - obs = row.to_dict() - yield index, obs - - -# === Test === -if __name__ == '__main__': - - from datasets import load_dataset - - # Define all of the dataset subsets. - subsets = list(SUBSETS.keys()) - - # Load each dataset subset. - for subset in subsets: - dataset = load_dataset(_SCRIPT, subset) - data = dataset['data'] - assert len(data) > 0 - print('Read %i %s data points.' % (len(data), subset)) diff --git a/co/cannabis_licenses-data.parquet b/co/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..5e96f41c85e8974f5458d6d097849816824d44fd --- /dev/null +++ b/co/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f19639952c1bd866757334effc4cc84732f855766a187db72ecbda222b52a390 +size 87742 diff --git a/ct/cannabis_licenses-data.parquet b/ct/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..b3ef794f8dd99570749f04f4464276b4ac6f862c --- /dev/null +++ b/ct/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7ff4b2bd3baee5e321bf62de42aab31c345ae8c39781d1260290ac7b20f283e +size 17600 diff --git a/data/ak/licenses-ak-2022-10-06T17-46-29.csv b/data/ak/licenses-ak-2022-10-06T17-46-29.csv deleted file mode 100644 index 0a2b0ae12a6bad09f4092632df2bd0e78ab5b953..0000000000000000000000000000000000000000 --- a/data/ak/licenses-ak-2022-10-06T17-46-29.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:eb8d27262257ea27210b83b9f52188a2e5df7cce69c972c9acf834a816a536f3 -size 163578 diff --git a/data/ak/retailers-ak-2022-10-06T17-46-29.csv b/data/ak/retailers-ak-2022-10-06T17-46-29.csv deleted file mode 100644 index 347e7ff41ccc0bb3a68dc005c5f41539d124d65d..0000000000000000000000000000000000000000 --- a/data/ak/retailers-ak-2022-10-06T17-46-29.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:180bbc362a8f184318959d766c7f2d715f60d5499666569d151dccaf5b96baa2 -size 59583 diff --git a/data/all/licenses-2022-10-06T18-46-11.csv b/data/all/licenses-2022-10-06T18-46-11.csv deleted file mode 100644 index dc8d0df1a20fd658a183e52dcd59f43614a2c895..0000000000000000000000000000000000000000 --- a/data/all/licenses-2022-10-06T18-46-11.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:091d343ceee078d47fa9a8c235060f8ee20a500bb3844f752cd243237aeaea0c -size 6961305 diff --git a/data/all/licenses-2022-10-08T14-03-08.csv b/data/all/licenses-2022-10-08T14-03-08.csv deleted file mode 100644 index 7ff5725f411d9777becda28daae3026c4994b4f3..0000000000000000000000000000000000000000 --- a/data/all/licenses-2022-10-08T14-03-08.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:75e7975601c8f9bc21918c9642dfc7ddcfbfd89427b1553ff754f0fd53d4d309 -size 3192307 diff --git a/data/all/retailers-2022-10-07T10-20-55.csv b/data/all/retailers-2022-10-07T10-20-55.csv deleted file mode 100644 index 1c44ca392f03a7792b9b5b5d9697ae2fbb331aec..0000000000000000000000000000000000000000 --- a/data/all/retailers-2022-10-07T10-20-55.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:63de8f476d9f52e9a0a1a3bf28f0fe3ad5e601bad87f5cd7b915ecda1e1c53df -size 1551940 diff --git a/data/az/licenses-az-2022-10-07T10-12-07.csv b/data/az/licenses-az-2022-10-07T10-12-07.csv deleted file mode 100644 index 4d0f5206c8c70ea9934f7c0e6f4c51bae977b05c..0000000000000000000000000000000000000000 --- a/data/az/licenses-az-2022-10-07T10-12-07.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b9e87fee772c87b19d2caae58e4df9b00a5a6dead34178423a193b3b4fd237bb -size 86738 diff --git a/data/az/retailers-az-2022-10-07T10-12-07.csv b/data/az/retailers-az-2022-10-07T10-12-07.csv deleted file mode 100644 index bb7002a1195d2024d567721b874d03c5616ebcea..0000000000000000000000000000000000000000 --- a/data/az/retailers-az-2022-10-07T10-12-07.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ed851b83841db5526b3f21e954dfda1d6e15242ecd1f992cc0a285c3aee6c9f9 -size 61925 diff --git a/data/ca/licenses-ca-2022-10-06T18-10-15.csv b/data/ca/licenses-ca-2022-10-06T18-10-15.csv deleted file mode 100644 index 6e0c62b2a4556d157f1592d0c7aa7964bc6723cb..0000000000000000000000000000000000000000 --- a/data/ca/licenses-ca-2022-10-06T18-10-15.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9563c185dfe5f594203bee3dceeca3e5bd130d71077a1a359281a2b6e7834e20 -size 5604246 diff --git a/data/co/licenses-co-2022-10-06T18-28-29.csv b/data/co/licenses-co-2022-10-06T18-28-29.csv deleted file mode 100644 index 16d58e5d8a5c8023ed95eae2f295c0e4eed714ef..0000000000000000000000000000000000000000 --- a/data/co/licenses-co-2022-10-06T18-28-29.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:693636fbd2b290f8a121300ac86fa6831a4741aabf2db890393c83b596a9527b -size 448918 diff --git a/data/co/retailers-co-2022-10-06T18-28-29.csv b/data/co/retailers-co-2022-10-06T18-28-29.csv deleted file mode 100644 index 33ff73ecfac4bdaf2f2006fd178c5a05096667bb..0000000000000000000000000000000000000000 --- a/data/co/retailers-co-2022-10-06T18-28-29.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:427f3dcfe94b5feead000d0c0e8735a21c14928a1a702f3f90cfe2dd896759a4 -size 261301 diff --git a/data/ct/retailers-ct-2022-10-06T18-28-33.csv b/data/ct/retailers-ct-2022-10-06T18-28-33.csv deleted file mode 100644 index ad28b00635d35c6ee9d488500d243663b1f7adfe..0000000000000000000000000000000000000000 --- a/data/ct/retailers-ct-2022-10-06T18-28-33.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8eae29b21d9124148d8dbe68f3cb158a88902b22c0532eda78627a6b81eafb04 -size 5995 diff --git a/data/il/retailers-il-2022-10-06T18-28-55.csv b/data/il/retailers-il-2022-10-06T18-28-55.csv deleted file mode 100644 index da47a7e80652f59f2ef8bdcd118acf00f7b2b7b5..0000000000000000000000000000000000000000 --- a/data/il/retailers-il-2022-10-06T18-28-55.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2f96d64d5efbf0103392d9c34483977c97d7c776b46cada18e7faf35807e4932 -size 35040 diff --git a/data/ma/licenses-ma-2022-10-07T14-45-39.csv b/data/ma/licenses-ma-2022-10-07T14-45-39.csv deleted file mode 100644 index 227ae4b755afee98f817218719da9239d6c0c326..0000000000000000000000000000000000000000 --- a/data/ma/licenses-ma-2022-10-07T14-45-39.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:38036322058b3fc45112bca58728904a2cb9e48ade60371feb5edcdae934b8f0 -size 260727 diff --git a/data/ma/retailers-ma-2022-10-07T14-45-39.csv b/data/ma/retailers-ma-2022-10-07T14-45-39.csv deleted file mode 100644 index 4c085308363daf74fef99d8cf1429e23fa550618..0000000000000000000000000000000000000000 --- a/data/ma/retailers-ma-2022-10-07T14-45-39.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f076c79fc442d8f94142c724fa20bafa4e6c02e72431da594fc3d1cf892c61e2 -size 101882 diff --git a/data/me/licenses-me-2022-10-07T15-26-01.csv b/data/me/licenses-me-2022-10-07T15-26-01.csv deleted file mode 100644 index 47244bf5d10c5d64296b6accc0536aaf231544b4..0000000000000000000000000000000000000000 --- a/data/me/licenses-me-2022-10-07T15-26-01.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:92bbfa576b32396673cdc8c95ee5e4902ebf5ff33ed6084c988882ed41fe877e -size 128972 diff --git a/data/mi/licenses-mi-2022-10-08T13-49-04.csv b/data/mi/licenses-mi-2022-10-08T13-49-04.csv deleted file mode 100644 index 141fcc45f93828885985d9a95d746bc5993cd832..0000000000000000000000000000000000000000 --- a/data/mi/licenses-mi-2022-10-08T13-49-04.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5295070f77b7a572c13de1c069428e5e71cc9dd422ad096745816c0d8fa64e1e -size 38635 diff --git a/data/mt/retailers-mt-2022-10-07T16-28-10.csv b/data/mt/retailers-mt-2022-10-07T16-28-10.csv deleted file mode 100644 index b049055eb948406daac7c1817d6c40db1b9f4be3..0000000000000000000000000000000000000000 --- a/data/mt/retailers-mt-2022-10-07T16-28-10.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2b1bd3b1dfdcb846bb3b3b002e9116596e8b9869b35a0462fcdf8d82176efcc9 -size 117170 diff --git a/data/nj/licenses-nj-2022-10-06T18-39-17.csv b/data/nj/licenses-nj-2022-10-06T18-39-17.csv deleted file mode 100644 index 060ab366f79ae631b0eacde6b38118047ca893e7..0000000000000000000000000000000000000000 --- a/data/nj/licenses-nj-2022-10-06T18-39-17.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:eeb27486bc5cfb4b8ab0568f85b2d48a5aadb77fd2f68850a4e325c8793aef64 -size 5525 diff --git a/data/nm/retailers-nm-2022-10-05T15-09-21.csv b/data/nm/retailers-nm-2022-10-05T15-09-21.csv deleted file mode 100644 index c5c855cd07059fb93b968aae3cb836a4b6060f10..0000000000000000000000000000000000000000 --- a/data/nm/retailers-nm-2022-10-05T15-09-21.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:978d2a7dab0c9e4dffdfb6e29d01974429de3cdd9887ac13893aec74790ef896 -size 128187 diff --git a/data/nv/licenses-nv-2022-10-06T18-42-39.csv b/data/nv/licenses-nv-2022-10-06T18-42-39.csv deleted file mode 100644 index 1a9f2bd20609e8654c80282f9c4f462023ee05df..0000000000000000000000000000000000000000 --- a/data/nv/licenses-nv-2022-10-06T18-42-39.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2f0c00bfd35141ca85d1fb29cf1d972124e384bf5432d8ba060ffd236bed8d4b -size 129201 diff --git a/data/nv/retailers-nv-2022-10-06T18-43-01.csv b/data/nv/retailers-nv-2022-10-06T18-43-01.csv deleted file mode 100644 index 2778b69e2244388600cbb86b6735188a39e55698..0000000000000000000000000000000000000000 --- a/data/nv/retailers-nv-2022-10-06T18-43-01.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:df8707ab150055148ae3ab65313aa73f5d1f6ccb32bc4fc20785f4c3ba9e6ece -size 22015 diff --git a/data/or/licenses-or-2022-10-07T14-47-55.csv b/data/or/licenses-or-2022-10-07T14-47-55.csv deleted file mode 100644 index bbb959f087ac27e2ae2fd61d051a86dd93877ff0..0000000000000000000000000000000000000000 --- a/data/or/licenses-or-2022-10-07T14-47-55.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:99cdb82c0ceb4741110f7e425ba0c2c380ca681f63683c77937c34c5cca0ce2b -size 209474 diff --git a/data/ri/licenses-ri-2022-10-06T18-45-41.csv b/data/ri/licenses-ri-2022-10-06T18-45-41.csv deleted file mode 100644 index beaa4622408762739e9b41b16978ea2f823368db..0000000000000000000000000000000000000000 --- a/data/ri/licenses-ri-2022-10-06T18-45-41.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:303cf4840665188d577305de183ad2425b162abd7117e7ff08a9e423b2215e12 -size 2029 diff --git a/data/vt/licenses-vt-2022-10-06T18-46-08.csv b/data/vt/licenses-vt-2022-10-06T18-46-08.csv deleted file mode 100644 index 2cdde878c790e7ce87ff4a461715c3148cada5c3..0000000000000000000000000000000000000000 --- a/data/vt/licenses-vt-2022-10-06T18-46-08.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d7c39454cba0f7aa44884128dd884a3b4b1f1aa23971e9b6e4e82a2077340223 -size 44534 diff --git a/data/vt/retailers-vt-2022-10-06T18-46-08.csv b/data/vt/retailers-vt-2022-10-06T18-46-08.csv deleted file mode 100644 index 29156925d5874d55d59fda31ca870c206bc9ed07..0000000000000000000000000000000000000000 --- a/data/vt/retailers-vt-2022-10-06T18-46-08.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3b32c6e31d1e62f21e245a193185850a2351829906ba7a45d73b0c5221776778 -size 1092 diff --git a/data/wa/labs-wa-2022-10-07T09-06-02.csv b/data/wa/labs-wa-2022-10-07T09-06-02.csv deleted file mode 100644 index 5d3b1e3357b0c555b7422aeb067f8ffbaa2e373a..0000000000000000000000000000000000000000 --- a/data/wa/labs-wa-2022-10-07T09-06-02.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:600e9f95ecc08bdad9bc6a07e1d1498ca672c297237356ff02ca7246cc8f06c4 -size 657 diff --git a/data/wa/licenses-wa-2022-10-07T09-06-02.csv b/data/wa/licenses-wa-2022-10-07T09-06-02.csv deleted file mode 100644 index 517b08c1c8564a2c43d188d57a213984e9c3d44e..0000000000000000000000000000000000000000 --- a/data/wa/licenses-wa-2022-10-07T09-06-02.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:81adc3f14025f17fb82eb29e12615baf7b5d45546e2c4fa4ea748653e6cb05a2 -size 222007 diff --git a/data/wa/retailers-wa-2022-10-07T09-06-02.csv b/data/wa/retailers-wa-2022-10-07T09-06-02.csv deleted file mode 100644 index 1487be62531de834332fcc967511449fc7e2cdcb..0000000000000000000000000000000000000000 --- a/data/wa/retailers-wa-2022-10-07T09-06-02.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:43e1a1305c4461f364454c4096be48d31d84952697ed8af4c7d05c0fdf5ea3f8 -size 133780 diff --git a/env.example b/env.example deleted file mode 100644 index 76b54cda55ff4a0fee357b260032db9654a943ad..0000000000000000000000000000000000000000 --- a/env.example +++ /dev/null @@ -1,2 +0,0 @@ -FRED_API_KEY=abc -GOOGLE_MAPS_API_KEY=xyz diff --git a/il/cannabis_licenses-data.parquet b/il/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..5fae8f0f53b22b6fe9da3c90b6974978d304e6e0 --- /dev/null +++ b/il/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e5a125c2fe65bd8f59c35d23f1a3bb242ed7d45fdc499b5bf7b8f0cc277a239 +size 24583 diff --git a/ma/cannabis_licenses-data.parquet b/ma/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..ee7b03b009eaa356941cc03ef7035c5bf7392223 --- /dev/null +++ b/ma/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03bdb879900c9a1a9afb6e362123db2798bc7b41929ec2b3a7dcf9af3302364b +size 43965 diff --git a/me/cannabis_licenses-data.parquet b/me/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..95941e9a324648948937c45541926347593fee8a --- /dev/null +++ b/me/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7443995bf5b85a2fb52082e98ed9d8dffbf5ce7cc80e1389d44be915455f82f +size 45437 diff --git a/mi/cannabis_licenses-data.parquet b/mi/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..5c84dd70754fb0e6877a03ffd62426e50c866bec --- /dev/null +++ b/mi/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ed53217226f0bab9e9f0009e704e3a0a8d71212bdfd5d5c596ff4fe7791bd56 +size 17155 diff --git a/mt/cannabis_licenses-data.parquet b/mt/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..169f40646b712fd41b89ded5f2455a684508096a --- /dev/null +++ b/mt/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a729493c750d80482fba958d0976b89a64642adcbec00a7e57f19a8b5994fcc9 +size 46957 diff --git a/nj/cannabis_licenses-data.parquet b/nj/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..0bd874c1850b84435b4fb6afcd45067990e65157 --- /dev/null +++ b/nj/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f49eeb56339e999020bb8fcf7691756cf054b439603e41d2f0754a2e4ec40d5c +size 16951 diff --git a/nm/cannabis_licenses-data.parquet b/nm/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..924f684fd73b10fb3bc6d0029d6e057e9b9f746e --- /dev/null +++ b/nm/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eeaa7204834910c1785781144b50d5c0015bb2690dce4497ff43e87016ca9373 +size 39584 diff --git a/nv/cannabis_licenses-data.parquet b/nv/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..53372e23f760757b141222b885e2961f4a22e148 --- /dev/null +++ b/nv/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f7ca332d616e2e26efbf6d631f599969dde3b5fab68e6777fba406c216e4b64 +size 20749 diff --git a/or/cannabis_licenses-data.parquet b/or/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..4b2fd8707f969f0501afd5a5384e0bf2fa51bf2f --- /dev/null +++ b/or/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0330aa4b2e0c6d34e41175a171df9f2de236dcb4af8c631e8b80873401326a5e +size 72467 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5fafaf59cedc185f7d2a541002ce7649b7b7f3ce..0000000000000000000000000000000000000000 --- a/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Cannabis Licenses | Python Requirements -# Created: 9/28/2022 -# Updated: 10/6/2022 -beautifulsoup4==4.11.1 -cannlytics==0.0.13 -chromedriver-binary==107.0.5304.18.0 -firebase_admin==5.3.0 -folium==0.12.1.post1 -fredapi==0.5.0 -matplotlib==3.6.0 -pandas==1.4.4 -pdfplumber==0.7.4 -python-dotenv==0.21.0 -requests==2.28.1 -seaborn==0.12.0 -selenium==4.5.0 -xlrd==2.0.1 -zipcodes==1.2.0 diff --git a/ri/cannabis_licenses-data.parquet b/ri/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..bbb458f46091bce17b74c25c87385f6f35e78ecb --- /dev/null +++ b/ri/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a6535550c4da1e45f50a08cff844f814893137e704e940b3699b43f0e8d2c09 +size 15881 diff --git a/subsets.json b/subsets.json deleted file mode 100644 index d481a252981645b082595359518bbbf257d9ee1c..0000000000000000000000000000000000000000 --- a/subsets.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "all": { - "name": "all", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/main.py", - "data_source": "", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/all/licenses-2022-10-08T14-03-08.csv" - }, - "ak": { - "name": "ak", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ak.py", - "data_source": "https://www.commerce.alaska.gov/abc/marijuana/Home/licensesearch", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/ak/retailers-ak-2022-10-06T17-46-29.csv" - }, - "az": { - "name": "az", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_az.py", - "data_source": "https://azcarecheck.azdhs.gov/s/?licenseType=null", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/az/retailers-az-2022-10-07T10-12-07.csv" - }, - "ca": { - "name": "ca", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ca.py", - "data_source": "https://search.cannabis.ca.gov/", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/ca/licenses-ca-2022-10-06T18-10-15.csv" - }, - "co": { - "name": "co", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_co.py", - "data_source": "https://sbg.colorado.gov/med/licensed-facilities", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/co/retailers-co-2022-10-06T18-28-29.csv" - }, - "ct": { - "name": "ct", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ct.py", - "data_source": "https://portal.ct.gov/DCP/Medical-Marijuana-Program/Connecticut-Medical-Marijuana-Dispensary-Facilities", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/ct/retailers-ct-2022-10-06T18-28-33.csv" - }, - "il": { - "name": "il", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_il.py", - "data_source": "https://www.idfpr.com/LicenseLookup/AdultUseDispensaries.pdf", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/il/retailers-il-2022-10-06T18-28-55.csv" - }, - "ma": { - "name": "ma", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ma.py", - "data_source": "https://masscannabiscontrol.com/open-data/data-catalog/", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/ma/retailers-ma-2022-10-07T14-45-39.csv" - }, - "me": { - "name": "me", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_me.py", - "data_source": "https://www.maine.gov/dafs/ocp/open-https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/adult-use", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/me/licenses-me-2022-10-07T15-26-01.csv" - }, - "mi": { - "name": "mi", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_mi.py", - "data_source": "https://michigan.maps.arcgis.com/apps/webappviewer/index.html?id=cd5a1a76daaf470b823a382691c0ff60", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/mi/licenses-mi-2022-10-08T13-49-04.csv" - }, - "mt": { - "name": "mt", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_mt.py", - "data_source": "https://mtrevenue.gov/cannabis/#CannabisLicenses", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/mt/retailers-mt-2022-10-07T16-28-10.csv" - }, - "nj": { - "name": "nj", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_nj.py", - "data_source": "https://data.nj.gov/stories/s/ggm4-mprw", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/nj/licenses-nj-2022-10-06T18-39-17.csv" - }, - "nm": { - "name": "nm", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_nm.py", - "data_source": "https://nmrldlpi.force.com/bcd/s/public-search-license?division=CCD&language=en_US", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/nm/retailers-nm-2022-10-05T15-09-21.csv" - }, - "nv": { - "name": "nv", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_nv.py", - "data_source": "https://ccb.nv.gov/list-of-licensees/", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/nv/retailers-nv-2022-10-06T18-43-01.csv" - }, - "or": { - "name": "or", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ca.py", - "data_source": "https://www.oregon.gov/olcc/marijuana/pages/recreational-marijuana-licensing.aspx", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/or/licenses-or-2022-10-07T14-47-55.csv" - }, - "ri": { - "name": "ri", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_ri.py", - "data_source": "https://dbr.ri.gov/office-cannabis-regulation/compassion-centers/licensed-compassion-centers", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/ri/licenses-ri-2022-10-06T18-45-41.csv" - }, - "vt": { - "name": "vt", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_vt.py", - "data_source": "https://ccb.vermont.gov/licenses", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/vt/retailers-vt-2022-10-06T18-46-08.csv" - }, - "wa": { - "name": "wa", - "url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/blob/main/algorithms/get_licenses_wa.py", - "data_source": "https://lcb.wa.gov/records/frequently-requested-lists", - "data_url": "https://huggingface.co/datasets/cannlytics/cannabis_licenses/resolve/main/data/wa/retailers-wa-2022-10-07T09-06-02.csv" - } -} diff --git a/vt/cannabis_licenses-data.parquet b/vt/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..c97e5a90c290af6e9ba41e2e2ebae0ee6cb4741b --- /dev/null +++ b/vt/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:186e5d0cac487919a98bc031fb8e3c0df437a2374c1e7a829631d612daad1411 +size 14721 diff --git a/wa/cannabis_licenses-data.parquet b/wa/cannabis_licenses-data.parquet new file mode 100644 index 0000000000000000000000000000000000000000..d8213cb3e435016f200ba571fac945b206e8d3ae --- /dev/null +++ b/wa/cannabis_licenses-data.parquet @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28bf10b01a92c172329627b03fd5fbde93796aa37dc87b9c2684d6d1eba8ee02 +size 54050