@@ -56,7 +56,7 @@ def _from_tagged_table(
56
56
The tagged table.
57
57
time_name: str
58
58
Name of the time column.
59
- Retruns
59
+ Returns
60
60
-------
61
61
time_series : TimeSeries
62
62
the created time series
@@ -94,7 +94,6 @@ def _from_tagged_table(
94
94
return result
95
95
96
96
@staticmethod
97
- # idk if this method should exist, because we cant use it like the Method in TaggedTable, but the Method is static and this seem to doesnt get checked by the megalinter.
98
97
def _from_table_to_time_series (
99
98
table : Table ,
100
99
target_name : str ,
@@ -112,16 +111,16 @@ def _from_table_to_time_series(
112
111
time_name: str
113
112
Name of the date column.
114
113
feature_names : list[str] | None
115
- Names of the feature columns. If None, all columns except the target column are used.
116
- Retruns
114
+ Names of the feature columns. If None, all columns except the target and time columns are used.
115
+ Returns
117
116
-------
118
117
time_series : TimeSeries
119
118
the created time series
120
119
121
120
Raises
122
121
------
123
122
UnknownColumnNameError
124
- If target_name matches none of the column names.
123
+ If target_name or time_name matches none of the column names.
125
124
Value Error
126
125
If no feature columns are specified
127
126
@@ -153,7 +152,7 @@ def __init__(
153
152
feature_names : list [str ] | None = None ,
154
153
):
155
154
"""
156
- Create a tagged table from a mapping of column names to their values.
155
+ Create a time series from a mapping of column names to their values.
157
156
158
157
Parameters
159
158
----------
@@ -164,7 +163,7 @@ def __init__(
164
163
time_name : str
165
164
Name of the time column
166
165
feature_names : list[str] | None
167
- Names of the feature columns. If None, all columns except the target column are used.
166
+ Names of the feature columns. If None, all columns except the target and time columns are used.
168
167
169
168
Raises
170
169
------
@@ -214,35 +213,14 @@ def time(self) -> Column:
214
213
"""
215
214
return self ._time
216
215
217
- # ------------------------------------------------------------------------------------------------------------------
218
- # Specific methods from time series class:
219
- # ------------------------------------------------------------------------------------------------------------------
220
-
221
- # def _create_moving_average(self, window_size: int) -> Column:
222
- # calculate the windows and the moving average of a timeserties, this function for now only has intern use
223
- # some unexpected behavior while casting to series agains, because it addds NAN values
224
- # return Column._from_pandas_series(pd.Series(self.target._data.rolling(window_size).mean()))
225
- # pass
226
- # def plot_moving_average(self, window_size: int) -> Image:
227
- # this method should plot the moving average of a time series
228
- # pass
229
-
230
- # def show_time_series(self) -> Image:
231
- # this method should plot the time series
232
- # pass
233
-
234
- # def decompose_time_series(self) -> Image:
235
- # this Method should show a plot of a decomposed time series
236
- # pass
237
-
238
216
# ------------------------------------------------------------------------------------------------------------------
239
217
# Overriden methods from TaggedTable class:
240
218
# ------------------------------------------------------------------------------------------------------------------
241
219
def _as_table (self : TimeSeries ) -> Table :
242
220
"""
243
221
Return a new `Table` with the tagging removed.
244
222
245
- The original table is not modified.
223
+ The original time series is not modified.
246
224
247
225
Parameters
248
226
----------
@@ -252,7 +230,7 @@ def _as_table(self: TimeSeries) -> Table:
252
230
Returns
253
231
-------
254
232
table: Table
255
- The table as an untagged Table, i.e. without the information about which columns are features, target or time.
233
+ The time series as an untagged Table, i.e. without the information about which columns are features, target or time.
256
234
257
235
"""
258
236
return Table .from_columns (super ().to_columns ())
@@ -261,7 +239,7 @@ def add_column(self, column: Column) -> TimeSeries:
261
239
"""
262
240
Return a new `TimeSeries` with the provided column attached at the end, as neither target nor feature column.
263
241
264
- The original table is not modified.
242
+ The original time series is not modified.
265
243
266
244
Parameters
267
245
----------
@@ -271,7 +249,7 @@ def add_column(self, column: Column) -> TimeSeries:
271
249
Returns
272
250
-------
273
251
result : TimeSeries
274
- The table with the column attached as neither target nor feature column.
252
+ The time series with the column attached as neither target nor feature column.
275
253
276
254
Raises
277
255
------
@@ -299,7 +277,7 @@ def add_column_as_feature(self, column: Column) -> TimeSeries:
299
277
Returns
300
278
-------
301
279
result : TimeSeries
302
- The table with the attached feature column.
280
+ The time series with the attached feature column.
303
281
304
282
Raises
305
283
------
@@ -345,7 +323,7 @@ def add_columns(self, columns: list[Column] | Table) -> TimeSeries:
345
323
"""
346
324
Return a new `TimeSeries` with multiple added columns, as neither target nor feature columns.
347
325
348
- The original table is not modified.
326
+ The original time series is not modified.
349
327
350
328
Parameters
351
329
----------
@@ -360,9 +338,9 @@ def add_columns(self, columns: list[Column] | Table) -> TimeSeries:
360
338
Raises
361
339
------
362
340
DuplicateColumnNameError
363
- If at least one column name from the provided column list already exists in the table .
341
+ If at least one column name from the provided column list already exists in the time series .
364
342
ColumnSizeError
365
- If at least one of the column sizes from the provided column list does not match the table .
343
+ If at least one of the column sizes from the provided column list does not match the time series .
366
344
"""
367
345
return TimeSeries ._from_tagged_table (
368
346
super ().add_columns (columns ),
@@ -373,7 +351,7 @@ def add_row(self, row: Row) -> TimeSeries:
373
351
"""
374
352
Return a new `TimeSeries` with an extra Row attached.
375
353
376
- The original table is not modified.
354
+ The original time series is not modified.
377
355
378
356
Parameters
379
357
----------
@@ -388,15 +366,15 @@ def add_row(self, row: Row) -> TimeSeries:
388
366
Raises
389
367
------
390
368
UnknownColumnNameError
391
- If the row has different column names than the table .
369
+ If the row has different column names than the time series .
392
370
"""
393
371
return TimeSeries ._from_tagged_table (super ().add_row (row ), time_name = self .time .name )
394
372
395
373
def add_rows (self , rows : list [Row ] | Table ) -> TimeSeries :
396
374
"""
397
375
Return a new `TimeSeries` with multiple extra Rows attached.
398
376
399
- The original table is not modified.
377
+ The original time series is not modified.
400
378
401
379
Parameters
402
380
----------
@@ -406,12 +384,12 @@ def add_rows(self, rows: list[Row] | Table) -> TimeSeries:
406
384
Returns
407
385
-------
408
386
result : TimeSeries
409
- A new time series which combines the original table and the given rows.
387
+ A new time series which combines the original time series and the given rows.
410
388
411
389
Raises
412
390
------
413
391
UnknownColumnNameError
414
- If at least one of the rows have different column names than the table .
392
+ If at least one of the rows have different column names than the time series .
415
393
"""
416
394
return TimeSeries ._from_tagged_table (super ().add_rows (rows ), time_name = self .time .name )
417
395
@@ -440,7 +418,7 @@ def keep_only_columns(self, column_names: list[str]) -> TimeSeries:
440
418
"""
441
419
Return a new `TimeSeries` with only the given column(s).
442
420
443
- The original table is not modified.
421
+ The original time series is not modified.
444
422
445
423
Parameters
446
424
----------
@@ -457,7 +435,7 @@ def keep_only_columns(self, column_names: list[str]) -> TimeSeries:
457
435
UnknownColumnNameError
458
436
If any of the given columns does not exist.
459
437
IllegalSchemaModificationError
460
- If none of the given columns is the target column or any of the feature columns.
438
+ If none of the given columns is the target or time column or any of the feature columns.
461
439
"""
462
440
if self .target .name not in column_names :
463
441
raise IllegalSchemaModificationError ("Must keep the target column." )
@@ -479,9 +457,9 @@ def keep_only_columns(self, column_names: list[str]) -> TimeSeries:
479
457
480
458
def remove_columns (self , column_names : list [str ]) -> TimeSeries :
481
459
"""
482
- Return a new `TimeSeries` with the given column(s) removed from the table .
460
+ Return a new `TimeSeries` with the given column(s) removed from the time series .
483
461
484
- The original table is not modified.
462
+ The original time series is not modified.
485
463
486
464
Parameters
487
465
----------
@@ -526,7 +504,7 @@ def remove_columns_with_missing_values(self) -> TimeSeries:
526
504
"""
527
505
Return a new `TimeSeries` with every column that misses values removed.
528
506
529
- The original table is not modified.
507
+ The original time series is not modified.
530
508
531
509
Returns
532
510
-------
@@ -561,7 +539,7 @@ def remove_columns_with_non_numerical_values(self) -> TimeSeries:
561
539
"""
562
540
Return a new `TimeSeries` with every column that contains non-numerical values removed.
563
541
564
- The original table is not modified.
542
+ The original time series is not modified.
565
543
566
544
Returns
567
545
-------
@@ -665,9 +643,9 @@ def rename_column(self, old_name: str, new_name: str) -> TimeSeries:
665
643
Parameters
666
644
----------
667
645
old_name : str
668
- The old name of the target column.
646
+ The old name of the column.
669
647
new_name : str
670
- The new name of the target column.
648
+ The new name of the column.
671
649
672
650
Returns
673
651
-------
@@ -705,7 +683,7 @@ def replace_column(self, old_column_name: str, new_columns: list[Column]) -> Tim
705
683
becomes the new target or time column. If the column to be replaced is a feature column, the new columns that replace it
706
684
all become feature columns.
707
685
708
- The order of columns is kept. The original table is not modified.
686
+ The order of columns is kept. The original time series is not modified.
709
687
710
688
Parameters
711
689
----------
@@ -717,7 +695,7 @@ def replace_column(self, old_column_name: str, new_columns: list[Column]) -> Tim
717
695
Returns
718
696
-------
719
697
result : TimeSeries
720
- A time series with the old column replaced by the new column .
698
+ A time series with the old column replaced by the new columns .
721
699
722
700
Raises
723
701
------
@@ -728,7 +706,7 @@ def replace_column(self, old_column_name: str, new_columns: list[Column]) -> Tim
728
706
ColumnSizeError
729
707
If the size of the column does not match the amount of rows.
730
708
IllegalSchemaModificationError
731
- If the target column would be removed or replaced by more than one column.
709
+ If the target or time column would be removed or replaced by more than one column.
732
710
"""
733
711
if old_column_name == self .time .name :
734
712
if len (new_columns ) != 1 :
@@ -830,7 +808,7 @@ def sort_columns(
830
808
831
809
If no comparator is given, the columns will be sorted alphabetically by their name.
832
810
833
- The original table is not modified.
811
+ The original time series is not modified.
834
812
835
813
Parameters
836
814
----------
0 commit comments