Posted under » Python Data Analysis on 27 June 2023
From View and copy
np Repeat will look like this
import numpy as np a = np.array([120,121,122]) np.repeat(a, 5) array([120, 120, 120, 120, 120, 121, 121, 121, 121, 121, 122, 122, 122, 122, 122])
Maybe you should do tile instead
np.tile(a, 5) array([120, 121, 122, 120, 121, 122, 120, 121, 122, 120, 121, 122, 120, 121, 122])
So you want to output to a file.
with open("output.txt", "a") as f: print(np.tile(a, 5), file=f) print('byee from Anoneh', file=f)
Note that if you want to overwrite the contents of output.txt use "w" instead of "a".
Another example of file output.