-
Notifications
You must be signed in to change notification settings - Fork 42
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
Integrate JsonProvider with Deedle #14
Comments
👍 |
This almost works, but forces full expansion of the JSON record (due to recursion): let rec expander key value =
seq {
match value with
| JsonValue.String (s) -> yield key,typeof<string>,box s
| JsonValue.Boolean (b) -> yield key,typeof<bool>,box b
| JsonValue.Float (f) -> yield key,typeof<float>,box f
| JsonValue.Null (_) -> yield key,typeof<obj>,box ()
| JsonValue.Number (n) -> yield key,typeof<decimal>,box n
| JsonValue.Record (r) -> yield! r |> Seq.collect ((<||)expander)
| JsonValue.Array (a) ->
yield! a
|> Seq.collect (expander "arrayItem")
}
Frame.CustomExpanders.Add(typeof<JsonDocument>, fun o -> (o :?> JsonDocument).JsonValue |> expander "root")
Frame.CustomExpanders.Add(typeof<JsonValue>, fun o -> o :?> JsonValue |> expander "root")
// Test
[ for l in weatherHistory.List -> series [ "It" => l ] ]
|> Frame.ofRowsOrdinal
|> Frame.expandAllCols 10 |
@mandest I completely forgot about this. Do you know what the issue was with my original attempt? (Or was the only issue the fact that it only handled records?) |
@tpetricek I honestly am not 100% sure. If you handle just the record cases, many more items get expanded (eg. |
FsLab is now changing to be an incubation space for F# data science projects, per discussion in #137 (comment) Closing this out as it relates to the old FsLab package collection. |
It should be possible to use
Frame.expandAllCols
onJsonValue
to flatten json values into columns. Something like this (but this does not quite work):The text was updated successfully, but these errors were encountered: