Skip to content

Commit ab070fa

Browse files
committed
Added test, added tolist to _dir_deletions, changed whatsnew and api.rst
1 parent 392c4c2 commit ab070fa

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

doc/source/api.rst

+2
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ Conversion
324324
Series.to_period
325325
Series.to_timestamp
326326
Series.tolist
327+
Series.to_list
327328
Series.get_values
328329

329330

@@ -1535,6 +1536,7 @@ Conversion
15351536
Index.map
15361537
Index.ravel
15371538
Index.tolist
1539+
Index.to_list
15381540
Index.to_native_types
15391541
Index.to_series
15401542
Index.to_frame

doc/source/whatsnew/v0.24.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ Other API Changes
10721072
- The order of the arguments of :func:`DataFrame.to_html` and :func:`DataFrame.to_string` is rearranged to be consistent with each other. (:issue:`23614`)
10731073
- :meth:`CategoricalIndex.reindex` now raises a ``ValueError`` if the target index is non-unique and not equal to the current index. It previously only raised if the target index was not of a categorical dtype (:issue:`23963`).
10741074
- ``Series.tolist()`` and ``Index.tolist()`` now have an alias ``to_list`` (:issue:`8826`)
1075+
- :func:`Series.tolist` and :func:`Index.tolist()` now have an alias ``to_list`` (:issue:`8826`)
10751076

10761077
.. _whatsnew_0240.deprecations:
10771078

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class Categorical(ExtensionArray, PandasObject):
309309
# ops, which raise
310310
__array_priority__ = 1000
311311
_dtype = CategoricalDtype(ordered=False)
312-
_deprecations = frozenset(['labels'])
312+
_deprecations = frozenset(['labels', 'tolist'])
313313
_typ = 'categorical'
314314

315315
def __init__(self, values, categories=None, ordered=None, dtype=None,

pandas/core/indexes/base.py

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from pandas.core.ops import get_op_result_name, make_invalid_op
4242
import pandas.core.sorting as sorting
4343
from pandas.core.strings import StringMethods
44+
from pandas.core.accessor import DirNamesMixin
4445

4546
from pandas.io.formats.printing import (
4647
default_pprint, format_object_attrs, format_object_summary, pprint_thing)
@@ -202,6 +203,8 @@ class Index(IndexOpsMixin, PandasObject):
202203
>>> pd.Index(list('abc'))
203204
Index(['a', 'b', 'c'], dtype='object')
204205
"""
206+
_deprecations = DirNamesMixin._deprecations | frozenset(['tolist'])
207+
205208
# To hand over control to subclasses
206209
_join_precedence = 1
207210

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
136136
_accessors = {'dt', 'cat', 'str', 'sparse'}
137137
_deprecations = generic.NDFrame._deprecations | frozenset(
138138
['asobject', 'reshape', 'get_value', 'set_value',
139-
'from_csv', 'valid'])
139+
'from_csv', 'valid', 'tolist'])
140140

141141
# Override cache_readonly bc Series is mutable
142142
hasnans = property(base.IndexOpsMixin.hasnans.func,

pandas/tests/test_base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1099,9 +1099,10 @@ class TestToIterable(object):
10991099
'method',
11001100
[
11011101
lambda x: x.tolist(),
1102+
lambda x: x.to_list(),
11021103
lambda x: list(x),
11031104
lambda x: list(x.__iter__()),
1104-
], ids=['tolist', 'list', 'iter'])
1105+
], ids=['tolist', 'to_list', 'list', 'iter'])
11051106
@pytest.mark.parametrize('typ', [Series, Index])
11061107
def test_iterable(self, typ, method, dtype, rdtype):
11071108
# gh-10904

0 commit comments

Comments
 (0)