Python - Is it possible to round and replace an array at the same time?

Viewed 35

How can I round and replace an array at the same time? My code line:

plt.text(*max_p_tranformed[:-1][0]+1, *max_p_tranformed[:-1][1], (str(np.round(deflp1[idx]),2).replace(' [', '').replace('[', '').replace(']', '')))

And the return is: str() argument 2 must be str, not int

Any suggestion to overcome this?

1 Answers

After another test, here is the answer:

plt.text(*max_p_tranformed[:-1][0]+1, *max_p_tranformed[:-1][1], str(np.round(deflp1[idx],2)).replace(' [', '').replace('[', '').replace(']', ''))
Related