Download func_format.py from pengyuyan1222/Multi_ABtest_Result_Analytics: direct link, hf CLI and curl.
- Browser
- Download file 775 Bytes
-
https://huggingface.co/spaces/pengyuyan1222/Multi_ABtest_Result_Analytics/resolve/main/func_format.py
- Command line
-
hf download hf://spaces/pengyuyan1222/Multi_ABtest_Result_Analytics/func_format.py
-
curl -L -o func_format.py https://huggingface.co/spaces/pengyuyan1222/Multi_ABtest_Result_Analytics/resolve/main/func_format.py
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 |