Skip to content

Commit 45d0ae2

Browse files
committed
TST:Same return values in drop_duplicates for Series and DataFrames(#14192)
Add keep kwarg and new columns
1 parent 1b0333b commit 45d0ae2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/test_base.py

+15
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,21 @@ def test_duplicated_drop_duplicates_index(self):
949949
s.drop_duplicates(inplace=True)
950950
tm.assert_series_equal(s, original)
951951

952+
def test_drop_duplicates_series_vs_dataframe(self):
953+
# GH 14192
954+
df = pd.DataFrame({'a': [1, 1, 1, 'one', 'one'],
955+
'b': [2, 2, np.nan, np.nan, np.nan],
956+
'c': [3, 3, np.nan, np.nan, 'three'],
957+
'd': [1, 2, 3, 4, 4],
958+
'e': [datetime(2015, 1, 1), datetime(2015, 1, 1),
959+
datetime(2015, 2, 1), pd.NaT, pd.NaT]
960+
})
961+
for column in df.columns:
962+
for keep in ['first', 'last', False]:
963+
dropped_frame = df[[column]].drop_duplicates(keep=keep)
964+
dropped_series = df[column].drop_duplicates(keep=keep)
965+
tm.assert_frame_equal(dropped_frame, dropped_series.to_frame())
966+
952967
def test_fillna(self):
953968
# # GH 11343
954969
# though Index.fillna and Series.fillna has separate impl,

0 commit comments

Comments
 (0)