Skip to content

Commit

Permalink
optimise select and with_columns
Browse files Browse the repository at this point in the history
  • Loading branch information
aivanoved committed Sep 19, 2024
1 parent 24b4028 commit 0e8c239
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions narwhals/_pandas_like/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def select(
) -> Self:
if exprs and all(isinstance(x, str) for x in exprs) and not named_exprs:
# This is a simple slice => fastpath!
return self._from_native_frame(self._native_frame.loc[:, list(exprs)])
return self._from_native_frame(self._native_frame[list(exprs)])
new_series = evaluate_into_exprs(self, *exprs, **named_exprs)
if not new_series:
# return empty dataframe, like Polars does
Expand Down Expand Up @@ -349,7 +349,7 @@ def with_columns(
)
)
else:
to_concat.append(self._native_frame.loc[:, name])
to_concat.append(self._native_frame[name])
to_concat.extend(
validate_dataframe_comparand(index, new_column_name_to_new_column_map[s])
for s in new_column_name_to_new_column_map
Expand Down

0 comments on commit 0e8c239

Please sign in to comment.