Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion packages/bigframes/bigframes/core/rewrite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -33,7 +34,6 @@
rewrite_range_rolling,
simplify_complex_windows,
)
from bigframes.core.rewrite.nullity import simplify_join

__all__ = [
"as_sql_nodes",
Expand Down
3 changes: 2 additions & 1 deletion packages/bigframes/bigframes/core/rewrite/nullity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading