-1

How to add + sign to ids which were generated by np.arange(len(web))

user458
  • 369
  • 1
  • 9
  • You need to convert them to strings if you want to concatenate a string to them. – Barmar Nov 18 '21 at 18:09
  • See https://stackoverflow.com/questions/9958846/converting-int-arrays-to-string-arrays-in-numpy-without-truncation for how to convert it to a string array. – Barmar Nov 18 '21 at 18:10

1 Answers1

1

Convert your array to strings. Then use map() to convert them to strings and add +, and convert this to an array.

r = np.arange(len(web))
rplus = np.array(map(lambda x: '+' + str(x), r)
mathfux
  • 5,759
  • 1
  • 14
  • 34
Barmar
  • 741,623
  • 53
  • 500
  • 612