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

Insert column/row into DataFrame at specified location. #507

Open
kojix2 opened this issue Apr 19, 2019 · 8 comments
Open

Insert column/row into DataFrame at specified location. #507

kojix2 opened this issue Apr 19, 2019 · 8 comments

Comments

@kojix2
Copy link
Member

kojix2 commented Apr 19, 2019

Hello.
Daru::DataFrame doesn't seem to have insert function.

set_at or set_row_at will overwrite.
[]= add_vector does not specify the insertion location.

@Shekharrajak
Copy link
Member

[]= add_vector does not specify the insertion location.

Can you please elaborate a bit this line?

@Shekharrajak
Copy link
Member

This is good point.

we can add another column easily but then we have to order it. You can also do df[:player] = df.index but yeah we should have a method to insert a column in specific place. may be we can have #insert method having information about index of column, vector name and vector value.

@kojix2
Copy link
Member Author

kojix2 commented Apr 22, 2019

That's exactly what I wanted to say.

@Shekharrajak
Copy link
Member

Thanks for letting us know this usecase.

@cyrillefr
Copy link
Contributor

Hello @Shekharrajak , I would like to work on this one.

@Shekharrajak
Copy link
Member

@cyrillefr , please go ahead. You can discuss your approach here once so that we can verify that you are going in right way then you can open a PR.

@cyrillefr
Copy link
Contributor

Hello @Shekharrajak , sorry for the little delay.
My idea is : add some new data at the end, then reorder.
The method would look like this:
def insert_vector n, name, source
vector = Daru::Vector.new(source, index: @index, name: @name)
@data << vector
@vectors = @vectors.add name
ordr = @vectors.dup.to_a
elmnt = ordr.pop
ordr = ordr.insert n, elmnt
self.order=ordr
end

@Shekharrajak
Copy link
Member

Thanks @cyrillefr , please go ahead open a PR with few corner test cases. Love to see the changes in new release :)

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

No branches or pull requests

3 participants