I have two arrays (size 6x3) and would like to write the content into a file.
pos_pb_now = np.array(pos_pb_now, dtype='f')
pos_pw_now = np.array(pos_pw_now, dtype='f')
and
np.savetxt(f_store_handler, pos_pb_now, fmt='%5.2f')
gives
File "/usr/lib/python3/dist-packages/numpy/lib/npyio.py", line 1215, in savetxt
fh.write(asbytes(format % tuple(row) + newline))
TypeError: write() argument must be str, not bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/family/glade/game_uwr/game_uwr.py", line 871, in store_coord
np.savetxt(f_store_handler, pos_pb_now, fmt='%5.2f')
File "/usr/lib/python3/dist-packages/numpy/lib/npyio.py", line 1219, in savetxt
% (str(X.dtype), format))
TypeError: Mismatch between array dtype ('float32') and format specifier ('%5.2f %5.2f %5.2f')
Has anybody an idea how to solve the issue? So far no success in looking at several explanation in python forums.
Background: the 6 are 6 players of a team, moving in 3 dimensions (space). The 2 arrays represent 2 teams (white and blue). By storing their movements into a file (with append), I can call their 3D movement later (simulate/calculate in excel) and make match analysis. A bit like a soccer analysis but in 3D. It will be a tool for the trainer to explain to beginners how to go at the right position and make the right movement.
shape = (6, 3) example
[[ 0.83333331 1. 4. ]
[ 2.5 1. 4. ]
[ 4.16666651 1. 4. ]
[ 5.83333349 1. 4. ]
[ 7.5 1. 4. ]
[ 9.16666698 1. 4. ]]
dtype = float32