Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ Styler

Other
^^^^^
- Bug in :class:`Series` constructor raising DeprecationWarning when ``index`` is a list of :class:`Series` (:issue:`55228`)
- Bug in :func:`cut` incorrectly allowing cutting of timezone-aware datetimes with timezone-naive bins (:issue:`54964`)
- Bug in :meth:`DataFrame.apply` where passing ``raw=True`` ignored ``args`` passed to the applied function (:issue:`55009`)
- Bug in rendering a :class:`Series` with a :class:`MultiIndex` when one of the index level's names is 0 not having that name displayed (:issue:`55415`)
Expand Down
9 changes: 7 additions & 2 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -863,10 +863,15 @@ def is_all_arraylike(obj: list) -> bool:
object val
bint all_arrays = True

from pandas.core.dtypes.generic import (
ABCIndex,
ABCSeries,
)

for i in range(n):
val = obj[i]
if not (isinstance(val, list) or
util.is_array(val) or hasattr(val, "_data")):
if not (isinstance(val, (list, ABCSeries, ABCIndex))
or util.is_array(val)):
# TODO: EA?
# exclude tuples, frozensets as they may be contained in an Index
all_arrays = False
Expand Down
18 changes: 8 additions & 10 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2134,16 +2134,14 @@ def test_series_constructor_datetimelike_index_coercion(self):
# to DatetimeIndex GH#39307, GH#23598
assert not isinstance(ser.index, DatetimeIndex)

def test_series_constructor_infer_multiindex(self):
index_lists = [["a", "a", "b", "b"], ["x", "y", "x", "y"]]

multi = Series(1.0, index=[np.array(x) for x in index_lists])
assert isinstance(multi.index, MultiIndex)

multi = Series(1.0, index=index_lists)
assert isinstance(multi.index, MultiIndex)

multi = Series(range(4), index=index_lists)
@pytest.mark.parametrize("container", [None, np.array, Series, Index])
@pytest.mark.parametrize("data", [1.0, range(4)])
def test_series_constructor_infer_multiindex(self, container, data):
indexes = [["a", "a", "b", "b"], ["x", "y", "x", "y"]]
if container is not None:
indexes = [container(ind) for ind in indexes]

multi = Series(data, index=indexes)
assert isinstance(multi.index, MultiIndex)


Expand Down