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
21,684,926
21,684,997
0.000662
counter2
How to concatenate String count and Int
21684926_21684997_8
7,078,232
7,143,658
0.000662
import setupcon setupcon.setup_console() import logging
Python 2.7: output utf-8 in Windows console
7078232_7143658_17
29,493,472
29,635,865
0.000661
currentUser = x Some(userDataGrouped)
Does spark utilize the sorted order of hbase keys, when using hbase as data source
29493472_29635865_7
2,053,657
30,436,124
0.000661
openTag = "<span style='font-size: .80em; color: " openTagEnd = ";font-family: courier, arial, helvetica, sans-serif;'>"
Git-diff to HTML
2053657_30436124_16
26,003,718
26,024,255
0.00066
from oauth2client.appengine import StorageByKeyName credentials = StorageByKeyName(CredentialsModel, ClientID, 'credentials').get()
User info using OAuth with Google App Engine
26003718_26024255_7
24,152,420
24,153,431
0.00066
pieFact *= 1.1 updatePieFact()
Pass Dynamic Javascript Variable to Django/Python
24152420_24153431_19
5,532,363
40,915,226
0.00066
from nltk.tokenize import MWETokenizer tokenizer = MWETokenizer()
Python: Tokenizing with phrases
5532363_40915226_10
24,023,052
24,024,139
0.000659
from werkzeug.datastructures import ImmutableOrderedMultiDict class OrderedRequest(Request): parameter_storage_class = ImmutableOrderedMultiDict app = Flask(__name__)
How to get the Jinja2 generated input value data?
24023052_24024139_19
9,988,517
10,031,281
0.000658
import images2gif frames = images2gif.readGif('rose.gif', False) for frame in frames: pass
Resize GIF animation, pil/imagemagick, python
9988517_10031281_19
33,019,420
33,020,269
0.000658
from toolz.functoolz import curry @curry def processDataLine(arg1, arg2, dataline): pass
Spark RDD - Mapping with extra arguments
33019420_33020269_13
4,690,423
4,695,498
0.000657
B2 = A2 B3 = A3 + B2
Get formula from Excel cell with python xlrd
4690423_4695498_9
17,803,829
20,720,019
0.000657
req1 == 1.0 req2 == 1.0
How to customize a requirements.txt for multiple environments?
17803829_20720019_7
1,786,206
1,812,263
0.000656
import java.util.ArrayList import java.util.HashMap import java.util.List
is there a Java equivalent of Python's defaultdict?
1786206_1812263_15
21,553,764
21,553,941
0.000656
import java.io.File import org.openqa.selenium.WebDriver import org.openqa.selenium.firefox.FirefoxDriver
How to run Selenium Scripts in webservers?
21553764_21553941_8
14,775,040
14,775,453
0.000656
from matplotlib import ticker scale_pow = 2
matplotlib axis label format
14775040_14775453_17
16,328,040
17,948,626
0.000656
from amazon.api import AmazonAPI amazon = AmazonAPI(ACCESS_KEY, SECRET, ASSOC) results = amazon.search(Keywords='book name', SearchIndex='Books')
Searching for books with the Amazon Product Advertising API - Python
16328040_17948626_13
4,477,269
10,626,361
0.000655
from django.db.backends.signals import connection_created def activate_foreign_keys(sender, connection, **kwargs): """Enable integrity constraint with sqlite.""" if connection.vendor == 'sqlite': pass
How to make ON DELETE CASCADE work in sqlite 3.7.4?
4477269_10626361_19
7,636,984
36,651,981
0.000655
from asciimatics.screen import Screen def demo(screen): pass
Linux Terminal Display and Python
7636984_36651981_16
7,351,270
7,351,353
0.000655
from pprint import PrettyPrinter class MyPrettyPrinter(PrettyPrinter): pass
Control a print format when printing a list in Python
7351270_7351353_16
11,172,448
11,172,774
0.000654
master = true workers = 2 uid = altera
configuring nginx and uwsgi for python flask application
11172448_11172774_11
19,705,785
19,706,670
0.000654
import http.server, ssl server_address = 'localhost', 4443 httpd = http.server.HTTPServer(server_address, http.server. SimpleHTTPRequestHandler) httpd.socket = ssl.wrap_socket(httpd.socket, server_side=True, certfile= 'localhost.pem', ssl_version=ssl.PROTOCOL_TLSv1)
Python 3 HTTPS Webserver
19705785_19706670_14
39,644,514
39,694,727
0.000654
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import ec backend = default_backend() key = ec.generate_private_key(ec.SECP256R1(), backend)
How to find ASN.1 components of EC key python-cryptography
39644514_39694727_17
23,740,880
23,745,571
0.000653
from djcelery.models import PeriodicTask, CrontabSchedule every_hours_crontab = CrontabSchedule(minute=0) every_hours_crontab.save()
Add, modify, remove celery.schedules at run time
23740880_23745571_14
2,067,036
2,067,071
0.000653
some_values = ['a', 'b', 'c', 'd', 'e', 'f'] other_values = [4, 8, 15, 16, 23, 42] context['zipped_values'] = zip(some_values, other_values)
Accessing parallel arrays in Django templates?
2067036_2067071_9
27,790,415
41,891,285
0.000652
from functools import partial bs_parse = partial(bs4.BeautifulSoup, features='lxml')
Set lxml as default BeautifulSoup parser
27790415_41891285_9
42,364,851
42,364,973
0.000652
amin = 0 amax = 2
Python: Generating all n-length arrays combinations of values within a range
42364851_42364973_12
31,967,170
33,519,170
0.000652
131
How to structure a program to work with minesweeper configurations
31967170_33519170_16
17,791,481
41,110,107
0.000652
import re def get_property(prop, project): pass
Creating a __version__ attribute for python packages without getting into trouble
17791481_41110107_16
1,878,470
1,878,486
0.00065
rslt
Add tuple to list of tuples in Python
1878470_1878486_12
11,213,646
14,303,683
0.00065
l = misc.lena() import pylab as pl
Use pylab to plot image returned from Scipy
11213646_14303683_14
10,390,927
10,391,047
0.000649
from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter ssl_cert = 'path/to/ssl_certificate' ssl_key = 'path/to/ssl_private_key' CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(ssl_cert, ssl_key, None)
bottle on cherrypy server + ssl
10390927_10391047_13
19,471,708
29,636,575
0.000648
import subprocess fabric_json = ( '{"objects": [{"opacity": 1, "strokeMiterLimit": 10, "isMulticolor": false, "height": 203, "visible": true, "stroke": null, "filters": [], "hexColors": ["#085a68", "#ca350a", "#d8ec73"], "fill": "rgb(0,0,0)", "angle": 0, "fillRule": "nonzero", "flipX": false, "flipY": false, "top": 205.78, "scaleX": 0.46, "scaleY": 0.46, "strokeLineJoin": "miter", "width": 200, "backgroundColor": "", "clipTo": null, "type": "image", "strokeLineCap": "butt", "strokeDashArray": null, "strokeWidth": 1, "originY": "top", "originX": "left", "globalCompositeOperation": "source-over", "designId": 2825, "alignY": "none", "alignX": "none", "shadow": null, "crossOrigin": "", "src": "http://localhost.com/designs/sampleimage.png", "meetOrSlice": "meet", "designFileName": "sampleimage.png", "left": 208.68}], "backgroundImage": {"opacity": 1, "strokeMiterLimit": 10, "height": 630, "visible": true, "stroke": null, "filters": [], "fill": "rgb(0,0,0)", "angle": 0, "fillRule": "nonzero", "flipX": false, "flipY": false, "top": 0, "scaleX": 1, "scaleY": 1, "strokeLineJoin": "miter", "width": 530, "backgroundColor": "", "clipTo": null, "type": "image", "strokeLineCap": "butt", "strokeDashArray": null, "strokeWidth": 1, "originY": "top", "originX": "left", "globalCompositeOperation": "source-over", "alignY": "none", "alignX": "none", "shadow": null, "crossOrigin": "", "src": "http://localhost.com:5000/static/images/fabric/ts_rne_front.png", "meetOrSlice": "meet", "left": 0}, "background": "#bf1515"}' )
Construct image from Fabric.js JSON on python server
19471708_29636575_10
3,285,443
5,647,140
0.000647
rem -= root
Improving pure Python prime sieve by recurrence formula
3285443_5647140_13
24,011,399
39,538,451
0.000646
import django django.VERSION
Activating a virtual env not working
24011399_39538451_4
4,264,634
27,483,156
0.000646
from itertools import repeat for unused in repeat(None, 10): del unused
More Pythonic Way to Run a Process X Times
4264634_27483156_8
32,593,155
32,593,392
0.000646
none
psycopg2 installed successfully, but cannot be imported into python
32593155_32593392_17
35,911,252
42,121,886
0.000645
import os
Disable Tensorflow debugging information
35911252_42121886_5
24,197,970
24,198,880
0.000645
mypackage
PyCharm import external library
24197970_24198880_1
4,711,179
4,711,886
0.000645
import dis def test(): """This is a standard doc string"""
Auto expanding blocks of comments in emacs
4711179_4711886_14
7,249,488
7,254,337
0.000645
import foo as module module_name = module.__name__ import_line = 'from %s import (%%s)' % module_name length = len(import_line) - 3 print(import_line % (',\n' + length * ' ').join([a for a in dir(module) if not re.match('__.*[^_]{2}', a)]))
Tool to help eliminate wildcard imports
7249488_7254337_9
15,491,861
25,988,432
0.000645
from sortedcontainers import SortedDict d = SortedDict({(1): 5, (2): 5, (4): 5}) d d[3] = 5
Add keys in dictionary in SORTED order
15491861_25988432_13
9,002,982
40,115,296
0.000645
import elasticsearch as ES import elasticsearch.helpers as ESH es = ES.Elasticsearch() docs = [doc1, doc2, doc3]
Elasticsearch bulk index in chunks using PyEs
9002982_40115296_14
15,670,505
15,761,249
0.000644
py - execute - clause - python2 py - execute - clause - python3
Comparison of Python modes for Emacs
15670505_15761249_10
32,095,935
32,105,181
0.000643
from crontab import CronTab cron = CronTab()
Python script to send mail at specific time and day every month
32095935_32105181_8
15,691,740
15,691,929
0.000642
a a2 = a
Does assignment with advanced indexing copy array data?
15691740_15691929_11
22,180,315
38,094,922
0.000642
[aliases] test = pytest [pytest]
How to make pylint a part of setup.py test process?
22180315_38094922_7
20,637,439
20,637,559
0.000641
from io import StringIO s = '1, 2\n3, 4\n5, 6'
Skip rows during csv import pandas
20637439_20637559_14
42,107,268
42,633,407
0.000641
import folium m = folium.Map(location=[40.66393072, -73.93827499], zoom_start=13) folium.TopoJson(open('census_tracts_2010.geojson'), object_path= 'objects.nyct2010').add_to(m)
GeoJSON data not displaying in Python folium map
42107268_42633407_9
7,078,232
7,143,658
0.000641
setupcon.setup_console() import logging
Python 2.7: output utf-8 in Windows console
7078232_7143658_16
2,236,498
15,065,711
0.000641
import socket prv_getaddrinfo = socket.getaddrinfo dns_cache = {} def new_getaddrinfo(*args): pass
Tell urllib2 to use custom DNS
2236498_15065711_15
33,212,855
33,213,529
0.000641
field2
How can I create a Matlab struct array from scipy.io?
33212855_33213529_11
9,525,220
9,788,109
0.00064
from eventlet import tpool def m(): pass try: raise TypeError except: pass
SQLAlchemy raises None, causes TypeError
9525220_9788109_16
7,249,488
7,254,337
0.00064
import foo as module module_name = module.__name__
Tool to help eliminate wildcard imports
7249488_7254337_10
18,183,810
18,869,058
0.00064
from gensim import corpora docs = ['this is a foo bar', 'you are a foo'] texts = [[i for i in doc.lower().split()] for doc in docs]
Gensim Dictionary Implementation
18183810_18869058_19
25,104,154
40,746,017
0.00064
import requests from pkg_resources import parse_version def versions(name): url = 'https://pypi.python.org/pypi/{}/json'.format(name)
pypi see older versions of package
25104154_40746017_10
8,281,371
8,287,065
0.000639
import netifaces as ni ni.interfaces() ni.ifaddresses('eth0')
Python, How to get all external ip addresses with multiple NICs
8281371_8287065_12
3,333,550
25,235,213
0.000638
directories = [self._root.template_path], imports = ['from utils.view import handle_unicode'], default_filters = ['handle_unicode']
how to deal with unicode in mako?
3333550_25235213_16
10,399,614
10,399,796
0.000638
tmpdict
Accessing value inside nested dictionaries
10399614_10399796_5
10,818,824
10,818,843
0.000638
import pwd import grp
How to set a files owner in python?
10818824_10818843_15
13,936,068
13,936,747
0.000638
return NULL char * credsCopy
Passing binary data from Python to C API extension
13936068_13936747_9
25,760,023
25,781,806
0.000637
views.py from axes.decorators import watch_login
Django login with django-axes
25760023_25781806_4
13,988,111
13,993,480
0.000637
import matplotlib.units as muints muints.registry
Importing pandas in python changes how matplotlib handles datetime objects?
13988111_13993480_7
15,670,505
15,761,249
0.000636
py - execute - clause - python2 py - execute - clause - python3 py - execute - clause - ipython
Comparison of Python modes for Emacs
15670505_15761249_8
1,285,911
1,552,005
0.000636
setup = ( """from random import randint as R;d=dict((str(R(0,1000000)),R(0,1000000)) for i in range(D));q=dict((str(R(0,1000000)),R(0,1000000)) for i in range(Q));print("looking for %s items in %s"%(len(q),len(d)))""" ) Timer('set(q) <= set(d)', 'D=1000000;Q=100;' + setup).timeit(1)
python: How do I check that multiple keys are in a dict in one go?
1285911_1552005_12
9,153,527
9,153,630
0.000636
from ui_sub_direcotory import menu from domain_sub_directory import domain
Import module in another directory from a "parallel" sub-directory
9153527_9153630_9
14,915,340
14,926,214
0.000635
from ez_setup import use_setuptools use_setuptools() from setuptools import setup
how to write setup.py for this application structure?
14915340_14926214_11
24,519,046
24,519,467
0.000635
answer = a * b format = """ A multiline string """
Python 2 newline tokens in tokenize module
24519046_24519467_14
3,733,554
3,733,570
0.000635
import pprint x = {'planet': {'name': 'Earth', 'has': {'plants': 'yes', 'animals': 'yes', 'cryptonite': 'no'}}} pp = pprint.PrettyPrinter(indent=4)
Howto Format dict string outputs nicely
3733554_3733570_10
5,872,858
21,736,385
0.000634
import rtmidi_python as rtmidi vmidi_out = rtmidi.MidiOut()
Configure Mac OS X MIDI programatically
5872858_21736385_11
3,848,091
3,850,585
0.000634
s2 s1 ^ s2
Python set iteration order varies from run to run
3848091_3850585_14
12,322,289
12,336,039
0.000633
quotes
KDB+ like asof join for timeseries data in pandas?
12322289_12336039_9
38,907,219
38,917,817
0.000632
threshold(gr, bw, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU) vector < vector < Point >> contours vector < Vec4i > hierarchy
Detection of irregular shapes using houghcircle function opencv python
38907219_38917817_13
2,676,434
27,361,869
0.000631
from ewmh import EWMH import random ewmh = EWMH() wins = ewmh.getClientList()
X11 - How to raise another application's window using Python
2676434_27361869_19
11,472,810
14,405,269
0.00063
from verlib import NormalizedVersion as V assert V('0.7.9') < V('0.8a0') < V('0.8a1') < V('0.8b0') < V('0.8b1') < V( '0.8b2') < V('0.8.0') < V('0.8.1a0') < V('0.8.1') < V('0.9') < V('1.0a3' ) < V('1.0b2') < V('1.0b20') < V('1.0c0') < V('1.0') < V('1.0.1')
How to specify version ranges in install_requires (setuptools, distribute)
11472810_14405269_8
17,492,298
17,492,375
0.00063
os.getcwd() from conf.configmanager import ConfigManager
path one level too low in python console of pycharm
17492298_17492375_8
23,195,321
23,195,675
0.00063
UPPERCASE
How to convert string to uppercase / lowercase in Jinja2?
23195321_23195675_0
864,956
865,737
0.000629
OK
Problems using nose in a virtualenv
864956_865737_10
28,505,222
28,510,351
0.000629
file1 file2
Python - List files and folders in Bucket
28505222_28510351_10
28,397,473
28,397,561
0.000627
import time max_execution_time = 10000000
Stop Sublime Text from executing infinite loop
28397473_28397561_19
37,893,755
37,901,914
0.000626
import notebook_util
Tensorflow set CUDA_VISIBLE_DEVICES within jupyter
37893755_37901914_13
2,561,902
2,562,292
0.000626
import os import subprocess null = open(os.devnull, 'w')
Python - Execute Process -> Block till it exits & Supress Output
2561902_2562292_9
30,200,494
30,201,400
0.000626
X2
Referencing a numpy arrray without creating an expensive copy
30200494_30201400_11
1,629,687
1,630,614
0.000625
from xml.dom.minidom import parseString dom = parseString("""<message> <text> Hello! </text> </message>""") dom.childNodes[0].childNodes text = dom.getElementsByTagName('text')[0].childNodes[0]
Alter XML while preserving layout
1629687_1630614_17
6,570,075
6,570,190
0.000625
for x, field in zip(FlightsResultsSorter, named_tuple_sex._fields): pass
Getting name of value from namedtuple
6570075_6570190_5
12,544,510
12,544,831
0.000625
row = ( """172.16.0.3 - - [25/Sep/2002:14:04:19 +0200] "GET / HTTP/1.1" 401 - "" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020827" """ )
Parsing apache log files
12544510_12544831_5
10,479,319
10,479,343
0.000625
rr
Possible to return two lists from a list comprehension?
10479319_10479343_5
39,840,323
41,769,005
0.000624
reader = tf.TFRecordReader(options=tf.python_io.TFRecordOptions(tf. python_io.TFRecordCompressionType.ZLIB))
Benchmark of HowTo: Reading Data
39840323_41769005_6
13,902,805
13,902,835
0.000624
t1 = Timer(stmt=stmt1, setup='from __main__ import data, OrderedDict') t2 = Timer(stmt=stmt2, setup='from __main__ import data') t1.timeit(number=1000)
List of all unique characters in a string?
13902805_13902835_14
26,870,303
26,876,001
0.000623
end end
Find out largest string value size for keys in Redis database
26870303_26876001_6
14,652,826
14,653,833
0.000623
import java.io.File import java.io.IOException import java.util.ArrayList
Comparing two documents using regex
14652826_14653833_18
33,689,721
33,740,817
0.000623
import bitarray as bt tp = (bt.bitarray(p) & bt.bitarray(g)).count()
Calculating Precision, Recall and F-score in one pass - python
33689721_33740817_11
15,930,885
39,730,668
0.000623
import traces ts = traces.TimeSeries(data=[(datetime(2016, 9, 27, 23, 0, 0, 100000), 10), (datetime(2016, 9, 27, 23, 0, 1, 200000), 8), (datetime(2016, 9, 27, 23, 0, 1, 600000), 0), (datetime(2016, 9, 27, 23, 0, 6, 300000), 4)])
Converting irregularly time stamped measurements into equally spaced, time-weighted averages
15930885_39730668_9
18,327,790
24,312,648
0.000622
derp_r2_sum_select = """ select sum(`derp_related_2`.`amount`) from `derp_related_2` where `derp_related_2`.`fk` = `derp`.`pk`" """
Django aggregation across multiple tables in ModelAdmin queryset
18327790_24312648_16
3,144,089
3,177,320
0.000622
python import project import sys for line in sys.path: pass
Expand Python Search Path to Other Source
3144089_3177320_11
15,664,101
15,664,124
0.000622
def foo(): if conditional(): logger.info( "<Conditional's meaning> happened, so we're not setting up the interface." ) import dis
How to cleanly keep below 80-char width with long strings?
15664101_15664124_11
15,691,740
15,691,929
0.000621
a2 = a a[b] = 1 a2 is a
Does assignment with advanced indexing copy array data?
15691740_15691929_10
18,236,123
20,249,402
0.000621
import mock m = mock.MagicMock() m.p
Python PropertyMock side effect with AttributeError and ValueError
18236123_20249402_12
23,064,549
33,194,319
0.00062
import EXIF with open('image.jpg', 'rb') as fh: tags = EXIF.process_file(fh, stop_tag='EXIF DateTimeOriginal') dateTaken = tags['EXIF DateTimeOriginal']
Get date and time when photo was taken from EXIF data using PIL
23064549_33194319_12
24,011,399
39,538,451
0.00062
python import django
Activating a virtual env not working
24011399_39538451_5
4,729,832
9,471,374
0.00062
import csv as csv_mod import codecs file = request.FILES['file'] dialect = csv_mod.Sniffer().sniff(codecs.EncodedFile(file, 'utf-8').read(1024)) file.open()
Proccessing a Django UploadedFile as UTF-8 with universal newlines
4729832_9471374_16