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

Tables.columns should return a DataFrameColumns object #2244

Closed
oschulz opened this issue May 11, 2020 · 3 comments
Closed

Tables.columns should return a DataFrameColumns object #2244

oschulz opened this issue May 11, 2020 · 3 comments
Labels

Comments

@oschulz
Copy link

oschulz commented May 11, 2020

Currently, we have

cols = Tables.columns(df::DataFrame) === df

Returning the DataFrame isself is not ideal, I think. A DataFrame is conceptually not really a collection of columns - for example, length(cols) is not defined, and you also can't map(f, cols) over the columns, nor can you iterate over the columns with [... for col in cols] or similar.

I think we should do

Tables.columns(df::DataFrame) = eachcol(df)

instead.

@quinnj
Copy link
Member

quinnj commented May 11, 2020

The only things required of the return type of Tables.columns is that Tables.columnnames and Tables.getcolumn are defined, which DataFrame satisfies. I think what you're looking for is Tables.Columns(df), which provides the iteration/getindex/getproperty convenience methods you mentioned.

@bkamins
Copy link
Member

bkamins commented May 11, 2020

Both DataFrameColumns and DataFrame support Tables.columns interface. Also if I understand things correctly Tables.columns does not promise an object that is "conceptually a collection of columns".

Can you please give more justification for the proposed change? The reason is that we would like to avoid being breaking till 1.0 release and what we have now conforms to the Tables.columns contract.

@oschulz
Copy link
Author

oschulz commented May 12, 2020

Ah, right. Indeed, I should have used Tables.columntable(df) or Tables.Colums(df) - thanks!

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

3 participants