Skip to content

Commit a17ddab

Browse files
committed
Fix unused import and docstrings per pep8radius docformatter; change other uses of assert_index_equal to testing instead os self
1 parent ab168e7 commit a17ddab

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

pandas/core/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,7 @@ def remove_unused_categories(self, inplace=False):
930930
return cat
931931

932932
def map(self, mapper):
933-
"""
934-
Apply mapper function to its categories (not codes).
933+
"""Apply mapper function to its categories (not codes).
935934
936935
Parameters
937936
----------
@@ -944,6 +943,7 @@ def map(self, mapper):
944943
Returns
945944
-------
946945
applied : Categorical or Index.
946+
947947
"""
948948
new_categories = self.categories.map(mapper)
949949
try:

pandas/indexes/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2427,8 +2427,7 @@ def groupby(self, values):
24272427
return result
24282428

24292429
def map(self, mapper):
2430-
"""
2431-
Apply mapper function to an index.
2430+
"""Apply mapper function to an index.
24322431
24332432
Parameters
24342433
----------
@@ -2441,6 +2440,7 @@ def map(self, mapper):
24412440
The output of the mapping function applied to the index.
24422441
If the function returns a tuple with more than one element
24432442
a MultiIndex will be returned.
2443+
24442444
"""
24452445
from .multi import MultiIndex
24462446
mapped_values = self._arrmap(self.values, mapper)

pandas/indexes/category.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,7 @@ def take(self, indices, axis=0, allow_fill=True,
517517
return self._create_from_codes(taken)
518518

519519
def map(self, mapper):
520-
"""
521-
Apply mapper function to its categories (not codes).
520+
"""Apply mapper function to its categories (not codes).
522521
523522
Parameters
524523
----------
@@ -531,6 +530,7 @@ def map(self, mapper):
531530
Returns
532531
-------
533532
applied : CategoricalIndex or Index
533+
534534
"""
535535
return self._shallow_copy_with_infer(self.values.map(mapper))
536536

pandas/tests/indexes/test_base.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ def test_sub(self):
770770
def test_map_identity_mapping(self):
771771
# GH 12766
772772
for name, cur_index in self.indices.items():
773-
self.assert_index_equal(cur_index, cur_index.map(lambda x: x))
773+
tm.assert_index_equal(cur_index, cur_index.map(lambda x: x))
774774

775775
def test_map_with_tuples(self):
776776
# GH 12766
@@ -779,35 +779,35 @@ def test_map_with_tuples(self):
779779
# returns an Index.
780780
boolean_index = tm.makeIntIndex(3).map(lambda x: (x,))
781781
expected = Index([(0,), (1,), (2,)])
782-
self.assert_index_equal(boolean_index, expected)
782+
tm.assert_index_equal(boolean_index, expected)
783783

784784
# Test that returning a tuple from a map of a single index
785785
# returns a MultiIndex object.
786786
boolean_index = tm.makeIntIndex(3).map(lambda x: (x, x == 1))
787787
expected = MultiIndex.from_tuples([(0, False), (1, True), (2, False)])
788-
self.assert_index_equal(boolean_index, expected)
788+
tm.assert_index_equal(boolean_index, expected)
789789

790790
# Test that returning a single object from a MultiIndex
791791
# returns an Index.
792792
first_level = ['foo', 'bar', 'baz']
793793
multi_index = MultiIndex.from_tuples(lzip(first_level, [1, 2, 3]))
794794
reduced_index = multi_index.map(lambda x: x[0])
795-
self.assert_index_equal(reduced_index, Index(first_level))
795+
tm.assert_index_equal(reduced_index, Index(first_level))
796796

797797
def test_map_tseries_indices_return_index(self):
798798
date_index = tm.makeDateIndex(10)
799799
exp = Index([1] * 10)
800-
self.assert_index_equal(exp, date_index.map(lambda x: 1))
800+
tm.assert_index_equal(exp, date_index.map(lambda x: 1))
801801

802802
period_index = tm.makePeriodIndex(10)
803-
self.assert_index_equal(exp, period_index.map(lambda x: 1))
803+
tm.assert_index_equal(exp, period_index.map(lambda x: 1))
804804

805805
tdelta_index = tm.makeTimedeltaIndex(10)
806-
self.assert_index_equal(exp, tdelta_index.map(lambda x: 1))
806+
tm.assert_index_equal(exp, tdelta_index.map(lambda x: 1))
807807

808808
date_index = tm.makeDateIndex(24, freq='h', name='hourly')
809809
exp = Index(range(24), name='hourly')
810-
self.assert_index_equal(exp, date_index.map(lambda x: x.hour))
810+
tm.assert_index_equal(exp, date_index.map(lambda x: x.hour))
811811

812812
def test_append_multiple(self):
813813
index = Index(['a', 'b', 'c', 'd', 'e', 'f'])

pandas/tseries/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from pandas.util.decorators import Appender, cache_readonly
2828
import pandas.types.concat as _concat
2929
import pandas.tseries.frequencies as frequencies
30-
import pandas.algos as _algos
3130

3231

3332
class DatelikeOps(object):

pandas/tseries/tests/test_timedeltas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ def test_map(self):
15141514
f = lambda x: x.days
15151515
result = rng.map(f)
15161516
exp = Int64Index([f(x) for x in rng])
1517-
self.assert_index_equal(result, exp)
1517+
tm.assert_index_equal(result, exp)
15181518

15191519
def test_misc_coverage(self):
15201520

pandas/tseries/tests/test_timeseries.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3701,7 +3701,7 @@ def test_map_bug_1677(self):
37013701

37023702
result = index.map(f)
37033703
expected = Index([f(index[0])])
3704-
self.assert_index_equal(result, expected)
3704+
tm.assert_index_equal(result, expected)
37053705

37063706
def test_groupby_function_tuple_1677(self):
37073707
df = DataFrame(np.random.rand(100),

0 commit comments

Comments
 (0)