-
Notifications
You must be signed in to change notification settings - Fork 123
Description
Describe the bug
I couldn't locate the exact documentation that lays out the usage of column() / col() and literal() / lit(). Here's what I encountered, I will start describing the problem for column() followed by literal():
-
column() / col()
.select('id')
-> worked as intended
.drop('id')
-> worked as intended
.sort('id')
-> didn't work ->AttributeError: 'str' object has no attribute 'expr'
I had to fix it with.sort(col('id'))
.filter(col('id') > 123)
-> worked as intended
.with_columns(ID_students = F.when(col('id') > 123, lit('Good')).end())
-> worked as intended -
literal() / lit()
< removed > Found the answer myself
To Reproduce
Steps to reproduce the behavior: You may use the codes above the reproduce the inconsistency mentioned.
Expected behavior
I'm speaking from my experience with Polars - which is also built on Rust.
For col(), I expect that col() is not required for select
, drop
and sort
operations, except for filter
and with_columns
. There may be more operations out there that I am not aware of that may not need col() to work. In Polars, .sort('id')
works right off the bat.
P.S. I made reference to Polars as their syntax are very similar to each other. Please let me know if I shouldn't be viewing from Polars' perspective due to something crucial between the two packages that I am not aware of. Thanks.
Additional context
Just wish to understand the usage of column() better so that I don't have to guess when and when not to use them.
My data are stored in CSV file if that matters.