使用 2 列中的值和 return 结果作为新列执行函数

perform function using values from 2 columns and return result as new column

我有一个名为 "final" 的数据框,它按日期索引(作为日期时间索引),并且每列根据以下内容命名:

final = final[['stn', 'years_of_data', 'total_minutes', 'avg_daily', 'TOA_daily']]

final.head()

           stn  years_of_data   total_minutes   avg_daily   TOA_daily
date                    
1900-01-01  AlberniElementary   4       5760    26.100  101.700
1900-01-01  AlberniWeather      6       8265    25.000  101.700
1900-01-01  Arbutus             8       11162   31.200  101.700
1900-01-01  Arrowview           7       10080   23.200  101.700
1900-01-01  Bayside             6       8597    31.600  101.700

我想 produce/add 一列名为 "AC" 的值,基于 "avg_daily" 和 "TOA_daily" 的划分。

我希望结果如下所示:

           stn  years_of_data   total_minutes   avg_daily   TOA_daily   AC
date                    
1900-01-01  AlberniElementary   4       5760    26.100  101.700  0.257
1900-01-01  AlberniWeather      6       8265    25.000  101.700  0.246
1900-01-01  Arbutus             8       11162   31.200  101.700  0.307
1900-01-01  Arrowview           7       10080   23.200  101.700  0.228
1900-01-01  Bayside             6       8597    31.600  101.700  0.311

我研究了 creating a function to do this, but confused as to how to map and/or apply it in my case, especially the part returning the result as a new column 的方法。

尝试

final['AC'] = final['avg_daily']/final['TOA_daily']

添加所需的列。