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

Is there a way to transform DataFrame to user customer struct? #192

Open
liracle opened this issue Jul 29, 2022 · 3 comments
Open

Is there a way to transform DataFrame to user customer struct? #192

liracle opened this issue Jul 29, 2022 · 3 comments

Comments

@liracle
Copy link

liracle commented Jul 29, 2022

I want something like json.Unmarshal , code like this

type People struct {
	Name string `dataframe:"name"`
	Age  int    `dateframe:"age"`
	Male bool   `dateframe:"male"`
}
df := dataframe.LoadRecords(
	[][]string{
		[]string{"name", "age", "male"},
		[]string{"Cloris", "24", "false"},
		[]string{"Ben", "55", "true"},
	},
	dataframe.DetectTypes(false),
	dataframe.DefaultType(series.String),
	dataframe.WithTypes(map[string]series.Type{
		"age":  series.Int,
		"male": series.Bool,
	}),
)
var peoples []People
df.Unmarshal(&peoples)

and will get peoples output:

// peoples
// People{Name:"Cloris", Age:24, "Male":false}
// People{Name:"Ben", Age:55, "Male":true}
@liracle
Copy link
Author

liracle commented Jul 30, 2022

In my way, now i use mapstructure implement this, but i think it should be built-in function

@liracle
Copy link
Author

liracle commented Jul 30, 2022

I want contribute my code. Is this repository being maintained now?

@stkrzysiak
Copy link

I'm not sure if it's maintained much, github insights seems to only show a month, thought it was more in the past. Last merge was October 10th, with a whopping PR outstanding #180 from March of this year. Seems like the pushback was how big the PR was and no issue describing the need. Maybe if you PR you'll get a merge. I'm curious, would you bring mapstructure into this repo or do a similar approach w/o using mapstructure?

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

2 participants