Skip to content

Commit

Permalink
precommit workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dshettyepi committed Nov 29, 2024
1 parent 0f7a548 commit 5175288
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3298,21 +3298,21 @@ def test_loc_reindexing_of_empty_index(self):
expected = DataFrame(index=[1, 1, 2, 2], data=["1", "1", "2", "2"])
tm.assert_frame_equal(df, expected)

def test_loc_setitem_matching_index(self,series_with_simple_index):
def test_loc_setitem_matching_index(self, series_with_simple_index):
# GH 25548
ser1=series_with_simple_index.copy()
ser1=ser1[~ser1.index.duplicated(keep='first')]
ser2=ser1.copy()
ser1 = series_with_simple_index.copy()
ser1 = ser1[~ser1.index.duplicated(keep="first")]
ser2 = ser1.copy()
# Testing on upto 2 indices
for nsize in range(1,min(len(ser1),3)):
random_sample=ser1.sample(n=nsize)
matching_mask=ser1.index.isin(random_sample.index)
for nsize in range(1, min(len(ser1), 3)):
random_sample = ser1.sample(n=nsize)
matching_mask = ser1.index.isin(random_sample.index)
# Remove values at indices to test assignment
ser1.loc[matching_mask]=np.NaN
ser1.loc[matching_mask]=random_sample
tm.assert_series_equal(ser1,ser2)
#exclude row and index and test assignment of unmatched indices
exclude_mask=~matching_mask
ser2.loc[matching_mask]=ser1.loc[exclude_mask]
ser1.loc[matching_mask]=np.NaN
tm.assert_series_equal(ser2,ser1)
ser1.loc[matching_mask] = np.NaN
ser1.loc[matching_mask] = random_sample
tm.assert_series_equal(ser1, ser2)
# exclude row and index and test assignment of unmatched indices
exclude_mask = ~matching_mask
ser2.loc[matching_mask] = ser1.loc[exclude_mask]
ser1.loc[matching_mask] = np.NaN
tm.assert_series_equal(ser2, ser1)

0 comments on commit 5175288

Please sign in to comment.