Simple, expressive pipeline syntax to transform and manipulate data with ease
Project description
viper
Simple, expressive pipeline syntax to transform and manipulate data with ease
Overview
viper
is a Python package that provides a simple, expressive way to work with data. It allows you to easily manipulate and transform data using a pipeline syntax similar to that of dplyr.
Pipelining your DataFrame manipulation operations offers several benefits:
- improved code readability (no need to 'comment the what')
- no need to save intermediate dataframes
- ability to chain a long sequence of operations in a single command
- thinking of coding as a series of transformations between the input and the desired output can improve the design and make it less coupled
Docs
Complete documentation and reference are available on the package's site.
Quick Start
Installation:
pip install viper-df
Here is an example of how to use viper
to analyze the famed mtcars
dataset.
We want to find:
- the average consumption, expressed in Miles/(US) gallon
- the average power
Furthermore:
- only consider those cars that weigh more than 2000lbs
- group the results by the number of cylinders and number of gears
- arrange in descending orders by the grouping variables
import viper as v
from viper.data import mtcars
v.pipeline(
mtcars,
v.rename(
"hp = power",
"mpg = consumption",
),
v.mutate(
consumption=lambda r: 1 / r["consumption"]
),
v.filter(
lambda r: r["wt"] > 2
),
v.group_by("cyl", "gear"),
v.summarize(
"power = mean()",
"consumption = mean()"
),
v.arrange(
"cyl desc",
"gear desc"
),
)
# power consumption
# cyl gear
# 8 5 299.500000 0.064979
# 3 194.166667 0.068824
# 6 5 175.000000 0.050761
# 4 116.500000 0.050875
# 3 107.500000 0.050989
# 4 5 91.000000 0.038462
# 4 85.000000 0.041259
# 3 97.000000 0.046512
Here you can find more examples, particularly on joins.
Roadmap
The future development of the package will probably focus on:
- adding
pivot_longer
andpivot_wider
functions - adding more
join_*
functions
Contributions
You are welcome to contribute to the project or open issues if you have any ideas.
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
File details
Details for the file viper_df-0.0.7.tar.gz
.
File metadata
- Download URL: viper_df-0.0.7.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2006a101abfbb49abbff371f8f7ffdfa4737a9908cd454b30e26c09892447741 |
|
MD5 | c49911aaa99acc69e505bd0937b29486 |
|
BLAKE2b-256 | d14d32961c648b1d9c3951c401bd621018d074c3952ca4508ae320d46ad896b0 |
File details
Details for the file viper_df-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: viper_df-0.0.7-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 623b116e706100be38057b23d69a980ca45dcf541c3b77fa2f6a9794dd770b26 |
|
MD5 | 42bb03836e606a76e168d9fc1a795a79 |
|
BLAKE2b-256 | 3cbcca27080425e31df008b8fed2cbcb44ac4572589c773b278ded2b2ec1e587 |