@@ -1979,8 +1979,8 @@ def _get_series_list(self, others, ignore_index=False):
1979
1979
elif isinstance (others , DataFrame ):
1980
1980
fut_warn = not others .index .equals (idx )
1981
1981
if ignore_index and fut_warn :
1982
- # without copy, this could change (the corresponding list
1983
- # element of) "others" that was passed to str.cat
1982
+ # without copy, this could change "others"
1983
+ # that was passed to str.cat
1984
1984
others = others .copy ()
1985
1985
others .index = idx
1986
1986
return ([others [x ] for x in others ], fut_warn )
@@ -1993,22 +1993,27 @@ def _get_series_list(self, others, ignore_index=False):
1993
1993
los = []
1994
1994
fut_warn = False
1995
1995
while others :
1996
- nxt = others .pop (0 )
1997
- # safety for iterators etc.; nxt is list-like as per above
1998
- # do not map indexed objects, which would lose their index
1999
- if not isinstance (nxt , (DataFrame , Series , Index )):
1996
+ nxt = others .pop (0 ) # list-like as per check above
1997
+ # safety for iterators and other non-persistent list-likes
1998
+ # do not map indexed/typed objects; would lose information
1999
+ if not isinstance (nxt , (DataFrame , Series ,
2000
+ Index , np .ndarray )):
2000
2001
nxt = list (nxt )
2001
2002
2002
- # Nested list-likes are forbidden - content of nxt must be
2003
- # strings/NaN/None. Need to robustify check against
2004
- # x in nxt being list-like (otherwise ambiguous boolean).
2005
- is_legal = all ((isinstance (x , compat .string_types )
2006
- or (not is_list_like (x ) and isnull (x ))
2007
- or x is None )
2008
- for x in nxt )
2003
+ # known types without deep inspection
2004
+ no_deep = ((isinstance (nxt , np .ndarray ) and nxt .ndim == 1 )
2005
+ or isinstance (nxt , (Series , Index )))
2006
+ # Nested list-likes are forbidden - elements of nxt must be
2007
+ # strings/NaN/None. Need to robustify NaN-check against
2008
+ # x in nxt being list-like (otherwise ambiguous boolean)
2009
+ is_legal = ((no_deep and nxt .dtype == object )
2010
+ or all ((isinstance (x , compat .string_types )
2011
+ or (not is_list_like (x ) and isnull (x ))
2012
+ or x is None )
2013
+ for x in nxt ))
2009
2014
# DataFrame is false positive of is_legal
2010
2015
# because "x in df" returns column names
2011
- if isinstance (nxt , DataFrame ) or not is_legal :
2016
+ if not is_legal or isinstance (nxt , DataFrame ):
2012
2017
raise TypeError (err_msg )
2013
2018
2014
2019
tmp = self ._get_series_list (nxt , ignore_index = ignore_index )
0 commit comments