Skip to content

Commit 7df4639

Browse files
committed
Added test, added tolist to _dir_deletions, changed whatsnew and api.rst
1 parent 70c3dda commit 7df4639

File tree

6 files changed

+10
-4
lines changed

6 files changed

+10
-4
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

@@ -1536,6 +1537,7 @@ Conversion
15361537
Index.map
15371538
Index.ravel
15381539
Index.tolist
1540+
Index.to_list
15391541
Index.to_native_types
15401542
Index.to_series
15411543
Index.to_frame

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ Other API Changes
911911
- Slicing a single row of a DataFrame with multiple ExtensionArrays of the same type now preserves the dtype, rather than coercing to object (:issue:`22784`)
912912
- :class:`DateOffset` attribute `_cacheable` and method `_should_cache` have been removed (:issue:`23118`)
913913
- :meth:`Index.hasnans` and :meth:`Series.hasnans` now always return a python boolean. Previously, a python or a numpy boolean could be returned, depending on circumstances (:issue:`23294`).
914-
- ``Series.tolist()`` and ``Index.tolist()`` now have an alias ``to_list`` (:issue:`8826`)
914+
- :func:`Series.tolist` and :func:`Index.tolist()` now have an alias ``to_list`` (:issue:`8826`)
915915

916916
.. _whatsnew_0240.deprecations:
917917

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class Categorical(ExtensionArray, PandasObject):
323323
# ops, which raise
324324
__array_priority__ = 1000
325325
_dtype = CategoricalDtype(ordered=False)
326-
_deprecations = frozenset(['labels'])
326+
_deprecations = frozenset(['labels', 'tolist'])
327327
_typ = 'categorical'
328328

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

pandas/core/indexes/base.py

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
pprint_thing, default_pprint, format_object_summary, format_object_attrs)
6464
from pandas.core.ops import make_invalid_op
6565
from pandas.core.strings import StringMethods
66+
from pandas.core.accessor import DirNamesMixin
6667

6768
__all__ = ['Index']
6869

@@ -219,6 +220,8 @@ class Index(IndexOpsMixin, PandasObject):
219220
DatetimeIndex, TimedeltaIndex, PeriodIndex
220221
Int64Index, UInt64Index, Float64Index
221222
"""
223+
_deprecations = DirNamesMixin._deprecations | frozenset(['tolist'])
224+
222225
# To hand over control to subclasses
223226
_join_precedence = 1
224227

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
146146
_accessors = {'dt', 'cat', 'str', 'sparse'}
147147
_deprecations = generic.NDFrame._deprecations | frozenset(
148148
['asobject', 'reshape', 'get_value', 'set_value',
149-
'from_csv', 'valid'])
149+
'from_csv', 'valid', 'tolist'])
150150

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

pandas/tests/test_base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1074,9 +1074,10 @@ class TestToIterable(object):
10741074
'method',
10751075
[
10761076
lambda x: x.tolist(),
1077+
lambda x: x.to_list(),
10771078
lambda x: list(x),
10781079
lambda x: list(x.__iter__()),
1079-
], ids=['tolist', 'list', 'iter'])
1080+
], ids=['tolist', 'to_list', 'list', 'iter'])
10801081
@pytest.mark.parametrize('typ', [Series, Index])
10811082
def test_iterable(self, typ, method, dtype, rdtype):
10821083
# gh-10904

0 commit comments

Comments
 (0)