No project description provided
Project description
INEapy
INEapy is a comprehensive Python library designed to provide seamless access to data from the Spanish National Statistics Institute (INE). The library is structured into two primary modules: ine_wrapper and ine_consultor, each serving distinct purposes to cater to different user needs.
If you want to access to the API's details, check it's documentation.
Installation
To install INEapy, simply run the following command:
pip install ineapy
Overview
INEapy offers a robust interface for interacting with the INE's extensive data offerings. Whether you need low-level access to the API or a more abstracted, user-friendly interface, INEapy has you covered.
Modules
INEWrapper
The ine_wrapper module provides a direct and low-level interface with the INE API, allowing users to perform HTTP requests to various endpoints with precision and control.
Key Features:
- Comprehensive access to all available operations in the INE API
- Rigorous parameter validation to ensure data integrity
- Efficient pagination handling for large datasets
- Multi-language support (ES/EN) for broader accessibility
Initialization:
from ineapy import INEWrapper
# Initialize the wrapper (default in Spanish)
wrapper = INEWrapper()
# Initialize the wrapper in English
wrapper_en = INEWrapper(language="EN")
Core Methods:
get_operacion(cod_operation, det, tip): Retrieve detailed information about a statistical operation.get_operaciones_disponibles(det, tip, geo): Access the list of available operations.get_publicaciones_operacion(cod_operation, det, tip): Fetch publications associated with a specific operation.get_variables(): Access the complete list of variables available in the system.get_variables_operacion(cod_operation, det, tip): Retrieve variables associated with a specific operation.get_valores_variable(id_variable, det, tip): Obtain possible values for a given variable.get_serie(cod_serie, det, tip): Access information about a specific series.get_datos_serie(cod_serie, nult, date, det, tip): Retrieve data from a specific series.get_datos_metadata_operacion(cod_operation, filters, p, det, tip, nult, date): Fetch data with metadata for an operation.get_tablas_operacion(cod_operation, det, tip): Access tables associated with a specific operation.get_grupos_tabla(id_table, det, tip): Retrieve groups of a table.get_valores_grupos_tabla(id_table, id_grupo, det, tip): Obtain values of a table group.get_datos_tabla(id_table, nult, date, det, tip, filters): Retrieve data from a specific table.
Common Parameters:
det: Detail level (0, 1, or 2)tip: Response type ("", "A", "M", "AM")- "": Normal response
- "A": Friendly response
- "M": Includes metadata
- "AM": Friendly with metadata
nult: Number of latest data points to retrievedate: Date filter in the format "yyyymmdd:yyyymmdd"filters: List of filters in the format "id_variable:id_value"
Usage Example:
from ineapy import INEWrapper
# Initialize the wrapper
wrapper = INEWrapper()
# List available operations
response = wrapper.get_operaciones_disponibles(det=0, tip="")
operations = response.json()
# Get information about an operation
response = wrapper.get_operacion("IPC", det=0, tip="M")
data = response.json()
# Get data from a series
response = wrapper.get_datos_serie("IPC277517", nult=12)
series_data = response.json()
INEConsultor
The ine_consultor module offers a high-level abstraction over ine_wrapper, simplifying access to INE data and enhancing data manipulation capabilities.
Key Features:
- Simplified interface for streamlined data access
- Automatic conversion of responses to more manageable formats
- Comprehensive methods for listing and querying operations, variables, and series
Initialization:
from ineapy import INEConsultor
# Initialize the consultant (default in Spanish)
consultor = INEConsultor()
# Initialize the consultant in English
consultor_en = INEConsultor(language="EN")
Core Methods:
list_operations(filter_geo): List available operations.get_info_operation(cod_operation): Retrieve information about a specific operation.list_variables(cod_operation): List available variables, either general or specific to an operation.list_periodicities(): List available periodicities.list_filters_from_variable(id_variable): List values for a specific variable.list_filters_from_variable_operation(cod_operation, id_variable): List values for a variable within an operation.get_info_serie(cod_serie): Retrieve detailed information about a series.get_data_serie(cod_serie, nult, date): Access data from a specific series.get_data_operation(cod_operation, filters, p, date, nult): Retrieve data from an operation with specified filters.list_groups_from_table(id_table): List groups within a table.list_filters_from_table(id_table): List available filters for a table.get_data_table(id_table, nult, date, filters): Access data from a specific table.
Usage Example:
from ineapy import INEConsultor
import pandas as pd
# Initialize the consultant
consultor = INEConsultor()
# List available operations
operations = consultor.list_operations()
# Get information about the IPC operation
operation_info = consultor.get_info_operation("IPC")
# List variables for an operation
variables = consultor.list_variables("IPC")
# Get data from a series with the last 12 values
data = consultor.get_data_serie("IPC277517", nult=12)
# Convert to pandas DataFrame
df = pd.DataFrame(data)
Data Structure
Responses from INEConsultor are consistently returned in simplified formats, typically as lists of dictionaries or dictionaries. Dates are automatically converted to pandas datetime objects to facilitate analysis.
Contribution
Contributions to INEapy are highly encouraged. To contribute, please:
- Fork the repository
- Create a branch for your feature
- Commit your changes
- Push to the branch
- Open a Pull Request
By following these steps, you can help enhance the functionality and usability of INEapy for the community.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ineapy-0.1.1.tar.gz.
File metadata
- Download URL: ineapy-0.1.1.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10b0d0868f9e83652983c05b84d4e07a3a7200b312a72f857816d9f3eacd1a72
|
|
| MD5 |
82e1eea743c1f9010252048ef626d8bd
|
|
| BLAKE2b-256 |
5627b3af84535cb00d39b65f85aa6ba2a4345dfdfb8b4f96598d942d8b3e7cfc
|
File details
Details for the file ineapy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ineapy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebf5e9643a54c6f15bc4d70765af832d91c95a15bc9584d85176014bc79f6605
|
|
| MD5 |
6a414ddf8607237539d60683c125a81e
|
|
| BLAKE2b-256 |
19fe279b32528644675064349c4d977f9fcd8bdba0e13ea29788e9af65cc7ce6
|