Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer as destination in src => fun => dest #2985

Closed
pdeffebach opened this issue Jan 8, 2022 · 3 comments
Closed

Integer as destination in src => fun => dest #2985

pdeffebach opened this issue Jan 8, 2022 · 3 comments
Labels

Comments

@pdeffebach
Copy link
Contributor

Motivated by this discourse discussion

MWE:

julia> df = DataFrame(a = [1, 2]);

julia> transform(df, :a => (identity => 1))
ERROR: ArgumentError: Unrecognized column selector: :a => (identity => 1)
@bkamins
Copy link
Member

bkamins commented Jan 8, 2022

@pdeffebach I am not sure what you would want to achieve here. How should 1 as target column name be interpreted (as it is an invalid column name)?

Do you mean transform(df, :a => (identity => "1")) or transform(df, :a => identity, renamecols=false) or transform(df, :a => (identity => identity))?

@pdeffebach
Copy link
Contributor Author

pdeffebach commented Jan 8, 2022

1 should be interpreted as positional. renamecols solves the problem where src and dest are the same integer. But if they were different one might want to write

2 => f => 1

to take the 2nd column, apply f, then stick the result in the 1st position.

fwiw I don't think this is a good idea or a feature that should be added at the point. Closing, at least we can point to this issue in the future if needed.

@bkamins
Copy link
Member

bkamins commented Jan 8, 2022

stick the result in the 1st position.

position is determined by the order of transformations passed. The problem is that if you pass 1 as output position there is no way to determine what should be the name of this column (note that the name is for NEW data frame, which is initially empty i.e. does not have any names)

2 as source specifier is fully un-ambiguous as OLD data frame has some columns and we can check what is the name and value of column #2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants