direl-ts-tool-kit 0.4.4__py3-none-any.whl → 0.4.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- direl_ts_tool_kit/plot/plot_ts.py +1 -1
- direl_ts_tool_kit/utilities/data_prep.py +4 -2
- direl_ts_tool_kit-0.4.7.dist-info/METADATA +96 -0
- direl_ts_tool_kit-0.4.7.dist-info/RECORD +11 -0
- {direl_ts_tool_kit-0.4.4.dist-info → direl_ts_tool_kit-0.4.7.dist-info}/licenses/LICENCE +0 -0
- {direl_ts_tool_kit-0.4.4.dist-info → direl_ts_tool_kit-0.4.7.dist-info}/top_level.txt +0 -0
- direl_ts_tool_kit-0.4.4.dist-info/METADATA +0 -53
- direl_ts_tool_kit-0.4.4.dist-info/RECORD +0 -11
- {direl_ts_tool_kit-0.4.4.dist-info → direl_ts_tool_kit-0.4.7.dist-info}/WHEEL +0 -0
|
@@ -26,7 +26,7 @@ def plot_time_series(
|
|
|
26
26
|
Defaults to "BLUE_LINES".
|
|
27
27
|
time_unit : str, optional
|
|
28
28
|
The time granularity of the data to define x-axis tick locators.
|
|
29
|
-
Options include 'Year', 'Month', 'Weekday', or '
|
|
29
|
+
Options include 'Year', 'Month', 'Weekday', 'Day' or 'Hour'. Defaults to "Year".
|
|
30
30
|
rot : int, optional
|
|
31
31
|
Rotation angle (in degrees) for the x-axis tick labels. Defaults to 90.
|
|
32
32
|
auto_format_label : bool, optional
|
|
@@ -114,13 +114,15 @@ def reindex_and_aggregate(df_ts, column_name, freq="MS"):
|
|
|
114
114
|
implicitly after the `groupby`).
|
|
115
115
|
"""
|
|
116
116
|
|
|
117
|
-
date_aux = generate_dates(df_ts, freq=
|
|
117
|
+
date_aux = generate_dates(df_ts, freq=freq)
|
|
118
118
|
df_date = pd.DataFrame({"date_aux": date_aux})
|
|
119
119
|
df_ts = df_ts.groupby(["date"]).sum().reset_index()
|
|
120
120
|
|
|
121
121
|
result = pd.merge(df_ts, df_date, left_on="date", right_on="date_aux", how="outer")
|
|
122
122
|
df_ts_new = result[["date_aux", column_name]]
|
|
123
|
-
df_ts_new.
|
|
123
|
+
df_ts_new = df_ts_new.rename(columns={"date_aux": "date"})
|
|
124
|
+
df_ts_new.set_index(df_ts_new["date"], inplace=True)
|
|
125
|
+
df_ts_new.drop(columns=[df_ts_new.index.name], inplace=True)
|
|
124
126
|
df_ts_new.notnull().apply(pd.Series.value_counts)
|
|
125
127
|
|
|
126
128
|
return df_ts_new
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: direl-ts-tool-kit
|
|
3
|
+
Version: 0.4.7
|
|
4
|
+
Summary: A toolbox for time series analysis and visualization.
|
|
5
|
+
Home-page: https://gitlab.com/direl/direl_tool_kit
|
|
6
|
+
Author: Diego Restrepo-Leal
|
|
7
|
+
Author-email: diegorestrepoleal@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENCE
|
|
17
|
+
Requires-Dist: pandas>=1.0.0
|
|
18
|
+
Requires-Dist: numpy>=1.18.0
|
|
19
|
+
Requires-Dist: matplotlib>=3.0.0
|
|
20
|
+
Requires-Dist: openpyxl
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: description-content-type
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
Dynamic: requires-dist
|
|
29
|
+
Dynamic: requires-python
|
|
30
|
+
Dynamic: summary
|
|
31
|
+
|
|
32
|
+
# direl-ts-tool-kit
|
|
33
|
+
> A Toolbox for Time Series Analysis and Visualization
|
|
34
|
+
|
|
35
|
+
A lightweight Python library developed to streamline common tasks in time series processing, including data preparation,
|
|
36
|
+
visualization with a consistent aesthetic style, and handling irregular indices.
|
|
37
|
+
|
|
38
|
+
## Key features and functions
|
|
39
|
+
|
|
40
|
+
The library provides the following key functionalities, primarily centered around data preparation and plotting.
|
|
41
|
+
|
|
42
|
+
### Data preparation and index management
|
|
43
|
+
#### parse_datetime_index
|
|
44
|
+
`parse_datetime_index(df_raw, date_column="date", format=None)`
|
|
45
|
+
|
|
46
|
+
Parses a specified column into datetime objects and sets it as the DataFrame index.
|
|
47
|
+
|
|
48
|
+
This function prepares raw data for time series analysis by ensuring the
|
|
49
|
+
DataFrame is indexed by the correct datetime type.
|
|
50
|
+
|
|
51
|
+
#### generate_dates
|
|
52
|
+
`generate_dates(df_ts, freq="MS")`
|
|
53
|
+
|
|
54
|
+
Generates a continuous DatetimeIndex covering the time span of the input DataFrame.
|
|
55
|
+
|
|
56
|
+
The function determines the start and end dates from the existing DataFrame index
|
|
57
|
+
and creates a new, regular date sequence based on the specified frequency.
|
|
58
|
+
|
|
59
|
+
#### reindex_and_aggregate
|
|
60
|
+
`reindex_and_aggregate(df_ts, column_name, freq="MS")`
|
|
61
|
+
|
|
62
|
+
Re-indexes a time series DataFrame to a regular frequency, aggregates values,
|
|
63
|
+
and introduces NaN for missing time steps.
|
|
64
|
+
|
|
65
|
+
This function first identifies the time range from the original (potentially irregular)
|
|
66
|
+
index, aggregates data if necessary (e.g., if multiple entries exist per time step),
|
|
67
|
+
and then merges the data onto a complete date range, effectively filling gaps
|
|
68
|
+
with NaN values.
|
|
69
|
+
|
|
70
|
+
#### remove_outliers_by_threshold
|
|
71
|
+
`remove_outliers_by_threshold(df_ts, column_name, lower_bound, upper_bound)`
|
|
72
|
+
|
|
73
|
+
Replaces values in a specified column with NaN if they fall outside a defined range (outlier removal).
|
|
74
|
+
|
|
75
|
+
This function identifies data points that are either below the lower
|
|
76
|
+
bound or above the upper bound and treats them as missing data.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Visualization and styling
|
|
80
|
+
|
|
81
|
+
#### plot_time_series
|
|
82
|
+
`plot_time_series(df_ts, variable, units="", color="BLUE_LINES", time_unit="Year", rot=90, auto_format_label=True)`
|
|
83
|
+
|
|
84
|
+
Plots a time series with custom styling and dual-level grid visibility.
|
|
85
|
+
|
|
86
|
+
This function automatically sets major and minor time-based locators
|
|
87
|
+
on the x-axis based on the specified time unit, and formats the y-axis
|
|
88
|
+
to use scientific notation.
|
|
89
|
+
|
|
90
|
+
#### save_figure
|
|
91
|
+
`save_figure(fig, file_name, variable_name="", path="./")`
|
|
92
|
+
|
|
93
|
+
Saves a Matplotlib figure in three common high-quality formats (PNG, PDF, SVG).
|
|
94
|
+
|
|
95
|
+
The function creates a consistent file name structure:
|
|
96
|
+
{path}/{file_name}_{variable_name}.{extension}.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
direl_ts_tool_kit/__init__.py,sha256=W99Wd3BeEFKOxT51TApURElbDJvqIjD8u_-qDoCYSJ0,94
|
|
2
|
+
direl_ts_tool_kit/plot/__init__.py,sha256=CMwyv-kiE74nwr3MJPL7gWIJmcfZ8UQCRu7mBGGQ4rI,49
|
|
3
|
+
direl_ts_tool_kit/plot/plot_style.py,sha256=vhzcDa3LzgkHuy-GnliofGZ8TDntkm3_1C5kgl2Gx3E,1010
|
|
4
|
+
direl_ts_tool_kit/plot/plot_ts.py,sha256=Fi_J-5qyDxcR-Z6sRHksn1e5QZcKqITGbpH3-bAX-Jw,5015
|
|
5
|
+
direl_ts_tool_kit/utilities/__init__.py,sha256=jMtxYZUtwlhgI99sxe_8MMzsDnxtbTP7Ivh9tUOeIwQ,25
|
|
6
|
+
direl_ts_tool_kit/utilities/data_prep.py,sha256=k3eOwQEEd5mxy2DtT_Gdo7BhkzEmSQqvMJ89y8mH5CQ,6024
|
|
7
|
+
direl_ts_tool_kit-0.4.7.dist-info/licenses/LICENCE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
direl_ts_tool_kit-0.4.7.dist-info/METADATA,sha256=_dkAzfvanVsIlFE8IaNZyrODe85qLKNTBdrxLAkcLjk,3536
|
|
9
|
+
direl_ts_tool_kit-0.4.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
direl_ts_tool_kit-0.4.7.dist-info/top_level.txt,sha256=vMCRudnGnsdRg_6fUftnG8PF2Y1m0bjBDMf3pCAp6bc,18
|
|
11
|
+
direl_ts_tool_kit-0.4.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: direl-ts-tool-kit
|
|
3
|
-
Version: 0.4.4
|
|
4
|
-
Summary: A toolbox for time series analysis and visualization.
|
|
5
|
-
Home-page: https://gitlab.com/direl/direl_tool_kit
|
|
6
|
-
Author: Diego Restrepo-Leal
|
|
7
|
-
Author-email: diegorestrepoleal@gmail.com
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Intended Audience :: Science/Research
|
|
13
|
-
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
14
|
-
Requires-Python: >=3.8
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
License-File: LICENCE
|
|
17
|
-
Requires-Dist: pandas>=1.0.0
|
|
18
|
-
Requires-Dist: numpy>=1.18.0
|
|
19
|
-
Requires-Dist: matplotlib>=3.0.0
|
|
20
|
-
Requires-Dist: openpyxl
|
|
21
|
-
Dynamic: author
|
|
22
|
-
Dynamic: author-email
|
|
23
|
-
Dynamic: classifier
|
|
24
|
-
Dynamic: description
|
|
25
|
-
Dynamic: description-content-type
|
|
26
|
-
Dynamic: home-page
|
|
27
|
-
Dynamic: license-file
|
|
28
|
-
Dynamic: requires-dist
|
|
29
|
-
Dynamic: requires-python
|
|
30
|
-
Dynamic: summary
|
|
31
|
-
|
|
32
|
-
# direl-ts-tool-kit: A Toolbox for Time Series Analysis and Visualization
|
|
33
|
-
A lightweight Python library developed to streamline common tasks in time series processing, including data preparation,
|
|
34
|
-
visualization with a consistent aesthetic style, and handling irregular indices.
|
|
35
|
-
|
|
36
|
-
## Key features and functions
|
|
37
|
-
|
|
38
|
-
The library provides the following key functionalities, primarily centered around data preparation and plotting.
|
|
39
|
-
|
|
40
|
-
### Data preparation and index management
|
|
41
|
-
|
|
42
|
-
| Function | Description |
|
|
43
|
-
|---------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
44
|
-
| parse_datetime_index(df_raw, date_column, format) | Converts a specified column (defaults to "date") from a raw DataFrame into a proper DatetimeIndex. It handles specific format strings to ensure correct date parsing, and returns the cleaned, indexed DataFrame. |
|
|
45
|
-
| generate_dates(df_ts, freq) | Creates a complete and regular pd.DatetimeIndex spanning from the first to the last date found in the input DataFrame's index. This is primarily used to define a target index for reindexing operations. |
|
|
46
|
-
| reindex_and_aggregate(df_ts, column_name) | Aligns an irregularly indexed time series DataFrame to a regular frequency. It aggregates data within each time step (e.g., calculates the mean) and fills any resulting time gaps with NaN values. |
|
|
47
|
-
|
|
48
|
-
### Visualization and styling
|
|
49
|
-
|
|
50
|
-
| Function | Description |
|
|
51
|
-
|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
52
|
-
| plot_time_series(df_ts, variable, ...) | Generates a customizable time series plot using Matplotlib. It automatically handles x-axis localization based on time_unit (Year, Month, etc.), applies a consistent aesthetic style, and supports automatic formatting of the Y-axis label. |
|
|
53
|
-
| paper_colors (Dictionary) | A global dictionary containing a predefined palette of high-contrast, professional color codes (hex values). These color keys (e.g., "BLUE_LINES", "ORANGE_BARS") are used to ensure visual consistency across all generated plots. |
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
direl_ts_tool_kit/__init__.py,sha256=W99Wd3BeEFKOxT51TApURElbDJvqIjD8u_-qDoCYSJ0,94
|
|
2
|
-
direl_ts_tool_kit/plot/__init__.py,sha256=CMwyv-kiE74nwr3MJPL7gWIJmcfZ8UQCRu7mBGGQ4rI,49
|
|
3
|
-
direl_ts_tool_kit/plot/plot_style.py,sha256=vhzcDa3LzgkHuy-GnliofGZ8TDntkm3_1C5kgl2Gx3E,1010
|
|
4
|
-
direl_ts_tool_kit/plot/plot_ts.py,sha256=OPmdaXGUv_oNaXQ4epiPX1fKTtxyaWuoGfHPa5if96U,5008
|
|
5
|
-
direl_ts_tool_kit/utilities/__init__.py,sha256=jMtxYZUtwlhgI99sxe_8MMzsDnxtbTP7Ivh9tUOeIwQ,25
|
|
6
|
-
direl_ts_tool_kit/utilities/data_prep.py,sha256=rEBRr4SDc2oAlpHB3_cjjn-u0JSAwhzVxNEQ7pQCRc4,5900
|
|
7
|
-
direl_ts_tool_kit-0.4.4.dist-info/licenses/LICENCE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
direl_ts_tool_kit-0.4.4.dist-info/METADATA,sha256=XQJDtkSqf341qUVR3haRDVxmcQxT1cwQn9Kj76MdMWE,3931
|
|
9
|
-
direl_ts_tool_kit-0.4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
direl_ts_tool_kit-0.4.4.dist-info/top_level.txt,sha256=vMCRudnGnsdRg_6fUftnG8PF2Y1m0bjBDMf3pCAp6bc,18
|
|
11
|
-
direl_ts_tool_kit-0.4.4.dist-info/RECORD,,
|
|
File without changes
|