python dict to array code example
Example 1: python numpy array to list
# Basic syntax:
numpy_array.tolist()
# Example usage:
your_array = np.array([[1, 2, 3], [4, 5, 6]])
your_array
--> array([[1, 2, 3],
[4, 5, 6]])
your_array.tolist()
--> [[1, 2, 3], [4, 5, 6]]
Example 2: python dictionary to array
dict = {"a": 1, "b": 2, "c": 3, "d": 4}
data = list(dict.items())
an_array = np.array(data)
print(an_array)
OUTPUT
[['a' '1']
['b' '2']
['c' '3']
['d' '4']]