Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PyTrendy Logo

PyTrendy

PyPI version Python License: MIT
Tests Release
codecov Downloads

PyTrendy is a robust solution for identifying and analysing trends in time series. Unlike other trend detection packages, it is robust to noisy and flat segments, and handles gradual and abrupt trend cases with high precision. It aims to be the best package for trend detection in Python.

Read more in the documentation: russellsb.github.io/pytrendy/main

Why PyTrendy?

Most time series tools give you either a "trend component" (via decomposition) or "changepoints" (the moments of shift). PyTrendy is built for automated trend detection, answering what trends existed, how strong were they, and when did they start and end?

  • Beyond step changes - ruptures is the gold standard for abrupt shifts, but it doesn't handle gradual slope changes (digital marketing, stocks, energy). PyTrendy detects both in a single run.
  • The flat/noise problem - closest peers (pytrendseries, trendet, tstrends) over-fit trends on flat or noisy periods. PyTrendy's signal-processing and post-processing logic ensures trends are only detected when they are precise and valid.
  • Strategic value - where dozens of time series interact, knowing how they align or confound at specific times is invaluable for experiment design.

Features

Quickstart

Install the package from PyPi.

pip install pytrendy

Import pytrendy, and apply trend detection on daily time series data.

import pytrendy as pt
df = pt.load_data('series_synthetic')
results = pt.detect_trends(df, date_col='date', value_col='gradual', plot=True)
results.print_summary()

Detected: 
- 3 Uptrends. 
- 3 Downtrends.
- 2 Flats.
- 0 Noise.

The best detected trend is Down between dates 2025-05-09 - 2025-06-17

Full Results:
-------------------------------------------------------------------------------
            direction       start         end  steps  total_change  change_rank trend_class
time_index                                                                                
1                 Up  2025-01-02  2025-01-24     22     14.013348            5     gradual
2               Down  2025-01-25  2025-02-05     11    -13.564214            6     gradual
3               Flat  2025-02-06  2025-02-09      3     -1.168831            8         NaN
4                 Up  2025-02-10  2025-03-17     35     26.190476            3     gradual
5               Down  2025-03-18  2025-04-01     14    -22.721861            4     gradual
6                 Up  2025-04-02  2025-05-08     36     72.611833            2     gradual
7               Down  2025-05-09  2025-06-17     39    -73.253968            1     gradual
8               Flat  2025-06-18  2025-06-30     12      3.910534            7         NaN
-------------------------------------------------------------------------------

Explore the strongest uptrends:

results.filter_segments(direction='Up', sort_by='change_rank')[:3]
time_index direction start end trend_class pct_change steps total_change SNR change_rank
7 Up 2025-04-02 2025-05-08 gradual 367.50% 36 72.61 21.70 2
4 Up 2025-02-10 2025-03-17 gradual 179.93% 35 26.19 18.61 3
1 Up 2025-01-02 2025-01-24 gradual 104.41% 22 14.01 22.21 5

filter_segments ranks segments by magnitude (change_rank). See the API reference for all filter and sort options.

For the full per-segment metrics table, use results.df.

For more examples on interpreting the results, see Detect Gradual Trends.

Metadata

Release files for pytrendy 2.0.0.dev9

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

Source distribution (sdist)

Source distribution for pytrendy 2.0.0.dev9
File Size Uploaded Provenance Actions
pytrendy-2.0.0.dev9.tar.gz 50.1 kB With provenance Details for pytrendy-2.0.0.dev9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytrendy 2.0.0.dev9
File Interpreter ABI Platform Actions
pytrendy-2.0.0.dev9-py3-none-any.whl Python 3 none any Details for pytrendy-2.0.0.dev9-py3-none-any.whl

Total release size: 109.0 kB

Release files / pytrendy-2.0.0.dev9.tar.gz

Download URL pytrendy-2.0.0.dev9.tar.gz
Size 50.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9d12b284672b4c5b824fe298d0ddd32c9e972ecf64a7f845e06afae00a5b6e43
BLAKE2b-256 checksum
How to use checksums
2fc6225978011a6a8245e636829f855989c95c1a3f8bfa8a2d4eaf7191b14416
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / pytrendy-2.0.0.dev9-py3-none-any.whl

Download URL pytrendy-2.0.0.dev9-py3-none-any.whl
Size 58.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9640b214d42de3f0ace627bbd4f772a85e97744992af47c0dd52673dcc41a1f1
BLAKE2b-256 checksum
How to use checksums
f8536c3bb1f025f4d787948fd0b7141f0e30dfb3a5e3b3fcb391ee3c5c758226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for pytrendy 2.0.0.dev9

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytrendy-2.0.0.dev9.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

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
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