Skip to content

Commit ea7efff

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 48655b5 commit ea7efff

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
@@ -2426,8 +2426,7 @@ def groupby(self, values):
24262426
return result
24272427

24282428
def map(self, mapper):
2429-
"""
2430-
Apply mapper function to an index.
2429+
"""Apply mapper function to an index.
24312430
24322431
Parameters
24332432
----------
@@ -2440,6 +2439,7 @@ def map(self, mapper):
24402439
The output of the mapping function applied to the index.
24412440
If the function returns a tuple with more than one element
24422441
a MultiIndex will be returned.
2442+
24432443
"""
24442444
from .multi import MultiIndex
24452445
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
@@ -769,7 +769,7 @@ def test_sub(self):
769769
def test_map_identity_mapping(self):
770770
# GH 12766
771771
for name, cur_index in self.indices.items():
772-
self.assert_index_equal(cur_index, cur_index.map(lambda x: x))
772+
tm.assert_index_equal(cur_index, cur_index.map(lambda x: x))
773773

774774
def test_map_with_tuples(self):
775775
# GH 12766
@@ -778,35 +778,35 @@ def test_map_with_tuples(self):
778778
# returns an Index.
779779
boolean_index = tm.makeIntIndex(3).map(lambda x: (x,))
780780
expected = Index([(0,), (1,), (2,)])
781-
self.assert_index_equal(boolean_index, expected)
781+
tm.assert_index_equal(boolean_index, expected)
782782

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

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

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

801801
period_index = tm.makePeriodIndex(10)
802-
self.assert_index_equal(exp, period_index.map(lambda x: 1))
802+
tm.assert_index_equal(exp, period_index.map(lambda x: 1))
803803

804804
tdelta_index = tm.makeTimedeltaIndex(10)
805-
self.assert_index_equal(exp, tdelta_index.map(lambda x: 1))
805+
tm.assert_index_equal(exp, tdelta_index.map(lambda x: 1))
806806

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

811811
def test_append_multiple(self):
812812
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
@@ -3689,7 +3689,7 @@ def test_map_bug_1677(self):
36893689

36903690
result = index.map(f)
36913691
expected = Index([f(index[0])])
3692-
self.assert_index_equal(result, expected)
3692+
tm.assert_index_equal(result, expected)
36933693

36943694
def test_groupby_function_tuple_1677(self):
36953695
df = DataFrame(np.random.rand(100),

0 commit comments

Comments
 (0)