Python Forum
remove b due to conversion in PyQ
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
remove b due to conversion in PyQ
#4
There is no 'b' in the df. That is why you cannot remove it. The 'b' is added when the value is displayed. It provides information about the data type. In your example the 'b' is telling you that '234xyz678kkkkkk' is a byte string or bytes. You can convert this to a str by decoding the bytes to unicode characters.
x = b'1234'
print(x, x.decode('utf8'))
Output:
b'1234' 1234
The square brackets is telling you that this is a list. You need to index the list to get the value or unpack the list to get all the values.
x = [1, 2, 3]
print(x, x[2], *x)
Output:
[1, 2, 3] 3 1 2 3
You need to remember that the way a value is displayed when you print it or view it in you IDE is only somebodies idea of how to best represent that value. bytes do not have a 'b' and lists do not have brackets. These are only visual clues added when the object is converted to a string for display purposes.
Reply


Messages In This Thread
remove b due to conversion in PyQ - by Creepy - Jul-15-2021, 08:14 PM
RE: remove b due to conversion in PyQ - by Creepy - Jul-16-2021, 04:57 PM
RE: remove b due to conversion in PyQ - by deanhystad - Jul-16-2021, 05:54 PM
RE: remove b due to conversion in PyQ - by Creepy - Jul-16-2021, 07:19 PM
RE: remove b due to conversion in PyQ - by Creepy - Jul-20-2021, 06:54 PM
RE: remove b due to conversion in PyQ - by Creepy - Jul-21-2021, 05:57 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020