Convert Unique Numbers To Md5 Hash Using Pandas


Answer :

hashlib.md5 takes a single string as input -- you can't pass it an array of values as you can with some NumPy/Pandas functions. So instead, you could use a list comprehension to build a list of md5sums:



ob['md5'] = [hashlib.md5(val).hexdigest() for val in ob['ssno']]


In case you are hashing to SHA256, you'll need to encode your string first to (probably) UTF-8:


ob['sha256'] = [hashlib.sha256(val.encode('UTF-8')).hexdigest() for val in ob['ssno']]


Comments

Popular posts from this blog

530 Valid Hostname Is Expected When Setting Up IIS 10 For Multiple Sites

C Perror Example

Converting A String To Int In Groovy