From f0e97ba3e2b52e61da24409ebdca265c287413b6 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:11:13 +0000 Subject: [PATCH 1/2] add cast --- spec/API_specification/dataframe_api/column_object.py | 8 ++++++++ spec/API_specification/dataframe_api/dataframe_object.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/spec/API_specification/dataframe_api/column_object.py b/spec/API_specification/dataframe_api/column_object.py index b3e10738..8d44672d 100644 --- a/spec/API_specification/dataframe_api/column_object.py +++ b/spec/API_specification/dataframe_api/column_object.py @@ -1057,3 +1057,11 @@ def persist(self) -> Self: at most once per dataframe, and as late as possible in the pipeline. """ ... + + def cast(self, dtype: DType) -> Self: + """Cast specified columns to specified dtypes. + + Cross-kind casting (e.g. integer to string) is not supported and may + vary across implementations. + """ + ... diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index 4e423fd2..6e0fd178 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -925,3 +925,11 @@ def persist(self) -> Self: features.append(column_name) """ ... + + def cast(self, dtypes: Mapping[str, DType]) -> Self: + """Convert specified columns to specified dtypes. + + Cross-kind casting (e.g. integer to string) is not supported and may + vary across implementations. + """ + ... From ebaeb67d1454d9840a7af05d41bd84eabe624103 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:18:25 +0000 Subject: [PATCH 2/2] note what may vary across implementations --- spec/API_specification/dataframe_api/column_object.py | 6 ++++-- spec/API_specification/dataframe_api/dataframe_object.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/spec/API_specification/dataframe_api/column_object.py b/spec/API_specification/dataframe_api/column_object.py index 8d44672d..199f91d8 100644 --- a/spec/API_specification/dataframe_api/column_object.py +++ b/spec/API_specification/dataframe_api/column_object.py @@ -1061,7 +1061,9 @@ def persist(self) -> Self: def cast(self, dtype: DType) -> Self: """Cast specified columns to specified dtypes. - Cross-kind casting (e.g. integer to string) is not supported and may - vary across implementations. + The following is not specified and may vary across implementations: + + - Cross-kind casting (e.g. integer to string, or to float) + - Behaviour in the case of overflows """ ... diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index 6e0fd178..6255402b 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -929,7 +929,9 @@ def persist(self) -> Self: def cast(self, dtypes: Mapping[str, DType]) -> Self: """Convert specified columns to specified dtypes. - Cross-kind casting (e.g. integer to string) is not supported and may - vary across implementations. + The following is not specified and may vary across implementations: + + - Cross-kind casting (e.g. integer to string, or to float) + - Behaviour in the case of overflows """ ...