Time series extraction from the Peruvian Central Bank Database (BCRP Statistics)
Project description
bcrp-webscrapper
This repository has a module that allows the scrapping of the Peruvian Central of Reserve (BCRP) Statistics Database.
Structure
The repository contains the following folders:
src
: Contains the.py
files where the functions are defined, specifically under thebcrp_webscrapper
subdirectory.test
: Includes example usage and tests for the functions, such as the Jupyter Notebookbcrp_webscrapping_test.ipynb
.dist
: Contains the distribution packages, such as.tar.gz
and.whl
files, for different versions of the project.build
: Holds build-related files, including intermediate files and directories used during the packaging process.
Getting Started
Prerequisites
You need to make sure you have installed the following modules.
- Requests
- Unidecode
- Selenium
- Webdriver_manager
- openpyxl
pip install requests
pip install unidecode
pip install selenium
pip install webdriver_manager
pip install openpyxl
pip install more-itertools
Installation
pip install bcrp-webscrapper
Functions
The module defines the following main functions:
bcrp_search()
This function provides a basic searcher for the BCRP Database website. We provide the name of the series and the frequency we want and search for the data available. It returns a dataframe with all series that match our input.
bcrp_dataframe()
This function scraps series from the BCRP Database and gives us a dataframe with the series.
bcrp_graph()
This function graphs series from the BCRP Database.
download_graph()
This function scraps series from the BCRP Database and downloads the image in the given format (png, jpg, pdf).
Usage
- Example 1
from bcrp_webscrapper import *
var = "Expectativas"
freq = "Mensual"
print(bcrp.bcrp_search( var , freq))
var2 = "PBI"
print(bcrp.bcrp_search( var2 ))
- Example 2
from bcrp_webscrapper import *
codes = ['PD04637PD', 'PD04638PD']
start_date = '2012-03-12'
end_date = '2022-05-30'
freq = 'Diario'
bcrp.bcrp_dataframe( codes , start_date , end_date , freq)
- Example 3
from bcrp_webscrapper import *
codes = ['PD09919MA', 'PD09920MA']
start_date = '2015'
end_date = '2022'
bcrp.bcrp_graph( codes , start_date , end_date )
For more examples, please refer to the the test folder.
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
- Email: estcab00@gmail.com
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
File details
Details for the file bcrp_webscrapper-1.0.6.tar.gz
.
File metadata
- Download URL: bcrp_webscrapper-1.0.6.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 949f04b97363d42810907272129432b1a0bfdf2bf9dd71208473cc6719db5318 |
|
MD5 | c598e00760e3af109f5f346a1ac2a12f |
|
BLAKE2b-256 | c335170e64f2d3d6179c0775c2b90cb9e1a069755287c02bcd23f4ac9c795680 |
File details
Details for the file bcrp_webscrapper-1.0.6-py3-none-any.whl
.
File metadata
- Download URL: bcrp_webscrapper-1.0.6-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60a9b6199fdb8abb6425b41e404a5f3a364ab281ba8e4fd16213addbd5edf1d6 |
|
MD5 | 3687246c9c1b45588aa897e12b040f53 |
|
BLAKE2b-256 | f08953a936fdc87dc8afc907ae3d16e9a5a6eab5bab7d880e7849a7868d94867 |