Skip to content

Commit fe5245b

Browse files
fix: avoid copy argument warning in to_pandas (googleapis#16917)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-cloud-python/issues) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes internal issue b/508671576 🦕 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 9f42fe1 commit fe5245b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/bigframes/bigframes/core/blocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ def _materialize_local(
848848
else:
849849
raw_df = result_batches.to_pandas()
850850
df = self._copy_index_to_pandas(raw_df)
851-
df.set_axis(self.column_labels, axis=1, copy=False)
851+
df.columns = self.column_labels
852852
return df, execute_result.query_job
853853

854854
def split(

packages/bigframes/bigframes/dataframe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,8 @@ def to_pandas(
17431743
)
17441744
if query_job:
17451745
self._set_internal_query_job(query_job)
1746-
return df.set_axis(self._block.column_labels, axis=1, copy=False)
1746+
df.columns = self._block.column_labels
1747+
return df
17471748

17481749
def to_pandas_batches(
17491750
self,
@@ -1869,7 +1870,8 @@ def peek(
18691870
raise ValueError(
18701871
"Cannot peek efficiently when data has aggregates, joins or window functions applied. Use force=True to fully compute dataframe."
18711872
)
1872-
return maybe_result.set_axis(self._block.column_labels, axis=1, copy=False)
1873+
maybe_result.columns = self._block.column_labels
1874+
return maybe_result
18731875

18741876
def nlargest(
18751877
self,

0 commit comments

Comments
 (0)