Merubah tipe data b’ pada python


Jika kita menemukan data b’ pada python, maka kita perlu melakukan decode agar data tersebut dapat diproses lebih lanjut.

Jika format data dalam bentuk pandas data frame

seri_data_y = pd.Series(y)
result_y = seri_data_y.str.decode(encoding = ‘UTF-8’)

Jika format data dalam bentuk bebas,

data = b'The string'

data_y.decode(encoding = ‘UTF-8’)

rujukan:

https://stackoverflow.com/questions/6269765/what-does-the-b-character-do-in-front-of-a-string-literal

https://www.tutorialspoint.com/python/string_decode

https://www.geeksforgeeks.org/python-pandas-series-str-decode/


Leave a Reply