Skip to content

Commit 06d9d06

Browse files
committed
Merge pull request #5896 from ahlmss/AHLRAP-3152
Fix bug where use of .ix[tuple(...)]=x fails to correctly check out of b...
2 parents 045e93a + cbc1465 commit 06d9d06

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Diff for: doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Bug Fixes
8484
- Regresssion in handling of empty Series as indexers to Series (:issue:`5877`)
8585
- Bug in internal caching, related to (:issue:`5727`)
8686
- Testing bug in reading json/msgpack from a non-filepath on windows under py3 (:issue:`5874`)
87+
- Bug when assigning to .ix[tuple(...)] (:issue:`5896`)
8788

8889
pandas 0.13.0
8990
-------------

Diff for: pandas/core/indexing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ def _convert_to_indexer(self, obj, axis=0, is_setter=False):
903903
return {'key': obj}
904904

905905
# a positional
906-
if obj >= len(self.obj) and not isinstance(labels, MultiIndex):
906+
if (obj >= self.obj.shape[axis] and
907+
not isinstance(labels, MultiIndex)):
907908
raise ValueError("cannot set by positional indexing with "
908909
"enlargement")
909910

Diff for: pandas/tests/test_indexing.py

+8
Original file line numberDiff line numberDiff line change
@@ -2352,6 +2352,14 @@ def check_slicing_positional(index):
23522352
#self.assertRaises(TypeError, lambda : s.iloc[2.0:5.0])
23532353
#self.assertRaises(TypeError, lambda : s.iloc[2:5.0])
23542354

2355+
def test_set_ix_out_of_bounds_axis_0(self):
2356+
df = pd.DataFrame(randn(2, 5), index=["row%s" % i for i in range(2)], columns=["col%s" % i for i in range(5)])
2357+
self.assertRaises(ValueError, df.ix.__setitem__, (2, 0), 100)
2358+
2359+
def test_set_ix_out_of_bounds_axis_1(self):
2360+
df = pd.DataFrame(randn(5, 2), index=["row%s" % i for i in range(5)], columns=["col%s" % i for i in range(2)])
2361+
self.assertRaises(ValueError, df.ix.__setitem__, (0 , 2), 100)
2362+
23552363

23562364
if __name__ == '__main__':
23572365
import nose

0 commit comments

Comments
 (0)