Created
February 16, 2018 22:24
-
-
Save kevdougful/54adb27ee5b764db64aefe1f57bbcd46 to your computer and use it in GitHub Desktop.
NodeJS Dataframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go from this: | |
const data = [ | |
{ | |
id: 1, | |
response: 'weight', | |
value: 34.2 | |
}, | |
{ | |
id: 1, | |
response: 'height', | |
value: 110.0 | |
}, | |
{ | |
id: 2, | |
response: 'weight', | |
value: 22.1 | |
}, | |
{ | |
id: 3, | |
response: 'weight', | |
value: 52.1 | |
}, | |
{ | |
id: 3, | |
response: 'height', | |
value: 75.2 | |
} | |
] | |
// To this: | |
const dataframe = { | |
id: [1, 2, 3], | |
weight: [34.2, 22.1, 52.1], | |
height: [110.0, null, 75.2] | |
} | |
// With a function that looks like this: | |
const func = (longData, columnKey, valueKey) => { | |
} | |
// And would be called like this | |
func(data, 'response', 'value') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Look at this ugliness: