Get data

Get macroeconomic data

pynsee.macrodata.get_series(*idbanks, update=False, silent=False, metadata=True, startPeriod=None, endPeriod=None, firstNObservations=None, lastNObservations=None, updatedAfter=None)

Get data from INSEE series idbank

Parameters:
  • idbanks (str or list or pd.series) – some idbanks provided by get_idbank_list()

  • update (bool, optional) – Set to True, to update manually the data

  • False. (stored locally on the computer. Defaults to)

  • silent (bool, optional) – Set to True, to disable messages printed in log info

  • metadata (bool, optional) – If True, some metadata is added to the data

  • startPeriod (str, optional) – start date of the data.

  • endPeriod (str, optional) – end date of the data.

  • firstNObservations (int, optional) – get the first N observations for each key series (idbank).

  • lastNObservations (int, optional) – get the last N observations for each key series (idbank).

  • updatedAfter (str, optional) – starting point for querying the previous releases (format yyyy-mm-ddThh:mm:ss)

Returns:

DataFrame – contains the data, indexed by DATE and sorted by IDBANK

Examples

>>> from pynsee.macrodata import get_series_list, get_series
>>> # inflation figures in France
>>> df_idbank = get_series_list("IPC-2015")
>>> df_idbank = df_idbank.loc[
>>>                    (df_idbank.FREQ == "M") & # monthly
>>>                    (df_idbank.NATURE == "INDICE") & # index
>>>                    (df_idbank.MENAGES_IPC == "ENSEMBLE") & # all kinds of household
>>>                    (df_idbank.REF_AREA == "FE") & # all France including overseas departements
>>>                    (df_idbank.COICOP2016.str.match("^[0-9]{2}$"))] # coicop aggregation level
>>> # get data
>>> data = get_series(df_idbank.IDBANK)
pynsee.macrodata.get_dataset(dataset, update=False, silent=False, metadata=True, filter=None, startPeriod=None, endPeriod=None, firstNObservations=None, lastNObservations=None, updatedAfter=None)

Get dataset’s data from INSEE BDM database

Parameters:
  • dataset (str) – an INSEE dataset included in the list provided by get_dataset_list()

  • update (bool, optional) – Set to True, to update manually the data stored locally on the computer. Defaults to False.

  • silent (bool, optional) – Set to True, to disable messages printed in log info

  • metadata (bool, optional) – If True, some metadata is added to the data

  • filter (str, optional) – Use the filter to choose only some values in a dimension.

  • means (It is recommended to use it for big datasets. A dimension left empty)

  • values. (all values are selected. To select multiple values in one dimension put a "+" between those)

  • startPeriod (str, optional) – start date of the data.

  • endPeriod (str, optional) – end date of the data.

  • firstNObservations (int, optional) – get the first N observations for each key series (idbank).

  • lastNObservations (int, optional) – get the last N observations for each key series (idbank).

  • updatedAfter (str, optional) – starting point for querying the previous releases (format yyyy-mm-ddThh:mm:ss)

Raises:

ValueError – dataset should be in INSEE’s datasets list

Returns:

DataFrame – contains the data

Examples

>>> from pynsee.macrodata import get_dataset
>>> ipc_data = get_dataset("IPC-2015",
>>>        filter = "M......ENSEMBLE...CVS.2015",
>>>        updatedAfter = "2017-07-11T08:45:00")
>>> #
>>> business_climate = get_dataset("CLIMAT-AFFAIRES", lastNObservations = 1)
pynsee.macrodata.get_series_title(series)

Get French and English titles of a list of series (idbanks)

Parameters:

series (list) – a list of series (idbanks)

Examples

>>> from pynsee import get_series_list, get_series_title
>>> series = get_series_list("CLIMAT-AFFAIRES")
>>> series = series.loc[:3, "IDBANK"].to_list()
>>> titles = get_series_title(series)

Get and analyze geographical data

pynsee.geodata.get_geodata(dataset_id: str, update: bool = False, crs: Any = 'EPSG:3857', constrain_area: GeoDataFrame | None = None, silent: bool = False) → GeoFrDataFrame

Get geographical data with identifier and from IGN API

Parameters:
  • id (str) – data identifier from get_geodata_list function

  • update (bool, optional) – data is saved locally, set update=True to trigger an update. Defaults to False.

  • crs (any valid CRS input, optional) – CRS used for the geodata output. Defaults to ‘EPSG:3857’.

  • constrain_area (GeoDataFrame, optional) – GeoDataFrame used to constrain the area of interest. Defaults to None.

  • silence (bool, optional) – whether to print warnings or not. Defaults to False.

Examples

>>> from pynsee.geodata import get_geodata_list, get_geodata
>>> #
>>> # Get a list of geographical limits of French administrative areas from IGN API
>>> geodata_list = get_geodata_list()
>>> #
>>> # Get geographical limits of departments
>>> df = get_geodata('ADMINEXPRESS-COG-CARTO.LATEST:departement')
class pynsee.geodata.geofrdataframe.GeoFrDataFrame(*args, **kwargs)

Class for handling GeoDataFrames built from IGN’s geographical data. It inherits from GeoDataFrame.

get_geom()

Return the combination of all geometries in the GeoFrDataFrame.

Deprecated since version 0.2.0: Use geometry instead and call union_all() on it. See also the documentation of geopandas.

Example

>>> geo = gdf.geometry.union_all()
transform_overseas(*args, **kwargs) → GeoFrDataFrame

Apply translation and zoom to oversea territories.

See: pynsee.geodata.transform_overseas().

translate(*args, **kwargs) → GeoSeries | GeoFrDataFrame

This function is a deprecated alias of transform_overseas(). It will try to guess whether you want to run transform_overseas or the real GeoDataFrame.translate() depending on the arguments that were passed. If no arguments are passed, it will run transform_overseas.

Warning

Starting with pynsee >= 0.3.0, this function will only run GeoSeries.translate(). Do switch to transform_overseas() if this is what you wanted to run.

zoom(*args, **kwargs) → GeoFrDataFrame

Zoom for parisian departments.

See: pynsee.geodata.zoom().

pynsee.geodata.transform_overseas(gdf: GeoDataFrame, departement: tuple[str, ...] = ('971', '972', '974', '973', '976', 'NR'), factor: tuple[float | None, ...] = (None, None, None, 0.35, None, None), center: tuple[float, float] = (-133583.39, 5971815.98), radius: float = 650000, angle: float = 0.3490658503988659, startAngle: float = 2.443460952792061) → GeoDataFrame

Move overseas departements closer to metropolitan France

Parameters:
  • departement (tuple, optional) – list of departements to be moved, overseas departement list is used by default

  • factor (tuple, optional) – make departements bigger or smaller, it should correspond to the departement list.

  • function (This parameter is used by shapely.affinity.scale)

  • value. (please refer to its documentation to choose the)

  • default (By)

  • None (only Guyane's size is reduced. If the value is)

  • performed. (no rescaling is)

  • center (tuple, optional) – center point from which offshore points are computed to move overseas departement

  • a (It should be defined as) – 3857

  • radius (float, optional) – radius used with center point to make offshore points, distance in meter

  • angle (float, optional) – angle used between offshore points, by default it is pi/9

  • startAngle (float, optional) – start angle defining offshore points, by default it is pi * (1 - 1.5 * 1/9))

Notes

by default translate method focuses on overseas departement, but it can be used to move any departement anywhere on the map

Examples

>>> from pynsee.geodata import get_geodata_list, get_geodata
>>> #
>>> # Get a list of geographical limits of French administrative areas from IGN API
>>> geodata_list = get_geodata_list()
>>> #
>>> # Get geographical limits of departments
>>> gdf = get_geodata('ADMINEXPRESS-COG-CARTO.LATEST:departement')
>>> #
>>> # Move overseas departements closer to metropolitan France
>>> dfTranslate = gdf.translate()
pynsee.geodata.zoom(gdf: GeoDataFrame, departement: tuple[str, ...] = ('75', '92', '93', '94'), center: tuple[float, float] = (-133583.39, 5971815.98), radius: float = 650000, startAngle: float = 1.9198621771937625, factor: float = 2) → GeoDataFrame

Zoom on parisian departements

Parameters:
  • departement (list, optional) – list of departements to be moved, departements closest to Paris are selected by default

  • center (tuple, optional) – center point from which an offshore point is computed to move Parisian departements

  • a (It should be defined as) – 3857

  • radius (float, optional) – radius used with center point to make offshore point, distance in meter

  • startAngle (float, optional) – start angle defining offshore point, by default it is pi * (1 - 2.5 * 1/9))

  • factor (float, optional) – make departements bigger or smaller.

  • function (This parameter is used by shapely.affinity.scale)

  • value. (please refer to its documentation to choose the)

Notes

by default zoom method focuses on the closest departements to Paris, but the function can be used to make a zoom on any departement anywhere on the map

Examples

>>> from pynsee.geodata import get_geodata_list, get_geodata
>>> #
>>> # Get a list of geographical limits of French administrative areas from IGN API
>>> geodata_list = get_geodata_list()
>>> #
>>> # Get geographical limits of departments
>>> df = get_geodata('ADMINEXPRESS-COG-CARTO.LATEST:departement')
>>> #
>>> # Zoom on parisian departements
>>> dfZoom = df.zoom()

Get local data

pynsee.localdata.get_local_data(variables, dataset_version, nivgeo='FE', geocodes=['1'], update=False, silent=False, backwardperiod=6)

Get INSEE local numeric data

Parameters:
  • variables (str) – one or several variables separated by an hyphen (see get_local_metadata)

  • dataset_version (str) – code of a dataset version (see get_local_metadata), if dates are replaced by ‘latest’ the function triggers a loop to find the latest data available (examples: ‘GEOlatestRPlatest’, ‘GEOlatestFLORESlatest’).

  • nivgeo (str) – code of kind of French administrative area (see get_nivgeo_list), by default it is ‘FE’ ie all France

  • geocodes (list) – code one specific area (see get_geo_list), by default it is [‘1’] ie all France

  • update (bool) – data is saved locally, set update=True to trigger an update

  • silent (bool, optional) – Set to True to disable messages printed in log info

  • backwardperiod (int, optional) – this arg is used only whenever the latest data is searched, it specifies the number of past years the loop should run through.

Raises:

ValueError – Error if geocodes is not a list

Examples

>>> from pynsee.localdata import get_local_metadata, get_nivgeo_list, get_geo_list, get_local_data
>>> metadata = get_local_metadata()
>>> nivgeo = get_nivgeo_list()
>>> departement = get_geo_list('departements')
>>> #
>>> data_all_france = get_local_data(dataset_version='GEO2020RP2017',
>>>                        variables =  'SEXE-DIPL_19')
>>> #
>>> data_91_92 = get_local_data(dataset_version='GEO2020RP2017',
>>>                        variables =  'SEXE-DIPL_19',
>>>                        nivgeo = 'DEP',
>>>                        geocodes = ['91','92'])
>>> #
>>> # get latest data for from RP (Recensement / Census) on socio-professional categories by sexe in Paris
>>> data_paris = get_local_data(dataset_version='GEOlatestRPlatest',
>>>                        variables =  'CS1_8-SEXE',
>>>                        nivgeo = 'COM',
>>>                        geocodes = '75056')
pynsee.localdata.get_population()

Get population data on all French communes (cities)

Examples

>>> from pynsee.localdata import get_population
>>> pop = get_population()
pynsee.localdata.get_old_city(code, date=None)

Get data about the old cities made from the new one

Notes

Local data is always provided with a cities classification which depends on a year. This classification evolves over time due to the merger of some cities. It is often useful to keep track of these mergers to reconcile some data.

Parameters:
  • code (str) – city code

  • date (str, optional) – date used to analyse the data, format : ‘AAAA-MM-JJ’. If date is None, by default it supposed to be the current year.

Examples

>>> from pynsee.localdata import get_old_city
>>> df = get_old_city(code = '24259')
pynsee.localdata.get_new_city(code, date=None)

Get data about the new city made from the old ones

Notes

Local data is always provided with a cities classification which depends on a year. This classification evolves over time due to the merger of some cities. It is often useful to keep track of these mergers to reconcile some data.

To get a city at a given date, use get_area_projection instead.

Parameters:
  • code (str) – city code

  • date (str, optional) – date used to analyse the data, format : ‘AAAA-MM-JJ’. If date is None, by default it supposed to be ten years before current year.

Examples

>>> from pynsee.localdata import get_next_city
>>> df = get_next_city(code = '24431', date = '2018-01-01')
pynsee.localdata.get_ascending_area(area: str, code: str, date: str = None, type: str = None, update: bool = False, silent: bool = False)

Get information about areas containing a given area

Parameters:
  • area (str) – case sensitive, area type, any of (‘arrondissement’, ‘arrondissementMunicipal’, ‘circonscriptionTerritoriale’, ‘commune’, ‘communeAssociee’, ‘communeDeleguee’, ‘departement’, ‘district’)

  • code (str) – area code

  • type (str) – case insensitive, any of ‘Arrondissement’, ‘Departement’, ‘Region’, ‘UniteUrbaine2020’, ‘ZoneDEmploi2020’, …

  • date (str, optional) – date used to analyse the data, format : ‘AAAA-MM-JJ’. If date is None, by default the current date is used.

  • update (bool) – locally saved data is used by default. Trigger an update with update=True.

  • silent (bool, optional) – Set to True to disable messages printed in log info

Examples

>>> from pynsee.localdata import get_ascending_area
>>> df = get_ascending_area("commune", code='59350', date='2018-01-01')
>>> df = get_ascending_area("departement", code='59')
pynsee.localdata.get_descending_area(area: str, code: str, date: str = None, type: str = None, update: bool = False, silent: bool = False)

Get information about areas contained in a given area

Parameters:
  • area (str) – case sensitive, area type, any of (‘aireDAttractionDesVilles2020’, ‘arrondissement’, ‘collectiviteDOutreMer’, ‘commune’, ‘departement’, ‘region’, ‘uniteUrbaine2020’, ‘zoneDEmploi2020’)

  • code (str) – area code

  • type (str) – case insensitive, any of ‘Arrondissement’, ‘Departement’, ‘Region’, ‘UniteUrbaine2020’, ‘ZoneDEmploi2020’, …

  • date (str, optional) – date used to analyse the data, format : ‘AAAA-MM-JJ’. If date is None, by default the current date is used/

  • update (bool) – locally saved data is used by default. Trigger an update with update=True.

  • silent (bool, optional) – Set to True to disable messages printed in log info

Examples

>>> from pynsee.localdata import get_area_descending
>>> df = get_descending_area("commune", code='59350', date='2018-01-01')
>>> df = get_descending_area("departement", code='59', date='2018-01-01')
>>> df = get_descending_area("zoneDEmploi2020", code='1109')

Get metadata

pynsee.metadata.get_definition(ids)

Get the definition of a concept from its identifier

Parameters:

ids (list) – a list of concept identifiers

Raises:

ValueError – an error is raised if ids is not a list

Examples

>>> from pynsee.metadata import get_definition_list, get_definition
>>> def_list = get_definition_list()
>>> # geographic areas definition
>>> geo_definitions = get_definition(['c1468', 'c1282', 'c1762',
>>>                       'c1501', 'c1346', 'c1502', 'c1912',
>>>                       'c1361', 'c2173', 'c2070'])
pynsee.metadata.get_legal_entity(codes, print_err_msg=True, update=False, silent=False)

Get legal entities labels

Parameters:
  • codes (list) – list of legal entities code of 2 or 4 characters

  • update (bool, optional) – Trigger an update, otherwise locally saved data is used. Defaults to False

  • silent (bool, optional) – Set to True, to disable messages printed in log info

Examples

>>> from pynsee.metadata import get_legal_entity
>>> legal_entity = get_legal_entity(codes = ['5599', '83'])

Get sirene data

pynsee.sirene.get_sirene_data(*id)

Get data about one or several companies from siren or siret identifiers

Notes

This function may return personal data, please check and comply with the legal framework relating to personal data protection

Examples

>>> from pynsee.sirene import get_sirene_data
>>> df = get_sirene_data("552081317", "32227167700021")
>>> df = get_sirene_data(['32227167700021', '26930124800077'])
pynsee.sirene.get_sirene_relatives(*siret)

Find parent or child entities for one siret entity (etablissement)

Parameters:

siret (str or list) – siret or list of siret codes

Raises:

ValueError – siret should be str or list

Returns:

pandas.DataFrame – dataframe containing the query content

Examples

>>> # find parent or child entities for one siret entity (etablissement)
>>> data = get_sirene_relatives('00555008200027')
>>> data = get_sirene_relatives(['39860733300059', '00555008200027'])
class pynsee.sirene.sirenedataframe.SireneDataFrame(*args, **kwargs)

Class for handling dataframes built from INSEE SIRENE API’s data

get_location(update=False) → GeoFrDataFrame | SireneDataFrame

Get latitude and longitude from OpenStreetMap, add geometry column and turn SireneDataframe into GeoFrDataFrame.

Parameters:

update (bool, optional) – data is saved locally, set update=True to trigger an update. Defaults to False.

Notes

If it fails to find the exact location, by default it returns the location of the city. Whether the exact location has been found or not is encoded in the exact_location column of the new GeoFrDataFrame.

Examples

>>> from pynsee.metadata import get_activity_list
>>> from pynsee.sirene import search_sirene
>>> #
>>> #  Get activity list
>>> naf5 = get_activity_list('NAF5')
>>> #
>>> # Get alive legal entities belonging to the automotive industry
>>> df = search_sirene(variable = ["activitePrincipaleEtablissement"],
>>>                    pattern = ['29.10Z'], kind = 'siret')
>>> #
>>> # Keep businesses with more than 100 employees
>>> df = df.loc[df['effectifsMinEtablissement'] > 100]
>>> df = df.reset_index(drop=True)
>>> #
>>> # Get location
>>> df = df.get_location()

Get data from INSEE files

pynsee.download.download_file(id, variables=None, update=False, silent=False) → DataFrame

User level function to download files from insee.fr

Note: in the case of vintaged ids (ie. TAG_COM_2025), it should be safe to use a _LATEST tag instead if you just want the latest available dataset (ie TAG_COM_LATEST). In case of side-effects, pay attention to the log entries and revert to the vintaged id.

Parameters:
  • id (str) – file id, check get_file_list to have a full list of available files

  • variables (list) – a list of variables to load from the data file, use get_column_metadata function to have the full list

  • update (bool, optional) – Trigger an update, otherwise locally saved data is used. Defaults to False.

  • silent (bool, optional) – Set to True, to disable messages printed in log info

Returns:

Returns the request dataframe as a pandas object

Examples

>>> from pynsee.download import download_file
>>> df = download_file("TAG_COM_LATEST")
pynsee.download.get_column_metadata(id)

Get metadata about an insee.fr file

Returns:

Returns the request dataframe as a pandas object

Examples

>>> from pynsee.download import get_column_metadata
>>> rp_logement_metadata = get_column_metadata("RP_LOGEMENT_2016")

Get MELODI data

pynsee.melodi.get_catalog(language: str = 'all', update: bool = False, silent: bool = False) → DataFrame

Retrieve MELODI’s full catalog.

Parameters:

language (str, optional) – Filter metadata to select a desired language, if available. The default is “all”, which won’t filter anything. Covered values are “fr”, “en”.

Returns:

  • dataset (pd.DataFrame)

  • Ex – accessURL byteSize format 0 https://api.insee.fr/melodi/file/DD_CNA_AGREGA… 1895856 CSV 1 https://api.insee.fr/melodi/file/DD_CNA_BRANCH… 3551601 CSV

    id issued language mediaType 0 DD_CNA_AGREGATS_CSV_FR 2024-07-18T15:46:53 FR text/csv

    1 DD_CNA_BRANCHES_CSV_FR 2024-11-22T13:11:59 FR text/csv

    modified packageFormat 0 2025-08-29T13:38:30 application/zip

    1 2025-05-27T17:45:13 application/zip

    title dataset_identifier 0 Produit Intérieur Brut (PIB) et grands agrégat… DD_CNA_AGREGATS

    1 Activité des branches de l’économie DD_CNA_BRANCHES

    abstract_fr 0 Données annuelles de Produit Intérieur Brut (P…

    1 Données annuelles sur l’activité des branches …

    abstract_en accessRights_fr 0 Annual data on Gross Domestic Product (GDP) an… Libre

    1 Annual data on the activity of branches within… Libre

    accrualPeriodicity_fr accrualPeriodicity_en confidentialityStatus_fr 0 Annuel Annual Libre

    1 Annuel Annual Libre

    creator description_fr 0 Insee Le produit intérieur brut (PIB) est le princip…

    1 Insee Données annuelles sur l’activité des branches …

    description_en 0 Gross domestic product (GDP) is the main aggre…

    1 Annual data on the activity of industries as r…

    ordreComposants processStep_fr 0 ACCOUNTING_ENTRY, ACTIVITY, COUNTERPART_AREA, … inseeApi

    1 REF_SECTOR, COUNTERPART_AREA, ACCOUNTING_ENTRY… inseeApi

    processStep_en publisher_fr 0 inseeApi Institut national de la statistique et des etu…

    1 inseeApi Institut national de la statistique et des etu…

    publisher_en 0 National Institute of Statistics and Economic …

    1 National Institute of Statistics and Economic …

    scopeNote_fr 0

    1 La version du dataset mise en ligne le 8 octob…

    scopeNote_en spatial_fr 0 France entière

    1 The version of the dataset published online on… France entière

    spatial_en dsd subtitle_fr 0 France DSD_NA_MAIN Comptes nationaux annuels - Base 2020

    1 France DSD_NA_MAIN Comptes nationaux annuels - Base 2020

    subtitle_en endPeriod startPeriod 0 Base 2020 - Annual Results 2024-01-01T00:00:00 1949-01-01T00:00:00

    1 National accounts - Base 2020 2024-01-01T00:00:00 1949-01-01T00:00:00

    title_fr 0 Produit Intérieur Brut (PIB) et grands agrégat…

    1 Activité des branches de l’économie

    title_en type_fr 0 Gross domestic product (GDP) and main economic… Données agrégées

    1 Production and generation of income by industry Données agrégées

    1 http://id.insee.fr/catalogues/jeuDeDonnees/a85…

    uuid accessRights_en type_en 0 2ccb4960-fb78-4ef9-93f6-2edf14cb53c8 None None

    1 2017dbc2-177f-29d7-4f74-749965615961 None None

    confidentialityStatus_en spatialTemporal

    0 None None 1 None None

Examples

>>> get_catalog()
>>> get_catalog(language="fr")
pynsee.melodi.get_dataset(id_dataset, language: str = 'all', raise_if_not_ok: bool = True, update: bool = False, silent: bool = False, **filters) → DataFrame

Get a MELODI dataset (pagination is handled by pynsee if need be).

Notes

As pagination is handled internally, page, maxResult and totalCount should NOT be passed in **filters and will be ignored. range will also be ignored: to retrieve a dataset’s dimensions, use pynsee.melodi.get_range.

Parameters:
  • id_dataset (str) – Dataset’s identifier (its “name”, e.g. “DS_TICM_PRATIQUES”).

  • language (str, optional) – If set to “all”, will keep metadata’s labels in every available language. Can be used to keep only one desired language label (API covered languages include either “en” or “fr”). The default is “all”.

  • raise_if_not_ok (bool, optional) – If set to True, a RequestException will automatically be raised if the response is not ok (= status_code < 400). The default is True.

  • **filters – Optional filters to be used on MELODI. To get the available filters, please look at pynsee.melodi.get_range. Note that even if MELODI’s filters’ labels are UPPERCASE, pynsee handles lowercase in consistence with python’s conventions.

Returns:

observations (pd.DataFrame) – Dataset’s as a DataFrame.

Examples

>>> get_dataset("DS_TICM_PRATIQUES")

# TICM_MEASURE SEX FREQ EMPSTA TIME_PERIOD EDUC PCS_ESE AGE # 0 PROFIL _T A _T 2022 _T _T Y60T74 # 1 TEL_PAR_INT F A _T 2023 _T _T Y_GE60 # 2 WEB_12MOIS_X_EGOV F A _T 2015 _T _T Y_GE60 # 3 LECTURE _T A _T 2012 2_353 _T Y15T44 # 4 WEB_3MOIS F A _T 2025 _T _T Y45T59 # .. … .. … … … … … … # 331 VENTE_3MOIS _T A _T 2010 4T8 _T Y45T59 # 332 WEB_12MOIS_X_EGOV _T A _T 2009 0T1 _T Y15T44 # 333 NO_WEB_12MOIS M A _T 2015 _T _T Y_GE60 # 334 LECTURE _T A _T 2018 0T1 _T Y15T44 # 335 WEB_3MOIS _T A _T 2013 2_353 _T Y15T44

# OBS_STATUS OBS_VALUE_NIVEAU title_en # 0 A 19.4 Internet use of individuals # 1 A 38.6 Internet use of individuals # 2 L NaN Internet use of individuals # 3 L NaN Internet use of individuals # 4 A 96.4 Internet use of individuals # .. … … … # 331 L NaN Internet use of individuals # 332 L NaN Internet use of individuals # 333 L NaN Internet use of individuals # 334 L NaN Internet use of individuals # 335 A 93.9 Internet use of individuals

# title_fr identifier publisher_id # 0 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # 1 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # 2 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # 3 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # 4 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # .. … … … # 331 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # 332 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # 333 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # 334 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE # 335 Pratiques en ligne des personnes DS_TICM_PRATIQUES INSEE

# publisher_fr # 0 Institut national de la statistique et des etu… # 1 Institut national de la statistique et des etu… # 2 Institut national de la statistique et des etu… # 3 Institut national de la statistique et des etu… # 4 Institut national de la statistique et des etu… # .. … # 331 Institut national de la statistique et des etu… # 332 Institut national de la statistique et des etu… # 333 Institut national de la statistique et des etu… # 334 Institut national de la statistique et des etu… # 335 Institut national de la statistique et des etu…

# publisher_en # 0 National Institute of Statistics and Economic … # 1 National Institute of Statistics and Economic … # 2 National Institute of Statistics and Economic … # 3 National Institute of Statistics and Economic … # 4 National Institute of Statistics and Economic … # .. … # 331 National Institute of Statistics and Economic … # 332 National Institute of Statistics and Economic … # 333 National Institute of Statistics and Economic … # 334 National Institute of Statistics and Economic … # 335 National Institute of Statistics and Economic …

# [10336 rows x 16 columns]

>>> get_dataset("DS_TICM_PRATIQUES", language="fr").head(2)

# TICM_MEASURE SEX FREQ EMPSTA TIME_PERIOD EDUC PCS_ESE AGE OBS_STATUS # 0 PROFIL _T A _T 2022 _T _T Y60T74 A # 1 TEL_PAR_INT F A _T 2023 _T _T Y_GE60 A

# OBS_VALUE_NIVEAU title_fr identifier # 0 19.4 Pratiques en ligne des personnes DS_TICM_PRATIQUES # 1 38.6 Pratiques en ligne des personnes DS_TICM_PRATIQUES

# publisher_id publisher_fr # 0 INSEE Institut national de la statistique et des etu… # 1 INSEE Institut national de la statistique et des etu…

>>> get_dataset(
    "DS_TICM_PRATIQUES",
    language="fr",
    time_period=2025,
    sex="F",
    age="Y45T59"
    )

# TICM_MEASURE SEX FREQ EMPSTA TIME_PERIOD EDUC PCS_ESE AGE # 0 WEB_3MOIS F A _T 2025 _T _T Y45T59 # 1 RESEAUX_SOC F A _T 2025 _T _T Y45T59 # 2 ACHA_3MOIS F A _T 2025 _T _T Y45T59 # 3 WEB_12MOIS_X_EGOV F A _T 2025 _T _T Y45T59 # 4 COMPTE_BANCAIRE F A _T 2025 _T _T Y45T59 # 5 ACHA_12MOIS F A _T 2025 _T _T Y45T59 # 6 EGOV_12MOIS F A _T 2025 _T _T Y45T59 # 7 TEL_PAR_INT F A _T 2025 _T _T Y45T59 # 8 VENTE_3MOIS F A _T 2025 _T _T Y45T59 # 9 NO_WEB_12MOIS F A _T 2025 _T _T Y45T59 # 10 EMAIL F A _T 2025 _T _T Y45T59 # 11 LECTURE F A _T 2025 _T _T Y45T59 # 12 PROFIL F A _T 2025 _T _T Y45T59 # 13 QUOTIDIEN F A _T 2025 _T _T Y45T59 # 14 INFO_PRODUITS F A _T 2025 _T _T Y45T59 # 15 NO_EGOV F A _T 2025 _T _T Y45T59

# OBS_STATUS OBS_VALUE_NIVEAU title_fr # 0 A 96.4 Pratiques en ligne des personnes # 1 A 71.5 Pratiques en ligne des personnes # 2 A 71.6 Pratiques en ligne des personnes # 3 A 5.1 Pratiques en ligne des personnes # 4 A 80.0 Pratiques en ligne des personnes # 5 A 83.2 Pratiques en ligne des personnes # 6 A 92.1 Pratiques en ligne des personnes # 7 A 75.1 Pratiques en ligne des personnes # 8 A 25.7 Pratiques en ligne des personnes # 9 A 2.9 Pratiques en ligne des personnes # 10 A 92.2 Pratiques en ligne des personnes # 11 A 54.8 Pratiques en ligne des personnes # 12 L NaN Pratiques en ligne des personnes # 13 A 91.1 Pratiques en ligne des personnes # 14 A 70.2 Pratiques en ligne des personnes # 15 A 7.9 Pratiques en ligne des personnes

# identifier publisher_id # 0 DS_TICM_PRATIQUES INSEE # 1 DS_TICM_PRATIQUES INSEE # 2 DS_TICM_PRATIQUES INSEE # 3 DS_TICM_PRATIQUES INSEE # 4 DS_TICM_PRATIQUES INSEE # 5 DS_TICM_PRATIQUES INSEE # 6 DS_TICM_PRATIQUES INSEE # 7 DS_TICM_PRATIQUES INSEE # 8 DS_TICM_PRATIQUES INSEE # 9 DS_TICM_PRATIQUES INSEE # 10 DS_TICM_PRATIQUES INSEE # 11 DS_TICM_PRATIQUES INSEE # 12 DS_TICM_PRATIQUES INSEE # 13 DS_TICM_PRATIQUES INSEE # 14 DS_TICM_PRATIQUES INSEE # 15 DS_TICM_PRATIQUES INSEE

# publisher_fr # 0 Institut national de la statistique et des etu… # 1 Institut national de la statistique et des etu… # 2 Institut national de la statistique et des etu… # 3 Institut national de la statistique et des etu… # 4 Institut national de la statistique et des etu… # 5 Institut national de la statistique et des etu… # 6 Institut national de la statistique et des etu… # 7 Institut national de la statistique et des etu… # 8 Institut national de la statistique et des etu… # 9 Institut national de la statistique et des etu… # 10 Institut national de la statistique et des etu… # 11 Institut national de la statistique et des etu… # 12 Institut national de la statistique et des etu… # 13 Institut national de la statistique et des etu… # 14 Institut national de la statistique et des etu… # 15 Institut national de la statistique et des etu…

Raises:
  • RequestException – If the JSON cannot be parsed.

  • ValueError – If the result after pagination is incoherent with the estimated results’ shape. This should NOT happen and is triggered to warn users to get in touch if this arises.

pynsee.melodi.get_range(id_dataset: str, language: str = 'all', include_values: bool = False, raise_if_not_ok: bool = True, update: bool = False, silent: bool = False) → DataFrame

Get a dataset’s available columns’ names (see “/range” endpoint of MELODI API).

Available columns’ names (dimensions and modalities) can be retrieved in a sparse format (with only the columns’ descriptions) or a long format (including all available values for each column).

Parameters:
  • id_dataset (str) – Dataset’s identifier.

  • language (str, optional) – If set to “all”, will keep metadata’s labels in every available language. Can be used to keep only one desired language label (API covered languages include either “en” or “fr”). The default is “all”.

  • include_values (bool, optional) – Whether to include each available value for each dimension. The default is False, resulting to the sparse format. Set to True to get the long format dataframe.

  • raise_if_not_ok (bool, optional) – If set to True, a RequestException will automatically be raised if the response is not ok (= status_code < 400). The default is True.

Returns:

ranges (pd.DataFrame) – DataFrame describing the available ranges.

Examples

>>> get_range("DS_RP_POPULATION_PRINC")

# concept_code concept_en concept_fr type # 0 OBS_STATUS Observation status Statut de l’observation modalites # 1 GEO Geography Géographie geo # 2 SEX Sex Sexe modalites # 3 FREQ Frequency Fréquence modalites # 4 TIME_PERIOD Time period Période temporelle date # 5 RP_MEASURE Census measure Mesure du recensement modalites # 6 AGE Age Âge modalites

>>> get_range("DS_RP_POPULATION_PRINC", language="fr")

# concept_code concept_fr type # 0 OBS_STATUS Statut de l’observation modalites # 1 GEO Géographie geo # 2 SEX Sexe modalites # 3 FREQ Fréquence modalites # 4 TIME_PERIOD Période temporelle date # 5 RP_MEASURE Mesure du recensement modalites # 6 AGE Âge modalites

>>> get_range("DS_RP_POPULATION_PRINC", language="fr", include_values=True)

# concept_code concept_fr type code id # 0 OBS_STATUS Statut de l’observation modalites K None # 1 OBS_STATUS Statut de l’observation modalites A None # 2 OBS_STATUS Statut de l’observation modalites W None # 3 GEO Géographie geo 783 2026-ARR-783 # 4 GEO Géographie geo 791 2026-ARR-791 # … … … … … … # 41786 AGE Âge modalites Y40T54 None # 41787 AGE Âge modalites Y_GE65 None # 41788 AGE Âge modalites Y15T24 None # 41789 AGE Âge modalites Y65T79 None # 41790 AGE Âge modalites _T None

# iri # 0 None # 1 None # 2 None # 3 http://id.insee.fr/geo/arrondissement/c4d36a67… # 4 http://id.insee.fr/geo/arrondissement/62f3a762… # … … # 41786 None # 41787 None # 41788 None # 41789 None # 41790 None

# value_fr type_code type_fr # 0 Données inclues dans une autre catégorie None None # 1 Normale None None # 2 Inclut les données d’une autre catégorie None None # 3 Saint-Germain-en-Laye ARR Arrondissement # 4 Bressuire ARR Arrondissement # … … … … # 41786 De 40 à 54 ans None None # 41787 65 ans ou plus None None # 41788 De 15 à 24 ans None None # 41789 De 65 à 79 ans None None # 41790 Total None None

# [41791 rows x 9 columns]

pynsee.melodi.get_series(id_banks: str, language: str = 'all', raise_if_not_ok: bool = True, update: bool = False, silent: bool = False)

Get MELODI time series by idbank identifier(s).

Retrieves one or more series from the /data/series/{idbanks} endpoint. Multiple idbanks can be passed separated by +.

Parameters:
  • id_banks (str) – One or more idbank identifiers, separated by +. Example: "010770930" or "010598544+010770930".

  • language (str, optional) – If set to "all", keeps metadata labels in every available language. Set to "fr" or "en" to keep only one. The default is "all".

  • raise_if_not_ok (bool, optional) – If True, raises a RequestException when the response status code is >= 400. The default is True.

Returns:

pd.DataFrame – One row per observation across all requested series, with dimensions, attributes, measures, and series metadata as columns. Returns an empty DataFrame if the API returns no data, and logs a warning in that case. MELODI does not validate the idbank itself, so this occurs both for unknown idbanks and for idbanks that exist in BDM but have no corresponding MELODI dataset yet.

Examples

>>> get_series("010770930")
>>> get_series("010598544+010770930")
>>> get_series("010770930", language="fr")