Awesome pandas_historical created by dvvolynkin
Project description
pandas_historical
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
Release history Release notifications | RSS feed
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 pandas_historical-0.1.2.tar.gz.
File metadata
- Download URL: pandas_historical-0.1.2.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.8.2 requests/2.27.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1eef41412e96b8e47e736570913356d76d84fb37c44044921051e7c99d36e90
|
|
| MD5 |
e919a19f4fb590b50555ba7fa938c180
|
|
| BLAKE2b-256 |
9e86a171a56b4acace55013d2384bf8bef62e52aeeaec407fd13ee7ff184e4a4
|
File details
Details for the file pandas_historical-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pandas_historical-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.8.2 requests/2.27.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce1c63cd7ea785ccd0a853e039ce8d8e08256f6f114cc133872dc929db9338af
|
|
| MD5 |
f7cb161a2feed3dbe47b2be2a5ec2d85
|
|
| BLAKE2b-256 |
d682b898fe38abb4bf0f4b9b24ccc7f5ced8d0f90ce9d6dd1fd8df0e72f43a95
|