From 49bd3a94e44d52960b8b6e93bb981e728a32fc0a Mon Sep 17 00:00:00 2001 From: "thomas.grandjean" Date: Tue, 25 Jul 2023 12:11:15 +0200 Subject: [PATCH] Remove pynsee_print_url from env --- pynsee/localdata/Untitled.ipynb | 580 -------------------------------- pynsee/utils/_request_insee.py | 9 +- 2 files changed, 2 insertions(+), 587 deletions(-) delete mode 100644 pynsee/localdata/Untitled.ipynb diff --git a/pynsee/localdata/Untitled.ipynb b/pynsee/localdata/Untitled.ipynb deleted file mode 100644 index 1534fa9b..00000000 --- a/pynsee/localdata/Untitled.ipynb +++ /dev/null @@ -1,580 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "39d1624b-597d-4f77-83ef-0956010e2dc0", - "metadata": {}, - "outputs": [], - "source": [ - "from pynsee import *" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "54a6736a-3829-45e3-ab9f-bf7de5268b39", - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "from pynsee.localdata._get_insee_local_onegeo import _get_insee_local_onegeo" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "c1d6667f-ed91-4269-a584-bde052c59fec", - "metadata": {}, - "outputs": [], - "source": [ - "pop = get_local_data(dataset_version='POPLEGlatest',\n", - " variables = 'IND_POPLEGALES',\n", - " nivgeo = 'COM',\n", - " geocodes = ['75056', '13055'])" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "30457829-b242-4a1f-b1e2-e7df6ae0e752", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
CODEGEONIVGEOUNITUNIT_label_frIND_POPLEGALESOBS_VALUEIND_POPLEGALES_labelDATASET_VERSIONDATASET_NAMEDATA_DATEGEO_DATECODEGEO_label
075056COMPOPMUNPopulation municipale12145906La modalité uniquePOPLEG2020Populations légales20202022Paris
175056COMPOPCAPPopulation comptée à part116692La modalité uniquePOPLEG2020Populations légales20202022Paris
\n", - "
" - ], - "text/plain": [ - " CODEGEO NIVGEO UNIT UNIT_label_fr IND_POPLEGALES OBS_VALUE \\\n", - "0 75056 COM POPMUN Population municipale 1 2145906 \n", - "1 75056 COM POPCAP Population comptée à part 1 16692 \n", - "\n", - " IND_POPLEGALES_label DATASET_VERSION DATASET_NAME DATA_DATE \\\n", - "0 La modalité unique POPLEG2020 Populations légales 2020 \n", - "1 La modalité unique POPLEG2020 Populations légales 2020 \n", - "\n", - " GEO_DATE CODEGEO_label \n", - "0 2022 Paris \n", - "1 2022 Paris " - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop[:2]" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "07327bf1-8164-44c6-bba4-d9ac3cfa9608", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "os.environ[\"pynsee_print_url\"] = 'True'" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "9781ea39-d0d6-4b06-bd44-540c85390ea0", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Getting data: 0%| | 0/2 [00:00\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
CODEGEONIVGEOUNITUNIT_label_frINDICS_FILO_DISP_DETOBS_VALUEINDICS_FILO_DISP_DET_labelDATASET_VERSIONDATASET_NAMEDATA_DATEGEO_DATECODEGEO_label
075056COMD1Premier décile110820.0La modalité uniqueGEO2021FILO2018Fichier localisé social et fiscal20182021Paris
175056COMD9Neuvième décile168990.0La modalité uniqueGEO2021FILO2018Fichier localisé social et fiscal20182021Paris
275056COMRDRapport interdécile (sans unité)16.4La modalité uniqueGEO2021FILO2018Fichier localisé social et fiscal20182021Paris
\n", - "" - ], - "text/plain": [ - " CODEGEO NIVGEO UNIT UNIT_label_fr INDICS_FILO_DISP_DET \\\n", - "0 75056 COM D1 Premier décile 1 \n", - "1 75056 COM D9 Neuvième décile 1 \n", - "2 75056 COM RD Rapport interdécile (sans unité) 1 \n", - "\n", - " OBS_VALUE INDICS_FILO_DISP_DET_label DATASET_VERSION \\\n", - "0 10820.0 La modalité unique GEO2021FILO2018 \n", - "1 68990.0 La modalité unique GEO2021FILO2018 \n", - "2 6.4 La modalité unique GEO2021FILO2018 \n", - "\n", - " DATASET_NAME DATA_DATE GEO_DATE CODEGEO_label \n", - "0 Fichier localisé social et fiscal 2018 2021 Paris \n", - "1 Fichier localisé social et fiscal 2018 2021 Paris \n", - "2 Fichier localisé social et fiscal 2018 2021 Paris " - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df = get_local_data(dataset_version='GEO2021FILO2018',\n", - " variables = 'INDICS_FILO_DISP_DET',\n", - " nivgeo = 'COM',\n", - " update=True,\n", - " geocodes = ['75056', '13055'])\n", - "df[:3]" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "0cf3129a-c6c4-4d27-96e8-66148d9eb03f", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Finding Latest Dataset Version: 27%|██▋ | 27/100 [00:03<00:09, 7.44it/s]API query number limit reached - function might be slowed down\n", - "Finding Latest Dataset Version: 99%|█████████▉| 99/100 [03:17<00:01, 1.99s/it]\n" - ] - }, - { - "ename": "ValueError", - "evalue": "!!! Latest dataset version not found !!!\nPlease, consider having a look at api.insee.fr or get_local_metadata function", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mRequestException\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m/opt/mamba/lib/python3.10/site-packages/pynsee/localdata/_find_latest_local_dataset.py:48\u001b[0m, in \u001b[0;36m_find_latest_local_dataset\u001b[0;34m(dataset_version, variables, nivgeo, codegeo, update)\u001b[0m\n\u001b[1;32m 47\u001b[0m sys\u001b[38;5;241m.\u001b[39mstdout \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mopen\u001b[39m(os\u001b[38;5;241m.\u001b[39mdevnull, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m---> 48\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43m_get_insee_local_onegeo\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 49\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdv\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnivgeo\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnivgeo\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcodegeo\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcodegeo\u001b[49m\n\u001b[1;32m 50\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m \n\u001b[1;32m 51\u001b[0m sys\u001b[38;5;241m.\u001b[39mstdout \u001b[38;5;241m=\u001b[39m sys\u001b[38;5;241m.\u001b[39m__stdout__\n", - "File \u001b[0;32m/opt/mamba/lib/python3.10/site-packages/pynsee/localdata/_get_insee_local_onegeo.py:22\u001b[0m, in \u001b[0;36m_get_insee_local_onegeo\u001b[0;34m(variables, dataset_version, nivgeo, codegeo)\u001b[0m\n\u001b[1;32m 18\u001b[0m link \u001b[38;5;241m=\u001b[39m link \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgeo-\u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m@\u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m/\u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m-\u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(\n\u001b[1;32m 19\u001b[0m variables, dataset_version, nivgeo, codegeo, modalite\n\u001b[1;32m 20\u001b[0m )\n\u001b[0;32m---> 22\u001b[0m request \u001b[38;5;241m=\u001b[39m \u001b[43m_request_insee\u001b[49m\u001b[43m(\u001b[49m\u001b[43mapi_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mlink\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfile_format\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mapplication/json;charset=utf-8\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 24\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n", - "File \u001b[0;32m/opt/mamba/lib/python3.10/site-packages/pynsee/utils/_request_insee.py:119\u001b[0m, in \u001b[0;36m_request_insee\u001b[0;34m(api_url, sdmx_url, file_format, print_msg)\u001b[0m\n\u001b[1;32m 118\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mError \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcode\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m - \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mCODES[code]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mQuery:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mapi_url\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m--> 119\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m requests\u001b[38;5;241m.\u001b[39mexceptions\u001b[38;5;241m.\u001b[39mRequestException(msg)\n\u001b[1;32m 120\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m code \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m200\u001b[39m:\n", - "\u001b[0;31mRequestException\u001b[0m: Error 404 - Not Found : no results available\nQuery:\nhttps://api.insee.fr/donnees-locales/V0.1/donnees/geo-INDICS_FILO_DISP@GEO2014FILO2014/COM-75056.all", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[7], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mget_local_data\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdataset_version\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mGEOlatestFILOlatest\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mINDICS_FILO_DISP\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mnivgeo\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mCOM\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43mupdate\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[43mgeocodes\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m75056\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m13055\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 6\u001b[0m df[:\u001b[38;5;241m3\u001b[39m]\n", - "File \u001b[0;32m/opt/mamba/lib/python3.10/site-packages/pynsee/localdata/get_local_data.py:109\u001b[0m, in \u001b[0;36mget_local_data\u001b[0;34m(variables, dataset_version, nivgeo, geocodes, update)\u001b[0m\n\u001b[1;32m 105\u001b[0m pattern \u001b[38;5;241m=\u001b[39m re\u001b[38;5;241m.\u001b[39mcompile(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.*latest$\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 107\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m pattern\u001b[38;5;241m.\u001b[39mmatch(dataset_version):\n\u001b[0;32m--> 109\u001b[0m dataset_version \u001b[38;5;241m=\u001b[39m \u001b[43m_find_latest_local_dataset\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdataset_version\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnivgeo\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mgeocodes\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mupdate\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 111\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\u001b[38;5;129;01mnot\u001b[39;00m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mexists(file_localdata)) \u001b[38;5;129;01mor\u001b[39;00m update:\n\u001b[1;32m 113\u001b[0m list_data_all \u001b[38;5;241m=\u001b[39m [] \n", - "File \u001b[0;32m/opt/mamba/lib/python3.10/site-packages/pynsee/localdata/_find_latest_local_dataset.py:60\u001b[0m, in \u001b[0;36m_find_latest_local_dataset\u001b[0;34m(dataset_version, variables, nivgeo, codegeo, update)\u001b[0m\n\u001b[1;32m 58\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m!!! Latest dataset version not found !!!\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 59\u001b[0m msg \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mPlease, consider having a look at api.insee.fr or get_local_metadata function\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m---> 60\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg)\n\u001b[1;32m 61\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 62\u001b[0m dataset_version \u001b[38;5;241m=\u001b[39m dv\n", - "\u001b[0;31mValueError\u001b[0m: !!! Latest dataset version not found !!!\nPlease, consider having a look at api.insee.fr or get_local_metadata function" - ] - } - ], - "source": [ - "df = get_local_data(dataset_version='GEOlatestFILOlatest',\n", - " variables = 'INDICS_FILO_DISP',\n", - " nivgeo = 'COM',\n", - " update=True,\n", - " geocodes = ['75056', '13055'])\n", - "df[:3]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8e20fab7-933c-47a2-9a42-ccf2c0844d24", - "metadata": {}, - "outputs": [], - "source": [ - "from pynsee.localdata._get_insee_local_onegeo import _get_insee_local_onegeo\n", - "\n", - "df = _get_insee_local_onegeo(\n", - " 'INDICS_FILO_DISP', 'GEO2023FILO2020', nivgeo='COM', codegeo='75056'\n", - " ) \n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ddac4d01-aaf1-4df6-895e-d4612abe8e45", - "metadata": {}, - "outputs": [], - "source": [ - "df = get_local_data(dataset_version='GEO2023FILO2020',\n", - " variables = 'INDICS_FILO_DISP',\n", - " nivgeo = 'COM',\n", - " update=True,\n", - " geocodes = ['75056', '13055'])\n", - "df[:3]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c984f430-c3c5-4e8f-b298-71c5967a2ee2", - "metadata": {}, - "outputs": [], - "source": [ - "import re\n", - "import datetime\n", - "from tqdm import trange\n", - "import sys\n", - "\n", - "dataset_version='GEOlatestFILOlatest'\n", - "nivgeo = 'COM'\n", - "codegeo='75056'\n", - "variables= 'INDICS_FILO_DISP'\n", - "datasetname = dataset_version.replace('latest', '').replace('GEO', '')\n", - "\n", - "current_year = int(datetime.datetime.today().strftime('%Y')) \n", - "backwardperiod = 7\n", - "list_geo_dates = range(current_year, current_year-backwardperiod, -1) \n", - "list_data_dates = range(current_year, current_year-backwardperiod, -1)\n", - "\n", - "if re.compile('^GEOlatest.*latest$').match(dataset_version):\n", - "\n", - " list_dataset_version = ['GEO' + str(gdate) + datasetname + str(ddate)\n", - " for gdate in list_geo_dates\n", - " for ddate in list_data_dates]\n", - "else:\n", - " list_dataset_version = [datasetname + str(ddate) for ddate in list_data_dates]\n", - "\n", - "\n", - "list_dataset_version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "04ad35ec-fa09-4932-b1cf-050185568b8e", - "metadata": {}, - "outputs": [], - "source": [ - "df = _get_insee_local_onegeo(\n", - " 'INDICS_FILO_DISP', 'GEO2023FILO2020', nivgeo=nivgeo, codegeo=codegeo\n", - " ) " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "940966d3-75ef-47d0-9fe4-d681511cb6fe", - "metadata": {}, - "outputs": [], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "45ecb97d-b441-44a1-9b31-e079ccd7167f", - "metadata": {}, - "outputs": [], - "source": [ - "import pandas as pd\n", - "import numpy as np\n", - "pd.DataFrame({\"CODEGEO\": codegeo, \"OBS_VALUE\": None}, index=[0]) == df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e8e9972a-0ad4-45ed-bcc0-7f23058bab2d", - "metadata": {}, - "outputs": [], - "source": [ - "None == None" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "dc369dca-6721-48f9-bc74-0a53e1af0869", - "metadata": {}, - "outputs": [], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e8bcd76c-74d3-47ff-a717-d7c7867ec0ab", - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "for dvindex in trange(len(list_dataset_version),\n", - " desc='Finding Latest Dataset Version'):\n", - "\n", - " dv = list_dataset_version[dvindex]\n", - " try:\n", - " sys.stdout = open(os.devnull, 'w')\n", - " df = _get_insee_local_onegeo(\n", - " variables, dv, nivgeo=nivgeo, codegeo=codegeo\n", - " ) \n", - " sys.stdout = sys.__stdout__\n", - " except: \n", - " pass\n", - " else:\n", - " display(dv)\n", - " break" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "12fff72f-4f59-45b7-b9d5-35ad7b21a145", - "metadata": {}, - "outputs": [], - "source": [ - "dv" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b1f6a9cd-644e-4a3a-9017-25431c64c1db", - "metadata": {}, - "outputs": [], - "source": [ - "from pynsee.localdata._get_insee_local_onegeo import _get_insee_local_onegeo\n", - "\n", - "dataset_version='GEO2021FILO2018'\n", - "\n", - "df = _get_insee_local_onegeo(\n", - " variables='INDICS_FILO_DISP',\n", - " dataset_version = dataset_version, \n", - " nivgeo='COM',\n", - " codegeo='75056'\n", - " )\n", - "df[:3]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e8b3a352-d802-431e-a442-e1436d1a9f9a", - "metadata": {}, - "outputs": [], - "source": [ - "df = get_local_data(dataset_version='GEOlatestRPlatest',\n", - " variables = 'STOCD',\n", - " nivgeo = 'COM',\n", - " update=True,\n", - " geocodes = ['75056', '13055'])\n", - "df[:3]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ad044fbc-eb98-4e97-9a44-68892ede36e8", - "metadata": {}, - "outputs": [], - "source": [ - "meta = get_local_metadata()\n", - "meta.drop_duplicates(subset='DATASET')\n", - "meta[meta.DATASET.str.contains('FILO')][:10]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "65a15de6-0c43-4299-9878-8a68ce2d7d91", - "metadata": {}, - "outputs": [], - "source": [ - "meta['DATASET_VERSION'].unique()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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.10.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/pynsee/utils/_request_insee.py b/pynsee/utils/_request_insee.py index a16cf554..ba1f163c 100644 --- a/pynsee/utils/_request_insee.py +++ b/pynsee/utils/_request_insee.py @@ -49,15 +49,10 @@ def _request_insee( proxies = { "http": os.environ.get("http_proxy", pynsee._config["http_proxy"]), - "https": os.environ.get("https_proxy", pynsee._config["https_proxy"]) + "https": os.environ.get("https_proxy", pynsee._config["https_proxy"]), } - try: - print_url = os.environ["pynsee_print_url"] - if print_url == "True": - print(api_url) - except Exception: - pass + logger.debug(api_url) # force sdmx use with a system variable try: