2

I came across this question about pandas: Replacing loop with efficient pandas dataframe operation

It applies several statistical models to a dataframe and extracts some model statistics (intercept, slope, r-square, sample size - very common measures).

The question basically asks if there is an alternative method exists without going over the loop (many pandas questions ask the same thing: how can I do this without a loop).

The answer, if yes, wouldn't be too long to this question. It would be:

df.somefunction().someotherfunction()....

And a few similar lines.

There would not be many possible answers too, as the question's scope is very limited to start with. How many pandas solutions can you have?

I understand the question can be improved by defining the table structure, making the code more readable, etc. but what is being asked seems very clear to me.

Apparently at least five other people disagree with me so I'd like to learn what is the expected content for a question like this.

4
  • 1
    From the comment on the question "It feels like you're asking StackOverflow to refactor your code for you. If you are, you could at least try to make it follow PEP8 and perhaps spell out variable names a bit so we have any clue what is going on. But really, maybe you want to go to a rent-a-coder site instead."
    – Patrice
    Commented Apr 26, 2016 at 16:56
  • @Patrice: It's important to note here that the asker of this Meta question is not the OP of the other question.
    – Makoto
    Commented Apr 26, 2016 at 17:15
  • @Makoto that was noted. Doesn't change that the ayhan's answer is partly in the comment on the question.
    – Patrice
    Commented Apr 26, 2016 at 17:17
  • 1
    @Patrice: I'm not convinced. I mean, the comment comes across as snide and underhanded more than anything else; the only answers I'd glean from something like that are a) this person doesn't know what problem I'm trying to solve, and b) they're being a jerk about it.
    – Makoto
    Commented Apr 26, 2016 at 17:52

1 Answer 1

3

I've only skimmed the question, and I am indeed ignorant of the ways of Pandas, but this stuck out:

Is there a much simpler, faster way of doing this when the number of models gets into the many thousands?

This says two things to me:

  • "Faster" implies that it needs to be profiled
  • "Simpler" is subjective in that this may be as simple as it can be, or it could be simplified to a point where it's incredibly terse

I don't have a dog in this fight so I won't vote on the question either way, but if you strongly feel that this question is clear, then one way to make that case would be to rephrase the question being posed.

0

You must log in to answer this question.