Last active
July 15, 2025 20:42
-
-
Save deepyaman/141b393a067a02fc0b1d5cba0a59a16d to your computer and use it in GitHub Desktop.
Visualize catfact data with catfact
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://dlthub.com/docs/general-usage/http/overview | |
| import dlt | |
| from dlt.sources.helpers.rest_client import RESTClient | |
| catfact_client = RESTClient(base_url="https://catfact.ninja") | |
| @dlt.resource | |
| def get_breeds(): | |
| for page in catfact_client.paginate( | |
| "/breeds", | |
| params={ | |
| "per_page": 100, | |
| }, | |
| ): | |
| yield page | |
| pipeline = dlt.pipeline( | |
| pipeline_name="catfact_breeds", | |
| destination="duckdb", | |
| dataset_name="catfact_data", | |
| ) | |
| load_info = pipeline.run(get_breeds) | |
| print(load_info) | |
| # https://dlthub.com/docs/general-usage/dataset-access/dataset | |
| dataset = pipeline.dataset() | |
| breeds_relation = dataset["get_breeds"] | |
| # https://github.com/machow/catfact | |
| import catfact as fct | |
| import polars as pl | |
| from plotnine import ggplot, aes, geom_bar, coord_flip | |
| ( | |
| pl.from_arrow(breeds_relation.arrow()) | |
| .with_columns( | |
| fct.infreq(pl.col("origin")) | |
| ) | |
| >> ggplot(aes("origin")) | |
| + geom_bar() | |
| + coord_flip() | |
| ).show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| catfact | |
| dlt[duckdb] | |
| ibis-framework[duckdb] | |
| plotnine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
