diff --git a/src/safeds/data/tabular/containers/_column.py b/src/safeds/data/tabular/containers/_column.py index 015fe60d2..54c7e2531 100644 --- a/src/safeds/data/tabular/containers/_column.py +++ b/src/safeds/data/tabular/containers/_column.py @@ -27,6 +27,9 @@ T = TypeVar("T") R = TypeVar("R") +# Enable copy-on-write for pandas dataframes +pd.set_option("mode.copy_on_write", True) + class Column(Sequence[T]): """ diff --git a/src/safeds/data/tabular/containers/_row.py b/src/safeds/data/tabular/containers/_row.py index 6994b3248..ac87673ec 100644 --- a/src/safeds/data/tabular/containers/_row.py +++ b/src/safeds/data/tabular/containers/_row.py @@ -13,6 +13,9 @@ if TYPE_CHECKING: from collections.abc import Iterator +# Enable copy-on-write for pandas dataframes +pd.set_option("mode.copy_on_write", True) + class Row(Mapping[str, Any]): """ diff --git a/src/safeds/data/tabular/containers/_table.py b/src/safeds/data/tabular/containers/_table.py index 63c9a7cff..e8851422b 100644 --- a/src/safeds/data/tabular/containers/_table.py +++ b/src/safeds/data/tabular/containers/_table.py @@ -39,6 +39,9 @@ from ._tagged_table import TaggedTable +# Enable copy-on-write for pandas dataframes +pd.set_option("mode.copy_on_write", True) + # noinspection PyProtectedMember class Table: