pytrendy 1.4.0.dev5__py3-none-any.whl → 2.0.0.dev2__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.
@@ -3,6 +3,7 @@
3
3
  import pandas as pd
4
4
  import numpy as np
5
5
 
6
+
6
7
  def analyse_segments(df: pd.DataFrame, value_col: str, segments: list[dict]) -> list[dict]:
7
8
  """
8
9
  Enhances trend segments with quantitative metrics and rankings.
@@ -16,7 +17,7 @@ def analyse_segments(df: pd.DataFrame, value_col: str, segments: list[dict]) ->
16
17
 
17
18
  Metrics added include:
18
19
 
19
- - Absolute and percent change (based on start/end values)
20
+ - Percent change (based on start/end values)
20
21
 
21
22
  - Duration in days
22
23
 
@@ -39,18 +40,18 @@ def analyse_segments(df: pd.DataFrame, value_col: str, segments: list[dict]) ->
39
40
  Returns:
40
41
  list:
41
42
  A list of enhanced segment dictionaries with additional keys:
42
- - `'change'`, `'pct_change'`, `'days'`, `'total_change'`, `'SNR'`, `'change_rank'`
43
+ - `'total_change'`, `'pct_change'`, `'mltp_change'`, `'days'`, `'SNR'`, `'change_rank'`
43
44
  """
44
45
  segments_enhanced = []
45
46
  for segment in segments:
46
47
  segment_enhanced = segment.copy()
47
48
  df_segment = df.loc[segment['start']:segment['end']]
48
49
 
49
- # Calculate absolute and relative change from first point to last point of trend.
50
+ # Calculate relative change from first point to last point of trend.
50
51
  val_start = df_segment[value_col].iloc[0]
51
52
  val_end = df_segment[value_col].iloc[-1]
52
- segment_enhanced['change'] = float(val_end - val_start)
53
53
  segment_enhanced['pct_change'] = (float(val_end / val_start - 1) if val_start != 0 else np.nan)
54
+ segment_enhanced['mltp_change'] = (float(val_end / val_start) if val_start != 0 else np.nan)
54
55
 
55
56
  # Calculate days & cumulative total change
56
57
  days = segment['end'] - segment['start']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytrendy
3
- Version: 1.4.0.dev5
3
+ Version: 2.0.0.dev2
4
4
  Summary: Trend Detection in Python. Applicable for real-world industry use cases in time series.
5
5
  License: MIT License
6
6
 
@@ -8,7 +8,7 @@ pytrendy/io/plot_pytrendy.py,sha256=U2tPKypgfYXnfixS2loB1JZETA3dot-bvmA_xNu4gK0,
8
8
  pytrendy/io/prepare_index.py,sha256=QTquO_iktcx6UKRduVfdT5oTBlHJtStGMJnniBG4f-Q,8345
9
9
  pytrendy/io/results_pytrendy.py,sha256=h5Frarg6FpCORHP3s7a7t85lBkv8A0n0OqXc3yFFyNw,8384
10
10
  pytrendy/post_processing/__init__.py,sha256=bvn1pcxRAoyq5C1P7v5gnb6HiPzteyxT3y9dOY8Pemc,2569
11
- pytrendy/post_processing/segments_analyse.py,sha256=xVmY9vInxhkbgolPsDLHEwhrXAXStuPIhT9wtbMBFAU,3171
11
+ pytrendy/post_processing/segments_analyse.py,sha256=qkZHWQTl1LRz0W81VQdvO9yPgDwbp7Gj4wFZeOE6Rw4,3188
12
12
  pytrendy/post_processing/segments_get.py,sha256=A7fc2BPkEPTOUCDX7R3eX-6mWmQV8YKIS-I70ji7Ev0,2552
13
13
  pytrendy/post_processing/segments_refine/__init__.py,sha256=Mcv4xfV442j1TE3udmRRyTjKNFrSE8brcNlzWMJvkMc,3501
14
14
  pytrendy/post_processing/segments_refine/abrupt_shaving.py,sha256=5e0dS0yQ51wT2Hvogm0MdGHjq-3F7aG7jutygmu1VM4,7378
@@ -19,7 +19,7 @@ pytrendy/post_processing/segments_refine/trend_classify.py,sha256=aJwutjfMz64t7f
19
19
  pytrendy/post_processing/segments_refine/update_neighbours.py,sha256=4MqOEllUADv8W5nBwfGL3NZNlM9cEYwh3ohb3VWIWU8,3784
20
20
  pytrendy/process_signals.py,sha256=eE7gpnagkNuIcWDKxMvq8tdiv15XrK7rbOqcF_Tdg3c,11564
21
21
  pytrendy/simpledtw.py,sha256=tGsbnRgh4VqnA5XVxPCfYHnJXjvLlVHVGHQ4cGX4eUw,2945
22
- pytrendy-1.4.0.dev5.dist-info/METADATA,sha256=XUsdAMjXe6ZvCeZqIQXvVo-qck9q5RPbHY2TIWutlF4,8684
23
- pytrendy-1.4.0.dev5.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
24
- pytrendy-1.4.0.dev5.dist-info/licenses/LICENSE,sha256=I00f93GihSG6Gqqw3qerxzO53oj_crz0sjynXCiHX_0,1079
25
- pytrendy-1.4.0.dev5.dist-info/RECORD,,
22
+ pytrendy-2.0.0.dev2.dist-info/METADATA,sha256=EcbKrHtCML6KZKiq-vVIftrRFabYiIjTYQNhbMzOY0A,8684
23
+ pytrendy-2.0.0.dev2.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
24
+ pytrendy-2.0.0.dev2.dist-info/licenses/LICENSE,sha256=I00f93GihSG6Gqqw3qerxzO53oj_crz0sjynXCiHX_0,1079
25
+ pytrendy-2.0.0.dev2.dist-info/RECORD,,