From 5175288f5ecad815b17b4a52acc8bb8d77afc6e7 Mon Sep 17 00:00:00 2001 From: dshettyepi Date: Fri, 29 Nov 2024 13:16:49 +0200 Subject: [PATCH] precommit workflow --- pandas/tests/indexing/test_loc.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index c252139d87d62..da37b1f9a63bc 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -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)