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
hey all, running into a little problem on grouping functions! So I have this code within my flask view; ``` if convertToJson(track_table_row,categories): flash(str(title) + ' Has been uploaded to site','success') updatePriTableApproval(trackId,link) return redirect(url_for('...
2018-01-23T10:50:48.000419
Milo
pythondev_help_Milo_2018-01-23T10:50:48.000419
1,516,704,648.000419
30,824
pythondev
help
hi everyone
2018-01-23T10:58:25.000569
Kimbery
pythondev_help_Kimbery_2018-01-23T10:58:25.000569
1,516,705,105.000569
30,825
pythondev
help
<@Milo> what type are the variables `track_table_row` and `categories`? and what changes depending on the button pressed?
2018-01-23T10:59:06.000227
Emerald
pythondev_help_Emerald_2018-01-23T10:59:06.000227
1,516,705,146.000227
30,826
pythondev
help
hi, learning pandas and hoping someone can help me with my code snippet
2018-01-23T10:59:52.001304
Kimbery
pythondev_help_Kimbery_2018-01-23T10:59:52.001304
1,516,705,192.001304
30,827
pythondev
help
<@Kimbery> what would be the index of your intended Rejected dataframe?
2018-01-23T11:01:29.000603
Emerald
pythondev_help_Emerald_2018-01-23T11:01:29.000603
1,516,705,289.000603
30,828
pythondev
help
would it be `a, b, c, d, e`
2018-01-23T11:01:41.001061
Emerald
pythondev_help_Emerald_2018-01-23T11:01:41.001061
1,516,705,301.001061
30,829
pythondev
help
and a 1 if rejected, 0 if not?
2018-01-23T11:01:46.000878
Emerald
pythondev_help_Emerald_2018-01-23T11:01:46.000878
1,516,705,306.000878
30,830
pythondev
help
`track_table_row` is a list of dictionaries and `categories` is a list, sorry omitted a line before which handles inserting data according which button is pressed, and one of the `track_table_row` dictionaries has a time value that is unique to the button press
2018-01-23T11:02:52.000806
Milo
pythondev_help_Milo_2018-01-23T11:02:52.000806
1,516,705,372.000806
30,831
pythondev
help
<@Floy> :taco: <@Micki> :taco:: <@Emerald> :taco: <@Zack> :taco:: Thanks for the git help. Got it sorted eventually and learned some valuable git lessons :toot:
2018-01-23T11:06:27.000297
Porsha
pythondev_help_Porsha_2018-01-23T11:06:27.000297
1,516,705,587.000297
30,832
pythondev
help
you could do something like this: ``` all = ['a','b','c','d','e'] accepted = ['a','b'] rejects = dict([(k,0 if k in accepted else 1) for k in all]) pd.DataFrame({'Rejected': rejects.values()}, index=rejects.keys()) ```
2018-01-23T11:06:39.000319
Emerald
pythondev_help_Emerald_2018-01-23T11:06:39.000319
1,516,705,599.000319
30,833
pythondev
help
@will, yes
2018-01-23T11:07:30.000261
Kimbery
pythondev_help_Kimbery_2018-01-23T11:07:30.000261
1,516,705,650.000261
30,834
pythondev
help
That would give you: ``` Rejected a 0 c 1 b 0 e 1 d 1 ```
2018-01-23T11:07:48.000172
Emerald
pythondev_help_Emerald_2018-01-23T11:07:48.000172
1,516,705,668.000172
30,835
pythondev
help
and if I was extracting the rejected column, it would be df[['Rejected']] ?
2018-01-23T11:08:23.000763
Kimbery
pythondev_help_Kimbery_2018-01-23T11:08:23.000763
1,516,705,703.000763
30,836
pythondev
help
and if you wanted it sorted, you could do `df.sort_index()`
2018-01-23T11:08:24.000928
Emerald
pythondev_help_Emerald_2018-01-23T11:08:24.000928
1,516,705,704.000928
30,837
pythondev
help
yep, that would give you only the column values. And if you wanted only those that were rejected, you would do `df[df['Rejected']==1]['Rejected']`
2018-01-23T11:09:44.000568
Emerald
pythondev_help_Emerald_2018-01-23T11:09:44.000568
1,516,705,784.000568
30,838
pythondev
help
or better yet, `df.loc[df['Rejected']==1, 'Rejected']`
2018-01-23T11:10:10.000478
Emerald
pythondev_help_Emerald_2018-01-23T11:10:10.000478
1,516,705,810.000478
30,839
pythondev
help
`.loc` first selects the rows (e.g. `df['Rejected']==1`) and then the columns (e.g. `'Rejected'`)
2018-01-23T11:10:39.000574
Emerald
pythondev_help_Emerald_2018-01-23T11:10:39.000574
1,516,705,839.000574
30,840
pythondev
help
thanks @will :slightly_smiling_face:
2018-01-23T11:11:01.001072
Kimbery
pythondev_help_Kimbery_2018-01-23T11:11:01.001072
1,516,705,861.001072
30,841
pythondev
help
and so depending on the button press you want to do what to the dictionary? do you mind including the line before?
2018-01-23T11:11:41.000784
Emerald
pythondev_help_Emerald_2018-01-23T11:11:41.000784
1,516,705,901.000784
30,842
pythondev
help
:thumbsup:
2018-01-23T11:11:46.001046
Emerald
pythondev_help_Emerald_2018-01-23T11:11:46.001046
1,516,705,906.001046
30,843
pythondev
help
@will great job :taco:
2018-01-23T11:21:50.000293
Kimbery
pythondev_help_Kimbery_2018-01-23T11:21:50.000293
1,516,706,510.000293
30,844
pythondev
help
so it would it looks like this currently; ``` if 'pri1' in request.form: track_table_row = insert_select_data_track_table(title,textarea,link,date,img_link,source,priDateTimeOne,order_no,pri_user,categories) if convertToJson(track_table_row,categories): flash(str(title) + ' Has been u...
2018-01-23T11:40:17.000581
Milo
pythondev_help_Milo_2018-01-23T11:40:17.000581
1,516,707,617.000581
30,845
pythondev
help
but there are also two more buttons
2018-01-23T11:40:26.000136
Milo
pythondev_help_Milo_2018-01-23T11:40:26.000136
1,516,707,626.000136
30,846
pythondev
help
just thinking as it seems there is a lot of repeated code
2018-01-23T11:40:42.000314
Milo
pythondev_help_Milo_2018-01-23T11:40:42.000314
1,516,707,642.000314
30,847
pythondev
help
yeah can’t you do something before this that does an inline if statement?
2018-01-23T12:00:19.001439
Emerald
pythondev_help_Emerald_2018-01-23T12:00:19.001439
1,516,708,819.001439
30,848
pythondev
help
something like `priDateTime = primeDateTimeOne if 'pri1' in request.form else primeDateTimeTwo`
2018-01-23T12:00:43.000708
Emerald
pythondev_help_Emerald_2018-01-23T12:00:43.000708
1,516,708,843.000708
30,849
pythondev
help
or are there more than one elif?
2018-01-23T12:00:47.001163
Emerald
pythondev_help_Emerald_2018-01-23T12:00:47.001163
1,516,708,847.001163
30,850
pythondev
help
if so, then maybe use a dictionary to map it out?
2018-01-23T12:00:54.000098
Emerald
pythondev_help_Emerald_2018-01-23T12:00:54.000098
1,516,708,854.000098
30,851
pythondev
help
something like…
2018-01-23T12:00:59.000917
Emerald
pythondev_help_Emerald_2018-01-23T12:00:59.000917
1,516,708,859.000917
30,852
pythondev
help
`pri_date_times = {'pri1': primeDateTimeOne, 'pri2': primeDateTimeTwo, ...}`
2018-01-23T12:01:32.001124
Emerald
pythondev_help_Emerald_2018-01-23T12:01:32.001124
1,516,708,892.001124
30,853
pythondev
help
and then you could do one if, to check if request.form is in the dict
2018-01-23T12:01:43.000611
Emerald
pythondev_help_Emerald_2018-01-23T12:01:43.000611
1,516,708,903.000611
30,854
pythondev
help
so something like…
2018-01-23T12:01:46.000602
Emerald
pythondev_help_Emerald_2018-01-23T12:01:46.000602
1,516,708,906.000602
30,855
pythondev
help
wait what does request.form hold?
2018-01-23T12:02:16.000406
Emerald
pythondev_help_Emerald_2018-01-23T12:02:16.000406
1,516,708,936.000406
30,856
pythondev
help
is it a dict?
2018-01-23T12:02:18.000599
Emerald
pythondev_help_Emerald_2018-01-23T12:02:18.000599
1,516,708,938.000599
30,857
pythondev
help
its the post data from the form submit
2018-01-23T12:04:41.000669
Milo
pythondev_help_Milo_2018-01-23T12:04:41.000669
1,516,709,081.000669
30,858
pythondev
help
essentially all these variables `title,textarea,link,date,img_link,source,priDateTimeTwo,order_no,pri_user,categories` and the button names
2018-01-23T12:05:10.000022
Milo
pythondev_help_Milo_2018-01-23T12:05:10.000022
1,516,709,110.000022
30,859
pythondev
help
there are 4 button, so up to pri4
2018-01-23T12:05:34.000564
Milo
pythondev_help_Milo_2018-01-23T12:05:34.000564
1,516,709,134.000564
30,860
pythondev
help
and one `del` button that deletes it
2018-01-23T12:05:49.000727
Milo
pythondev_help_Milo_2018-01-23T12:05:49.000727
1,516,709,149.000727
30,861
pythondev
help
ok one sec, grabbing lunch and will take a look
2018-01-23T12:21:30.000089
Emerald
pythondev_help_Emerald_2018-01-23T12:21:30.000089
1,516,710,090.000089
30,862
pythondev
help
Thank you
2018-01-23T12:46:23.000444
Milo
pythondev_help_Milo_2018-01-23T12:46:23.000444
1,516,711,583.000444
30,863
pythondev
help
I’d recommend doing an if statement with elif statements for whether each one is in request.forms
2018-01-23T12:46:26.000210
Emerald
pythondev_help_Emerald_2018-01-23T12:46:26.000210
1,516,711,586.00021
30,864
pythondev
help
then you don’t have to repeat all of the code
2018-01-23T12:46:33.000737
Emerald
pythondev_help_Emerald_2018-01-23T12:46:33.000737
1,516,711,593.000737
30,865
pythondev
help
so …
2018-01-23T12:46:37.000255
Emerald
pythondev_help_Emerald_2018-01-23T12:46:37.000255
1,516,711,597.000255
30,866
pythondev
help
``` if 'pri1' in request.form: primeDateTime = primeDateTimeOne elif 'pri2' in request.form: primeDateTime = primeDateTimeTwo .... track_table_row = insert_select_data_track_table(title, textarea, link, date, img_link, source, priDateTime, order_no, pri_user,categories) if convertToJson(track_table_row, categor...
2018-01-23T12:48:20.000390
Emerald
pythondev_help_Emerald_2018-01-23T12:48:20.000390
1,516,711,700.00039
30,867
pythondev
help
does that make sense?
2018-01-23T12:48:32.000568
Emerald
pythondev_help_Emerald_2018-01-23T12:48:32.000568
1,516,711,712.000568
30,868
pythondev
help
then you’d want an else that sets primeDateTime to something if none of them are presetn
2018-01-23T12:48:52.001128
Emerald
pythondev_help_Emerald_2018-01-23T12:48:52.001128
1,516,711,732.001128
30,869
pythondev
help
ah ok yes that does
2018-01-23T12:48:54.000929
Milo
pythondev_help_Milo_2018-01-23T12:48:54.000929
1,516,711,734.000929
30,870
pythondev
help
just to be safe
2018-01-23T12:48:55.000352
Emerald
pythondev_help_Emerald_2018-01-23T12:48:55.000352
1,516,711,735.000352
30,871
pythondev
help
cool, thank you so much for your help!
2018-01-23T12:49:25.000673
Milo
pythondev_help_Milo_2018-01-23T12:49:25.000673
1,516,711,765.000673
30,872
pythondev
help
<@Emerald> :taco:
2018-01-23T12:49:47.000148
Milo
pythondev_help_Milo_2018-01-23T12:49:47.000148
1,516,711,787.000148
30,873
pythondev
help
thanks!
2018-01-23T12:49:54.000359
Milo
pythondev_help_Milo_2018-01-23T12:49:54.000359
1,516,711,794.000359
30,874
pythondev
help
np!
2018-01-23T12:49:59.000570
Emerald
pythondev_help_Emerald_2018-01-23T12:49:59.000570
1,516,711,799.00057
30,875
pythondev
help
ofc!
2018-01-23T12:50:26.000436
Emerald
pythondev_help_Emerald_2018-01-23T12:50:26.000436
1,516,711,826.000436
30,876
pythondev
help
Hi, when doing unittesting from line 43, in line 18,19 i get undefined variable x1,y1 ?
2018-01-23T13:26:15.000671
Mariko
pythondev_help_Mariko_2018-01-23T13:26:15.000671
1,516,713,975.000671
30,877
pythondev
help
Hey <@Mariko> you should change line 18 and 19 to be… ``` self.p1 = p1 self.p2 = p2 ```
2018-01-23T13:27:47.000682
Emerald
pythondev_help_Emerald_2018-01-23T13:27:47.000682
1,516,714,067.000682
30,878
pythondev
help
you’re passing in the points you’ve already created, so you don’t need to create new points
2018-01-23T13:28:02.000361
Emerald
pythondev_help_Emerald_2018-01-23T13:28:02.000361
1,516,714,082.000361
30,879
pythondev
help
furthermore x1 and x2 aren’t passed as variables in `__init__` so they are undefined
2018-01-23T13:28:28.001110
Emerald
pythondev_help_Emerald_2018-01-23T13:28:28.001110
1,516,714,108.00111
30,880
pythondev
help
instead you’re passing in the two points you’ve created in lines 45 and 46 (`pp1` and `pp2`)
2018-01-23T13:29:13.000373
Emerald
pythondev_help_Emerald_2018-01-23T13:29:13.000373
1,516,714,153.000373
30,881
pythondev
help
Thank you, few hours wasted :smile:
2018-01-23T13:37:33.001098
Mariko
pythondev_help_Mariko_2018-01-23T13:37:33.001098
1,516,714,653.001098
30,882
pythondev
help
When answer was so simple :smile:
2018-01-23T13:37:44.000211
Mariko
pythondev_help_Mariko_2018-01-23T13:37:44.000211
1,516,714,664.000211
30,883
pythondev
help
<@Emerald> :taco:
2018-01-23T13:43:09.000377
Mariko
pythondev_help_Mariko_2018-01-23T13:43:09.000377
1,516,714,989.000377
30,884
pythondev
help
:parrot:
2018-01-23T13:43:22.000520
Emerald
pythondev_help_Emerald_2018-01-23T13:43:22.000520
1,516,715,002.00052
30,885
pythondev
help
Hello, anyone who could link me some articles/guides for a total beginner? I would like to learn the basics of python.
2018-01-23T15:05:56.000233
Phebe
pythondev_help_Phebe_2018-01-23T15:05:56.000233
1,516,719,956.000233
30,886
pythondev
help
Automate The Boring Stuff (<http://automatetheboringstuff.com/|automatetheboringstuff.com/>) is a great way to get excited about what Python can do. If that’s slightly over your skill level, it might make sense to start with Codecademy, or Treehouse (personally I really liked Treehouse)
2018-01-23T15:13:53.000531
Irene
pythondev_help_Irene_2018-01-23T15:13:53.000531
1,516,720,433.000531
30,887
pythondev
help
Hey friends. I'm trying to use python multithreading.Pool, and I keep getting hangs when I call `with multithreading.Pool() as pool` Do you friends know of any way to debug this?
2018-01-23T15:26:41.000949
Lai
pythondev_help_Lai_2018-01-23T15:26:41.000949
1,516,721,201.000949
30,888
pythondev
help
Remove the parantheses
2018-01-23T15:29:42.000042
Emerald
pythondev_help_Emerald_2018-01-23T15:29:42.000042
1,516,721,382.000042
30,889
pythondev
help
and then within the `with`, you can instantiate pool (e.g. `pool = pool(num_threads)` and do whatever you need to do, join, close, etc
2018-01-23T15:30:06.000233
Emerald
pythondev_help_Emerald_2018-01-23T15:30:06.000233
1,516,721,406.000233
30,890
pythondev
help
`AttributeError: __enter__` is thrown
2018-01-23T15:33:52.000329
Lai
pythondev_help_Lai_2018-01-23T15:33:52.000329
1,516,721,632.000329
30,891
pythondev
help
hmm, looks like you may need to call Pool() then since it’s a with statement
2018-01-23T15:34:49.000062
Emerald
pythondev_help_Emerald_2018-01-23T15:34:49.000062
1,516,721,689.000062
30,892
pythondev
help
are you joining the pool within the `with` statement?
2018-01-23T15:35:06.000110
Emerald
pythondev_help_Emerald_2018-01-23T15:35:06.000110
1,516,721,706.00011
30,893
pythondev
help
like ``` with multithreading.Pool() as pool: pool.map(func, interator) pool.close() pool.join() ```?
2018-01-23T15:36:01.000195
Emerald
pythondev_help_Emerald_2018-01-23T15:36:01.000195
1,516,721,761.000195
30,894
pythondev
help
Well, I can't get into the `with` statement, it hangs on `with multithreading.Pool() as pool` Nothing past that gets executed
2018-01-23T15:36:22.000350
Lai
pythondev_help_Lai_2018-01-23T15:36:22.000350
1,516,721,782.00035
30,895
pythondev
help
hmm.. I’ve never used `with` with multithreading. Are you sure that’s doable?
2018-01-23T15:36:56.000168
Emerald
pythondev_help_Emerald_2018-01-23T15:36:56.000168
1,516,721,816.000168
30,896
pythondev
help
the examples show it
2018-01-23T15:37:02.000620
Lai
pythondev_help_Lai_2018-01-23T15:37:02.000620
1,516,721,822.00062
30,897
pythondev
help
can you link them?
2018-01-23T15:37:31.000867
Emerald
pythondev_help_Emerald_2018-01-23T15:37:31.000867
1,516,721,851.000867
30,898
pythondev
help
well, either way: it hangs on `pool = Pool()` as well
2018-01-23T15:38:13.000125
Lai
pythondev_help_Lai_2018-01-23T15:38:13.000125
1,516,721,893.000125
30,899
pythondev
help
I didn’t know there was a multithreading library
2018-01-23T15:38:15.000410
Emerald
pythondev_help_Emerald_2018-01-23T15:38:15.000410
1,516,721,895.00041
30,900
pythondev
help
Hmm
2018-01-23T15:38:26.000155
Emerald
pythondev_help_Emerald_2018-01-23T15:38:26.000155
1,516,721,906.000155
30,901
pythondev
help
you'll probably want to use this <https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor>
2018-01-23T15:39:01.000750
Micki
pythondev_help_Micki_2018-01-23T15:39:01.000750
1,516,721,941.00075
30,902
pythondev
help
^^
2018-01-23T15:39:22.000013
Emerald
pythondev_help_Emerald_2018-01-23T15:39:22.000013
1,516,721,962.000013
30,903
pythondev
help
&gt; quote_page = ‘<http://www.bloomberg.com>
2018-01-23T15:46:51.000064
Barney
pythondev_help_Barney_2018-01-23T15:46:51.000064
1,516,722,411.000064
30,904
pythondev
help
I'm new to this, so can someone let me know how I can fix this issue?
2018-01-23T15:47:00.000582
Tianna
pythondev_help_Tianna_2018-01-23T15:47:00.000582
1,516,722,420.000582
30,905
pythondev
help
the character after `quote_page = ` is not a normal single-quote, but a "left single quotation mark", which is Unicode
2018-01-23T15:47:52.000131
Barney
pythondev_help_Barney_2018-01-23T15:47:52.000131
1,516,722,472.000131
30,906
pythondev
help
The opening quote you're using on line 6 is not an actual `'` character
2018-01-23T15:47:59.000307
Leanora
pythondev_help_Leanora_2018-01-23T15:47:59.000307
1,516,722,479.000307
30,907
pythondev
help
wait, lots of quotes in this snippet are wrong ones
2018-01-23T15:48:56.000246
Barney
pythondev_help_Barney_2018-01-23T15:48:56.000246
1,516,722,536.000246
30,908
pythondev
help
how did you manage it? :)
2018-01-23T15:49:00.000371
Barney
pythondev_help_Barney_2018-01-23T15:49:00.000371
1,516,722,540.000371
30,909
pythondev
help
I was working from a blog post... clearly I copied the errors from there :confused:
2018-01-23T15:49:39.000140
Tianna
pythondev_help_Tianna_2018-01-23T15:49:39.000140
1,516,722,579.00014
30,910
pythondev
help
yeah, the author's blog most likely messed up the quote characters
2018-01-23T15:50:22.000007
Barney
pythondev_help_Barney_2018-01-23T15:50:22.000007
1,516,722,622.000007
30,911
pythondev
help
I don't know why I was thinking backtick rather than single quote
2018-01-23T15:50:26.000571
Leanora
pythondev_help_Leanora_2018-01-23T15:50:26.000571
1,516,722,626.000571
30,912
pythondev
help
it feels so weird... if renaming a column in your model causes alembic to delete data (<https://www.compose.com/articles/schema-migrations-with-alembic-python-and-postgresql/>) why would anyone use it !?
2018-01-23T15:50:39.000160
Stefan
pythondev_help_Stefan_2018-01-23T15:50:39.000160
1,516,722,639.00016
30,913
pythondev
help
So essentially, I need to replace all instances where ' appears in my code?
2018-01-23T15:51:45.000494
Tianna
pythondev_help_Tianna_2018-01-23T15:51:45.000494
1,516,722,705.000494
30,914
pythondev
help
You need to replace all instance of `‘` or `’` with `'`
2018-01-23T15:52:17.000033
Leanora
pythondev_help_Leanora_2018-01-23T15:52:17.000033
1,516,722,737.000033
30,915
pythondev
help
Hmmmm
2018-01-23T15:52:24.000969
Leanora
pythondev_help_Leanora_2018-01-23T15:52:24.000969
1,516,722,744.000969
30,916
pythondev
help
``` # import libraries import urllib2 from bs4 import BeautifulSoup # specify the url quote_page = '<http://www.bloomberg.com/quote/SPX:IND>' # query the website and return the html to the variable 'page' page = urllib2.urlopen(quote_page) # parse the html using beautiful soup and store in variable `soup` soup = Bea...
2018-01-23T15:53:25.001031
Barney
pythondev_help_Barney_2018-01-23T15:53:25.001031
1,516,722,805.001031
30,917
pythondev
help
here you go
2018-01-23T15:53:27.000848
Barney
pythondev_help_Barney_2018-01-23T15:53:27.000848
1,516,722,807.000848
30,918
pythondev
help
The snippet I posted helps to explain what the issue was, if that single quote character looks all the same in your editor
2018-01-23T15:54:25.000719
Leanora
pythondev_help_Leanora_2018-01-23T15:54:25.000719
1,516,722,865.000719
30,919
pythondev
help
Thanks <@Barney> <@Leanora> :+1: it works as expected now
2018-01-23T15:55:05.000667
Tianna
pythondev_help_Tianna_2018-01-23T15:55:05.000667
1,516,722,905.000667
30,920
pythondev
help
hmm ``` def start_log_insert_processes(conn, stream): try: with concurrent.futures.ProcessPoolExecutor() as executor: loop = asyncio.new_event_loop() # cursor = conn.cursor() futures = [] for log in yaml.load_all(stream): futures.append(execut...
2018-01-23T15:59:30.000596
Lai
pythondev_help_Lai_2018-01-23T15:59:30.000596
1,516,723,170.000596
30,921
pythondev
help
<@Floy> do you know the answer :slightly_smiling_face:?
2018-01-23T16:03:03.000102
Stefan
pythondev_help_Stefan_2018-01-23T16:03:03.000102
1,516,723,383.000102
30,922
pythondev
help
no idea. I don’t think Django does it the same way?
2018-01-23T16:07:55.000387
Floy
pythondev_help_Floy_2018-01-23T16:07:55.000387
1,516,723,675.000387
30,923