From 18a0de7367f50c1a0558a99a723ba3a7c1c9702c Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Fri, 31 Aug 2018 07:54:54 +0200 Subject: [PATCH] Improve comments, fix doc string errors --- pandas/core/frame.py | 4 ++-- pandas/core/series.py | 2 +- pandas/tests/indexes/common.py | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 181dd8ab7f9bf..4a40716fbee76 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4382,8 +4382,8 @@ def duplicated(self, subset=None, keep='first', return_inverse=False): set on False and all others on True: >>> data = {'species': ['lama', 'cow', 'lama', 'ant', 'lama', 'bee'], - 'type': ['mammal'] * 3 + ['insect', 'mammal', 'insect']} - >>> animals = pd.DataFrame(data, index=[1, 4, 9, 16, 25]) + ... 'type': ['mammal'] * 3 + ['insect', 'mammal', 'insect']} + >>> animals = pd.DataFrame(data, index=[1, 4, 9, 16, 25, 36]) >>> animals species type 1 lama mammal diff --git a/pandas/core/series.py b/pandas/core/series.py index b473a70fb8258..19260efc51bd9 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -1633,7 +1633,7 @@ def duplicated(self, keep='first', return_inverse=False): set on False and all others on True: >>> animals = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama'], - index=[1, 4, 9, 16, 25]) + ... index=[1, 4, 9, 16, 25]) >>> animals.duplicated() 1 False 4 False diff --git a/pandas/tests/indexes/common.py b/pandas/tests/indexes/common.py index cc35744a69002..544a4855fdb32 100644 --- a/pandas/tests/indexes/common.py +++ b/pandas/tests/indexes/common.py @@ -406,7 +406,9 @@ def test_duplicated_inverse(self, indices, keep): return_inverse=True) tm.assert_numpy_array_equal(result_isdup, expected_isdup) - # test that result_inv works (and fits together with expected_isdup) + # the following tests the correctness of result_inv in two ways: + # - it needs to fit together with expected_isdup + # - it needs to correctly reconstruct the object unique = idx[~expected_isdup] reconstr = unique[result_inv] tm.assert_index_equal(reconstr, idx)