Skip to main content

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 the bcrp_webscrapper subdirectory.
  • test : Includes example usage and tests for the functions, such as the Jupyter Notebook bcrp_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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

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

bcrp_webscrapper-1.0.6.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

bcrp_webscrapper-1.0.6-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

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

Hashes for bcrp_webscrapper-1.0.6.tar.gz
Algorithm Hash digest
SHA256 949f04b97363d42810907272129432b1a0bfdf2bf9dd71208473cc6719db5318
MD5 c598e00760e3af109f5f346a1ac2a12f
BLAKE2b-256 c335170e64f2d3d6179c0775c2b90cb9e1a069755287c02bcd23f4ac9c795680

See more details on using hashes here.

File details

Details for the file bcrp_webscrapper-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for bcrp_webscrapper-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 60a9b6199fdb8abb6425b41e404a5f3a364ab281ba8e4fd16213addbd5edf1d6
MD5 3687246c9c1b45588aa897e12b040f53
BLAKE2b-256 f08953a936fdc87dc8afc907ae3d16e9a5a6eab5bab7d880e7849a7868d94867

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page