Skip to content
Draft
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
4 changes: 2 additions & 2 deletions packages/bigframes/bigframes/core/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,8 @@ def _materialize_local(
)
else:
raw_df = result_batches.to_pandas()
df = self._copy_index_to_pandas(raw_df)
df.set_axis(self.column_labels, axis=1, copy=False)

df = self._copy_index_to_pandas(raw_df).set_axis(self.column_labels, axis=1)
Comment on lines +850 to +851
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copy parameter in set_axis is deprecated in recent Pandas versions. To avoid the warning and prevent an unnecessary full copy of the DataFrame (which set_axis performs by default in newer versions), it is recommended to assign directly to the .columns attribute. This is the official Pandas recommendation for replacing set_axis(..., copy=False) when modifying a fresh object.

Suggested change
df = self._copy_index_to_pandas(raw_df).set_axis(self.column_labels, axis=1)
df = self._copy_index_to_pandas(raw_df)
df.columns = self.column_labels

return df, execute_result.query_job

def split(
Expand Down
4 changes: 2 additions & 2 deletions packages/bigframes/bigframes/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ def to_pandas(
)
if query_job:
self._set_internal_query_job(query_job)
return df.set_axis(self._block.column_labels, axis=1, copy=False)
return df.set_axis(self._block.column_labels, axis=1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copy parameter in set_axis is deprecated. To avoid the warning and prevent an unnecessary copy of the DataFrame, assign directly to the .columns attribute.

Suggested change
return df.set_axis(self._block.column_labels, axis=1)
df.columns = self._block.column_labels
return df


def to_pandas_batches(
self,
Expand Down Expand Up @@ -1869,7 +1869,7 @@ def peek(
raise ValueError(
"Cannot peek efficiently when data has aggregates, joins or window functions applied. Use force=True to fully compute dataframe."
)
return maybe_result.set_axis(self._block.column_labels, axis=1, copy=False)
return maybe_result.set_axis(self._block.column_labels, axis=1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copy parameter in set_axis is deprecated. To avoid the warning and prevent an unnecessary copy of the DataFrame, assign directly to the .columns attribute.

Suggested change
return maybe_result.set_axis(self._block.column_labels, axis=1)
maybe_result.columns = self._block.column_labels
return maybe_result


def nlargest(
self,
Expand Down
Loading