Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
570 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Big Query Client" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from cartoframes.auth import Credentials, set_default_credentials\n", | ||
"credentials = Credentials.from_file()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from cartoframes.data.clients.bigquery_client import BigQueryClient\n", | ||
"client = BigQueryClient('carto-do-customers', credentials)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"project = 'carto-do-customers'\n", | ||
"dataset = credentials.username.replace('-', '_')\n", | ||
"table = 'view_mastercard_financial_mrli_usa_block_2019_monthly_2019'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"client.download_to_file(project, dataset, table)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Catalog" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"id carto-do.bbva.financial_origindistributionages...\n", | ||
"name Destination Distribution Ages Genders\n", | ||
"description None\n", | ||
"provider_id bbva\n", | ||
"category_id financial\n", | ||
"data_source_id origindistributionagesgenders\n", | ||
"country_iso_code3 spain\n", | ||
"language_iso_code3 None\n", | ||
"geography_id carto-do.bbva.geography_spain_censustracts_2011\n", | ||
"temporal_aggregation monthly\n", | ||
"time_coverage None\n", | ||
"update_frequency None\n", | ||
"version 2017\n", | ||
"is_public_data None\n", | ||
"summary_jsonb None\n", | ||
"dtype: object" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from cartoframes.data.observatory.catalog import Catalog\n", | ||
"dataset = Catalog().categories.get('financial').datasets.get('carto-do.bbva.financial_origindistributionagesgenders_spain_censustracts_2011_monthly_2017')\n", | ||
"dataset.to_series()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from cartoframes.auth import Credentials, set_default_credentials\n", | ||
"credentials = Credentials.from_file()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dataset.download(credentials)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"id carto-do.bbva.geography_spain_censustracts_2011\n", | ||
"name Spain Census tracts\n", | ||
"description None\n", | ||
"provider_id bbva\n", | ||
"country_iso_code3 spain\n", | ||
"language_iso_code3 None\n", | ||
"geom_coverage None\n", | ||
"update_frequency None\n", | ||
"version 2011\n", | ||
"is_public_data None\n", | ||
"summary_jsonb None\n", | ||
"dtype: object" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from cartoframes.data.observatory.geography import Geography\n", | ||
"geography = Geography.get(dataset.geography)\n", | ||
"geography.to_series()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/home/simon/dev/cartoframes/env/src/carto/carto/resources.py:90: FutureWarning: This is part of a non-public CARTO API and may change in the future. Take this into account if you are using this in a production environment\n", | ||
" warnings.warn('This is part of a non-public CARTO API and may change in the future. Take this into account if you are using this in a production environment', FutureWarning)\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "988381ccb2a145008c0ae58b21d98427", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=35960), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/home/simon/dev/cartoframes/cartoframes/data/observatory/geography.py:79: UserWarning: Data saved: /home/simon/.config/cartoframes/carto-do-customers.simon_carto.view_bbva_geography_spain_censustracts_2011.csv.\n", | ||
" warn('Data saved: {}.'.format(file_path))\n", | ||
"/home/simon/dev/cartoframes/cartoframes/data/observatory/geography.py:80: UserWarning: Read it by: `pandas.read_csv('/home/simon/.config/cartoframes/carto-do-customers.simon_carto.view_bbva_geography_spain_censustracts_2011.csv')`.\n", | ||
" warn(\"Read it by: `pandas.read_csv('{}')`.\".format(file_path))\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'/home/simon/.config/cartoframes/carto-do-customers.simon_carto.view_bbva_geography_spain_censustracts_2011.csv'" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"geography.download(credentials)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dataset_no_permissions = Catalog().categories.get('financial').datasets.get('carto-do.mastercard.financial_mrli_usa_zipcode_2019_monthly_2019')\n", | ||
"dataset_no_permissions.download(credentials)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.