The time series toolkit for Python
Please ⭐ us on GitHub (it takes 2-seconds and means a lot).
Time series analysis is fundamental in many fields, from business forecasting to scientific research. While the Python ecosystem offers tools like pandas, they sometimes can be verbose and not optimized for all operations, especially for complex time-based aggregations and visualizations.
Enter pytimetk. Crafted with a blend of ease-of-use and computational efficiency, pytimetk significantly simplifies the process of time series manipulation and visualization. By leveraging the polars backend, you can experience speed improvements ranging from 3X to a whopping 30X. Let's dive into a comparative analysis.
| Features/Properties | pytimetk | pandas (+matplotlib) |
|---|---|---|
| Speed | 🚀 3X to 30X Faster | 🐢 Standard |
| Code Simplicity | 🎉 Concise, readable syntax | 📜 Often verbose |
summarize_by_time() |
🕐 2 lines, 13.4X faster | 🕐 6 lines, 2 for-loops |
plot_timeseries() |
🎨 2 lines, no customization | 🎨 16 lines, customization needed |
As evident from the table:
-
summarize_by_time()in pytimetk is not just about speed; it also simplifies your codebase, converting a 6-line, double for-loop routine inpandasinto a concise 2-line operation. -
Similarly,
plot_timeseries()dramatically streamlines the plotting process, encapsulating what would typically require 16 lines ofmatplotlibcode into a mere 2-line command in pytimetk, without sacrificing customization or quality.
Join the revolution in time series analysis. Reduce your code complexity, increase your productivity, and harness the speed that pytimetk brings to your workflows.
Explore more at pytimetk homepage.
Install the latest stable version of pytimetk using pip:
pip install pytimetkAlternatively you can install the development version:
pip install git+https://github.com/business-science/pytimetk.gitThis is a simple code to test the function summarize_by_time:
import pytimetk as tk
import pandas as pd
df = tk.datasets.load_dataset('bike_sales_sample')
df['order_date'] = pd.to_datetime(df['order_date'])
df \
.groupby("category_2") \
.summarize_by_time(
date_column='order_date',
value_column= 'total_price',
freq = "MS",
agg_func = ['mean', 'sum']
)Get started with the pytimetk documentation
To install pytimetk using Poetry, follow these steps:
Make sure you have Python 3.9 or later installed on your system.
To install Poetry, you can use the official installer provided by Poetry. Do not use pip.
Clone the pytimetk repository from GitHub:
git clone https://github.com/business-science/pytimetkUse Poetry to install the package and its dependencies:
poetry installor you can create a virtualenv with poetry and install the dependencies
poetry shell
poetry install