pengyuyan1222's picture
Update func_format.py
95fa6b4 verified
Raw History Blame Contribute Delete
775 Bytes
import pandas as pd
def result_format(df):
# df['实验组转化率'] = df['实验组转化率'].apply(lambda x: f'{x:.2%}' if pd.notnull(x) else '')
# df['对照组转化率'] = df['对照组转化率'].apply(lambda x: f'{x:.2%}' if pd.notnull(x) else '')
df['置信度'] = df['置信度'].apply(lambda x: f'{x}%')
df['p值(调整后)'] = df['p值(调整后)'].apply(lambda x: f'{x:.5f}')
df['p值(原始)'] = df['p值(原始)'].apply(lambda x: f'{x:.5f}')
df['绝对提升'] = df.apply(lambda row: f"{row['绝对提升']:.2%}" if row['指标类型'] == 'ratio' else (f"{row['绝对提升']:.1f}" if row['指标类型'] == 'mean' else row['绝对提升']),axis=1)
df['相对提升'] = df['相对提升'].apply(lambda x: f'{x:.2%}')
return df