question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

f_oneway should accept a nested list

See original GitHub issue

When 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:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
EverLookNeverSeecommented, Apr 6, 2020

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!

1reaction
erfannarimancommented, Apr 6, 2020

have some ideas for contribution … Im not confident if my code is written well enough and Im not sure how to write good tests

We can help with that. If you have ideas for new features, it is best to discuss them on the mailing list or in a github issue like this one. But once there is agreement that a new feature would be a good fit for scipy, pull requests are welcome. (As are pull requests to fix bugs.)

If you do end up submitting a pull request, don’t be surprised if you are asked to make a lot of changes. It can take a while to learn all our requirements for documentation, coding style (including PEP 8), unit tests, commit messages, and so on.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found