Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: class for time series #508

Merged
merged 72 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
a7e553b
added the functionalities for the time series class and the first test
Dec 5, 2023
ee71da8
added alot of time_series feature and fixed bugs
Dec 6, 2023
eb5b64e
- reestablished my workspace, which also took alot of time
Dec 12, 2023
1097bb7
added all needed tests and setting up the pr
Dec 13, 2023
7e4ed42
Merge branch 'main' of https://github.com/Safe-DS/Library into 481-ti…
Dec 14, 2023
031651c
added comment so I can push my poetry
Dec 14, 2023
0a52dfc
Update poetry.lock
sibre28 Dec 15, 2023
e5cac1c
updated poetry.lock
Gerhardsa0 Dec 15, 2023
902b6c3
Revert "updated poetry.lock"
Gerhardsa0 Dec 15, 2023
81b2ee0
updated poetry.lock
Gerhardsa0 Dec 15, 2023
0f6a937
updated poetry.lock
Gerhardsa0 Dec 15, 2023
03699b3
edited example
Gerhardsa0 Dec 15, 2023
b3f42d3
edited example
Gerhardsa0 Dec 15, 2023
aeb07d7
edited example
Gerhardsa0 Dec 15, 2023
d8b0ec2
updated poetry.lock
Dec 19, 2023
49c7901
updated poetry.lock
Dec 19, 2023
2c498d6
some Linter Changes
Dec 19, 2023
2c674b2
some Linter Changes
Dec 19, 2023
f3ed1e0
some Linter Changes
Dec 19, 2023
c7eab12
spilled water over my keyboard, which changed the project and I rever…
Dec 19, 2023
2ee36d3
renamed the function, so the Liskov substitution principle is not con…
Dec 19, 2023
369a42f
updated comment
Dec 19, 2023
5243d2c
Merge branch 'main' of https://github.com/Safe-DS/Library into 481-ti…
Dec 20, 2023
f5e1b99
updated comment
Dec 20, 2023
b5373e5
updated comment
Dec 20, 2023
33ed21b
again Linter changes, now mypy should run through
Dec 20, 2023
f997589
added coverage
Dec 20, 2023
b814bce
updated comment
Dec 20, 2023
93ce4d6
updated imports
Dec 20, 2023
2aff4b1
going to update init
Dec 20, 2023
c4100d0
going to update init
Dec 20, 2023
7563e6b
going to update init
Dec 20, 2023
754ba39
updated comments
Dec 20, 2023
ec2a13a
updated comments
Dec 20, 2023
e71452a
updated comments
Dec 20, 2023
8e29f1f
style: apply automated linter fixes
megalinter-bot Dec 20, 2023
7f31dbe
style: apply automated linter fixes
megalinter-bot Dec 20, 2023
1db4c45
updated tests
Dec 20, 2023
187f684
Merge remote-tracking branch 'origin/481-timeseries-class-in-safe-ds-…
Dec 20, 2023
88f0ac7
updated tests
Dec 20, 2023
d4023d0
the push befor shouldnt work normally
Dec 20, 2023
c61fd57
why are they not on main?
Dec 20, 2023
6a7fb44
added some coverage
Dec 20, 2023
79aba43
fixed print statement
Dec 20, 2023
8cbe5e3
fixed print statement
Dec 20, 2023
221b5b2
style: apply automated linter fixes
megalinter-bot Dec 20, 2023
c16778f
style: apply automated linter fixes
megalinter-bot Dec 20, 2023
b1b0017
updated code coverage, now everything should be fine
Dec 20, 2023
38424ca
Merge remote-tracking branch 'origin/481-timeseries-class-in-safe-ds-…
Dec 20, 2023
c3c2db1
updated
Jan 14, 2024
db5b0f5
added test after review(1), will be added more
Jan 15, 2024
9594a3e
Apply suggestions from code review
Gerhardsa0 Jan 15, 2024
39ff8c2
Apply suggestions from code review
Gerhardsa0 Jan 15, 2024
160e889
fixed tests
Jan 16, 2024
8982880
style: apply automated linter fixes
megalinter-bot Jan 16, 2024
262b9e6
Apply suggestions from code review
Gerhardsa0 Jan 24, 2024
2a4cee3
applied review changes
Gerhardsa0 Jan 24, 2024
313f484
fixed tests
Gerhardsa0 Jan 24, 2024
c9946ea
style: apply automated linter fixes
megalinter-bot Jan 24, 2024
a351946
fixed tests
Gerhardsa0 Jan 25, 2024
c441414
applied review changes
Gerhardsa0 Jan 25, 2024
c9705d0
style: apply automated linter fixes
megalinter-bot Jan 25, 2024
819f0c3
Merge branch 'main' into 481-timeseries-class-in-safe-ds-std-lib-1
Gerhardsa0 Jan 25, 2024
2f35452
Update src/safeds/data/tabular/containers/_time_series.py
Gerhardsa0 Jan 26, 2024
9f85a12
Update src/safeds/data/tabular/containers/_time_series.py
Gerhardsa0 Jan 26, 2024
066f534
applied review changes
Gerhardsa0 Jan 26, 2024
f7a7435
applied review changes
Gerhardsa0 Jan 26, 2024
d978d2b
Merge remote-tracking branch 'origin/481-timeseries-class-in-safe-ds-…
Gerhardsa0 Jan 26, 2024
5d4fd98
applied review changes
Gerhardsa0 Jan 26, 2024
aa264c6
fixed linter error
Gerhardsa0 Jan 26, 2024
cb9a008
style: apply automated linter fixes
megalinter-bot Jan 26, 2024
415aebd
Update src/safeds/data/tabular/containers/_time_series.py
Gerhardsa0 Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/safeds/data/tabular/containers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
from ._row import Row
from ._table import Table
from ._tagged_table import TaggedTable
from ._time_series import TimeSeries

__all__ = [
"Column",
"Row",
"Table",
"TaggedTable",
"TimeSeries",
]
39 changes: 39 additions & 0 deletions src/safeds/data/tabular/containers/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from safeds.data.tabular.transformation import InvertibleTableTransformer, TableTransformer

from ._tagged_table import TaggedTable
from ._time_series import TimeSeries

# Enable copy-on-write for pandas dataframes
pd.options.mode.copy_on_write = True
Expand Down Expand Up @@ -1715,6 +1716,44 @@ def tag_columns(self, target_name: str, feature_names: list[str] | None = None)

return TaggedTable._from_table(self, target_name, feature_names)

# rethink name here
Gerhardsa0 marked this conversation as resolved.
Show resolved Hide resolved
def time_columns(self, target_name: str, time_name: str, feature_names: list[str] | None = None) -> TimeSeries:
"""
Return a new `TimeSeries` with columns marked as a target and time column or feature columns.

The original table is not modified.

Parameters
----------
target_name : str
Name of the target column.
time_name : str
Name of the time column.
feature_names : list[str] | None
Names of the feature columns. If None, all columns except the target column are used.
Gerhardsa0 marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
time_series : TimeSeries
A new tagged table with the given target and feature names.
Gerhardsa0 marked this conversation as resolved.
Show resolved Hide resolved

Raises
------
ValueError
If the target column is also a feature column.
ValueError
If no feature columns are specified.
Gerhardsa0 marked this conversation as resolved.
Show resolved Hide resolved

Examples
--------
>>> from safeds.data.tabular.containers import Table, TimeSeries
>>> table = Table.from_dict({"time": ["01.01", "01.02", "01.03"], "price": [1.10, 1.19, 1.79], "amount_bought": [74, 72, 51]})
>>> tagged_table = table.time_columns(target_name="amount_bought",time_name = "time", feature_names=["price"])
"""
from ._time_series import TimeSeries

Marsmaennchen221 marked this conversation as resolved.
Show resolved Hide resolved
return TimeSeries._from_table_to_time_series(self, target_name, time_name, feature_names)

def transform_column(self, name: str, transformer: Callable[[Row], Any]) -> Table:
"""
Return a new `Table` with the provided column transformed by calling the provided transformer.
Expand Down
8 changes: 4 additions & 4 deletions src/safeds/data/tabular/containers/_tagged_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def add_row(self, row: Row) -> TaggedTable:
Returns
-------
table : TaggedTable
A new table with the added row at the end.
A new tagged table with the added row at the end.

Raises
------
Expand All @@ -373,7 +373,7 @@ def add_rows(self, rows: list[Row] | Table) -> TaggedTable:
Returns
-------
result : TaggedTable
A new table which combines the original table and the given rows.
A new tagged table which combines the original table and the given rows.

Raises
------
Expand All @@ -386,7 +386,7 @@ def filter_rows(self, query: Callable[[Row], bool]) -> TaggedTable:
"""
Return a new `TaggedTable` containing only rows that match the given Callable (e.g. lambda function).

The original table is not modified.
The original tagged table is not modified.

Parameters
----------
Expand All @@ -395,7 +395,7 @@ def filter_rows(self, query: Callable[[Row], bool]) -> TaggedTable:

Returns
-------
table : TaggedTable
result : TaggedTable
A table containing only the rows to match the query.
Gerhardsa0 marked this conversation as resolved.
Show resolved Hide resolved
"""
return TaggedTable._from_table(
Expand Down
Loading