DataFrame.toJSON
Convert DataFrame to JSON format
Convert DataFrame/Series to JSON and return value
const dfd = require("danfojs-node")
let data = {
Abs: [20.2, 30, 47.3],
Count: [34, 4, 5],
"country code": ["NG", "FR", "GH"],
};
let df = new dfd.DataFrame(data);
const jsonObj = df.toJSON(); //defaults to column format
console.log(jsonObj);
//output
[
{ Abs: 20.2, Count: 34, 'country code': 'NG' },
{ Abs: 30, Count: 4, 'country code': 'FR' },
{ Abs: 47.3, Count: 5, 'country code': 'GH' }
]
//row format
const jsonObjRow = df.toJSON({
format: "row"
});
console.log(jsonObjRow);
//output
{
Abs: [ 20.2, 30, 47.3 ],
Count: [ 34, 4, 5 ],
'country code': [ 'NG', 'FR', 'GH' ]
}Convert DataFrame/Series to JSON and write to local file path
Convert DataFrame/Series to JSON and download file in browser
Last updated