You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "deanm0000 (via GitHub)" <gi...@apache.org> on 2025/03/20 20:21:43 UTC
Re: [I] Create more user friendly aliases from `col` [datafusion-python]
deanm0000 commented on issue #754:
URL: https://github.com/apache/datafusion-python/issues/754#issuecomment-2741575371
Another potential friendly alias method is to use **kwargs in `select` and `aggregate`. Here's a select implementation:
```python
def select(self, *exprs: Expr | str, **kwargs: Expr | str) -> DataFrame:
exprs_internal = [
Expr.column(arg).expr if isinstance(arg, str) else arg.expr for arg in exprs
]
for name, expr_or_str in kwargs.items():
if isinstance(expr_or_str, str):
expr_or_str=col(expr_or_str)
exprs_internal.append(expr_or_str.alias(name))
return DataFrame(self.df.select(*exprs_internal))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org