question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Catalog by smart classes

See original GitHub issue

Pandas implementation of the catalog doesn’t work pretty well because of these two main issues:

Thus, let’s move to an approach where classes are smarter.

At the definition, we’re just including the properties that work as methods. The rest of the properties are not defined but must appear with the same name as in the metadata DB.

[] Denotes a list that will work as an Entity List (see below)

Methods are replaced by properties. I think it’s better for a catalog, i.e., Catalog.countries 👍 instead of Catalog.countries()

EntityList

  1. get: It will allow finding by id: Catalog.countries.get('es')

  2. to_dataframe: returns a pandas dataframe of the list.

Classes

Catalog

Catalog.countries => [Country] #Static Catalog.datasets => [Datasets] #Static Catalog.categories => [Category] #Static

Country

Country.get(<country_id>) => Country #Static Country.id => String Country.categories => [Category] Country.datasets => [Dataset] Country.geographies => [Geography]

Category

Category.get(<category_id>) Category.id => String Category.datasets => [Dataset] Category.geographies => [Geography] #It returns all the geographies with datasets for this category (country and category), This instance of category must be create with the optional parameter category_id Category.countries => [Country]

Dataset

Dataset.get(<dataset_id>) #Static Dataset.id => String Dataset.variables => [Variable] Dataset.variables_groups => { ‘group_1’: [Variable], ‘group_2’: [Variable] } # It removes the concept of Variables Groups! Dataset.geography => Geography

Variable Variable.get(<variable_id>) #static Variable.id => String Variable.dataset => Dataset

Geography

Geography.get(<geography_id>) Geography.datasets = [Dataset] Geography.support = String (admin|quadgrid|postalcodes) Geography.support_level = 1,2,3,4 Geography.country = Country

If Geography class is instantiate by providing category_id, datasets method will return all the datasets filtered by the category provided.

Usage

Get all categories of a country

Country.get(‘usa’).categories

Convert a list to pandas

Country.get(‘usa’).categories.to_dataframe().head() Country.get(‘usa’).geographies.to_dataframe().head() Country.get(‘usa’).datasets.to_dataframe().head()

Get all datasets of a category

Country.get(‘usa’).categories.get(‘demographics’).datasets

Get all datasets of a category

Category.get(‘geomgraphics’).countries.get(‘usa’).datasets

Get all boundaries with demographics datasets

Country.get(‘usa’).categories.get(‘demographics’).geographies

Get all demographics datasets for block groups of a country

Country.get(‘usa’).categories.get(‘demographics’).geographies.get(‘block_groups’).datasets()

cc: @alrocar @cmongut

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
eslohocommented, Oct 10, 2019

After talking with @alasarr we agreed on that notation and decided to allow the entities to keep the filters of their creation so following queries will take them into account 😃

0reactions
eslohocommented, Oct 11, 2019

Missing methods have been added in PR #1093

Read more comments on GitHub >

github_iconTop Results From Across the Web

Higher Education Catalog and Curriculum Management ...
Online academic catalog and curriculum management software by Watermark streamlines the production process in one turnkey single solution.
Read more >
Organization, Regulations, and Courses 2022-23 - ORC|Catalog
2022 New Undergraduate Course Supplement · About This Catalog · Dartmouth College Mission Statement · Organization of Dartmouth College 2022-23 ...
Read more >
Smart Catalog - NMSU Training Central
Hello. Thank you for joining me for this tutorial on the Smart Catalog system. This demonstrated tutorial will guide users in the navigation...
Read more >
Smart Courses Documentation - Creativas Help Center
Smart Courses Documentation. Creativas. 22 subscribers. Smart Courses for Confluence - LMS ... Course catalog · Taking courses · Metrics and reporting.
Read more >
Get Smart
Get Smart Teaching Supplies located in south Florida selling thousands of educational items and toys and gifts for children of all ages!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found