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.""" 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..c38aad7dfe77 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py @@ -553,6 +553,49 @@ def to_parquet( """ 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, + ) -> Optional[str]: + """ + 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, orient: Literal[ 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..007b8b8e735e 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py @@ -549,6 +549,49 @@ def to_markdown( """ 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, + ) -> Optional[str]: + """ + 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, into: type[dict] = dict,