I am using the statsmodels.stats.multitest.multipletests function
to correct p-values I have stored in a dataframe:
p_value_df = pd.DataFrame({"id": [123456, 456789], "p-value": [0.098, 0.05]})
for _, row in p_value_df.iterrows():
p_value = row["p-value"]
print(p_value)
results = multi.multipletests(
p_value,
alpha=0.05,
method="bonferroni",
maxiter=1,
is_sorted=False,
returnsorted=False,
)
print(results)
I would really like to add each of the elements of the tuple output as a new column in the p_value_df and am a bit stuck.
I've attempted to convert the results to a list and use zip(*tuples_converted_to_list) but as some of the values are floats this throws an error.
Additionally, I'd like to pull the array elements so that array([False]) is just False.
Can anyone make any recommendations on a strategy to do this?

I would use a listcomp to make a nested list of the multitests, then pass it to the
DataFrameconstructor and finallyjoinit with the originalp_value_df:Output :