workspace
stringclasses 1
value | channel
stringclasses 1
value | sentences
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
| sentence_id
stringlengths 44
53
| timestamp
float64 1.5B
1.56B
| __index_level_0__
int64 0
106k
|
---|---|---|---|---|---|---|---|
pythondev
|
help
|
I want to look into data visualization with python, what are some decent data sources I can use for free without violating any laws?
|
2017-08-31T11:40:54.000148
|
Ramona
|
pythondev_help_Ramona_2017-08-31T11:40:54.000148
| 1,504,179,654.000148 | 91,603 |
pythondev
|
help
|
<https://github.com/caesar0301/awesome-public-datasets>
|
2017-08-31T11:43:29.000626
|
Meg
|
pythondev_help_Meg_2017-08-31T11:43:29.000626
| 1,504,179,809.000626 | 91,604 |
pythondev
|
help
|
Wow this is a gigantic collection! Thanks <@Meg> :taco:
|
2017-08-31T11:57:58.000217
|
Ramona
|
pythondev_help_Ramona_2017-08-31T11:57:58.000217
| 1,504,180,678.000217 | 91,605 |
pythondev
|
help
|
its not an actual storage, more like a curated list of links for you to retrieve yourself
|
2017-08-31T11:58:19.000583
|
Meg
|
pythondev_help_Meg_2017-08-31T11:58:19.000583
| 1,504,180,699.000583 | 91,606 |
pythondev
|
help
|
but I think it should fit your needs
|
2017-08-31T11:58:27.000310
|
Meg
|
pythondev_help_Meg_2017-08-31T11:58:27.000310
| 1,504,180,707.00031 | 91,607 |
pythondev
|
help
|
also, there's <http://academictorrents.com/>
|
2017-08-31T11:58:44.000228
|
Meg
|
pythondev_help_Meg_2017-08-31T11:58:44.000228
| 1,504,180,724.000228 | 91,608 |
pythondev
|
help
|
<@Patty> might be interested in that too
|
2017-08-31T11:58:54.000243
|
Meg
|
pythondev_help_Meg_2017-08-31T11:58:54.000243
| 1,504,180,734.000243 | 91,609 |
pythondev
|
help
|
Hey all. I have a question, and I hope this is the right Slack to ask it in. I am trying to get Molecule to work on Windows 7 to test Ansbile roles. I get everything installed, however, when I try and run Molecule, it tells me that sh 1.12.14 is currently not available on Windows, and to install pbs instead. I used pip install pbs, but now I am not sure how to actually get Molecule to use it instead of sh.
|
2017-08-31T12:08:30.000093
|
Everett
|
pythondev_help_Everett_2017-08-31T12:08:30.000093
| 1,504,181,310.000093 | 91,610 |
pythondev
|
help
|
I am trying to understand why the multi-processing code keeps waiting. My code works completely fine standalone. Here is the dumbed down version (does not compile) : ``` import someLib
##someLib library has both Request and process modules
def delegate(response, unwm_img_path, wm_url):
'''
do something here
'''
def worker(image_url):
print(image_url)
start = time.time()
i = 0
req.image_path = get_path(image_url)
print('before: ', req.image_path)
new_rows = delegate(someLib.process(req), req.image_path, image_url)
print('after: ', req.image_path)
if new_rows is not None:
print(new_rows)
else:
print('not processing ', image_url)
else:
print('failed to open image:', image_url)
if __name__ == '__main__':
with open(file_path, 'r') as f:
image_urls = sum(list(csv.reader(f)), [])
if os.path.exists(cf_file_path):
append_write = 'a' # append if already exists
else:
append_write = 'w' # make a new file if not
1_file = open(cfile_path, append_write)
2_file = open(afile, append_write)
wr = csv.writer(cfile, quoting=csv.QUOTE_ALL)
wr2 = csv.writer(afile)
req = someLib.Request()
pool = Pool()
pool.map(worker, image_urls)
pool.close()
pool.join() ```
|
2017-08-31T13:58:28.000113
|
Tameika
|
pythondev_help_Tameika_2017-08-31T13:58:28.000113
| 1,504,187,908.000113 | 91,611 |
pythondev
|
help
|
<@Tameika> where does it stop behaving in a predictable manner?
|
2017-08-31T14:01:20.000120
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:01:20.000120
| 1,504,188,080.00012 | 91,612 |
pythondev
|
help
|
<@Suellen> : i think the problem is this line : ` new_rows = delegate(someLib.process(req), req.image_path, image_url)`
|
2017-08-31T14:03:38.000167
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:03:38.000167
| 1,504,188,218.000167 | 91,613 |
pythondev
|
help
|
when I comment that line, the whole program runs fine
|
2017-08-31T14:04:21.000657
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:04:21.000657
| 1,504,188,261.000657 | 91,614 |
pythondev
|
help
|
so, relevant code is probably there
|
2017-08-31T14:05:27.000471
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:05:27.000471
| 1,504,188,327.000471 | 91,615 |
pythondev
|
help
|
true, i think it has got do with the fact that the `someLib.process(req)` is being called by multiple workers
|
2017-08-31T14:08:14.000679
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:08:14.000679
| 1,504,188,494.000679 | 91,616 |
pythondev
|
help
|
what is that library?
|
2017-08-31T14:08:25.000210
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:08:25.000210
| 1,504,188,505.00021 | 91,617 |
pythondev
|
help
|
hm.. even if it's not thread-safe, does that mean it's not multiprocess-safe?
|
2017-08-31T14:08:50.000573
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:08:50.000573
| 1,504,188,530.000573 | 91,618 |
pythondev
|
help
|
I'm honestly not sure
|
2017-08-31T14:09:00.000086
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:09:00.000086
| 1,504,188,540.000086 | 91,619 |
pythondev
|
help
|
it is a library which I created myself to wrap C++ code. Didnt take it account thread safety
|
2017-08-31T14:09:58.000451
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:09:58.000451
| 1,504,188,598.000451 | 91,620 |
pythondev
|
help
|
in theory it should be ok, since a whole process is launched for the task
|
2017-08-31T14:10:43.000300
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:10:43.000300
| 1,504,188,643.0003 | 91,621 |
pythondev
|
help
|
a debugger of some kind is your best bet, guessing will only take you so far
|
2017-08-31T14:11:20.000057
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:11:20.000057
| 1,504,188,680.000057 | 91,622 |
pythondev
|
help
|
One guess left:
> req = someLib.Request()
|
2017-08-31T14:11:40.000068
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:11:40.000068
| 1,504,188,700.000068 | 91,623 |
pythondev
|
help
|
This is a shared resource that's used between processes
|
2017-08-31T14:11:50.000367
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:11:50.000367
| 1,504,188,710.000367 | 91,624 |
pythondev
|
help
|
that's not very good
|
2017-08-31T14:12:03.000786
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:12:03.000786
| 1,504,188,723.000786 | 91,625 |
pythondev
|
help
|
can you refactor it so that each worker gets its own copy?
|
2017-08-31T14:12:15.000189
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:12:15.000189
| 1,504,188,735.000189 | 91,626 |
pythondev
|
help
|
sure will do
|
2017-08-31T14:13:32.000139
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:13:32.000139
| 1,504,188,812.000139 | 91,627 |
pythondev
|
help
|
it still waits
|
2017-08-31T14:21:56.000327
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:21:56.000327
| 1,504,189,316.000327 | 91,628 |
pythondev
|
help
|
essentially it prints all the 'before' statements and hangs
|
2017-08-31T14:22:22.000594
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:22:22.000594
| 1,504,189,342.000594 | 91,629 |
pythondev
|
help
|
inside `delegate` too?
|
2017-08-31T14:24:10.000141
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:24:10.000141
| 1,504,189,450.000141 | 91,630 |
pythondev
|
help
|
up until you call a C function?
|
2017-08-31T14:24:18.000350
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:24:18.000350
| 1,504,189,458.00035 | 91,631 |
pythondev
|
help
|
delegate does not call the C function , it is `someLib.process(req)` which does
|
2017-08-31T14:25:07.000320
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:25:07.000320
| 1,504,189,507.00032 | 91,632 |
pythondev
|
help
|
i even decoupled that line into 2 lines : ```c_resp = someLib.process(req)
|
2017-08-31T14:25:51.000064
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:25:51.000064
| 1,504,189,551.000064 | 91,633 |
pythondev
|
help
|
` new_rows = delegate(c_resp, req.image_path, image_url)```
|
2017-08-31T14:26:16.000055
|
Tameika
|
pythondev_help_Tameika_2017-08-31T14:26:16.000055
| 1,504,189,576.000055 | 91,634 |
pythondev
|
help
|
you most definitely need a real debugger then
|
2017-08-31T14:27:15.000177
|
Suellen
|
pythondev_help_Suellen_2017-08-31T14:27:15.000177
| 1,504,189,635.000177 | 91,635 |
pythondev
|
help
|
in pycharm when querying a database using an sql console, is it possible to mimic the output format of `\G` ?
|
2017-08-31T16:34:43.000368
|
Bruno
|
pythondev_help_Bruno_2017-08-31T16:34:43.000368
| 1,504,197,283.000368 | 91,636 |
pythondev
|
help
|
it doesnt seem to like that. but when i have one record with a ton of columns, make it harder to read.
|
2017-08-31T16:35:07.000477
|
Bruno
|
pythondev_help_Bruno_2017-08-31T16:35:07.000477
| 1,504,197,307.000477 | 91,637 |
pythondev
|
help
|
ah on the top right theres a "Transpose" button. any ways to get that from the actual query?
|
2017-08-31T16:36:00.000194
|
Bruno
|
pythondev_help_Bruno_2017-08-31T16:36:00.000194
| 1,504,197,360.000194 | 91,638 |
pythondev
|
help
|
probably not :disappointed:
|
2017-08-31T16:39:37.000302
|
Suellen
|
pythondev_help_Suellen_2017-08-31T16:39:37.000302
| 1,504,197,577.000302 | 91,639 |
pythondev
|
help
|
but it's saved in your current session
|
2017-08-31T16:39:52.000392
|
Suellen
|
pythondev_help_Suellen_2017-08-31T16:39:52.000392
| 1,504,197,592.000392 | 91,640 |
pythondev
|
help
|
hmm. more efficient way to write this if theres a million `accounts` and you just need to return the first:
```
account = [acc for acc in portfolio if 'type' in acc and acc['type'] == 'annuity'][0]
```
while keeping it in a generator. easy if just using a loop
|
2017-08-31T17:20:49.000311
|
Bruno
|
pythondev_help_Bruno_2017-08-31T17:20:49.000311
| 1,504,200,049.000311 | 91,641 |
pythondev
|
help
|
<@Bruno> can you do `account = next(acc for acc in portfolio if 'type' in acc and acc['type'] == 'annuity')`
|
2017-08-31T17:30:55.000341
|
Antionette
|
pythondev_help_Antionette_2017-08-31T17:30:55.000341
| 1,504,200,655.000341 | 91,642 |
pythondev
|
help
|
What is the most effective way to perform `Open Image in new tab` and grab the url of that image in python?
|
2017-08-31T17:36:39.000232
|
Tameika
|
pythondev_help_Tameika_2017-08-31T17:36:39.000232
| 1,504,200,999.000232 | 91,643 |
pythondev
|
help
|
if you know what to open in a new tab, don't you know an URL already?
|
2017-08-31T17:37:38.000210
|
Suellen
|
pythondev_help_Suellen_2017-08-31T17:37:38.000210
| 1,504,201,058.00021 | 91,644 |
pythondev
|
help
|
I tried referring to this SO link : <https://stackoverflow.com/questions/40110394/how-to-get-absolute-path-for-image-on-a-website>
|
2017-08-31T17:37:46.000124
|
Tameika
|
pythondev_help_Tameika_2017-08-31T17:37:46.000124
| 1,504,201,066.000124 | 91,645 |
pythondev
|
help
|
but it does seem to retrieve all images
|
2017-08-31T17:37:54.000050
|
Tameika
|
pythondev_help_Tameika_2017-08-31T17:37:54.000050
| 1,504,201,074.00005 | 91,646 |
pythondev
|
help
|
<@Antionette> hmm, ill have to try that.
|
2017-08-31T17:39:28.000106
|
Bruno
|
pythondev_help_Bruno_2017-08-31T17:39:28.000106
| 1,504,201,168.000106 | 91,647 |
pythondev
|
help
|
don't forget about iter!
|
2017-08-31T17:40:31.000321
|
Suellen
|
pythondev_help_Suellen_2017-08-31T17:40:31.000321
| 1,504,201,231.000321 | 91,648 |
pythondev
|
help
|
<@Bruno> afaik it should only run until first is found
|
2017-08-31T17:40:40.000002
|
Antionette
|
pythondev_help_Antionette_2017-08-31T17:40:40.000002
| 1,504,201,240.000002 | 91,649 |
pythondev
|
help
|
doesn't exhaust the generator!
|
2017-08-31T17:40:43.000102
|
Suellen
|
pythondev_help_Suellen_2017-08-31T17:40:43.000102
| 1,504,201,243.000102 | 91,650 |
pythondev
|
help
|
no but if it doesnt exist it will throw an exception.
|
2017-08-31T17:45:12.000186
|
Bruno
|
pythondev_help_Bruno_2017-08-31T17:45:12.000186
| 1,504,201,512.000186 | 91,651 |
pythondev
|
help
|
so need try/catch
|
2017-08-31T17:45:29.000352
|
Bruno
|
pythondev_help_Bruno_2017-08-31T17:45:29.000352
| 1,504,201,529.000352 | 91,652 |
pythondev
|
help
|
which is fine.
|
2017-08-31T17:45:38.000261
|
Bruno
|
pythondev_help_Bruno_2017-08-31T17:45:38.000261
| 1,504,201,538.000261 | 91,653 |
pythondev
|
help
|
<@Bruno> I believe it could also take in a default argument like: `account = next((acc for acc in portfolio if 'type' in acc and acc['type'] == 'annuity'), false)` if you wanted to do it like that. I think your original example would have also thrown an error if it was not found (list index out of range)
|
2017-08-31T17:52:01.000050
|
Antionette
|
pythondev_help_Antionette_2017-08-31T17:52:01.000050
| 1,504,201,921.00005 | 91,654 |
pythondev
|
help
|
<https://docs.python.org/3/library/functions.html#next>
|
2017-08-31T17:53:25.000481
|
Antionette
|
pythondev_help_Antionette_2017-08-31T17:53:25.000481
| 1,504,202,005.000481 | 91,655 |
pythondev
|
help
|
hmm, interesting.
|
2017-08-31T17:55:32.000090
|
Bruno
|
pythondev_help_Bruno_2017-08-31T17:55:32.000090
| 1,504,202,132.00009 | 91,656 |
pythondev
|
help
|
the original shouldnt and just not return any results.
|
2017-08-31T17:56:10.000161
|
Bruno
|
pythondev_help_Bruno_2017-08-31T17:56:10.000161
| 1,504,202,170.000161 | 91,657 |
pythondev
|
help
|
the comprehension part would return an empty list and then trying to get the first element would raise the exception
|
2017-08-31T18:22:37.000205
|
Antionette
|
pythondev_help_Antionette_2017-08-31T18:22:37.000205
| 1,504,203,757.000205 | 91,658 |
pythondev
|
help
|
Dooood! FINALLY! I've read and read and looked at multiple examples and IT JUST CLICKED!
|
2017-08-31T18:51:13.000219
|
Deedee
|
pythondev_help_Deedee_2017-08-31T18:51:13.000219
| 1,504,205,473.000219 | 91,659 |
pythondev
|
help
|
:taco: <@Suellen>
|
2017-08-31T18:51:25.000367
|
Deedee
|
pythondev_help_Deedee_2017-08-31T18:51:25.000367
| 1,504,205,485.000367 | 91,660 |
pythondev
|
help
|
<@Antionette> ooh. youre right.
|
2017-08-31T19:01:40.000093
|
Bruno
|
pythondev_help_Bruno_2017-08-31T19:01:40.000093
| 1,504,206,100.000093 | 91,661 |
pythondev
|
help
|
<@Deedee> trying to understand unpacking?
|
2017-08-31T19:02:43.000277
|
Bruno
|
pythondev_help_Bruno_2017-08-31T19:02:43.000277
| 1,504,206,163.000277 | 91,662 |
pythondev
|
help
|
This is awesome! Thanks!
|
2017-08-31T19:03:26.000208
|
Deedee
|
pythondev_help_Deedee_2017-08-31T19:03:26.000208
| 1,504,206,206.000208 | 91,663 |
pythondev
|
help
|
:taco: <@Meg>
|
2017-08-31T19:03:31.000321
|
Deedee
|
pythondev_help_Deedee_2017-08-31T19:03:31.000321
| 1,504,206,211.000321 | 91,664 |
pythondev
|
help
|
I've done it before but haven't really grasped it. And I've encountered it in reading but, again, hadn't really grasped it. I think this did it though. :wink: No worries though <@Bruno> . I'll be posting here if I have issues w/ it moving forward hahaha
|
2017-08-31T19:07:01.000199
|
Deedee
|
pythondev_help_Deedee_2017-08-31T19:07:01.000199
| 1,504,206,421.000199 | 91,665 |
pythondev
|
help
|
cool. glad you got it.
|
2017-08-31T19:10:05.000162
|
Bruno
|
pythondev_help_Bruno_2017-08-31T19:10:05.000162
| 1,504,206,605.000162 | 91,666 |
pythondev
|
help
|
Bump...
Our boy is almost certain that this is an Azure Service Bus shortcoming, and not a problem w/ Python. Can anyone confirm? Again, error messages are in English.
|
2017-08-31T19:14:47.000268
|
Deedee
|
pythondev_help_Deedee_2017-08-31T19:14:47.000268
| 1,504,206,887.000268 | 91,667 |
pythondev
|
help
|
How it was originally shared here yesterday.
|
2017-08-31T19:15:43.000065
|
Deedee
|
pythondev_help_Deedee_2017-08-31T19:15:43.000065
| 1,504,206,943.000065 | 91,668 |
pythondev
|
help
|
Hi All!
|
2017-08-31T22:45:32.000007
|
Carlene
|
pythondev_help_Carlene_2017-08-31T22:45:32.000007
| 1,504,219,532.000007 | 91,669 |
pythondev
|
help
|
am I allowed to ask for coding help here?
|
2017-08-31T22:45:42.000115
|
Carlene
|
pythondev_help_Carlene_2017-08-31T22:45:42.000115
| 1,504,219,542.000115 | 91,670 |
pythondev
|
help
|
Stupid q but I nearly got kicked off another platform
|
2017-08-31T22:46:11.000094
|
Carlene
|
pythondev_help_Carlene_2017-08-31T22:46:11.000094
| 1,504,219,571.000094 | 91,671 |
pythondev
|
help
|
<@Carlene> yup! <#C07EFMZ1N|help> is for more general python questions and then we've got various channels for more specific stuff like <#C0LMFRMB5|django> <#C0LN2AD7T|flask>, etc.
|
2017-08-31T23:02:50.000087
|
Marcie
|
pythondev_help_Marcie_2017-08-31T23:02:50.000087
| 1,504,220,570.000087 | 91,672 |
pythondev
|
help
|
I believe it's best to `.gitignore` the `.pyc` files
|
2017-09-01T04:09:34.000095
|
Ciera
|
pythondev_help_Ciera_2017-09-01T04:09:34.000095
| 1,504,238,974.000095 | 91,673 |
pythondev
|
help
|
i did but they were added to the log before I added *.pyc to gitignore actually just did a commit without adding the files and it worked
|
2017-09-01T04:10:34.000147
|
Beverley
|
pythondev_help_Beverley_2017-09-01T04:10:34.000147
| 1,504,239,034.000147 | 91,674 |
pythondev
|
help
|
you might also want to do a commit that delete the one on master
|
2017-09-01T04:12:11.000198
|
Ciera
|
pythondev_help_Ciera_2017-09-01T04:12:11.000198
| 1,504,239,131.000198 | 91,675 |
pythondev
|
help
|
I have a list `seq`. I want to split this list up into sublists by grouping them around a function. Any idea what this might be called?
Best explained with an example probably:
`f(seq=range(8), grouping_function=lambda x: x % 3) == [[0,3,6]. [1,4,7], [2,5]]`
|
2017-09-01T05:15:21.000001
|
Lanita
|
pythondev_help_Lanita_2017-09-01T05:15:21.000001
| 1,504,242,921.000001 | 91,676 |
pythondev
|
help
|
groupby?
|
2017-09-01T05:16:25.000125
|
Suellen
|
pythondev_help_Suellen_2017-09-01T05:16:25.000125
| 1,504,242,985.000125 | 91,677 |
pythondev
|
help
|
oh... of course. I kept looking at things called partition. thanks.
|
2017-09-01T05:16:46.000242
|
Lanita
|
pythondev_help_Lanita_2017-09-01T05:16:46.000242
| 1,504,243,006.000242 | 91,678 |
pythondev
|
help
|
you might want to look at `more-itertools` or `boltons` library
|
2017-09-01T05:19:40.000055
|
Suellen
|
pythondev_help_Suellen_2017-09-01T05:19:40.000055
| 1,504,243,180.000055 | 91,679 |
pythondev
|
help
|
lots of short helper functions there
|
2017-09-01T05:19:50.000024
|
Suellen
|
pythondev_help_Suellen_2017-09-01T05:19:50.000024
| 1,504,243,190.000024 | 91,680 |
pythondev
|
help
|
<https://github.com/mahmoud/boltons/blob/master/boltons/iterutils.py#L470>
|
2017-09-01T05:20:46.000179
|
Suellen
|
pythondev_help_Suellen_2017-09-01T05:20:46.000179
| 1,504,243,246.000179 | 91,681 |
pythondev
|
help
|
```
>>> bucketize(range(10), lambda x: x % 3)
{0: [0, 3, 6, 9], 1: [1, 4, 7], 2: [2, 5, 8]}
```
|
2017-09-01T05:20:53.000008
|
Suellen
|
pythondev_help_Suellen_2017-09-01T05:20:53.000008
| 1,504,243,253.000008 | 91,682 |
pythondev
|
help
|
just look at the example!
|
2017-09-01T05:20:56.000041
|
Suellen
|
pythondev_help_Suellen_2017-09-01T05:20:56.000041
| 1,504,243,256.000041 | 91,683 |
pythondev
|
help
|
cool
|
2017-09-01T05:21:00.000040
|
Suellen
|
pythondev_help_Suellen_2017-09-01T05:21:00.000040
| 1,504,243,260.00004 | 91,684 |
pythondev
|
help
|
hello guys
|
2017-09-01T05:22:57.000209
|
Denna
|
pythondev_help_Denna_2017-09-01T05:22:57.000209
| 1,504,243,377.000209 | 91,685 |
pythondev
|
help
|
i have a question
|
2017-09-01T05:23:02.000135
|
Denna
|
pythondev_help_Denna_2017-09-01T05:23:02.000135
| 1,504,243,382.000135 | 91,686 |
pythondev
|
help
|
i have a user data with 20 different parameters and i have some "results" with predefined conditions
|
2017-09-01T05:23:28.000182
|
Denna
|
pythondev_help_Denna_2017-09-01T05:23:28.000182
| 1,504,243,408.000182 | 91,687 |
pythondev
|
help
|
like "((a=5 or b=3) and user.is_active) or user.is_admin"
|
2017-09-01T05:24:05.000038
|
Denna
|
pythondev_help_Denna_2017-09-01T05:24:05.000038
| 1,504,243,445.000038 | 91,688 |
pythondev
|
help
|
i can run eval(condition) for each result on each data but there are plenty of result items now, like 2000, it takes too long
|
2017-09-01T05:25:32.000362
|
Denna
|
pythondev_help_Denna_2017-09-01T05:25:32.000362
| 1,504,243,532.000362 | 91,689 |
pythondev
|
help
|
Perhaps there's a nicer way to solve my problem though: I want to grab the first value in each group created by splitting a sequence up using some function.
Right now I'm thinking of doing something like
```
for k, group in groupby(sorted(seq), partitionfunc):
yield next(group)
continue
```
|
2017-09-01T05:27:55.000084
|
Lanita
|
pythondev_help_Lanita_2017-09-01T05:27:55.000084
| 1,504,243,675.000084 | 91,690 |
pythondev
|
help
|
any advices to make it faster and more clean-logical-pythonic?
|
2017-09-01T05:27:56.000224
|
Denna
|
pythondev_help_Denna_2017-09-01T05:27:56.000224
| 1,504,243,676.000224 | 91,691 |
pythondev
|
help
|
<@Lanita> `next(groupby(...))`?
|
2017-09-01T05:30:30.000296
|
Suellen
|
pythondev_help_Suellen_2017-09-01T05:30:30.000296
| 1,504,243,830.000296 | 91,692 |
pythondev
|
help
|
<@Denna> those predifined conditions are string ?
|
2017-09-01T05:30:51.000036
|
Ciera
|
pythondev_help_Ciera_2017-09-01T05:30:51.000036
| 1,504,243,851.000036 | 91,693 |
pythondev
|
help
|
<@Denna> I think that depends largely on the semantics of those conditions. `eval` is almost certainly not the answer though
|
2017-09-01T05:30:51.000075
|
Gabriele
|
pythondev_help_Gabriele_2017-09-01T05:30:51.000075
| 1,504,243,851.000075 | 91,694 |
pythondev
|
help
|
<@Ciera> they are coming from users of the system
|
2017-09-01T05:31:21.000079
|
Denna
|
pythondev_help_Denna_2017-09-01T05:31:21.000079
| 1,504,243,881.000079 | 91,695 |
pythondev
|
help
|
not from a programmer
|
2017-09-01T05:31:31.000242
|
Denna
|
pythondev_help_Denna_2017-09-01T05:31:31.000242
| 1,504,243,891.000242 | 91,696 |
pythondev
|
help
|
also please use <https://get.slack.help/hc/en-us/articles/202288908-Format-your-messages#code-blocks> :slightly_smiling_face:
|
2017-09-01T05:31:36.000197
|
Ciera
|
pythondev_help_Ciera_2017-09-01T05:31:36.000197
| 1,504,243,896.000197 | 91,697 |
pythondev
|
help
|
you might want to look at testing framework that does thing like this
|
2017-09-01T05:31:57.000084
|
Ciera
|
pythondev_help_Ciera_2017-09-01T05:31:57.000084
| 1,504,243,917.000084 | 91,698 |
pythondev
|
help
|
but I don't remember how it's called :confused:
|
2017-09-01T05:32:07.000242
|
Ciera
|
pythondev_help_Ciera_2017-09-01T05:32:07.000242
| 1,504,243,927.000242 | 91,699 |
pythondev
|
help
|
How are users able to formulate these conditions when they obviously refer to code details (like the existence of an 'is_admin' property)
|
2017-09-01T05:32:50.000159
|
Gabriele
|
pythondev_help_Gabriele_2017-09-01T05:32:50.000159
| 1,504,243,970.000159 | 91,700 |
pythondev
|
help
|
Perhaps this explains it better:
```
from typing import Sequence, TypeVar, Callable, Any, Generator
from itertools import groupby
T = TypeVar("T")
def first_of_each_group(seq: Sequence[T], group_by: Callable[[T], Any])\
-> Generator:
"""Groups every object x in `seq` by the value from `group_by(x)`,
then returns the first entry of every group.
"""
for _, group in groupby(sorted(seq), group_by):
yield next(group)
continue
from unittest import TestCase
class FuncTest(TestCase):
def test_first_of_each_group(self):
input_data = [3, 1, 349, 12, 4, 939, 16]
group_by = lambda x: len(str(x))
expected_outut = [1, 349, 12]
self.assertCountEqual(
list(first_of_each_group(input_data, group_by)),
expected_output)
```
|
2017-09-01T05:34:30.000141
|
Lanita
|
pythondev_help_Lanita_2017-09-01T05:34:30.000141
| 1,504,244,070.000141 | 91,701 |
pythondev
|
help
|
we're giving a simple doc about available variables to them
|
2017-09-01T05:34:57.000013
|
Denna
|
pythondev_help_Denna_2017-09-01T05:34:57.000013
| 1,504,244,097.000013 | 91,702 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.