![](/img/trans.png)
[英]Is Python's hashlib.sha256(x).hexdigest() equivalent to Rs digest(x,algo=“sha256”)
[英]How to get sha256().hexdigest() in dataframe
我已閱讀 xlsx 表並在此代碼中使用了sha256().hexdigest()
,但出現錯誤:
for file in files_to_be_updated:
print("file",source_path + '/' + file)
file_bytes = pd.read_excel(source_path + '/' + file , index=False,encode="utf-8")
source_hash = sha256(file_bytes).hexdigest()
print(source_hash)
錯誤信息:
Traceback (most recent call last):
File "C:/Users/krishna/PycharmProjects/projcts/ispp-funds-platform-data-mart/test5.py", line 34, in <module>
source_hash = sha256(file_bytes).hexdigest()
TypeError: object supporting the buffer API required
您正在嘗試將 pandas dateframe 提供給 sha256 構造函數,該構造函數需要一個類似字節的對象。
如果您想要數據框的哈希值,請改用hash_pandas_object
中的pandas.util
,如下所示:
sha256(pd.util.hash_pandas_object(file_bytes).values).hexdigest()
看到這個答案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.