Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas_scd2-1.0.3.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandas_scd2-1.0.3-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

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

Hashes for pandas_scd2-1.0.3.tar.gz
Algorithm Hash digest
SHA256 48abee966b39b3799a08d381100bac3113b738a0181f37375fcddcbf63b88301
MD5 bcb2456fccfd132072cae2e6891f096c
BLAKE2b-256 728b7c17627bac1ca20027423edfb23e44d3f70c1a317ab9ebe8688251dc67c7

See more details on using hashes here.

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

Hashes for pandas_scd2-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ddcff10aeded8c6a37697d9cff8b08f07f0eb6e4fc1061f17794ffa847f1c0f6
MD5 6641b15c173bb12b349844979444ba46
BLAKE2b-256 3d305515e28d27571a72ffd01c850bc0be85dcb71d0fcd73fd423ac4e22cfe80

See more details on using hashes here.

Supported by

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