Skip to main content

pd-window-decorators

Easily apply windowing to functions that mutate Pandas DataFrames. Useful for data science projects where you want to apply a function for a DataFrame using smaller chunks of the DataFrame automatically. A moving window can be easily applied to the function using Python decorators.

Sliding Window

To apply a sliding window, import df_sliding_window from pd_window_decorators and apply it to your function. The decorator takes a timedelta object as a required argument to define the slice size. By default, the decorator will look for a Pandas DataFrame named df in the function arguments. The DataFrame must also have a time column. The column name is ds by default. The decorator also expects the function to return a DataFrame.

Example

Using the decorator with default arguments:

@df_sliding_window(window_size=timedelta(days=2))
def sum_all(df):
    df.loc[:, 'sum'] = df['y'].sum()
    return df

Using the decorator with custom arguments:

@df_sliding_window(window_size=timedelta(days=2), df_name='my_df', time_column='my_time')
def sum_all(my_df):
    df.loc[:, 'sum'] = df['y'].sum()
    return df

Note that in the second example, the DataFrame is named my_df and the df_name argument is set to my_df, so they match.

Arguments

Argument Type Optional Description
window_size timedelta True The size of the window to apply to the function.
df_name str False The name of the DataFrame variable to pass to the function as an argument. Defaults to df.
time_column str False The name of the column in the DataFrame that contains the time information. Defaults to ds.

Metadata

Release files for pd-window-decorators 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pd-window-decorators 0.0.1
File Size Uploaded Provenance Actions
pd-window-decorators-0.0.1.tar.gz 4.3 kB Without provenance Details for pd-window-decorators-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pd-window-decorators 0.0.1
File Interpreter ABI Platform Actions
pd_window_decorators-0.0.1-py3-none-any.whl Python 3 none any Details for pd_window_decorators-0.0.1-py3-none-any.whl

Total release size: 9.3 kB

Release files / pd-window-decorators-0.0.1.tar.gz

Download URL pd-window-decorators-0.0.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dbeb221723c27ede5ac48c353a3655239abafd981875ada97325a6e1f3a516ff
BLAKE2b-256 checksum
How to use checksums
04c2fcac5a0db166ed466f475020e580522cef5c17ff09e34471035650a818df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / pd_window_decorators-0.0.1-py3-none-any.whl

Download URL pd_window_decorators-0.0.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f340d8c3451fe5a863f353a2435a5000ac161989c7f99c5068277528bbe51df
BLAKE2b-256 checksum
How to use checksums
5db0c2299f80cbc714562f182bb0abab8827d24296bb6dca56c0807d084f8ec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for pd-window-decorators 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page