![]() |
Combining outputs into a dataframe - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Combining outputs into a dataframe (/thread-32904.html) |
Combining outputs into a dataframe - rybina - Mar-15-2021 Hi, I'm hoping for some help with combining several results into a dataframe. There are 12 queries with results like this in total, but for this I will only use the top 2 which I have simplified here. (I've used font colours just to try and make the question clearer). Effectively I'm just performing mannwhitney-u tests and combining the results together to see along side each other. The first query/result looks like: # significance test on matching period for product group value sample = matched_outlet_data_sample[matched_outlet_data_sample['is_matching_period'] == 1] control = matched_outlet_data_control[matched_outlet_data_control['is_matching_period'] == 1] mannwhitneyu(sample['product_volume'], control['product_volume']) which outputs: MannwhitneyuResult(statistic=2512124.0, pvalue=1.171173665936018e-16) the second query/result looks like: # significance test on matching period for product group volume sample = matched_outlet_data_sample[matched_outlet_data_sample['is_matching_period'] == 1] control = matched_outlet_data_control[matched_outlet_data_control['is_matching_period'] == 1] mannwhitneyu(sample['product_volume'], control['product_volume']) which outputs: MannwhitneyuResult(statistic=2217863.5, pvalue=1.3144757236956563e-46) And the dataframe I would like to achieve from this would look something like: (I don't know how to show tables here so i've just added commas as seperators) result, statistic, pvalue significance_test_on_matching_period_for_product_group_value, 2512124.0, 1.171173665936018e-16 significance_test_on_matching_period_for_product_group_volume, 2217863.5, 1.3144757236956563e-46 I don't know to do this, so any help would be really good. I suppose it would require creating a dataframe with one row, and then just adding a row to it with each result until all 12 results are in the dataframe? I know that this isn't the clearest presentation of the problem, so if anything isn't clear please do let me know. And thanks all, I really appreciate any help with this a new python user. |