Skip to content

Commit 968c6f7

Browse files
committed
formatting fixes
1 parent 6c6b25f commit 968c6f7

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

pandas/tests/indexing/test_loc.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3298,21 +3298,18 @@ def test_loc_reindexing_of_empty_index(self):
32983298
expected = DataFrame(index=[1, 1, 2, 2], data=["1", "1", "2", "2"])
32993299
tm.assert_frame_equal(df, expected)
33003300

3301-
def test_loc_setitem_matching_index(self, series_with_simple_index):
3301+
def test_loc_setitem_matching_index(self):
33023302
# GH 25548
3303-
ser1 = series_with_simple_index.copy()
3304-
ser1 = ser1[~ser1.index.duplicated(keep="first")]
3305-
ser2 = ser1.copy()
3306-
# Testing on upto 2 indices
3307-
for nsize in range(1, min(len(ser1), 3)):
3308-
random_sample = ser1.sample(n=nsize)
3309-
matching_mask = ser1.index.isin(random_sample.index)
3310-
# Remove values at indices to test assignment
3311-
ser1.loc[matching_mask] = np.nan
3312-
ser1.loc[matching_mask] = random_sample
3313-
tm.assert_series_equal(ser1, ser2)
3314-
# exclude row and index and test assignment of unmatched indices
3315-
exclude_mask = ~matching_mask
3316-
ser2.loc[matching_mask] = ser1.loc[exclude_mask]
3317-
ser1.loc[matching_mask] = np.nan
3318-
tm.assert_series_equal(ser2, ser1)
3303+
s = Series(0.0, index=list("abcd"))
3304+
s1 = Series(1.0, index=list("ab"))
3305+
s2 = Series(2.0, index=list("xy"))
3306+
3307+
# Test matching indices
3308+
s.loc[["a", "b"]] = s1
3309+
tm.assert_series_equal(s[["a", "b"]], s1)
3310+
3311+
# Test unmatched indices
3312+
s.loc[["a", "b"]] = s2
3313+
tm.assert_series_equal(
3314+
s[["a", "b"]], Series([np.nan, np.nan], index=["a", "b"])
3315+
)

0 commit comments

Comments
 (0)