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

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable