« first day (14 days earlier)      last day (30 days later) » 

02:09
@U12-Forward I have a self-deleted Python question (stackoverflow.com/questions/…), I used an old answer to try to solve my problem but the old answer had flaws. None of the existing Q/A I can find in other similar questions marked as duplicate actually solve my issue. I'm not quite sure how to re-write my question that will get my preferred solution. Can you help me navigate the re-write and undelete so it will get an answer?
 
2 hours later…
03:55
@JamesRisner Could you give me a link?
04:11
sec
I deleted it so it didn't catch a lot more downvotes
but I was trying to order the list so all the NaN, Inf, etc are at the end of the list. All the other questions have it at the beginning or randomly somewhere in the list.
Issue was I didn't realize one of the questions were for python 2.x and the other required numpy (np)
Ah...
It's a bit hard to fix that...
I need to rewrite it so it can be answered, because I can't find an example that does what I'm trying in all the "dup" targets.
... and boy are they a lot.
but ultimately, I'm just trying to find 3 legitimate questions (non-duplicates) that I can hope to get Cubed. I just need 3 more on SO
@JamesRisner You should have a desired output
Also, you should get rid of the second example, that works.
"I need the NaN, Inf, and other things sorted to end of the list. Here are the two attempts:"
but I didn't write out the output explicitly.
@JamesRisner I can answer it once you add a desired output
04:17
it got an answer, but they retracted when it got a close vote I think.
@JamesRisner I think that's a good answer
edit you desired output in, and accept the answer, I can vote it up if you want
Or add another good answer
Ok, let me type some. 5 mins
ok check now
do you think that is sufficient to help it stand on it's own and not have a chance they will dup it?
I don't think it would be a dupe
04:28
Any improvements you can see?
(I should make)
You should keep what you tried
The code attempt
this?
a = sorted(
n,
lambda x,y: x is float('nan') and -1
or (y is float('nan') and 1
or cmp(x,y)))
that's python 2.7 I think
or the second one?
Maybe something like:
```
a = sorted(
n,
lambda x,y: (x is float('nan') and -1)
or (y is float('nan') and 1))
```
that errors: python z.py
Traceback (most recent call last):
File "/Users/risner/Documents/stackoverflow/winterbash/z.py", line 3, in <module>
a = sorted(
TypeError: sorted expected 1 argument, got 2
@JamesRisner Yes
For your attempt :)
04:33
Pranav Hosangadi or someone put in a close typo due to that.
I need to craft something that doesn't error from a syntax error I guess.
That's a typeerror, should be fine
what's <list_reverseiterator object at 0x102ba3550> mean?
trying to reverse the sorted?
@JamesRisner Ye
n = [13, 4, 52, 3.1, float('nan'), float('inf'), 8.2]
print(n)
o = sorted(n, key = lambda x : float('inf') if (x != x) else x)
print(o)
print(reversed(o))
that outputs
[13, 4, 52, 3.1, nan, inf, 8.2]
[3.1, 4, 8.2, 13, 52, nan, inf]
<list_reverseiterator object at 0x102f7f550>
print(list(reversed(o)))
well, now it's working as I need. It wasn't earlier today.
04:45
[3.1, 4, 8.2, 13, 52, nan, inf]
[inf, nan, 52, 13, 8.2, 4, 3.1]
sigh
You want it to keep the nans and infs at the end of the list right?
oh right, the reverse is broken.
I'm putting this code into the question now.
I will answer it
edited and undeleted
@JamesRisner Check my answer.
04:58
good
thanks
Does it work?
[52, 13, 8.2, 4, 3.1, nan, inf]
yes well for reverse.
how to get the forward? use my code for forward?
that's suitable
I need to write two more, and hope someone doesn't come along and complete the close on this one.
so I'll be up late tonight. I'll check it out tomorrow and if it's still open accept thanks. I know way too little python so I'll stick to more sql questions ;-)
@JamesRisner Check my answer edit
nice
thanks for the Q edit also.
it's nicer now. more code formatting ;-)
off to SQL land to write some more workable questions.
thanks by the way, that was good advice on improving the question.
 
2 hours later…
07:02
@JamesRisner No problem!

« first day (14 days earlier)      last day (30 days later) »