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

Possible improvement of hcat #1301

Closed
bkamins opened this issue Dec 2, 2017 · 4 comments
Closed

Possible improvement of hcat #1301

bkamins opened this issue Dec 2, 2017 · 4 comments

Comments

@bkamins
Copy link
Member

bkamins commented Dec 2, 2017

Consider the following code:

 x = DataFrame([(i,j) for i in 1:3, j in 1:4])
hcat(x, [1,2,3])

works OK, but:

hcat([1,2,3], x)

fails.

Additionally:

hcat([1 2 3], x)

appends DataFrame to [1 2 3] in fourth position.

Is this intended, or should it be fixed.

@bkamins
Copy link
Member Author

bkamins commented Dec 2, 2017

Also this is probably something we should avoid (x is a DataFrame):

hcat(x, "bad mistake")

which produces StackOverflow.

@nalimilan
Copy link
Member

I don't think that's really intended, but it's difficult to fix in full generality since AFAIK there's no way to define a method which is called when at least one of the arguments is a DataFrame. See JuliaLang/julia#20815. I guess we could add methods to handle the two-argument case at least, since it's likely to be the most common one. PR welcome.

Regarding the stack overflow, it seems it could be fixed by adding a two-argument hcat! method to stop the recursive call of hcat!(a::DataFrame, b, c...).

@bkamins
Copy link
Member Author

bkamins commented Dec 2, 2017

This is what I meant. I will make a PR (I was not so much into DataFrames development earlier so I do not know well what already has been considered and decided).

@bkamins
Copy link
Member Author

bkamins commented Dec 5, 2017

closing as the PR is merged.

@bkamins bkamins closed this as completed Dec 5, 2017
This issue was closed.
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

2 participants