« first day (3407 days earlier)      last day (1766 days later) » 
06:00 - 21:0021:00 - 00:00

21:23
Is Python set always sorted?
I have a list l = [1,3,6,8,5,3,3,7,9,0,0,0,0,3,3,100]. When I do set_l = set(l) and see set_l, it does two things
1. Deletes duplicates. (Expected)
2. Always sorts (i thought set is unordered and can never be sorted)
@harvpan it never is
When I do set_l.add(-1) and print(set_l), it is added before 1, hence sorted.
Shouldn't it be added after 100 ?
Or simply anywhere since order is not kept?
the order of sets is "random" (unreliable, implementation detail)
>>> l = [1,3,6,8,5,3,3,7,9,0,0,0,0,3,3,100]

>>> set(l)
{0, 1, 3, 100, 5, 6, 7, 8, 9}
Interesting. I ran this small program again and again and always found it sorted
that's in my ipython ^
@harvpan if you're in London you might think that every taxi is black
21:27
Can you add (-1)?
>>> set_l
{0, 1, 3, 100, 5, 6, 7, 8, 9}

>>> set_l.add(-1)

>>> set_l
{0, 1, 3, 100, 5, 6, 7, 8, 9, -1}
Interesting. I wonder why my sets always shows up as sorted
It might depend on anything. Primarily: python version and environment.
For instance ipython used to order dict keys for pretty-printing, until dicts became well-ordered as a language feature in 3.7. They had to stop doing that.
Good point,
Thank you @AndrasDeak
no problem
21:51
@PaulMcG Here's a demo to show you how it reads, before I go about figuring out what each test should be returning.
22:04
rhubarb all @PaulMcG I'll try to work up the tests you've already got tonight.
wim
wim
twitches at misuse of "well-ordered"
meh
I don't like calling them "ordered" because that always sounds like "sorted" to me (OrderedDicts notwithstanding)
wim
wim
"dicts preserve insertion order" is the way to say it
"dicts became well-ordered" makes it sound like you can do d1 < d2 on dicts
indeed, but the sentence demanded an adjective and I wasn't going to rewrite it
wim
wim
became order-preserving
22:10
rbrb likewise - thank you all again for the friendly advice (still smarting a bit from that Java remark, but the sun will rise again tomorrow)
@wim perhaps
wim
wim
@PaulMcG I see what you did there
Oracle has entered the chat
22:38
Microsoft has entered the chat
Whats the best way to append a string to a dataframe cell and make sure there are no duplicates?
23:05
@Stramzik I don't understand "append [...] to a dataframe cell" vs "make sure there are no duplicates". One cell or many cells or all the cells in a column? Duplicates how?
@AndrasDeak lets say I take a cell from a dataframe which is empty to begin with. As i'm iterating over another df and if a condition is true i want to add the email to that cell.
But there is a possibility that the cell already contains the email after multiple iterations, in that case I dont want to add that email to that cell.
empty as in empty string, right?
yep
I tried this piece of code >>> new_df.iloc[j,3] = minidf.loc[0,k] if new_df.iloc[j,3]=='' else ", ".join((str(new_df.iloc[j,3]),minidf.loc[0,k]))
The reason I'm checking if the cell is empty is because if I try to concat to an empty string with","join it adds a "," at the begineeing
Does it really have to be on one line?
if whatever_email_address not in new_df.iloc[j, 3]:
    new_df.iloc[j, 3] += whatever_email_address
I'm afraid yes
23:18
Of course this doesn't lend itself well to vectorization, but this is probably true of your poblem in general. Though perhaps you can first grab the cells you want to change, and then change them at the same time.
@Stramzik can you explain why?
So basically the rows represent a unique server. Each server will have multiple managers and tech leads. Our goal is to have a row like this
06:00 - 21:0021:00 - 00:00

« first day (3407 days earlier)      last day (1766 days later) »