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

The order of the vectors when joining two data frames. #508

Open
kojix2 opened this issue Apr 22, 2019 · 0 comments
Open

The order of the vectors when joining two data frames. #508

kojix2 opened this issue Apr 22, 2019 · 0 comments

Comments

@kojix2
Copy link
Member

kojix2 commented Apr 22, 2019

The join method is frequently used in data frame operations.
Joining two data frames is easy in Daru. But the order of the vectors is a bit strange.

Ruby Daru

require 'daru'
people = Daru::DataFrame.new(ID: [20, 40],  Name: ["John Doe", "Jane Doe"])
jobs = Daru::DataFrame.new(ID: [20, 40], Job: ["Lawyer", "Doctor"])

Daru::Core::Merge.join(people, jobs, on: [:ID], how: :inner)
# people.join(jobs, how: :inner, on: [:ID])

The vector of Name and the vector of Job are separated to the left and right of the ID.

Julia DataFrame.jl

https://juliadata.github.io/DataFrames.jl/stable/man/joins.html

using DataFrames
people = DataFrame(ID = [20, 40], Name = ["John Doe", "Jane Doe"])
jobs = DataFrame(ID = [20, 40], Job = ["Lawyer", "Doctor"])

join(people, jobs, on = :ID)

The ID is at the left end. Even if you join multiple data frames, the position of the ID column does not change.

I think Julia's way is more practical.

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

1 participant