想實作根據現有的三列col1,col2,col3做簡單除法運算后追加3列新生成的列col1_new,col2_new,col3_new,代碼運行的時候一直報錯TypeError: unsupported operand type(s) for /: 'object' and '<class 'int'>'
代碼片段如下,
def func_process(file_in, file_out):
df = pd.read_csv(file_in)
df.eval("""col1_new = col1 / 2
col2_new = col2 / 4
col3_new = col3 / 8
""", inplace=True)
df.to_csv(file_out, encoding='utf-8', index=False)
if __name__ == '__main__':
input_file = 'C:/temp/csv/in/'
output_file = 'C:temp/csv/out/'
請教各位需要如何修改?謝謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/133823.html
下一篇:關于pd資料讀取與pptx問題
