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

Make a DataFrame not iterable #1513

Closed
pdeffebach opened this issue Sep 17, 2018 · 5 comments
Closed

Make a DataFrame not iterable #1513

pdeffebach opened this issue Sep 17, 2018 · 5 comments

Comments

@pdeffebach
Copy link
Contributor

I recently ran into the following problem doing a bunch of regressions on a DataFrame

regress.(Ref(df), [:y, :y1, :y2, :y3], :treat)

I needed the Ref(df) because otherwise Julia would try to iterate over a DataFrame. Since I don't think there is a way to just iterate through a DataFrame (we restrict iteration to eachcol and eachrow), we should maybe add a method for iterate(df::DataFrame) that makes it work like Ref.

I forget what the exact solution here is to make Julia always treat a DataFrame like a scalar.

@pdeffebach
Copy link
Contributor Author

We need to add the code

Base.broadcastable(df::AbstractDataFrame) = Ref(df)

somewhere.

@nalimilan
Copy link
Member

Makes sense. Though we may want to wait for a bit in case we decided to make data frames iterables over rows or columns (#1514).

@nalimilan
Copy link
Member

#1840 takes a different approach, which has quite strong advantages.

@bkamins
Copy link
Member

bkamins commented Jun 9, 2019

Yes, and with #1840 you still can do Ref(df) if you want to avoid broadcasting over it.

@bkamins
Copy link
Member

bkamins commented Jul 25, 2019

Closing it as AbstractDataFrame is considered 2-dimensional in broadcasting. Use Ref to protect it against being broadcasted over.

It is not related to being iterable - AbstractDataFrame is not iterable.

@bkamins bkamins closed this as completed Jul 25, 2019
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