File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -395,15 +395,13 @@ def with_columns(
395
395
if not new_columns and len (self ) == 0 :
396
396
return self
397
397
398
- # If the inputs are all Expressions which return full columns
399
- # (as opposed to scalars ), we can use a fast path (concat, instead of assign).
398
+ # If the inputs are all Expressions
399
+ # (as opposed to Series ), we can use a fast path (concat, instead of assign).
400
400
# We can't use the fastpath if any input is not an expression (e.g.
401
401
# if it's a Series) because then we might be changing its flags.
402
402
# See `test_memmap` for an example of where this is necessary.
403
- fast_path = (
404
- all (len (s ) > 1 for s in new_columns )
405
- and all (isinstance (x , PandasLikeExpr ) for x in exprs )
406
- and all (isinstance (x , PandasLikeExpr ) for (_ , x ) in named_exprs .items ())
403
+ fast_path = all (isinstance (x , PandasLikeExpr ) for x in exprs ) and all (
404
+ isinstance (x , PandasLikeExpr ) for (_ , x ) in named_exprs .items ()
407
405
)
408
406
409
407
if fast_path :
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ def validate_dataframe_comparand(index: Any, other: Any) -> Any:
129
129
if other .len () == 1 :
130
130
# broadcast
131
131
s = other ._native_series
132
- return s .__class__ (s .iloc [0 ], index = index , dtype = s .dtype )
132
+ return s .__class__ (s .iloc [0 ], index = index , dtype = s .dtype , name = s . name )
133
133
if other ._native_series .index is not index :
134
134
return set_axis (
135
135
other ._native_series ,
You can’t perform that action at this time.
0 commit comments