0

I'm wondering what this b charcter is and why it's appearing. I'm also wondering if I can get rid of it while printing the array?

Here's my example:

arr1 = np.array(['1', '2'], dtype = 'c')
print("array:", arr1, "and its dtype is: ", arr1.dtype)

And here's the output:

array: [b'1' b'2'] and its dtype is:  |S1
Ry-
  • 218,210
  • 55
  • 464
  • 476
shadewolf
  • 269
  • 1
  • 2
  • 8

1 Answers1

1

It means byte literal:

https://docs.python.org/2/whatsnew/2.6.html?highlight=string%20byte%20literal#pep-3112-byte-literals

As to getting rid of it you might try outputting as string rather than as an array object

for example:

s="["
for x in arr1:
    s += x.decode('utf-8')   
s+= "]"

print ("array: ", s , " and it's dtype is: ", arr1.dtype");
me_
  • 681
  • 1
  • 8
  • 18