<commit_before>{"cells":[{"cell_type":"markdown","metadata":{},"source":["# Publishing and sharing visualizations\n","\n","We're going to get through how to publish a visualization by getting the final URL to share it. For that purpose, we'll need to use the \"CARTO custom visualizations\", as known as **Kuviz**.\n","\n","Let's start by creating a default credentials."]},{"cell_type":"markdown","metadata":{},"source":["# Set the Credentials"]},{"cell_type":"markdown","metadata":{},"source":["You will need to use your `master API key` in the notebook in order to create a visualization, but it is not going to used in your visualization and your `mater API key` will not be shared:\n","- The visualizations use `default public API key` when possible (if you use public datasets from your CARTO account). \n","- If it is not possible, a `regular API key` is created with read only permissions of your data used in the map. \n","\n","You can get more info about API keys at https://carto.com/developers/auth-api/guides/types-of-API-Keys/"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.auth import Credentials, set_default_credentials\n\nset_default_credentials(Credentials.from_file())"},{"cell_type":"markdown","metadata":{},"source":["# Publish"]},{"cell_type":"markdown","metadata":{},"source":["### Case 1: public dataset from your CARTO account"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer\n\npublic_data_map = Map(Layer('')) # -> Set here a public table name from your account"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"public_data_map.publish('public_data_map')"},{"cell_type":"markdown","metadata":{},"source":"As you are using a public table from your account, the `publish` method uses `default public API key`."},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"public_data_map.publish('public_data_map_with_password', password=\"<PASSWORD>\")"},{"cell_type":"markdown","metadata":{},"source":["### Case 2: private dataset from your CARTO account"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"private_data_map = Map(Layer('')) # -> Set here a private table name from your account"},{"cell_type":"markdown","metadata":{},"source":["In this case, a `regular API key` has been created with read only permissions of your private table"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"private_data_map.publish('private_data_map')"},{"cell_type":"markdown","metadata":{},"source":["### Case 3: local data"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer\nfrom cartoframes.data import Dataset\n\n# getting a DataFrame from a table for the example\n# but you can try it with the DataFrame you wish \nds = Dataset('rings') # -> Set here a table name from your account\ndf = ds.download()\n\n# create the map with your DataFrame\nds = Dataset(df)\nlocal_data_map = Map(Layer(ds))"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"local_data_map.publish('local_data_map')"},{"cell_type":"markdown","metadata":{},"source":["In this case, a table has been created in your CARTO account and a `regular API key` with read only permissions of the table"]},{"cell_type":"markdown","metadata":{},"source":["# Publish with password"]},{"cell_type":"markdown","metadata":{},"source":["In any of the previous cases, you could create the shared visualization with a password. You only need to add a `password` parameter in the publish method"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer\n\npublic_data_map = Map(Layer('')) # -> Set here a public table name from your account"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"public_data_map.publish('public_data_map_with_password', password=\"<PASSWORD>\")"},{"cell_type":"markdown","metadata":{},"source":["# Updating a Kuviz"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer\n\ntmap = Map(Layer('public_table_name'))\ntmap.publish('cf_publish_update_1')"},{"cell_type":"markdown","metadata":{},"source":["Changing name"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"tmap.update_publication('cf_publish_case_2_password', password=None)"},{"cell_type":"markdown","metadata":{},"source":["Adding password"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"tmap.update_publication('cf_publish_case_2_password', password=\"<PASSWORD>\")"},{"cell_type":"markdown","metadata":{},"source":["Removing password"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"tmap.update_publication('cf_publish_update_4', password=None)"},{"cell_type":"markdown","metadata":{},"source":["# Delete a Kuviz"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer, basemaps\n\ntmap = Map(Layer('')) # -> Set here a public table name from your account\ntmap.publish('cf_publish_delete_1')"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"tmap.delete_publication()"},{"cell_type":"markdown","metadata":{},"source":["# Get all the visualizations"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map\nMap.all_publications()"}],"nbformat":4,"nbformat_minor":2,"metadata":{"language_info":{"name":"python","codemirror_mode":{"name":"ipython","version":3}},"orig_nbformat":2,"file_extension":".py","mimetype":"text/x-python","name":"python","npconvert_exporter":"python","pygments_lexer":"ipython3","version":3}}<commit_msg>Improve message 2<commit_after>{"cells":[{"cell_type":"markdown","metadata":{},"source":["# Publishing and sharing visualizations\n","\n","We're going to get through how to publish a visualization by getting the final URL to share it. For that purpose, we'll need to use the \"CARTO custom visualizations\", also known as **Kuviz**.\n","\n","Let's start by creating a default credentials."]},{"cell_type":"markdown","metadata":{},"source":["# Set the Credentials"]},{"cell_type":"markdown","metadata":{},"source":["You will need to use your `master API key` in the notebook in order to create a visualization, but it is not going to be used in your visualization and your `master API key` will not be shared:\n","- The visualizations use `default public API key` when possible (if you use public datasets from your CARTO account). \n","- If it is not possible, a `regular API key` is created with read only permissions of your data used in the map. \n","\n","You can get more info about API keys at https://carto.com/developers/auth-api/guides/types-of-API-Keys/"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.auth import Credentials, set_default_credentials\n\nset_default_credentials(Credentials.from_file())"},{"cell_type":"markdown","metadata":{},"source":["# Publish"]},{"cell_type":"markdown","metadata":{},"source":["### Case 1: public dataset from your CARTO account"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer\n\npublic_data_map = Map(Layer('')) # -> Set here a public table name from your account"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"public_data_map.publish('public_data_map')"},{"cell_type":"markdown","metadata":{},"source":"As you are using a public table from your account, the `publish` method uses `default public API key`."},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"public_data_map.publish('public_data_map_with_password', password=\"<PASSWORD>\")"},{"cell_type":"markdown","metadata":{},"source":["### Case 2: private dataset from your CARTO account"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"private_data_map = Map(Layer('')) # -> Set here a private table name from your account"},{"cell_type":"markdown","metadata":{},"source":["In this case, a `regular API key` has been created with read only permissions of your private table"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"private_data_map.publish('private_data_map')"},{"cell_type":"markdown","metadata":{},"source":["### Case 3: local data"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer\nfrom cartoframes.data import Dataset\n\n# getting a DataFrame from a table for the example\n# but you can try it with the DataFrame you wish \nds = Dataset('rings') # -> Set here a table name from your account\ndf = ds.download()\n\n# create the map with your DataFrame\nds = Dataset(df)\nlocal_data_map = Map(Layer(ds))"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"local_data_map.publish('local_data_map')"},{"cell_type":"markdown","metadata":{},"source":["In this case, a table has been created in your CARTO account and a `regular API key` with read only permissions of the table"]},{"cell_type":"markdown","metadata":{},"source":["# Publish with password"]},{"cell_type":"markdown","metadata":{},"source":["In any of the previous cases, you could create the shared visualization with a password. You only need to add a `password` parameter in the publish method"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer\n\npublic_data_map = Map(Layer('')) # -> Set here a public table name from your account"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"public_data_map.publish('public_data_map_with_password', password=\"<PASSWORD>\")"},{"cell_type":"markdown","metadata":{},"source":["# Updating a Kuviz"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer\n\ntmap = Map(Layer('public_table_name'))\ntmap.publish('cf_publish_update_1')"},{"cell_type":"markdown","metadata":{},"source":["Changing name"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"tmap.update_publication('cf_publish_case_2_password', password=None)"},{"cell_type":"markdown","metadata":{},"source":["Adding password"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"tmap.update_publication('cf_publish_case_2_password', password=\"<PASSWORD>\")"},{"cell_type":"markdown","metadata":{},"source":["Removing password"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"tmap.update_publication('cf_publish_update_4', password=None)"},{"cell_type":"markdown","metadata":{},"source":["# Delete a Kuviz"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map, Layer, basemaps\n\ntmap = Map(Layer('')) # -> Set here a public table name from your account\ntmap.publish('cf_publish_delete_1')"},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"tmap.delete_publication()"},{"cell_type":"markdown","metadata":{},"source":["# Get all the visualizations"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":"from cartoframes.viz import Map\nMap.all_publications()"}],"nbformat":4,"nbformat_minor":2,"metadata":{"language_info":{"name":"python","codemirror_mode":{"name":"ipython","version":3}},"orig_nbformat":2,"file_extension":".py","mimetype":"text/x-python","name":"python","npconvert_exporter":"python","pygments_lexer":"ipython3","version":3}}
{'fraction_non_alphanumeric': 0.21869754951325948, 'fraction_numerical': 0.002433702584759987, 'mean_word_length': 11.465481171548117, 'pattern_counts': {'":': 310, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2404062', 'n_tokens_mistral': 3532, 'n_tokens_neox': 3383, 'n_words': 738}