Skip to content

fix: Fix unordered mode using ordered path to print frame #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2024
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
7 changes: 5 additions & 2 deletions bigframes/core/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def to_pandas(
sampling_method: Optional[str] = None,
random_state: Optional[int] = None,
*,
ordered: bool = True,
ordered: Optional[bool] = None,
) -> Tuple[pd.DataFrame, bigquery.QueryJob]:
"""Run query and download results as a pandas DataFrame."""
if (sampling_method is not None) and (sampling_method not in _SAMPLING_METHODS):
Expand All @@ -517,7 +517,10 @@ def to_pandas(

df, query_job = self._materialize_local(
materialize_options=MaterializationOptions(
downsampling=sampling, ordered=ordered
downsampling=sampling,
ordered=ordered
if ordered is not None
else self.session._strictly_ordered,
)
)
df.set_axis(self.column_labels, axis=1, copy=False)
Expand Down
6 changes: 6 additions & 0 deletions tests/system/small/test_unordered.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def test_unordered_mode_cache_aggregate(unordered_session):
assert_pandas_df_equal(bf_result, pd_result, ignore_order=True)


def test_unordered_mode_print(unordered_session):
pd_df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}, dtype=pd.Int64Dtype())
df = bpd.DataFrame(pd_df, session=unordered_session).cache()
print(df)


@skip_legacy_pandas
def test_unordered_mode_read_gbq(unordered_session):
df = unordered_session.read_gbq(
Expand Down