Skip to content

TST: tests for GH4502, consistency in ix assignments, but ok in master #4509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2013
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
20 changes: 19 additions & 1 deletion pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import unittest
import nose
import itertools
import warnings

from pandas.compat import range, lrange, StringIO, lmap, map
from numpy import random, nan
Expand Down Expand Up @@ -954,6 +955,24 @@ def test_ix_assign_column_mixed(self):
df.ix[df.x % 2 == 0, 'y'] = df.ix[df.x % 2 == 0, 'y'] * 100
assert_frame_equal(df,expected)

# GH 4508, making sure consistency of assignments
df = DataFrame({'a':[1,2,3],'b':[0,1,2]})
df.ix[[0,2,],'b'] = [100,-100]
expected = DataFrame({'a' : [1,2,3], 'b' : [100,1,-100] })
assert_frame_equal(df,expected)

df = pd.DataFrame({'a': lrange(4) })
df['b'] = np.nan
df.ix[[1,3],'b'] = [100,-100]
expected = DataFrame({'a' : [0,1,2,3], 'b' : [np.nan,100,np.nan,-100] })
assert_frame_equal(df,expected)

# ok, but chained assignments are dangerous
df = pd.DataFrame({'a': lrange(4) })
df['b'] = np.nan
df['b'].ix[[1,3]] = [100,-100]
assert_frame_equal(df,expected)

def test_iloc_mask(self):

# GH 3631, iloc with a mask (of a series) should raise
Expand Down Expand Up @@ -985,7 +1004,6 @@ def test_iloc_mask(self):
('locs','.iloc') : 'iLocation based boolean indexing on an integer type is not available',
}

import warnings
warnings.filterwarnings(action='ignore', category=UserWarning)
result = dict()
for idx in [None, 'index', 'locs']:
Expand Down