tobgu/qframe

Passing a struct or a map into the df creation

2kikee122 opened this issue · 6 comments

hi guys

The below passes into the df but I get the error 'createColumn: unknown column data type "string" for column "Age"'

Would you be able to help me please?


        to_df := map[string]interface{}{
			"CreatedAt": CreatedDate,
			"Age": strconv.FormatFloat(rounded, 'f', 6, 64),
			"FavoriteCount": strconv.Itoa(FavoriteCount),
			"RetweetCount": strconv.Itoa(RetweetCount),
			"hour": hour,
			"day": day,
		}
		f := qframe.New(to_df)
		fmt.Println(f)
tobgu commented

Hi,

The values in the map need to be slices of data (eg. []int, []string, ...) rather than a single record of data. The input is column oriented.

See the docs:
https://godoc.org/github.com/tobgu/qframe#New
https://godoc.org/github.com/tobgu/qframe/types#DataSlice

And a complete example which should be easy to translate into what you need:
https://godoc.org/github.com/tobgu/qframe#example-New

One question on general things. Can I return a qframe from a function - what is its return type?

tobgu commented

Re questions: No worries! I'll try to point to documentation where such exist (to verify that it's understandable) or will add/refine docs where needed.

Re returning a QFrame: Sure you can, as a matter of fact that's exactly what most of the public methods on the QFrame itself does since it's immutable. The type is qframe.QFrame (https://github.com/tobgu/qframe/blob/master/qframe.go#L51).

tobgu commented

Closing this as there seem to be no outstanding issues.