Skip to content
Merged
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
6 changes: 4 additions & 2 deletions pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1908,8 +1908,10 @@ def _explode(self):
fill_value = pa.scalar([None], type=self._pa_array.type)
mask = counts == 0
if mask.any():
values = values.copy()
values[mask] = fill_value
# pc.if_else here is similar to `values[mask] = fill_value`
# but this avoids an object-dtype round-trip.
pa_values = pc.if_else(~mask, values._pa_array, fill_value)
values = type(self)(pa_values)
counts = counts.copy()
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated, but this need to be a copy (since it comes from a computed operation already)?

Copy link
Member Author

Choose a reason for hiding this comment

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

i dont see why it would. will remove it in my next "assorted cleanups" branch

counts[mask] = 1
values = values.fillna(fill_value)
Expand Down
Loading