@@ -1989,21 +1989,26 @@ def _get_series_list(self, others, ignore_index=False):
1989
1989
return ([others [x ] for x in others ], False )
1990
1990
elif is_list_like (others ):
1991
1991
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
1992
1995
if all (is_list_like (x ) for x in others ):
1993
1996
los = []
1994
1997
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)
1995
2000
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
1997
2002
if not isinstance (nxt , (DataFrame , Series ,
1998
2003
Index , np .ndarray )):
1999
- # safety for iterators and non-persistent list-likes
2004
+ # safety for non-persistent list-likes (e.g. iterators)
2000
2005
# do not map indexed/typed objects; info needed below
2001
2006
nxt = list (nxt )
2002
2007
2003
- # known types without deep inspection
2008
+ # known types for which we can avoid deep inspection
2004
2009
no_deep = ((isinstance (nxt , np .ndarray ) and nxt .ndim == 1 )
2005
2010
or isinstance (nxt , (Series , Index )))
2006
- # Nested list-likes are forbidden:
2011
+ # nested list-likes are forbidden:
2007
2012
# -> elements of nxt must not be list-like
2008
2013
is_legal = ((no_deep and nxt .dtype == object )
2009
2014
or all (not is_list_like (x ) for x in nxt ))
0 commit comments