DataFrame.to_json

Convert DataFrame to JSON format

danfo.DataFrame.to_json(path) [source]

Returns:

returns Promise

Examples

Convert DataFrame to JSON format

Node
Node
const dfd = require("danfojs-node")
let data = { "Abs": [20.2, 30, 47.3] ,
"Count": [34, 4, 5, 6] ,
"country code": ["NG", "FR", "GH"] }
let df = new dfd.DataFrame(data)
df.to_json("/home/link/to/path.csv").then((json) => {
console.log(json);
}).catch((err) => {
console.log(err);
})
Output
Output
[{"Abs":20.2,"Count":34,"country code":"NG"},
{"Abs":30,"Count":4,"country code":"FR"},
{"Abs":47.3,"Count":5,"country code":"GH"}]

To export DataFrame as CSV, use DataFrame.to_csv