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

DataFrames should be indexable by CartesianIndex{2} #1610

Closed
ExpandingMan opened this issue Nov 29, 2018 · 8 comments
Closed

DataFrames should be indexable by CartesianIndex{2} #1610

ExpandingMan opened this issue Nov 29, 2018 · 8 comments

Comments

@ExpandingMan
Copy link
Contributor

It should be possible to do, for example

for idx  CartesianIndices(size(df))
    println(df[idx])
end
@nalimilan
Copy link
Member

I guess that would be consistent, but in what situations would it be useful?

@ExpandingMan
Copy link
Contributor Author

It's just a standard way to iterate over things. I for one use it more and more. It's already column major so it's a good way to iterate. If you ever are iterating over a matrix and a dataframe at the same time, it might be useful.

I'd be happy to make the PR, when I get to it.

@nalimilan
Copy link
Member

Iterating over a data frame and a matrix at the same time is unlikely to be a good idea given how slow it's going to be compared to iterating over columns...

@ExpandingMan
Copy link
Contributor Author

Well, they are both column major so if you have to iterate over the dataframe anyway I don't really see what harm it would do (other than typing issues of course).

Regardless, is there some reason you are opposed to making dataframes indexable by CartesianIndex?

@nalimilan
Copy link
Member

Well the type-instability issue is a big problem in terms of performance. I'm not really opposed to supporting cartesian indexing, I'm just not sure it's really useful.

@bkamins
Copy link
Member

bkamins commented Dec 3, 2018

I think it is not a problem to have it for AbstractDataFrame and possibly for DataFrameRow also if we want a complete coverage.

@bkamins
Copy link
Member

bkamins commented Jul 12, 2019

We now allow CartesianIndex{2} indexing so I am closing this.

@bkamins bkamins closed this as completed Jul 12, 2019
@bkamins
Copy link
Member

bkamins commented Jul 12, 2019

(we do not provide CartesianIndices though. If you feel it should be added please reopen and it can be discussed.

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

No branches or pull requests

3 participants