Skip to main content

A toolbox for time series analysis and visualization.

Project description

direl-ts-tool-kit

A Toolbox for Time Series Analysis and Visualization

A lightweight Python library developed to streamline common tasks in time series processing, including data preparation, visualization with a consistent aesthetic style, and handling irregular indices.

Key features and functions

The library provides the following key functionalities, primarily centered around data preparation and plotting.

Data preparation and index management

parse_datetime_index

parse_datetime_index(df_raw, date_column="date", format=None)

Parses a specified column into datetime objects and sets it as the DataFrame index.

This function prepares raw data for time series analysis by ensuring the DataFrame is indexed by the correct datetime type.

generate_dates

generate_dates(df_ts, freq="MS")

Generates a continuous DatetimeIndex covering the time span of the input DataFrame.

The function determines the start and end dates from the existing DataFrame index and creates a new, regular date sequence based on the specified frequency.

reindex_and_aggregate

reindex_and_aggregate(df_ts, column_name, freq="MS")

Re-indexes a time series DataFrame to a regular frequency, aggregates values, and introduces NaN for missing time steps.

This function first identifies the time range from the original (potentially irregular) index, aggregates data if necessary (e.g., if multiple entries exist per time step), and then merges the data onto a complete date range, effectively filling gaps with NaN values.

remove_outliers_by_threshold

remove_outliers_by_threshold(df_ts, column_name, lower_bound, upper_bound)

Replaces values in a specified column with NaN if they fall outside a defined range (outlier removal).

This function identifies data points that are either below the lower bound or above the upper bound and treats them as missing data.

Visualization and styling

plot_time_series

plot_time_series(df_ts, variable, units="", color="BLUE_LINES", time_unit="Year", rot=90, auto_format_label=True)

Plots a time series with custom styling and dual-level grid visibility.

This function automatically sets major and minor time-based locators on the x-axis based on the specified time unit, and formats the y-axis to use scientific notation.

save_figure

save_figure(fig, file_name, variable_name="", path="./")

Saves a Matplotlib figure in three common high-quality formats (PNG, PDF, SVG).

The function creates a consistent file name structure: {path}/{file_name}_{variable_name}.{extension}.

Examples

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

direl_ts_tool_kit-0.4.9.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

direl_ts_tool_kit-0.4.9-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file direl_ts_tool_kit-0.4.9.tar.gz.

File metadata

  • Download URL: direl_ts_tool_kit-0.4.9.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for direl_ts_tool_kit-0.4.9.tar.gz
Algorithm Hash digest
SHA256 93d3cb61e962ff3d72f8558290b7327da5f1b8af4339525b3f8f6e3fa71bd91b
MD5 417c057c46323a0805a80b2843f4eba3
BLAKE2b-256 b9f609d0f99c6b187595d9ab83a6916868e7117a51eec34848b299ef4f3a02c6

See more details on using hashes here.

File details

Details for the file direl_ts_tool_kit-0.4.9-py3-none-any.whl.

File metadata

File hashes

Hashes for direl_ts_tool_kit-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5897543944ef41a61651d76a80201b4b085ca0284efe90cc82b0c7178110d5b3
MD5 c599dce8123586417e61d2025cf2c7f7
BLAKE2b-256 f7df5c1c5baa735c5f505dacd6df25ff7043877741aace99d2151db2acb9f3ad

See more details on using hashes here.

Supported by

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