Skip to main content

Add your description here

Project description

l4v1

l4v1 is a Python library designed to simplify some data-analytics tasks using data manipulation and visualization techniques. Built on top of Polars and Plotly, it offers a straightforward API for creating detailed summaries in a quick way. It is work in progress and more functionality is to be added in future.

Installation

You can install the l4v1 package directly from PyPI:

pip install l4v1

Usage

Impact Analysis

Impact Table

The impact_table function allows you to perform comparative analysis between two datasets—your primary dataset and a comparison dataset. This function is versatile, suitable for various analyses including period-to-period comparisons, budget vs. actual evaluations, or any scenario where understanding the drivers of change in an outcome metric (like revenue, orders, or any quantifiable metric) is crucial.

By specifying group dimensions, a volume metric (e.g., sales units or website visits), and an outcome metric (e.g., revenue, orders), you can dissect the contributing factors to performance variations. This tool is invaluable for identifying why certain metrics have increased or decreased compared to another period or benchmark.

Here's an example of how to use impact_table to compare week-to-week sales data, focusing on differences across product categories:

import polars as pl
from l4v1 import impact_table

# Load your datasets
sales_week1 = pl.read_csv("data/sales_week1.csv")
sales_week2 = pl.read_csv("data/sales_week2.csv")

# Perform the impact analysis
# Note, the primary and comparison DFs must be in the same format
impact_df = impact_table(
    df_primary=sales_week2, # Data to analyse
    df_comparison=sales_week1, # Data to compare against
    group_by_columns=["product_category"], # Dimension(s) to use
    volume_metric_name="item_quantity", # Column name containing volume (e.g. quantity)
    outcome_metric_name="revenue" # Column name containing outcome (e.g. revenue)
)

Impact Plot

After generating an impact table, you can visualize the results with impact_plot. This function creates a waterfall plot that highlights how different groups contributed to the overall change in outcomes:

from l4v1 import impact_plot

# Visualize the impact analysis
fig = impact_plot(
    impact_table=impact_df,
    format_data_labels="{:,.0f}€", # Optional data label format, e.g. 1050.123 >> 1,050€
    primary_total_label="Revenue Week 2", # Optional label
    comparison_total_label="Revenue Week 1", # Optional label
    title="Impact Analysis Example", # Optional title
    color_total="lightgray", # Optional for total bar colors
    color_increase="#00AF00", # Optional for increase bar color
    color_decrease="#FF0000" # Optional for decrease bar color
)
fig.show()

This will generate a waterfall plot that illustrates how different product categories impacted in less sales in the week 2.

Impact Plot Example

Interpreting the Results

The impact plot visualizes always three types of impacts rate, volume, and mix impact:

  • Rate Impact: Reflects changes in average values within each category, such as average unit price.
  • Volume Impact: Represents changes in quantity, like the number of units sold.
  • Mix Impact: Indicates shifts in the distribution across categories, such as a larger proportion of sales from high-value items.

Additionally, if there are new or discontinued elements between the datasets, they are categorized under "new" or "old" impacts, signifying their presence in only one of the datasets.

The impact plot aids in understanding the drivers behind revenue changes between the compared datasets.

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

l4v1-0.1.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

l4v1-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file l4v1-0.1.0.tar.gz.

File metadata

  • Download URL: l4v1-0.1.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.2

File hashes

Hashes for l4v1-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3505525b7fef178a008c73379758c69933d5f9e17a7348d001e954303c2e206c
MD5 60572835f079559a9fdbd491caaba7a8
BLAKE2b-256 6c46b948a4b471bfcc41d409801c9709a16262b947c93d36764a7f2e7de56df4

See more details on using hashes here.

File details

Details for the file l4v1-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: l4v1-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.2

File hashes

Hashes for l4v1-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2886eb15ab6a9106ab161a897339833346fed48b9112582b6da0ec84a177d23
MD5 68af1de3e2810a124a2a85afeeb3c96a
BLAKE2b-256 b7990ec5785f6e4a53190fbddf29ade5b397f8101b091b56761cd27a68ab192b

See more details on using hashes here.

Supported by

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