Skip to content

Commit 08593e0

Browse files
committed
Further comment improvements
1 parent 34cce91 commit 08593e0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pandas/core/strings.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,21 +1989,26 @@ def _get_series_list(self, others, ignore_index=False):
19891989
return ([others[x] for x in others], False)
19901990
elif is_list_like(others):
19911991
others = list(others) # ensure iterators do not get read twice etc
1992+
1993+
# in case of list-like `others`, all elements must be
1994+
# either one-dimensional list-likes or scalars
19921995
if all(is_list_like(x) for x in others):
19931996
los = []
19941997
warn = False
1998+
# iterate through list and append list of series for each
1999+
# element (which we check to be one-dimensional and non-nested)
19952000
while others:
1996-
nxt = others.pop(0) # nxt is list-like as per check above
2001+
nxt = others.pop(0) # nxt is guaranteed list-like by above
19972002
if not isinstance(nxt, (DataFrame, Series,
19982003
Index, np.ndarray)):
1999-
# safety for iterators and non-persistent list-likes
2004+
# safety for non-persistent list-likes (e.g. iterators)
20002005
# do not map indexed/typed objects; info needed below
20012006
nxt = list(nxt)
20022007

2003-
# known types without deep inspection
2008+
# known types for which we can avoid deep inspection
20042009
no_deep = ((isinstance(nxt, np.ndarray) and nxt.ndim == 1)
20052010
or isinstance(nxt, (Series, Index)))
2006-
# Nested list-likes are forbidden:
2011+
# nested list-likes are forbidden:
20072012
# -> elements of nxt must not be list-like
20082013
is_legal = ((no_deep and nxt.dtype == object)
20092014
or all(not is_list_like(x) for x in nxt))

0 commit comments

Comments
 (0)