convert np array to csv code example
Example 1: convert list to array python
import numpy as np
my_list = [2,4,6,8,10]
my_array = np.array(my_list)
print my_array
print type(my_array)
Example 2: convert json to 2d array
function jsonArrayTo2D(arrayOfObjects){
let header = [],
AoA = [];
arrayOfObjects.forEach(obj => {
Object.keys(obj).forEach(key => header.includes(key) || header.push(key))
let thisRow = new Array(header.length);
header.forEach((col, i) => thisRow[i] = obj[col] || '')
AoA.push(thisRow);
})
AoA.unshift(header);
return AoA;
}