Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG: df.iloc[:, :1] with EA column
  • Loading branch information
jbrockmendel committed Mar 23, 2020
commit fb8d7ce0638f54dcdbb520d3cc022e68a5bc2899
5 changes: 5 additions & 0 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,11 @@ def _slice(self, slicer):
if not com.is_null_slice(slicer[0]):
raise AssertionError("invalid slicing for a 1-ndim categorical")
slicer = slicer[1]
elif not isinstance(slicer, tuple) and self.ndim == 2:
# reached via getitem_block via _slice_take_blocks_ax0
# TODO(EA2D): wont be necessary with 2D EAs
# treat this like (slicer, slice(None)
slicer = slice(None)

return self.values[slicer]

Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/extension/base/getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def test_iloc_frame(self, data):
result = df.iloc[:4, 0]
self.assert_series_equal(result, expected)

# GH#32957 null slice along index, slice along rows
result = df.iloc[:, :1]
self.assert_frame_equal(result, df[["A"]])

def test_loc_series(self, data):
ser = pd.Series(data)
result = ser.loc[:3]
Expand Down