direl-ts-tool-kit 0.3.0__tar.gz → 0.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: direl-ts-tool-kit
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: A toolbox for time series analysis and visualization.
5
5
  Home-page: https://gitlab.com/direl/direl_tool_kit
6
6
  Author: Diego Restrepo-Leal
@@ -100,6 +100,10 @@ def plot_time_series(
100
100
  if time_unit == "Day":
101
101
  ax.xaxis.set_major_locator(mdates.DayLocator())
102
102
  ax.xaxis.set_minor_locator(mdates.HourLocator())
103
+
104
+ if time_unit == "Hour":
105
+ ax.xaxis.set_major_locator(mdates.HourLocator())
106
+ ax.xaxis.set_minor_locator(mdates.MinuteLocator())
103
107
 
104
108
  ax.tick_params(axis="x", rotation=rot)
105
109
  ax.grid(which="both")
@@ -1,12 +1,12 @@
1
1
  import pandas as pd
2
2
 
3
3
 
4
- def parse_datetime_index(df_raw, date_column="date"):
4
+ def parse_datetime_index(df_raw, date_column="date", format=None):
5
5
  """
6
6
  Parses a specified column into datetime objects and sets it as the DataFrame index.
7
7
 
8
- This function is crucial for preparing raw data (df_raw) for time series analysis
9
- by ensuring the DataFrame is indexed by the correct datetime type.
8
+ This function prepares raw data for time series analysis by ensuring the
9
+ DataFrame is indexed by the correct datetime type.
10
10
 
11
11
  Parameters
12
12
  ----------
@@ -15,17 +15,24 @@ def parse_datetime_index(df_raw, date_column="date"):
15
15
  date_column : str, optional
16
16
  The name of the column in 'df_raw' that contains the date/time information.
17
17
  Defaults to "date".
18
+ format : str, optional
19
+ The explicit format string (e.g., '%Y%m%d', '%Y-%m-%d %H:%M:%S')
20
+ to parse the dates, passed to `pd.to_datetime`. If None (default),
21
+ Pandas attempts to infer the format automatically.
18
22
 
19
23
  Returns
20
24
  -------
21
25
  df_ts : pd.DataFrame
22
- A copy of the original DataFrame with the specified date column removed
23
- and set as the DatetimeIndex. Ready for time series plotting.
26
+ A copy of the original DataFrame with the specified date column removed
27
+ and set as the DatetimeIndex. The returned DataFrame is ready for
28
+ time series operations.
24
29
  """
30
+ if not format:
31
+ date_parsed = pd.to_datetime(df_raw[date_column])
32
+ else:
33
+ date_parsed = pd.to_datetime(df_raw[date_column], format=format)
25
34
 
26
- date_parsed = pd.to_datetime(df_raw[date_column])
27
35
  df_ts = df_raw.copy()
28
- original_dates = df_raw[date_column]
29
36
  df_ts.drop(columns=[date_column], inplace=True)
30
37
  df_ts.set_index(date_parsed, inplace=True)
31
38
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: direl-ts-tool-kit
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: A toolbox for time series analysis and visualization.
5
5
  Home-page: https://gitlab.com/direl/direl_tool_kit
6
6
  Author: Diego Restrepo-Leal
@@ -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.3.0",
5
+ version="0.3.2",
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",