Skip to content

Commit b23bfa4

Browse files
fix: nameless column to_frame bug for pandas 3.0 (#17371)
Fixes #<519726816> 🦕 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 761c805 commit b23bfa4

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

packages/bigframes/bigframes/series.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,11 +2280,14 @@ def mask(self, cond, other=None) -> Series:
22802280
return self.where(~cond, other)
22812281

22822282
def to_frame(self, name: blocks.Label = None) -> bigframes.dataframe.DataFrame:
2283-
provided_name = name if name else self.name
2283+
provided_name = name if name is not None else self.name
22842284
# To be consistent with Pandas, it assigns 0 as the column name if missing. 0 is the first element of RangeIndex.
2285-
block = self._block.with_column_labels(
2286-
[provided_name] if provided_name else [0]
2287-
)
2285+
column_names: List[blocks.Label]
2286+
if provided_name is None or pandas.isna([cast(Any, provided_name)])[0]:
2287+
column_names = [0]
2288+
else:
2289+
column_names = [provided_name]
2290+
block = self._block.with_column_labels(column_names)
22882291
return bigframes.dataframe.DataFrame(block)
22892292

22902293
def to_csv(

0 commit comments

Comments
 (0)