f_oneway should accept a nested list
See original GitHub issueWhen you want to make a generic function which gathers all the lists with values and you want to compare their means with f_oneway
, you have to gather them in a list. Apparantly the functions f_oneway
does not accept a nested list, but only separate lists.
Example:
import pandas as pd
from scipy.stats import f_oneway
df = pd.DataFrame({'Weight': [4.17,5.58,5.18,6.11,4.5,4.61,5.17,4.53,5.33,5.14,4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69,6.31,5.12,5.54,5.5,5.37,5.29,4.92,6.15,5.8,5.26],
'Group': ['A','A','A','A','A','A','A','A','A','A','B','B','B','B','B','B','B','B','B','B','C','C','C','C','C','C','C','C','C','C']
})
This works, when we hardcode each separate list:
grps = [d['Weight'].tolist() for _, d in df.groupby('Group')]
l1 = grps[0]
l2 = grps[1]
l3 = grps[2]
F, p = f_oneway(l1,l2,l3)
print(F, p)
4.846087862380136 0.0159099583256229
This does not work, when we pass the nested list grps
to f_oneway
:
F, p = f_oneway(grps)
print(F, p)
[nan nan nan nan nan nan nan nan nan nan] [nan nan nan nan nan nan nan nan nan nan]
So am I missing something here, or is there any other solution to this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
10 Important Tips for Using Nested Lists in Python
This is one way of doing it. [element for element in sub_list for sub_list in nested_list]. First, iterate through the nested list, then...
Read more >Nested List Comprehension With Flow Control - Stack Overflow
This is searching for prime numbers between a and b. I will saving each prime number into a list. The code above above...
Read more >Make tar_watch aware of the nested lists in targets objects to ...
Another approach is to call tar_manifest() to get a list of target names and then use a multi-select widget to allow or exclude...
Read more >Does anybody else just not like the syntax for nested one-line ...
Suppose I want to do some list comprehension: new_list = [x*b for x in a] ... I agree - I find the nested...
Read more >Solved It isn't very convenient to piece together our trees
One way to do this is to use a special nested list format. Consider the following tree 72 24 78 8 51 25...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @erfannariman , Don’t worry. just try to learn and level up your technical skills. There is no need to be a professional and experienced programmer, start from small and simple. Good luck!
Yes I will submit a pull request in time. It’s not only about the code, also for the documentation or for the docstrings. About the “lot of changes”, that’s perfectly fine, even better to get feedback and learn! I will use the contributor guide as my guideline for now.