go-gota / gota

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

Blocker: Cant add []string as a value in dataframe. Is there any way to do that? #102

Closed ghost closed 4 years ago

ghost commented 4 years ago

type User struct { Name string Age int Accuracy float64 newColumn []string } users := []User{ User{"Aram", 17, 0.2, []string{"a","b"}, User{"Juan", 18, 0.8, []string{"c","d"}, User{"Ana", 22, 0.5, []string{"e","f"}, } df := dataframe.LoadStructs(users) fmt.Println(df)

Getting error: DataFrame error: type ([]string) is not supported.

My use case: I need to store a list of strings into a column as its values. for example: ColumnA ["A","B"] ["C","D"] .. .. .. and so on

kniren commented 4 years ago

No, there is no support to store more than a single element in a single cell. A workaround would be to transform your list of strings into a single string with a separator, for example "|":

type User struct {
    Name string
    Age int
    Accuracy float64
    newColumn string
}
users := []User{
    User{"Aram", 17, 0.2, "a|b"},
    User{"Juan", 18, 0.8, "c|d"},
    User{"Ana", 22, 0.5, "e|f"},
}

You would need then to split that string by the separator when you want to use it.

Since there are no plans on supporting this, for now, I'm closing the issue, but feel free to reply if you deem it necessary.

ariefrahmansyah commented 2 years ago

Hi @kniren Is there any update to support list type as a series element?