Data access¶
The Bulk API retrieves ILOSTAT datasets as pandas DataFrames using native ILOSTAT dataset identifiers and dimension codes.
Use get_df() to retrieve observations, get_toc() to discover
datasets, and get_dic() to explore dictionaries.
import ilostat
Discover datasets¶
The table of contents provides information about available datasets and their identifiers.
toc = ilostat.get_toc()
print(toc.head())
Data segments¶
ILOSTAT bulk data can be retrieved by indicator or reference area.
=== "Indicator"
```python
toc = ilostat.get_toc(segment="indicator")
```
=== "Reference area"
```python
toc = ilostat.get_toc(segment="ref_area")
```
The default segment is indicator. The table of contents is
available in English, French and Spanish.
Retrieve data¶
=== "By indicator"
```python
df = ilostat.get_df("UNE_TUNE_SEX_AGE_NB_A")
print(df.head())
```
=== "By reference area"
```python
df = ilostat.get_df(
"FRA_A",
segment="ref_area",
)
```
Multiple datasets¶
Several datasets can be retrieved in one call.
df = ilostat.get_df(
[
"UNE_TUNE_SEX_AGE_NB_A",
"EMP_TEMP_SEX_AGE_NB_A",
],
filters={
"ref_area": "FRA",
"timefrom": 2020,
},
)
The datasets are combined into a single pandas DataFrame.
Filter observations¶
Supply filters as a dictionary using native ILOSTAT dimension names.
=== "Single values"
```python
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
filters={
"ref_area": "FRA",
"sex": "SEX_F",
},
)
```
=== "Multiple values"
```python
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
filters={
"ref_area": ["FRA", "CHE"],
"sex": ["SEX_T", "SEX_F"],
},
)
```
=== "Partial matching"
```python
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
filters={"sex": "T"},
)
```
=== "Regular expressions"
```python
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
filters={"ref_area": "FRA|CHE"},
fixed=False,
)
```
The fixed parameter defaults to True. Set fixed=False
to use regular-expression matching.
Dimension codes
Consult the ILOSTAT dictionaries before constructing filters. Use complete dimension codes when you want to avoid unintended partial matches.
Filter by time¶
Use timefrom and timeto within the filters dictionary.
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
filters={
"ref_area": "FRA",
"timefrom": 2020,
"timeto": 2025,
},
)
Time values remain in their original ILOSTAT representation.
| Frequency | Example |
|---|---|
| Annual | 2025 |
| Quarterly | 2025Q1 |
| Monthly | 2025M01 |
Codes and labels¶
The type argument controls the representation of coded dimensions.
| Value | Description |
|---|---|
code |
Return codes (default) |
label |
Return labelled dimensions without their corresponding code columns |
both |
Return codes together with their labels |
=== "Codes"
```python
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
type="code",
)
```
=== "Labels"
```python
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
type="label",
)
```
=== "Codes and labels"
```python
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
type="both",
)
```
An illustrative result with type="both":
| ref_area | ref_area.label | sex | sex.label |
|---|---|---|---|
| FRA | France | SEX_T | Total |
Languages¶
| Code | Language |
|---|---|
en |
English (default) |
fr |
French |
es |
Spanish |
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
type="both",
lang="fr",
)
Observation notes¶
Observation notes are labelled automatically when type="both"
or type="label" is requested.
| Field | Description |
|---|---|
note_classif |
Classification notes |
note_indicator |
Indicator notes |
note_source |
Source notes |
Observations containing multiple note codes are resolved to their corresponding note labels.
Best-source observations¶
The best_source argument controls source selection.
| Value | Description |
|---|---|
yes |
Best-source observations (default) |
no |
Non-best-source observations |
all |
All observations |
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
best_source="all",
)
Multiple sources
When retrieving all sources, consider the source dimension before aggregating observations or comparing series.
Dictionaries and metadata¶
Dictionaries¶
Use get_dic() to retrieve the codes and labels associated
with ILOSTAT dimensions.
countries = ilostat.get_dic("ref_area")
sex = ilostat.get_dic("sex", lang="fr")
print(countries.head())
print(sex.head())
Dataset metadata¶
metadata = ilostat.get_metadata("UNE_TUNE_SEX_AGE_NB_A")
Dataset-specific dictionaries¶
dictionary = ilostat.get_dataset_dic("UNE_TUNE_SEX_AGE_NB_A")
Local caching and performance¶
Downloaded resources are cached locally and reused automatically.
Use the filters argument to request the observations needed
for your analysis rather than filtering the returned DataFrame
as a separate step.
For normal use, retain the default refresh=False. To force
a resource refresh:
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
refresh=True,
)
Inspect the cache location:
print(ilostat.get_cache_dir())
See Cache management for additional options.
Complete example¶
Retrieve female unemployment observations for France and Switzerland, with English codes and labels, over a selected period.
import ilostat
df = ilostat.get_df(
"UNE_TUNE_SEX_AGE_NB_A",
filters={
"ref_area": ["FRA", "CHE"],
"sex": "SEX_F",
"timefrom": 2020,
"timeto": 2025,
},
type="both",
lang="en",
best_source="yes",
)
print(df.head())
df.to_parquet("ilostat_unemployment.parquet", index=False)
SDMX-style data access¶
Use get_sdmx() when working with SDMX component identifiers
instead of native ILOSTAT dimension names.
df = ilostat.get_sdmx(
"UNE_TUNE_SEX_AGE_NB_A",
filters={
"REF_AREA": "FRA",
"SEX": "SEX_F",
"TIME_PERIOD": "2020:2025",
},
)
See the SDMX overview for data access, structures, codelists and dataflows.
API reference¶
For complete function signatures and parameters, see the API reference.