Dataframe中的時間是不能直接進行相加減的。如果將兩列時間進行加減,會彈出類型錯誤: TypeError: unsupported operand type(s) for -: 'str' and 'str' 1 所以需要先用pandas的to_datetime()方法,轉化成時間格式進行加減,然后再轉換成df格式 new_df = pd.DataFrame(pd.to_datetime(time_df['END_TIME']) - pd.to_datetime(time_df['START_TIME']))