results_pytrendy
Structured Access to Detection Results
PyTrendyResults
PyTrendyResults(segments, index_type='date')
Wrapper class for accessing and analysing detected trend segments.
This class provides utilities for summarizing, filtering, and exporting trend segments
detected by the detect_trends pipeline. It encapsulates both raw segment data and
enhanced metrics such as rankings and signal-to-noise ratios.
Initializes the results object with a list of segments.
Parameters:
-
(segmentslist) –List of dictionaries representing individual trend segments.
Source code in pytrendy/io/results_pytrendy.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
filter_segments
filter_segments(direction='Any', sort_by='time_index', format='df')
Filters and sorts segments based on direction and ranking.
Parameters:
-
(directionstr, default:'Any') –Filter by trend direction. Options:
'Any','Up/Down','Up','Down','Flat','Noise'. -
(sort_bystr, default:'time_index') –Sort segments by
'time_index'(ascending) or'change_rank'(descending). -
(formatstr, default:'df') –Output format.
'df'returns a DataFrame,'dict'returns a list of dictionaries.
Returns:
-
list | DataFrame–Union[
list,pd.DataFrame]: Filtered and sorted segments in the specified format.
Source code in pytrendy/io/results_pytrendy.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
print_summary
print_summary()
Prints a readable summary of detected trends.
Includes counts, best segment info, and a full tabular display.
Source code in pytrendy/io/results_pytrendy.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
set_best
set_best()
Identifies the best trend segment based on its total cumulative change, selecting the one with the lowest change rank.
1 2 3 | |
Source code in pytrendy/io/results_pytrendy.py
35 36 37 38 39 40 41 42 43 44 45 46 | |
set_df
set_df()
Converts a list of trend segments into a pandas DataFrame for easier downstream analysis and data representation.
1 2 3 | |
Source code in pytrendy/io/results_pytrendy.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
set_summary
set_summary()
Computes and stores summary statistics for trend segments, including a tabular overview and counts by direction.
1 2 | |
Source code in pytrendy/io/results_pytrendy.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |