Why Does Python Think My Array Is 0-d? (typeerror: Iteration Over A 0-d Array)
I'm aware that this may have been answered before but please check that other answers are relevant to this instance! I'm writing an array to a file as a string so that it can be st
Solution 1:
the_array = np.asarray(the_array)
is creating an array with one element in it: your string "[10, 20, 30, 40, 50]"
. Rather than read your file in, if you import json
and replace the_array = the_file.read()
with the_array = json.load(the_file)
, you'll get a list instead and can easily convert it to a numpy array.
Post a Comment for "Why Does Python Think My Array Is 0-d? (typeerror: Iteration Over A 0-d Array)"