我目前正在 Google Colab 中從 Google Drive 讀取一些影像,需要檢查每個影像檔案名是否與 Pandas 資料框中的值相對應。
我的代碼現在看起來像這樣:
for img in os.listdir(path):
if img in df['column']:
add image to a folder
else:
add image to other folder
似乎 Python 正在檢查實際影像是否在資料框中,而不是影像名稱,并將所有影像添加到另一個檔案夾中。在與資料框進行比較時,如何確保我實際查看的是影像檔案名?謝謝!
uj5u.com熱心網友回復:
_ in df[]
檢查索引,而不是值。
嘗試:
if img in df.values
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/352746.html
上一篇:如何使用CSS設定背景影像?
