使用Python中的pandas库实现。具体步骤如下:
import pandas as pd
df = pd.read_excel('data.xlsx')
df_new = df.query('(col2 > col1) & (col2 > col3)') # col1/col2/col3为数据表中对应列的名称
s = df_new[['col1', 'col2', 'col3']].max(axis=1) * 2 # 获取三列中的最大值并乘以2
df_new['new_col'] = s # 将Series对象添加为新列
print(df_new)
完整代码:
import pandas as pd
df = pd.read_excel('data.xlsx')
df_new = df.query('(col2 > col1) & (col2 > col3)')
s = df_new[['col1', 'col2', 'col3']].max(axis=1) * 2
df_new['new_col'] = s
print(df_new)