question_id
int64
502
42.8M
parent_answer_post_id
int64
595
42.8M
prob
float64
0
0.87
snippet
stringlengths
0
12.1k
intent
stringlengths
11
198
id
stringlengths
9
20
2,308,247
2,308,327
0.000428
import limits
Find maximum signed short integer in python
2308247_2308327_9
3,367,450
3,367,707
0.000427
cx
howto extract simple string from tuple in python (newbie question)
3367450_3367707_3
1,465,662
23,707,260
0.000427
from heap.heap import heap h = heap()
How can I implement decrease-key functionality in Python's heapq?
1465662_23707260_9
40,747,713
41,023,395
0.000427
old_vote = query(poll_user_id=session['poll_user_id'], poll=poll_id) if not old_vote: insert(poll_user_id=session['poll_user_id'], poll=poll_id, choice=form. choice)
flask save polls in cookie
40747713_41023395_14
33,689,721
33,740,817
0.000425
import bitarray as bt tp = (bt.bitarray(p) & bt.bitarray(g)).count() tn = (~bt.bitarray(p) & ~bt.bitarray(g)).count() fp = (bt.bitarray(p) & ~bt.bitarray(g)).count()
Calculating Precision, Recall and F-score in one pass - python
33689721_33740817_14
20,268,396
20,269,033
0.000425
import selenic.util util = selenic.util.Util(driver) foo = util.find_element((By.CSS_SELECTOR, '...')) with util.local_timeout(10): pass
Mixing implicit and explicit waits
20268396_20269033_10
32,611,222
34,383,055
0.000425
try: launch(file, globals, locals) except: import traceback
Prevent PyCharm from showing builtin modules on KeyboardInterrupt and other occasions
32611222_34383055_5
4,729,832
9,471,374
0.000424
import csv as csv_mod
Proccessing a Django UploadedFile as UTF-8 with universal newlines
4729832_9471374_19
7,249,488
7,254,337
0.000424
import re import foo as module
Tool to help eliminate wildcard imports
7249488_7254337_14
40,859,607
41,036,384
0.000423
then
Add usage help of command line tool to README.rst
40859607_41036384_5
2,236,498
15,065,711
0.000423
import socket prv_getaddrinfo = socket.getaddrinfo dns_cache = {}
Tell urllib2 to use custom DNS
2236498_15065711_17
9,195,455
10,065,932
0.000422
Parameters
How to document a method with parameter(s)?
9195455_10065932_0
22,973,049
23,732,784
0.00042
LocalFree(output.pbData) return true
Decrypt Chrome Linux BLOB encrypted cookies in Python
22973049_23732784_4
30,427,445
30,427,649
0.000419
END
Python psycopg2 cursors
30427445_30427649_12
12,166,819
12,166,860
0.000419
app book.py ccg chat
Use NLTK without installing
12166819_12166860_15
4,994,638
7,303,734
0.000419
from pyftpdlib.handlers import FTPHandler address = '0.0.0.0', 21 server = servers.FTPServer(address, FTPHandler)
One line ftp server in python
4994638_7303734_13
4,843,493
5,082,394
0.000418
check_vim create_dirs pull_sources gen_vim_config
Any pointers on using Ropevim? Is it a usable library?
4843493_5082394_10
4,994,638
7,303,734
0.000418
from pyftpdlib import servers from pyftpdlib.handlers import FTPHandler address = '0.0.0.0', 21
One line ftp server in python
4994638_7303734_12
25,493,625
25,493,765
0.000418
sku
vlookup in Pandas using join
25493625_25493765_5
12,521,552
12,525,243
0.000418
bar - (0.8).tar.gz baz - (0.3).tar.gz foo - (1.2).tar.gz
Installing PIP packages to a Virtualenv using a download cache
12521552_12525243_6
31,164,568
31,165,089
0.000416
print(timeit(setup= "import re; regex = re.compile(r'(\\d{1,3}\\.\\d{1,3}.\\d{1,3}.\\d{1,3})')" , stmt="r = regex.search('192.168.1.1 999.999.999.999')", number=1000000))
Python Regex slower than expected
31164568_31165089_8
6,071,784
6,072,233
0.000416
text = """show the (name) of the (person) calc the sqrt of (+ (* (2 4) 3))""" import pyparsing
Regex: Match brackets both greedy and non greedy
6071784_6072233_11
27,878,157
27,878,536
0.000414
from bokeh.models import SingleIntervalTicker, LinearAxis plot = bp.figure(plot_width=800, plot_height=200, x_axis_type=None) ticker = SingleIntervalTicker(interval=5, num_minor_ticks=10) xaxis = LinearAxis(ticker=ticker)
how to adjust # of ticks on Bokeh axis (labels are overlapping on small figures)
27878157_27878536_14
11,021,130
29,618,322
0.000413
wheel
Parallel Pip install
11021130_29618322_14
11,331,175
11,332,078
0.000412
from distutils.command.build import build class my_build(build): pass
Hook to add commands to distutils build?
11331175_11332078_16
7,117,143
7,141,077
0.000411
timeit.timeit( 'pygame.surfarray.blit_array(screen, pixels);pygame.display.flip()', setup= 'import pygame;import numpy as np;size=(1920,1080);screen=pygame.display.set_mode(size);pixels=np.random.randint(np.iinfo(np.uint32).max,size=size).astype(np.uint32)' , number=20) timeit.timeit( """ pygame.surfarray.blit_array(screen, pixels) pygame.display.flip() """, setup= """ import pygame import numpy as np size=(1920,1080) screen=pygame.display.set_mode(size) pixels=np.random.randint(np.iinfo(np.uint32).max,size=size).astype(np.uint32) """ , number=20)
Setting Pixels Quickly
7117143_7141077_5
29,349,607
29,350,541
0.00041
Conn_string = ( 'data source=Server_Name; initial catalog=Database_Name; trusted_connection=True' )
pymssql windows authentication
29349607_29350541_11
6,347,588
6,347,650
0.000409
import re re import_re()
Is it possible to import to the global scope from inside a function (Python)?
6347588_6347650_15
32,593,155
32,593,392
0.000406
none python26 - apple python27(active) python27 - apple python33
psycopg2 installed successfully, but cannot be imported into python
32593155_32593392_19
9,064,018
9,064,582
0.000406
FROM
How to debug: Internal Error current transaction is aborted, commands ignored until end of transaction block
9064018_9064582_3
35,721,503
40,512,757
0.000406
from gensim.models import Word2Vec from gensim.models.word2vec import LineSentence np.savetxt('train_data.txt', arr, delimiter=' ', fmt='%s')
Gensim word2vec on predefined dictionary and word-indices data
35721503_40512757_17
5,998,835
5,998,894
0.000405
from timeit import Timer mapped = Timer(setup= """from operator import itemgetter lst=( ("a",), ("b",), (1,), (2,))""", stmt='map(itemgetter(0), lst)') comprehended = Timer(setup='lst=( ("a",), ("b",), (1,), (2,))', stmt= '[i[0] for i in lst]') comprehended.repeat()
Python: Anyway to use map to get first element of a tuple
5998835_5998894_14
3,531,980
3,541,858
0.000403
[buildout] parts = python eggs = tornado
How to migrate from virtualenv to buildout?
3531980_3541858_10
1,639,855
15,278,298
0.000402
from pattern.de import parse, split s = parse('Die Katze liegt auf der Matte.') s = split(s)
POS tagging in German
1639855_15278298_8
8,634,197
37,401,221
0.000402
import ctypes libc = ctypes.cdll.LoadLibrary('libc.so.6') res_init = libc.__res_init
Permanent gaierror 'Temporary failure in name resolution' after running for a few hours
8634197_37401221_9
39,397,034
39,398,969
0.000402
fold ps
Script works differently when ran from the terminal and ran from Python
39397034_39398969_11
10,390,927
10,391,047
0.000401
import web from web.wsgiserver import CherryPyWSGIServer from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter ssl_cert = 'path/to/ssl_certificate'
bottle on cherrypy server + ssl
10390927_10391047_16
21,553,764
21,553,941
0.000401
import java.io.File import org.openqa.selenium.WebDriver import org.openqa.selenium.firefox.FirefoxDriver import org.openqa.selenium.firefox.FirefoxBinary
How to run Selenium Scripts in webservers?
21553764_21553941_10
29,349,607
29,350,541
0.0004
Conn_string = ( 'data source=Server_Name; initial catalog=Database_Name; trusted_connection=True' ) ScheduleConn = SqlConnection(Conn_string) ScheduleConn.Open()
pymssql windows authentication
29349607_29350541_13
7,125,009
29,694,950
0.000399
large x - large xx - large
How to change legend size with matplotlib.pyplot
7125009_29694950_12
5,474,514
5,474,796
0.000398
zero = 1 == 0 and 0 or 1 zero = False and 0 or 1
Use of OR as branch control in FP
5474514_5474796_11
29,349,607
29,350,541
0.000397
import clr clr.AddReference('System.Data') from System.Data.SqlClient import * Conn_string = ( 'data source=Server_Name; initial catalog=Database_Name; trusted_connection=True' )
pymssql windows authentication
29349607_29350541_12
6,294,436
6,817,194
0.000397
qqq
rpy2 convert Matrix -> DataFrame
6294436_6817194_5
35,721,503
40,512,757
0.000396
import numpy as np from gensim.models import Word2Vec from gensim.models.word2vec import LineSentence
Gensim word2vec on predefined dictionary and word-indices data
35721503_40512757_18
6,165,293
6,205,415
0.000396
double * weight double * l double * n double * dn
Wrap C struct with array member for access in python: SWIG? cython? ctypes?
6165293_6205415_9
6,209,094
27,737,092
0.000395
from localconfig import config config.read("""[one] key = 42 key2 = None""") config.one.key, type(config.one.key)
Converting ConfigParser values to python data types
6209094_27737092_13
24,187,248
24,187,326
0.000395
python 420
Python 2to3 tool adds a vowel to my integer
24187248_24187326_9
6,165,293
6,205,415
0.000394
double * l double * n double * dn
Wrap C struct with array member for access in python: SWIG? cython? ctypes?
6165293_6205415_8
29,853,322
29,853,487
0.000394
starts, ends
find stretches of Trues in numpy array
29853322_29853487_14
5,474,514
5,474,796
0.000391
zero = False and 0 or 1 zero = 0 or 1 zero = False or 1
Use of OR as branch control in FP
5474514_5474796_12
7,249,488
7,254,337
0.000391
import re import foo as module module_name = module.__name__
Tool to help eliminate wildcard imports
7249488_7254337_13
7,912,820
32,020,282
0.000391
stationLat
How do I change a value while debugging python with pdb?
7912820_32020282_4
2,298,517
23,859,736
0.000387
import pyqtree spindex = pyqtree.Index(bbox=[0, 0, 1000, 500])
Are any of these quad-tree libraries any good?
2298517_23859736_11
32,466,179
33,718,354
0.000387
SET
SQLAlchemy correlated update for multiple columns
32466179_33718354_2
22,011,481
26,852,052
0.000387
lngDiv.innerHtml = lng document.body.appendChild(lngDiv)
Get the parameters of a JavaScript function with Scrapy
22011481_26852052_11
24,688,802
30,339,387
0.000385
import gifmaker sequence = []
Saving an animated GIF in Pillow
24688802_30339387_16
1,639,855
15,278,298
0.000382
from pattern.de import parse, split s = parse('Die Katze liegt auf der Matte.') s = split(s) print(s.sentences[0])
POS tagging in German
1639855_15278298_9
26,003,718
26,024,255
0.000381
from oauth2client.appengine import CredentialsModel from oauth2client.appengine import StorageByKeyName credentials = StorageByKeyName(CredentialsModel, ClientID, 'credentials').get()
User info using OAuth with Google App Engine
26003718_26024255_9
2,298,517
23,859,736
0.000381
import pyqtree spindex = pyqtree.Index(bbox=[0, 0, 1000, 500]) for item in items: spindex.insert(item=item, bbox=item.bbox)
Are any of these quad-tree libraries any good?
2298517_23859736_12
13,115,176
13,115,205
0.00038
import mpmath mpmath.exp(-1200) mpmath.mp.dps = 200
Exponential of very small number in python
13115176_13115205_14
17,424,516
17,424,702
0.000379
from types import NoneType class InvalidKeyNone(NoneType): pass
How to inherit from Python None
17424516_17424702_9
20,268,396
20,269,033
0.000379
import selenic.util util = selenic.util.Util(driver)
Mixing implicit and explicit waits
20268396_20269033_11
17,710,347
17,787,172
0.000378
import scapy tcpdump = sniff(count=5, filter='host 64.233.167.99', prn=lambda x: x.summary() )
tcpdump to only print urls
17710347_17787172_6
6,731,345
6,731,481
0.000376
FOO = 'foo' PI = 3.14 import constants
How-to import constants in many files
6731345_6731481_7
18,236,123
20,249,402
0.000375
import mock m = mock.MagicMock() m.p del m.p
Python PropertyMock side effect with AttributeError and ValueError
18236123_20249402_13
35,446,211
35,479,765
0.000374
c.InteractiveShellApp.exec_lines = [ """import numpy as np import scipy as sp import matplotlib as plt """]
Configuring Jupyter default imports
35446211_35479765_2
2,037,327
2,037,372
0.000373
yield end
Translating function for finding all partitions of a set from Python to Ruby
2037327_2037372_2
1,850,607
1,851,645
0.000373
span
Python fraction of seconds
1850607_1851645_13
15,985,339
18,011,599
0.000371
import Selenium2Library s = Selenium2Library.Selenium2Library()
How do I get current URL in Selenium Webdriver 2 Python?
15985339_18011599_5
18,541,503
18,562,328
0.000366
import org.apache.hadoop.io.Text import org.apache.hadoop.mapred.lib.MultipleTextOutputFormat
Multiple Output Files for Hadoop Streaming with Python Mapper
18541503_18562328_4
35,792,422
35,793,409
0.000366
numpy import numpy.random numpy
Further confusion with imports in Python
35792422_35793409_2
12,329,807
12,330,005
0.000366
import multiprocessing daemon = False
Django app deployment on nGINX
12329807_12330005_14
20,250,130
20,251,772
0.000366
from IPython.core.magic import register_line_magic @register_line_magic def p(line): pass
from past import print_statement
20250130_20251772_10
31,164,568
31,165,089
0.000365
print(timeit(setup= "import re; regex = re.compile(r'((?:\\d{1,3}\\.){3}\\d{1,3})')", stmt= "r = regex.search('192.168.1.1 999.999.999.999')", number=1000000))
Python Regex slower than expected
31164568_31165089_9
4,151,919
30,311,111
0.000364
fi done
google app engine path in linux?
4151919_30311111_2
29,439,589
29,439,946
0.000363
chunk
How to create a pivot table on extremely large dataframes in Pandas
29439589_29439946_18
30,055,084
30,056,828
0.000362
py - 3 import subprocess
Python subprocess echo a unicode literal
30055084_30056828_9
11,856,293
11,856,667
0.00036
import inspect
Numpy dot product very slow using ints
11856293_11856667_6
24,187,248
24,187,326
0.000359
python3 420 420
Python 2to3 tool adds a vowel to my integer
24187248_24187326_8
5,370,762
5,506,230
0.000359
Else EndIf
How to hide Firefox window (Selenium WebDriver)?
5370762_5506230_4
20,250,130
20,251,772
0.000358
from IPython.core.magic import register_line_magic @register_line_magic def p(line): print(line)
from past import print_statement
20250130_20251772_11
21,123,473
21,127,663
0.000358
147 ipdb > 1 n = 4
How do I manipulate a variable whose name conflicts with PDB commands?
21123473_21127663_9
29,349,607
29,350,541
0.000357
clr.AddReference('System.Data') from System.Data.SqlClient import * Conn_string = ( 'data source=Server_Name; initial catalog=Database_Name; trusted_connection=True' )
pymssql windows authentication
29349607_29350541_14
3,848,239
3,848,399
0.000357
Array
Trying to group values?
3848239_3848399_9
18,747,555
18,747,872
0.000357
Jinja2 == 2.7 MarkupSafe == 0.18
Packaging single Python module with dependencies
18747555_18747872_5
41,737,930
41,738,016
0.000357
stripped
Get ratio between different members of a column in the best performance
41737930_41738016_4
14,376,900
42,328,327
0.000351
from django.test.client import Client, RequestFactory from django.test.testcases import LiveServerTestCase, SimpleTestCase, TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessAnyDBFeature, skipUnlessDBFeature
Is there a recommended format for multi-line imports?
14376900_42328327_6
29,976,744
29,977,026
0.000351
Duration
Python: converting Trip duration of h min sec and leave only minute count
29976744_29977026_11
25,597,815
25,608,446
0.00035
import sys s = slice(0, sys.maxsize + 1) s s.stop
Slice endpoints invisibly truncated
25597815_25608446_16
3,250,749
3,250,975
0.00035
import sys V = list(range(100000)) for x in V: pass
Using Windows Python from Cygwin
3250749_3250975_12
3,250,749
3,250,975
0.00035
import sys V = list(range(100000)) for x in V: pass
Using Windows Python from Cygwin
3250749_3250975_13
1,258,712
1,378,134
0.000349
today tomorrow
fuzzy timestamp parsing with Python
1258712_1378134_8
14,775,040
14,775,453
0.000348
from matplotlib import ticker scale_pow = 2 def my_formatter_fun(x, p): return '%.2f' % (x * 10 ** scale_pow)
matplotlib axis label format
14775040_14775453_18
6,731,345
6,731,481
0.000348
PI = 3.14 import constants print(constants.PI)
How-to import constants in many files
6731345_6731481_8
1,258,712
1,378,134
0.000348
noon midnight
fuzzy timestamp parsing with Python
1258712_1378134_7
24,187,248
24,187,326
0.000348
python 420 python3 420
Python 2to3 tool adds a vowel to my integer
24187248_24187326_11
22,951,026
23,555,321
0.000347
urlRequest.HTTPShouldHandleCookies = YES NSHTTPCookie * setCookie
django-allauth logging in with Facebook token from iOS Device
22951026_23555321_3
2,957,013
41,140,750
0.000347
Blue
BeautifulSoup: just get inside of a tag, no matter how many enclosing tags there are
2957013_41140750_4
2,308,247
2,308,327
0.000347
import pyximport pyximport.install() import limits
Find maximum signed short integer in python
2308247_2308327_10
14,961,562
14,961,653
0.000346
a import array
How do I convert a string of hexadecimal values to a list of integers?
14961562_14961653_5