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
<@Adrian> and are you using this for a ChoiceField by chance? It doesn't _have_ to be a tuple I don't think, it just needs to be iterable, so `l` probably works as is
2017-09-07T13:21:20.000065
Mallie
pythondev_help_Mallie_2017-09-07T13:21:20.000065
1,504,790,480.000065
92,603
pythondev
help
nice find, <@Glinda> :taco:
2017-09-07T13:22:11.000002
Meg
pythondev_help_Meg_2017-09-07T13:22:11.000002
1,504,790,531.000002
92,604
pythondev
help
Yes, thanks <@Glinda> :taco:
2017-09-07T13:23:00.000259
Margrett
pythondev_help_Margrett_2017-09-07T13:23:00.000259
1,504,790,580.000259
92,605
pythondev
help
Even if it needs to end up being a tuple. It's better to keep it in an some related object until you need to raw tuple.
2017-09-07T13:23:33.000654
Glinda
pythondev_help_Glinda_2017-09-07T13:23:33.000654
1,504,790,613.000654
92,606
pythondev
help
That way you can have it throw exceptions when you want do : a, b = item.var1, item.var2 if it tries to unpack a None or wrong object you can catch that exception to prevent an error.
2017-09-07T13:24:52.000093
Glinda
pythondev_help_Glinda_2017-09-07T13:24:52.000093
1,504,790,692.000093
92,607
pythondev
help
Yeah I have lots of shitty experience with importing terrible pandas csv
2017-09-07T13:25:40.000441
Glinda
pythondev_help_Glinda_2017-09-07T13:25:40.000441
1,504,790,740.000441
92,608
pythondev
help
csv with variable header location, first few rows with 1,2 columns and the header being at row 10, but row 11 has len(row_10) &lt; len(row_11) and you only want the data that's in that extra row.
2017-09-07T13:26:47.000626
Glinda
pythondev_help_Glinda_2017-09-07T13:26:47.000626
1,504,790,807.000626
92,609
pythondev
help
Because the developer didn't think naming that column was important.
2017-09-07T13:26:58.000401
Glinda
pythondev_help_Glinda_2017-09-07T13:26:58.000401
1,504,790,818.000401
92,610
pythondev
help
i gave up on giving up, got rid of the orm stuff… made a list of tuples and insert ignored them
2017-09-07T13:34:08.000188
Orpha
pythondev_help_Orpha_2017-09-07T13:34:08.000188
1,504,791,248.000188
92,611
pythondev
help
dont need to update because the url to the file wont change even if the file does
2017-09-07T13:34:37.000228
Orpha
pythondev_help_Orpha_2017-09-07T13:34:37.000228
1,504,791,277.000228
92,612
pythondev
help
but, it works, its good, thanks for the advise <@Johana>
2017-09-07T13:35:02.000234
Orpha
pythondev_help_Orpha_2017-09-07T13:35:02.000234
1,504,791,302.000234
92,613
pythondev
help
Can you remind me about the question/.
2017-09-07T13:35:06.000678
Glinda
pythondev_help_Glinda_2017-09-07T13:35:06.000678
1,504,791,306.000678
92,614
pythondev
help
Awesome, thaks for that, gonna look into it, sound definitely better what i used :stuck_out_tongue: <@Glinda> :taco:
2017-09-07T13:38:35.000574
Adrian
pythondev_help_Adrian_2017-09-07T13:38:35.000574
1,504,791,515.000574
92,615
pythondev
help
yeah I used it for a choicefield that was created through a django widget
2017-09-07T13:40:54.000338
Adrian
pythondev_help_Adrian_2017-09-07T13:40:54.000338
1,504,791,654.000338
92,616
pythondev
help
hello I have a question
2017-09-07T13:45:12.000421
Claudine
pythondev_help_Claudine_2017-09-07T13:45:12.000421
1,504,791,912.000421
92,617
pythondev
help
go ahead and just ask <@Claudine>
2017-09-07T13:46:34.000307
Beula
pythondev_help_Beula_2017-09-07T13:46:34.000307
1,504,791,994.000307
92,618
pythondev
help
I ended up using this to fix my mixed case header lines: ``` def lower_columns(df): df.columns=df.columns.str.lower() col_list = ['subnet_id', 'subnet_addr1'] sub = pd.read_csv(subnet_file, usecols=lambda x : x.lower() in col_list) lower_columns(sub) ```
2017-09-07T13:52:42.000717
Margrett
pythondev_help_Margrett_2017-09-07T13:52:42.000717
1,504,792,362.000717
92,619
pythondev
help
Hello all. This is the very first time, I am trying something like this in Python. I need help. I am writing a script that reads from a csv file and gets only the headers and then I need to insert those headers into a table on SQL, but how do I define the datatypes ? I can only read the header names from csv and not t...
2017-09-07T14:33:15.000630
Chasity
pythondev_help_Chasity_2017-09-07T14:33:15.000630
1,504,794,795.00063
92,620
pythondev
help
Are you using a python database orm?
2017-09-07T14:33:53.000171
Glinda
pythondev_help_Glinda_2017-09-07T14:33:53.000171
1,504,794,833.000171
92,621
pythondev
help
why do you need to define data type?
2017-09-07T14:34:04.000379
Glinda
pythondev_help_Glinda_2017-09-07T14:34:04.000379
1,504,794,844.000379
92,622
pythondev
help
I am trying to create ddl statement which would like create a new table on the sql using the columns I extracted from csv.
2017-09-07T14:34:50.000368
Chasity
pythondev_help_Chasity_2017-09-07T14:34:50.000368
1,504,794,890.000368
92,623
pythondev
help
How would I define the datatypes for those columns then ?
2017-09-07T14:35:03.000117
Chasity
pythondev_help_Chasity_2017-09-07T14:35:03.000117
1,504,794,903.000117
92,624
pythondev
help
CREATE TABLE TABLE ( COLUMN_NAME DATATYPE(SIZE));
2017-09-07T14:35:29.000670
Chasity
pythondev_help_Chasity_2017-09-07T14:35:29.000670
1,504,794,929.00067
92,625
pythondev
help
As per that definition, I would like to define the datatype and size.
2017-09-07T14:35:51.000624
Chasity
pythondev_help_Chasity_2017-09-07T14:35:51.000624
1,504,794,951.000624
92,626
pythondev
help
So if you are reading in csv, you are reading in a string.
2017-09-07T14:35:59.000687
Glinda
pythondev_help_Glinda_2017-09-07T14:35:59.000687
1,504,794,959.000687
92,627
pythondev
help
you can represent other items (int, float, string, char, bool, etc) using strings.
2017-09-07T14:36:20.000228
Glinda
pythondev_help_Glinda_2017-09-07T14:36:20.000228
1,504,794,980.000228
92,628
pythondev
help
So you need a way of parsing in these values and giving the corresponding string the correct type.
2017-09-07T14:36:42.000060
Glinda
pythondev_help_Glinda_2017-09-07T14:36:42.000060
1,504,795,002.00006
92,629
pythondev
help
Can you give an example of a few columns in the header and what you know the data type of each to be?
2017-09-07T14:37:02.000035
Glinda
pythondev_help_Glinda_2017-09-07T14:37:02.000035
1,504,795,022.000035
92,630
pythondev
help
Yea, so will I have to parse them manually, or are their any methods that are built in that would help me do it ?
2017-09-07T14:37:26.000175
Chasity
pythondev_help_Chasity_2017-09-07T14:37:26.000175
1,504,795,046.000175
92,631
pythondev
help
it really depends on what you have
2017-09-07T14:40:11.000191
Glinda
pythondev_help_Glinda_2017-09-07T14:40:11.000191
1,504,795,211.000191
92,632
pythondev
help
If one row of data =
2017-09-07T14:40:27.000076
Glinda
pythondev_help_Glinda_2017-09-07T14:40:27.000076
1,504,795,227.000076
92,633
pythondev
help
Let me share the script I have written.
2017-09-07T14:40:27.000094
Chasity
pythondev_help_Chasity_2017-09-07T14:40:27.000094
1,504,795,227.000094
92,634
pythondev
help
`True, 1.01, 2, hi, h`
2017-09-07T14:40:53.000182
Glinda
pythondev_help_Glinda_2017-09-07T14:40:53.000182
1,504,795,253.000182
92,635
pythondev
help
That will be slightly easier
2017-09-07T14:41:03.000318
Glinda
pythondev_help_Glinda_2017-09-07T14:41:03.000318
1,504,795,263.000318
92,636
pythondev
help
What you have written is doing it correctly
2017-09-07T14:49:07.000069
Glinda
pythondev_help_Glinda_2017-09-07T14:49:07.000069
1,504,795,747.000069
92,637
pythondev
help
csv datatype = varchar
2017-09-07T14:49:15.000389
Glinda
pythondev_help_Glinda_2017-09-07T14:49:15.000389
1,504,795,755.000389
92,638
pythondev
help
or string
2017-09-07T14:49:23.000335
Glinda
pythondev_help_Glinda_2017-09-07T14:49:23.000335
1,504,795,763.000335
92,639
pythondev
help
csv is storing your data as a string
2017-09-07T14:49:52.000540
Glinda
pythondev_help_Glinda_2017-09-07T14:49:52.000540
1,504,795,792.00054
92,640
pythondev
help
can you paste an example of your header/ dattype
2017-09-07T14:50:07.000168
Glinda
pythondev_help_Glinda_2017-09-07T14:50:07.000168
1,504,795,807.000168
92,641
pythondev
help
Sure.
2017-09-07T14:50:33.000273
Chasity
pythondev_help_Chasity_2017-09-07T14:50:33.000273
1,504,795,833.000273
92,642
pythondev
help
If this is a one time thing where you'll never read in this data again, you can make adictionary with the headerstring, in this dictionary you'll have 'head_string':'data_type' then you use that relate to your database entry.
2017-09-07T14:52:45.000336
Glinda
pythondev_help_Glinda_2017-09-07T14:52:45.000336
1,504,795,965.000336
92,643
pythondev
help
If you do it very often with the same heads, then you can do the same as first option.
2017-09-07T14:53:04.000241
Glinda
pythondev_help_Glinda_2017-09-07T14:53:04.000241
1,504,795,984.000241
92,644
pythondev
help
If the heads are different and you need to inspect the actual data this is where it gets complicated.
2017-09-07T14:53:16.000219
Glinda
pythondev_help_Glinda_2017-09-07T14:53:16.000219
1,504,795,996.000219
92,645
pythondev
help
I apparently dont understand how python logging works
2017-09-07T16:24:05.000212
Signe
pythondev_help_Signe_2017-09-07T16:24:05.000212
1,504,801,445.000212
92,646
pythondev
help
I try to set the logging level to `DEBUG`
2017-09-07T16:24:14.000531
Signe
pythondev_help_Signe_2017-09-07T16:24:14.000531
1,504,801,454.000531
92,647
pythondev
help
but debug statements still dont print
2017-09-07T16:24:23.000106
Signe
pythondev_help_Signe_2017-09-07T16:24:23.000106
1,504,801,463.000106
92,648
pythondev
help
Here is an MCVE: ``` import logging mylogger = logging.getLogger('myapp') mylogger.warn('warn1') mylogger.debug('debug1') mylogger.setLevel('DEBUG') mylogger.warn('warn2') mylogger.debug('debug2') ```
2017-09-07T16:24:29.000239
Signe
pythondev_help_Signe_2017-09-07T16:24:29.000239
1,504,801,469.000239
92,649
pythondev
help
which prints: ``` warn1 warn2 ```
2017-09-07T16:24:44.000196
Signe
pythondev_help_Signe_2017-09-07T16:24:44.000196
1,504,801,484.000196
92,650
pythondev
help
no debug2
2017-09-07T16:24:47.000021
Signe
pythondev_help_Signe_2017-09-07T16:24:47.000021
1,504,801,487.000021
92,651
pythondev
help
You need to call `logging.basicConfig()` first to ensure some handler is set to format it
2017-09-07T16:28:06.000306
Beula
pythondev_help_Beula_2017-09-07T16:28:06.000306
1,504,801,686.000306
92,652
pythondev
help
wow
2017-09-07T16:28:34.000218
Signe
pythondev_help_Signe_2017-09-07T16:28:34.000218
1,504,801,714.000218
92,653
pythondev
help
thats super dumb
2017-09-07T16:28:38.000353
Signe
pythondev_help_Signe_2017-09-07T16:28:38.000353
1,504,801,718.000353
92,654
pythondev
help
``` &gt;&gt;&gt; import logging &gt;&gt;&gt; logging.basicConfig() &gt;&gt;&gt; logger = logging.getLogger('foo') &gt;&gt;&gt; logger.setLevel(logging.DEBUG) &gt;&gt;&gt; logger.debug('foobar') DEBUG:foo:foobar ```
2017-09-07T16:29:04.000216
Beula
pythondev_help_Beula_2017-09-07T16:29:04.000216
1,504,801,744.000216
92,655
pythondev
help
yep. So weird that you have to call it for anything to work.
2017-09-07T16:29:16.000172
Signe
pythondev_help_Signe_2017-09-07T16:29:16.000172
1,504,801,756.000172
92,656
pythondev
help
would expect that to be default
2017-09-07T16:29:29.000084
Signe
pythondev_help_Signe_2017-09-07T16:29:29.000084
1,504,801,769.000084
92,657
pythondev
help
<https://docs.python.org/3/library/logging.html#logging.basicConfig> &gt; Does basic configuration for the logging system by creating a StreamHandler with a default Formatter and adding it to the root logger. The functions debug(), info(), warning(), error() and critical() will call basicConfig() automatically if no ha...
2017-09-07T16:30:08.000274
Beula
pythondev_help_Beula_2017-09-07T16:30:08.000274
1,504,801,808.000274
92,658
pythondev
help
well.. I thought I was crazy for the longest time
2017-09-07T16:30:36.000466
Signe
pythondev_help_Signe_2017-09-07T16:30:36.000466
1,504,801,836.000466
92,659
pythondev
help
Haha, yeah - python logging could use an overhaul
2017-09-07T16:30:46.000659
Beula
pythondev_help_Beula_2017-09-07T16:30:46.000659
1,504,801,846.000659
92,660
pythondev
help
e.g. make it pythonic for a start
2017-09-07T16:30:54.000415
Beula
pythondev_help_Beula_2017-09-07T16:30:54.000415
1,504,801,854.000415
92,661
pythondev
help
idea for a 3rd party package?
2017-09-07T16:31:05.000409
Signe
pythondev_help_Signe_2017-09-07T16:31:05.000409
1,504,801,865.000409
92,662
pythondev
help
a pythonic, sane, logger?
2017-09-07T16:31:14.000100
Signe
pythondev_help_Signe_2017-09-07T16:31:14.000100
1,504,801,874.0001
92,663
pythondev
help
that uses `.format` syntax
2017-09-07T16:31:22.000165
Signe
pythondev_help_Signe_2017-09-07T16:31:22.000165
1,504,801,882.000165
92,664
pythondev
help
I'd rather ship apps :smile: ¯\_(ツ)_/¯
2017-09-07T16:33:02.000457
Beula
pythondev_help_Beula_2017-09-07T16:33:02.000457
1,504,801,982.000457
92,665
pythondev
help
but it isn't a bad idea, one thing it should include is a better way to do MDC logging
2017-09-07T16:33:28.000413
Beula
pythondev_help_Beula_2017-09-07T16:33:28.000413
1,504,802,008.000413
92,666
pythondev
help
I mean, it could just read the stack
2017-09-07T16:35:02.000285
Signe
pythondev_help_Signe_2017-09-07T16:35:02.000285
1,504,802,102.000285
92,667
pythondev
help
<@Signe> <@Beula> I recall reading an article about <https://github.com/jd/daiquiri> It set up a modern logging configuration so you don't have to
2017-09-07T17:00:34.000189
Kiersten
pythondev_help_Kiersten_2017-09-07T17:00:34.000189
1,504,803,634.000189
92,668
pythondev
help
Found it: <https://julien.danjou.info/blog/python-logging-easy-with-daiquiri>
2017-09-07T17:01:58.000167
Kiersten
pythondev_help_Kiersten_2017-09-07T17:01:58.000167
1,504,803,718.000167
92,669
pythondev
help
Looks like it has some niceties, color by default to a terminal is nice
2017-09-07T17:04:29.000305
Beula
pythondev_help_Beula_2017-09-07T17:04:29.000305
1,504,803,869.000305
92,670
pythondev
help
Why did they do the same `getLogger` thing :disappointed:
2017-09-07T17:06:11.000077
Beula
pythondev_help_Beula_2017-09-07T17:06:11.000077
1,504,803,971.000077
92,671
pythondev
help
¯\_(ツ)_/¯
2017-09-07T17:12:39.000036
Kiersten
pythondev_help_Kiersten_2017-09-07T17:12:39.000036
1,504,804,359.000036
92,672
pythondev
help
I worked with a guy who spend a huge amount of time writing his own logger.
2017-09-07T17:15:14.000190
Junita
pythondev_help_Junita_2017-09-07T17:15:14.000190
1,504,804,514.00019
92,673
pythondev
help
really smart guy, but it was a huge waste of time
2017-09-07T17:15:20.000413
Junita
pythondev_help_Junita_2017-09-07T17:15:20.000413
1,504,804,520.000413
92,674
pythondev
help
I used logzero and I can't recommend it enough. It's relation to logging is like requests to urllib. <https://github.com/metachris/logzero>
2017-09-07T17:24:29.000332
Betsy
pythondev_help_Betsy_2017-09-07T17:24:29.000332
1,504,805,069.000332
92,675
pythondev
help
That one looks pretty solid <@Betsy> - thanks! :taco:
2017-09-07T17:27:35.000517
Beula
pythondev_help_Beula_2017-09-07T17:27:35.000517
1,504,805,255.000517
92,676
pythondev
help
ooooh nice! thanks <@Betsy> :taco:
2017-09-07T17:28:24.000275
Kiersten
pythondev_help_Kiersten_2017-09-07T17:28:24.000275
1,504,805,304.000275
92,677
pythondev
help
Sure thing, thanks for the tacos :laughing:
2017-09-07T17:29:24.000285
Betsy
pythondev_help_Betsy_2017-09-07T17:29:24.000285
1,504,805,364.000285
92,678
pythondev
help
hi
2017-09-07T18:41:22.000216
Liane
pythondev_help_Liane_2017-09-07T18:41:22.000216
1,504,809,682.000216
92,679
pythondev
help
hey <#C07EFMZ1N|help> -ers, I’m looking at the documentation for `functools.partials` (<https://docs.python.org/3.5/library/functools.html?highlight=functools#functools.partial>) and it’s pretty late. Can someone eli5 why the example assigns `.func`, `.args` and `.keywords` attributes to the returned function?
2017-09-07T22:57:54.000046
Winnifred
pythondev_help_Winnifred_2017-09-07T22:57:54.000046
1,504,825,074.000046
92,680
pythondev
help
<@Winnifred> It's just showing how they implement it, so the short is they store the "partial application" as attributes on the function object
2017-09-07T22:59:40.000047
Beula
pythondev_help_Beula_2017-09-07T22:59:40.000047
1,504,825,180.000047
92,681
pythondev
help
You can see the source here: <https://github.com/python/cpython/blob/3.5/Lib/functools.py#L240>
2017-09-07T22:59:47.000055
Beula
pythondev_help_Beula_2017-09-07T22:59:47.000055
1,504,825,187.000055
92,682
pythondev
help
Then later when the partial is actually called, it merges any additional args/kwargs with those stored values and calls the function
2017-09-07T23:02:02.000121
Beula
pythondev_help_Beula_2017-09-07T23:02:02.000121
1,504,825,322.000121
92,683
pythondev
help
ahhhhh
2017-09-07T23:02:09.000156
Winnifred
pythondev_help_Winnifred_2017-09-07T23:02:09.000156
1,504,825,329.000156
92,684
pythondev
help
nice
2017-09-07T23:02:11.000041
Winnifred
pythondev_help_Winnifred_2017-09-07T23:02:11.000041
1,504,825,331.000041
92,685
pythondev
help
okay
2017-09-07T23:02:12.000023
Winnifred
pythondev_help_Winnifred_2017-09-07T23:02:12.000023
1,504,825,332.000023
92,686
pythondev
help
thanks <@Beula> :taco:
2017-09-07T23:02:31.000057
Winnifred
pythondev_help_Winnifred_2017-09-07T23:02:31.000057
1,504,825,351.000057
92,687
pythondev
help
note to self, go to source code :slightly_smiling_face:
2017-09-07T23:02:55.000029
Winnifred
pythondev_help_Winnifred_2017-09-07T23:02:55.000029
1,504,825,375.000029
92,688
pythondev
help
:thumbsup::skin-tone-4: If you haven't seen it, there is a link on the top of many of the pages to jump to the file on github
2017-09-07T23:04:55.000117
Beula
pythondev_help_Beula_2017-09-07T23:04:55.000117
1,504,825,495.000117
92,689
pythondev
help
Is this an acceptable way to build this SQL string? In its current state, it works.
2017-09-08T00:16:53.000195
Virgen
pythondev_help_Virgen_2017-09-08T00:16:53.000195
1,504,829,813.000195
92,690
pythondev
help
is there a better way to achieve this goal?
2017-09-08T00:17:25.000171
Virgen
pythondev_help_Virgen_2017-09-08T00:17:25.000171
1,504,829,845.000171
92,691
pythondev
help
I had asked a similar question yesterday and was advised to read the following article.
2017-09-08T00:19:13.000111
Virgen
pythondev_help_Virgen_2017-09-08T00:19:13.000111
1,504,829,953.000111
92,692
pythondev
help
<https://www.digitalocean.com/community/tutorials/how-to-use-string-formatters-in-python-3>
2017-09-08T00:19:17.000049
Virgen
pythondev_help_Virgen_2017-09-08T00:19:17.000049
1,504,829,957.000049
92,693
pythondev
help
<@Virgen> not if any of that data is from a user input/untrusted source
2017-09-08T00:19:17.000087
Beula
pythondev_help_Beula_2017-09-08T00:19:17.000087
1,504,829,957.000087
92,694
pythondev
help
That opens yourself up to "sql injection"
2017-09-08T00:19:29.000039
Beula
pythondev_help_Beula_2017-09-08T00:19:29.000039
1,504,829,969.000039
92,695
pythondev
help
the data is from an API.
2017-09-08T00:19:48.000009
Virgen
pythondev_help_Virgen_2017-09-08T00:19:48.000009
1,504,829,988.000009
92,696
pythondev
help
It's still best to use parametrized queries - what db are you using?
2017-09-08T00:20:07.000008
Beula
pythondev_help_Beula_2017-09-08T00:20:07.000008
1,504,830,007.000008
92,697
pythondev
help
I get a JSON dump from the API, this then builds the sql statement to dump the data into teh DB.
2017-09-08T00:20:23.000019
Virgen
pythondev_help_Virgen_2017-09-08T00:20:23.000019
1,504,830,023.000019
92,698
pythondev
help
mssql2016 express
2017-09-08T00:20:47.000101
Virgen
pythondev_help_Virgen_2017-09-08T00:20:47.000101
1,504,830,047.000101
92,699
pythondev
help
with `pymssql`? ``` cursor.execute('SELECT * FROM persons WHERE salesrep=%s', 'John Doe') ```
2017-09-08T00:21:41.000102
Beula
pythondev_help_Beula_2017-09-08T00:21:41.000102
1,504,830,101.000102
92,700
pythondev
help
pyodbc
2017-09-08T00:22:03.000087
Virgen
pythondev_help_Virgen_2017-09-08T00:22:03.000087
1,504,830,123.000087
92,701
pythondev
help
is ```pymssql``` a better option than ```pyodbc```?
2017-09-08T00:23:03.000042
Virgen
pythondev_help_Virgen_2017-09-08T00:23:03.000042
1,504,830,183.000042
92,702