亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 pandas 數據框中檢索數據并在 os.system() 命令中輸入值

從 pandas 數據框中檢索數據并在 os.system() 命令中輸入值

互換的青春 2023-08-08 16:23:18
我有一個 Pandas 數據框,其中一整列數值應作為來自 的命令的輸入os.system()。這個 os.system() 正在執行一個 .exe 文件,如下所示 os.system(r'xxxx.exe --file "Input_directory" --output "Output_directory" --start 0 --end 10000')此命令中的開始到結束值應該從我的數據幀的列中獲取值。我嘗試循環遍歷我的 df 列。for i in df['xxx']:  os.system(r'xxxx.exe --file "Input_directory" --output "Output_directory" --start i --end i')起始值和結束值可以相同。但是在此命令中循環并輸入變量不起作用。還有其他方法嗎?
查看完整描述

2 回答

?
慕標5832272

TA貢獻1966條經驗 獲得超4個贊

for i in df['xxx']:
    os.system(r'xxxx.exe --file "Input_directory" --output "Output_directory" --start {} --end {}'.format(i, i))




查看完整回答
反對 回復 2023-08-08
?
波斯汪

TA貢獻1811條經驗 獲得超4個贊

嘗試這個

vals = df['col_name'].values.tolist() # Will fetch all the values of that column in a list form

現在您可以嘗試根據需要發送它們

我正在根據我的理解編寫答案,您想要發送列表的第一個和最后一個值

os.system(r'xxxx.exe --file "Input_directory" --output "Output_directory" --start {} --end {}'.format(vals[0], vals[-1]))



查看完整回答
反對 回復 2023-08-08
  • 2 回答
  • 0 關注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號