go-gota / gota

Gota: DataFrames and data wrangling in Go (Golang)
Other
2.97k stars 276 forks source link

How to merge a list of datasets #198

Closed MushiTheMoshi closed 1 year ago

MushiTheMoshi commented 1 year ago

Hi there,

Great work done here!

Looking for some help on how to merge multiple dataframes, I have tried using joins though these are creating extra column, additionally Outer join is not documented in the readme.

` type Vols struct {
Account string
VolumeId string
VolumeType string
}

df1 := dataframe.LoadStructs([]Vols{ {Account: "ACC1", VolumeId: "111", VolumeType: "GP2"} }) df2 := dataframe.LoadStructs([]Vols{ {Account: "ACC2", VolumeId: "222", VolumeType: "GP3"} })

fmt.Println(df2.OuterJoin(df1, "Account"))

//CURRENT RESULT: [2x5] DataFrame Account VolumeId_0 VolumeType_0 VolumeId_1 VolumeType_1 0: ACC2 222 GP3 NaN NaN
1: ACC1 NaN NaN 111 GP2

///////////////////////////////////////////// //EXPECTED RESULT: [2x3] DataFrame Account VolumeId VolumeType 0: ACC1 111 GP2 1: ACC2 222 GP3
`
Any help is much appreciated

Regards, Julio

MushiTheMoshi commented 1 year ago

concat did the job