{"action":"created","issue":{"url":"https://api.github.com/repos/v0dro/daru/issues/281","repository_url":"https://api.github.com/repos/v0dro/daru","labels_url":"https://api.github.com/repos/v0dro/daru/issues/281/labels{/name}","comments_url":"https://api.github.com/repos/v0dro/daru/issues/281/comments","events_url":"https://api.github.com/repos/v0dro/daru/issues/281/events","html_url":"https://github.com/v0dro/daru/issues/281","id":190761716,"number":281,"title":"Serious group_by bug","user":{"login":"gnilrets","id":2371577,"avatar_url":"https://avatars.githubusercontent.com/u/2371577?v=3","gravatar_id":"","url":"https://api.github.com/users/gnilrets","html_url":"https://github.com/gnilrets","followers_url":"https://api.github.com/users/gnilrets/followers","following_url":"https://api.github.com/users/gnilrets/following{/other_user}","gists_url":"https://api.github.com/users/gnilrets/gists{/gist_id}","starred_url":"https://api.github.com/users/gnilrets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnilrets/subscriptions","organizations_url":"https://api.github.com/users/gnilrets/orgs","repos_url":"https://api.github.com/users/gnilrets/repos","events_url":"https://api.github.com/users/gnilrets/events{/privacy}","received_events_url":"https://api.github.com/users/gnilrets/received_events","type":"User","site_admin":false},"labels":[{"id":384220784,"url":"https://api.github.com/repos/v0dro/daru/labels/bug:%20critical","name":"bug: critical","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-21T16:10:01Z","updated_at":"2016-11-23T12:46:31Z","closed_at":null,"body":"Looks like there's a pretty serious bug with group_by when the index isn't a sequential set of integers.\r\n\r\n````\r\nwtdf = Daru::DataFrame.new({ g: ['a','a','a'], num: [1,2,3]}, index: [2,12,23])\r\nputs wtdf.sum.inspect\r\n#=> #<Daru::Vector(1)>\r\n#     sum\r\n# num   6\r\n\r\nputs wtdf.group_by([:g]).sum.inspect\r\n#=> #<Daru::DataFrame(1x1)>\r\n#     num\r\n#   a   4\r\n````\r\n\r\nI think the problem is the way that group_by is making use of indexes:\r\n````\r\nwtdf.group_by([:g])\r\n#=> #<Daru::Core::GroupBy:0x007f9997672950 @groups={[\"a\"]=>[0, 1, 2]}, @non_group_vectors=[:num], @context=#<Daru::DataFrame(3x2)>\r\n#       g num\r\n#   2   a   1\r\n#  12   a   2\r\n#  23   a   3>\r\n````\r\n\r\nThe groups for the `\"a\"` category reference indexes `[0, 1, 2]`.  The group_by code is confusing order in the dataframe with the index.  So it first attempts to find index 0, which doesn't exist so it assumes it's the just the first element of the data frame.  Likewise for index 1.  But then it looks for index 2, which does exist, but it's the first record in the dataframe and that's already been counted.\r\n"},"comment":{"url":"https://api.github.com/repos/v0dro/daru/issues/comments/262503992","html_url":"https://github.com/v0dro/daru/issues/281#issuecomment-262503992","issue_url":"https://api.github.com/repos/v0dro/daru/issues/281","id":262503992,"user":{"login":"zverok","id":129656,"avatar_url":"https://avatars.githubusercontent.com/u/129656?v=3","gravatar_id":"","url":"https://api.github.com/users/zverok","html_url":"https://github.com/zverok","followers_url":"https://api.github.com/users/zverok/followers","following_url":"https://api.github.com/users/zverok/following{/other_user}","gists_url":"https://api.github.com/users/zverok/gists{/gist_id}","starred_url":"https://api.github.com/users/zverok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zverok/subscriptions","organizations_url":"https://api.github.com/users/zverok/orgs","repos_url":"https://api.github.com/users/zverok/repos","events_url":"https://api.github.com/users/zverok/events{/privacy}","received_events_url":"https://api.github.com/users/zverok/received_events","type":"User","site_admin":false},"created_at":"2016-11-23T12:46:31Z","updated_at":"2016-11-23T12:46:31Z","body":"Taking a look today."}}
{"actor":{"display_login":"zverok"}}