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

Implement an Arrange method for DataFrames #4

Closed
kniren opened this issue Nov 9, 2016 · 1 comment
Closed

Implement an Arrange method for DataFrames #4

kniren opened this issue Nov 9, 2016 · 1 comment

Comments

@kniren
Copy link
Collaborator

kniren commented Nov 9, 2016

One should be able to sort the DataFrame by one or several of it's columns.

func (d DataFrame) Arrange(keys string...) DataFrame { ... }

A possible implementation could start by enabling each Series to return a []int array containing it's sorted order. For example:

a := Strings("b", "c", "a")
var b []int = a.Order() // b == []int{2,3,1}

In case we have NA elements we should decide what to do with them. Maybe they all have the same order index and appear at the end?

a := Strings("b", nil, "c", nil,"a")
var b []int = a.order() // b == []int{2,4,3,4,1}

In any case, once we have an []int array for each key column we could calculate the new row order array and use it to sort the DataFrame.

@kniren
Copy link
Collaborator Author

kniren commented Dec 1, 2016

DataFrame.Arrange and Series.Order are implemented as of 65850ab

No matter the direction of ordering, NaN elements will always be sorted at the end.

@kniren kniren closed this as completed Dec 1, 2016
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

1 participant