direl-ts-tool-kit 0.4.4__tar.gz → 0.4.7__tar.gz

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.
Files changed (19) hide show
  1. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/LICENCE +0 -0
  2. direl_ts_tool_kit-0.4.7/PKG-INFO +96 -0
  3. direl_ts_tool_kit-0.4.7/README.md +65 -0
  4. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit/__init__.py +0 -0
  5. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit/plot/__init__.py +0 -0
  6. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit/plot/plot_style.py +0 -0
  7. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit/plot/plot_ts.py +1 -1
  8. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit/utilities/__init__.py +0 -0
  9. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit/utilities/data_prep.py +4 -2
  10. direl_ts_tool_kit-0.4.7/direl_ts_tool_kit.egg-info/PKG-INFO +96 -0
  11. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit.egg-info/SOURCES.txt +0 -0
  12. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit.egg-info/dependency_links.txt +0 -0
  13. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit.egg-info/requires.txt +0 -0
  14. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/direl_ts_tool_kit.egg-info/top_level.txt +0 -0
  15. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/setup.cfg +0 -0
  16. {direl_ts_tool_kit-0.4.4 → direl_ts_tool_kit-0.4.7}/setup.py +1 -1
  17. direl_ts_tool_kit-0.4.4/PKG-INFO +0 -53
  18. direl_ts_tool_kit-0.4.4/README.md +0 -22
  19. direl_ts_tool_kit-0.4.4/direl_ts_tool_kit.egg-info/PKG-INFO +0 -53
@@ -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,65 @@
1
+ # direl-ts-tool-kit
2
+ > A Toolbox for Time Series Analysis and Visualization
3
+
4
+ A lightweight Python library developed to streamline common tasks in time series processing, including data preparation,
5
+ visualization with a consistent aesthetic style, and handling irregular indices.
6
+
7
+ ## Key features and functions
8
+
9
+ The library provides the following key functionalities, primarily centered around data preparation and plotting.
10
+
11
+ ### Data preparation and index management
12
+ #### parse_datetime_index
13
+ `parse_datetime_index(df_raw, date_column="date", format=None)`
14
+
15
+ Parses a specified column into datetime objects and sets it as the DataFrame index.
16
+
17
+ This function prepares raw data for time series analysis by ensuring the
18
+ DataFrame is indexed by the correct datetime type.
19
+
20
+ #### generate_dates
21
+ `generate_dates(df_ts, freq="MS")`
22
+
23
+ Generates a continuous DatetimeIndex covering the time span of the input DataFrame.
24
+
25
+ The function determines the start and end dates from the existing DataFrame index
26
+ and creates a new, regular date sequence based on the specified frequency.
27
+
28
+ #### reindex_and_aggregate
29
+ `reindex_and_aggregate(df_ts, column_name, freq="MS")`
30
+
31
+ Re-indexes a time series DataFrame to a regular frequency, aggregates values,
32
+ and introduces NaN for missing time steps.
33
+
34
+ This function first identifies the time range from the original (potentially irregular)
35
+ index, aggregates data if necessary (e.g., if multiple entries exist per time step),
36
+ and then merges the data onto a complete date range, effectively filling gaps
37
+ with NaN values.
38
+
39
+ #### remove_outliers_by_threshold
40
+ `remove_outliers_by_threshold(df_ts, column_name, lower_bound, upper_bound)`
41
+
42
+ Replaces values in a specified column with NaN if they fall outside a defined range (outlier removal).
43
+
44
+ This function identifies data points that are either below the lower
45
+ bound or above the upper bound and treats them as missing data.
46
+
47
+
48
+ ### Visualization and styling
49
+
50
+ #### plot_time_series
51
+ `plot_time_series(df_ts, variable, units="", color="BLUE_LINES", time_unit="Year", rot=90, auto_format_label=True)`
52
+
53
+ Plots a time series with custom styling and dual-level grid visibility.
54
+
55
+ This function automatically sets major and minor time-based locators
56
+ on the x-axis based on the specified time unit, and formats the y-axis
57
+ to use scientific notation.
58
+
59
+ #### save_figure
60
+ `save_figure(fig, file_name, variable_name="", path="./")`
61
+
62
+ Saves a Matplotlib figure in three common high-quality formats (PNG, PDF, SVG).
63
+
64
+ The function creates a consistent file name structure:
65
+ {path}/{file_name}_{variable_name}.{extension}.
@@ -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 'Day'. Defaults to "Year".
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="MS")
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.set_index(df_ts_new["date_aux"], inplace=True)
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}.
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="direl-ts-tool-kit",
5
- version="0.4.4",
5
+ version="0.4.7",
6
6
  description="A toolbox for time series analysis and visualization.",
7
7
  long_description=open("README.md", encoding="utf-8").read(),
8
8
  long_description_content_type="text/markdown",
@@ -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,22 +0,0 @@
1
- # direl-ts-tool-kit: A Toolbox for Time Series Analysis and Visualization
2
- A lightweight Python library developed to streamline common tasks in time series processing, including data preparation,
3
- visualization with a consistent aesthetic style, and handling irregular indices.
4
-
5
- ## Key features and functions
6
-
7
- The library provides the following key functionalities, primarily centered around data preparation and plotting.
8
-
9
- ### Data preparation and index management
10
-
11
- | Function | Description |
12
- |---------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
13
- | 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. |
14
- | 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. |
15
- | 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. |
16
-
17
- ### Visualization and styling
18
-
19
- | Function | Description |
20
- |----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
21
- | 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. |
22
- | 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,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. |