Skip to main content

Awesome pandas_historical created by dvvolynkin

Project description


pandas_historical

codecov CI

Awesome pandas_historical created by dvvolynkin

Install it from PyPI

pip install pandas_historical

Usage

import pandas as pd

currencies_scraping = pd.DataFrame([
    {
        'date': '2022-02-21',
        'key': 'DOLLAR',
        'value': 78,
        'scraping_id': 123
    },
    {
        'date': '2022-02-21',
        'key': 'EURO',
        'value': 87,
        'scraping_id': 123
    },
    {
        'date': '2022-02-28',
        'key': 'DOLLAR',
        'value': 105,
        'scraping_id': 124
    },
    {
        'date': '2022-03-07',
        'key': 'EURO',
        'value': 139,
        'scraping_id': 125
    },
    {
        'date': '2022-03-07',
        'key': 'EURO',
        'value': 148,
        'scraping_id': 125
    }
])
currencies_scraping
date key value scraping_id
0 2022-02-21 DOLLAR 78 123
1 2022-02-21 EURO 87 123
2 2022-02-28 DOLLAR 105 124
3 2022-03-07 EURO 139 125
4 2022-03-07 EURO 148 125
from pandas_historical import make_historical_df

historical_df = make_historical_df(currencies_scraping)
historical_df
date key value scraping_id
0 2022-02-21 DOLLAR 78 123
1 2022-02-28 DOLLAR 105 124
2 2022-02-21 EURO 87 123
3 2022-03-07 EURO 139 125
4 2022-03-07 EURO 148 125
from pandas_historical import update_historical_df
new_values = pd.DataFrame([
    {
        'date': '2022-03-11',
        'key': 'DOLLAR',
        'value': 113,
        'scraping_id': 127
    },
    {
        'date': '2022-03-11',
        'key': 'EURO',
        'value': 144,
        'scraping_id': 127
    }
])
historical_df = update_historical_df(
    historical_df, new_values
)
historical_df
date key value scraping_id
0 2022-02-21 DOLLAR 78 123
1 2022-02-28 DOLLAR 105 124
2 2022-03-11 DOLLAR 113 127
3 2022-02-21 EURO 87 123
4 2022-03-07 EURO 139 125
5 2022-03-07 EURO 148 125
6 2022-03-11 EURO 144 127
from pandas_historical import get_history_state
get_history_state(historical_df)
date key value scraping_id
2 2022-03-11 00:00:00 DOLLAR 113 127
6 2022-03-11 00:00:00 EURO 144 127
get_history_state(historical_df, state_date='2022-03-07')
date key value scraping_id
1 2022-02-28 00:00:00 DOLLAR 105 124
4 2022-03-07 00:00:00 EURO 139 125

Development

Read the CONTRIBUTING.md file.

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

pandas_historical-0.1.2.tar.gz (7.7 kB view hashes)

Uploaded Source

Built Distribution

pandas_historical-0.1.2-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

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