From 419f28a8e7316a746b93ebfc856c70024c061b5a Mon Sep 17 00:00:00 2001 From: Shenyang Cai Date: Tue, 7 Apr 2026 00:20:39 +0000 Subject: [PATCH 1/4] docs(bigframes): Add docs to the to_csv methods of dataframe and series --- .../bigframes_vendored/pandas/core/frame.py | 43 +++++++++++++++++++ .../bigframes_vendored/pandas/core/series.py | 43 +++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py b/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py index 86bccbdbf186..14d4c91edadc 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py @@ -552,6 +552,49 @@ def to_parquet( ``None``, ``snappy``, or ``gzip``. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def to_csv( + self, + path_or_buf=None, + sep=",", + *, + header: bool = True, + index: bool = True, + allow_large_results: Optional[bool] = None, + ) -> dict | list[dict]: + """ + Write object to a comma-separated values (csv) file. + + **Examples:** + + >>> import bigframes.pandas as bpd + + >>> df = bpd.DataFrame({'col1': [1, 2], 'col2': [3, 4]}) + >>> df.to_csv() + \',col1,col2\\n0,1,3\\n1,2,4\\n\' + + Args: + path_or_buf (str, path object, file-like object, or None, default None): + String, path object (implementing os.PathLike[str]), or file-like object + implementing a write() function. If None, the result is returned as a string. + If a non-binary file object is passed, it should be opened with newline='', + disabling universal newlines. If a binary file object is passed, + mode might need to contain a 'b'. + Must contain a wildcard character '*' if this is a GCS path. + sep (str, default ','): + String of length 1. Field delimiter for the output file. + header (bool, default True): + Write out the column names. + index (bool, default True): + Write row names (index). + allow_large_results (bool, default None): + If not None, overrides the global setting to allow or disallow large + query results over the default size limit of 10 GB. + + Returns: + If path_or_buf is None, returns the resulting csv format as a string. Otherwise returns None. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) def to_dict( self, diff --git a/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py b/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py index f4e0903f9607..989c5e859f4a 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py @@ -548,6 +548,49 @@ def to_markdown( Series in Markdown-friendly format. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def to_csv( + self, + path_or_buf=None, + sep=",", + *, + header: bool = True, + index: bool = True, + allow_large_results: Optional[bool] = None, + ) -> dict | list[dict]: + """ + Write object to a comma-separated values (csv) file. + + **Examples:** + + >>> import bigframes.pandas as bpd + + >>> s = bpd.Series([1,2,3], name='my_series') + >>> s.to_csv() + \',my_series\\n0,1\\n1,2\\n2,3\\n\' + + Args: + path_or_buf (str, path object, file-like object, or None, default None): + String, path object (implementing os.PathLike[str]), or file-like object + implementing a write() function. If None, the result is returned as a string. + If a non-binary file object is passed, it should be opened with newline='', + disabling universal newlines. If a binary file object is passed, + mode might need to contain a 'b'. + Must contain a wildcard character '*' if this is a GCS path. + sep (str, default ','): + String of length 1. Field delimiter for the output file. + header (bool, default True): + Write out the column names. + index (bool, default True): + Write row names (index). + allow_large_results (bool, default None): + If not None, overrides the global setting to allow or disallow large + query results over the default size limit of 10 GB. + + Returns: + If path_or_buf is None, returns the resulting csv format as a string. Otherwise returns None. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) def to_dict( self, From 883a6e5d3e913906f8e8440ac517d7ac2c211958 Mon Sep 17 00:00:00 2001 From: Shenyang Cai Date: Tue, 7 Apr 2026 00:22:26 +0000 Subject: [PATCH 2/4] update return types --- .../third_party/bigframes_vendored/pandas/core/frame.py | 2 +- .../third_party/bigframes_vendored/pandas/core/series.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py b/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py index 14d4c91edadc..3be88634737f 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py @@ -561,7 +561,7 @@ def to_csv( header: bool = True, index: bool = True, allow_large_results: Optional[bool] = None, - ) -> dict | list[dict]: + ) -> Optional[str]: """ Write object to a comma-separated values (csv) file. diff --git a/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py b/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py index 989c5e859f4a..ab3b45110648 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py @@ -557,7 +557,7 @@ def to_csv( header: bool = True, index: bool = True, allow_large_results: Optional[bool] = None, - ) -> dict | list[dict]: + ) -> Optional[str]: """ Write object to a comma-separated values (csv) file. From f4790869edc525438294cf1bcf90e40f2e81874a Mon Sep 17 00:00:00 2001 From: Shenyang Cai Date: Tue, 7 Apr 2026 00:24:50 +0000 Subject: [PATCH 3/4] fix workspace format --- packages/bigframes/bigframes/core/rewrite/__init__.py | 2 +- packages/bigframes/bigframes/core/rewrite/nullity.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/bigframes/bigframes/core/rewrite/__init__.py b/packages/bigframes/bigframes/core/rewrite/__init__.py index 0842fde512a1..ab5559ab6554 100644 --- a/packages/bigframes/bigframes/core/rewrite/__init__.py +++ b/packages/bigframes/bigframes/core/rewrite/__init__.py @@ -18,6 +18,7 @@ from bigframes.core.rewrite.identifiers import remap_variables from bigframes.core.rewrite.implicit_align import try_row_join from bigframes.core.rewrite.legacy_align import legacy_join_as_projection +from bigframes.core.rewrite.nullity import simplify_join from bigframes.core.rewrite.order import bake_order, defer_order from bigframes.core.rewrite.pruning import column_pruning from bigframes.core.rewrite.scan_reduction import ( @@ -33,7 +34,6 @@ rewrite_range_rolling, simplify_complex_windows, ) -from bigframes.core.rewrite.nullity import simplify_join __all__ = [ "as_sql_nodes", diff --git a/packages/bigframes/bigframes/core/rewrite/nullity.py b/packages/bigframes/bigframes/core/rewrite/nullity.py index 4eef2be72db6..6307b12ec275 100644 --- a/packages/bigframes/bigframes/core/rewrite/nullity.py +++ b/packages/bigframes/bigframes/core/rewrite/nullity.py @@ -14,9 +14,10 @@ from __future__ import annotations -from bigframes.core import nodes import dataclasses +from bigframes.core import nodes + def simplify_join(node: nodes.BigFrameNode) -> nodes.BigFrameNode: """Simplify a join node by removing nullity checks.""" From d23cc79cb19b7b59ade80a9e2bcf1466d689f4ac Mon Sep 17 00:00:00 2001 From: Shenyang Cai Date: Tue, 7 Apr 2026 02:14:04 +0000 Subject: [PATCH 4/4] fix formats --- .../bigframes_vendored/pandas/core/frame.py | 10 +++++----- .../bigframes_vendored/pandas/core/series.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py b/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py index 3be88634737f..c38aad7dfe77 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py @@ -552,7 +552,7 @@ def to_parquet( ``None``, ``snappy``, or ``gzip``. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) - + def to_csv( self, path_or_buf=None, @@ -575,10 +575,10 @@ def to_csv( Args: path_or_buf (str, path object, file-like object, or None, default None): - String, path object (implementing os.PathLike[str]), or file-like object - implementing a write() function. If None, the result is returned as a string. - If a non-binary file object is passed, it should be opened with newline='', - disabling universal newlines. If a binary file object is passed, + String, path object (implementing os.PathLike[str]), or file-like object + implementing a write() function. If None, the result is returned as a string. + If a non-binary file object is passed, it should be opened with newline='', + disabling universal newlines. If a binary file object is passed, mode might need to contain a 'b'. Must contain a wildcard character '*' if this is a GCS path. sep (str, default ','): diff --git a/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py b/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py index ab3b45110648..007b8b8e735e 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py @@ -548,7 +548,7 @@ def to_markdown( Series in Markdown-friendly format. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) - + def to_csv( self, path_or_buf=None, @@ -571,10 +571,10 @@ def to_csv( Args: path_or_buf (str, path object, file-like object, or None, default None): - String, path object (implementing os.PathLike[str]), or file-like object - implementing a write() function. If None, the result is returned as a string. - If a non-binary file object is passed, it should be opened with newline='', - disabling universal newlines. If a binary file object is passed, + String, path object (implementing os.PathLike[str]), or file-like object + implementing a write() function. If None, the result is returned as a string. + If a non-binary file object is passed, it should be opened with newline='', + disabling universal newlines. If a binary file object is passed, mode might need to contain a 'b'. Must contain a wildcard character '*' if this is a GCS path. sep (str, default ','):