slowly changing dimension with pandas
Project description
pandas_scd
executing slowly changing dimension type 2 on pandas dataframes
given pandas df of the source table, and pandas df of the target table, returning pandas df with the entire new target after scd2
Installation
basic installtion :
pip install pandas-scd2
Getting started
from pandas_scd import scd2
import pandas as df
tgt = pd.DataFrame.from_dict({'first_name': ["Chris"], 'last_name': ['Paul'], 'team': ["Clippers"], "start_ts": [datetime(2012, 1, 14, 3, 21, 34)], "end_ts": [None], "is_active": [True]})
src = pd.DataFrame.from_dict({'first_name': ["Chris"], 'last_name': ['Paul'], 'team': ['Suns']})
final_df = scd2(src, tgt)
tgt:
| first_name | last_name | team | start_ts | end_ts | is_active |
|---|---|---|---|---|---|
| Chris | Paul | Clippers | 2012-01-14 03:21:34 | True |
src:
| first_name | last_name | team |
|---|---|---|
| Chris | Paul | Clippers |
final_df:
| first_name | last_name | team | start_ts | end_ts | is_active |
|---|---|---|---|---|---|
| Chris | Paul | Clippers | 2012-01-14 03:21:34 | 2018-01-01 00:00:00 | False |
| Chris | Paul | Suns | 2018-01-01 00:00:00 | True |
src: pandas dataframe with the source of the SCD
tgt: pandas dataframe with the target of the SCD (target can be empty)
cols_to_track: list of columns to track changes (default is all columns from the source table)
tz: pytz time zone to use on start_ts and end_ts, default is None (will use local time)
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_scd2-1.0.3.tar.gz.
File metadata
- Download URL: pandas_scd2-1.0.3.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48abee966b39b3799a08d381100bac3113b738a0181f37375fcddcbf63b88301
|
|
| MD5 |
bcb2456fccfd132072cae2e6891f096c
|
|
| BLAKE2b-256 |
728b7c17627bac1ca20027423edfb23e44d3f70c1a317ab9ebe8688251dc67c7
|
File details
Details for the file pandas_scd2-1.0.3-py3-none-any.whl.
File metadata
- Download URL: pandas_scd2-1.0.3-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddcff10aeded8c6a37697d9cff8b08f07f0eb6e4fc1061f17794ffa847f1c0f6
|
|
| MD5 |
6641b15c173bb12b349844979444ba46
|
|
| BLAKE2b-256 |
3d305515e28d27571a72ffd01c850bc0be85dcb71d0fcd73fd423ac4e22cfe80
|