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,171,189
2,171,624
0.000482
tz
python-tz am I wrong or it's a bug
2171189_2171624_9
17,555,208
17,555,296
0.000482
import re resourceProperties = 'test test token test'
Print search term that does not exist in list comprehension of a list comprension
17555208_17555296_11
1,675,943
1,676,000
0.000482
from textwrap import wrap def getAbstract(text, lines=5, screenwidth=100): width = len(' '.join([line for block in text.splitlines() for line in wrap(block, width=screenwidth)][:lines]))
Computing article abstracts
1675943_1676000_11
16,200,532
16,202,198
0.000481
from kombu import Exchange, Queue CELERY_DEFAULT_QUEUE = 'app1'
Running multiple instances of celery on the same server
16200532_16202198_5
2,957,013
41,140,750
0.00048
Blue Yellow
BeautifulSoup: just get inside of a tag, no matter how many enclosing tags there are
2957013_41140750_3
36,416,018
36,630,943
0.00048
from operator import mul pn = [0.4, 0.3, 0, 0] e = 0.01
Resolving Zeros in Product of items in list
36416018_36630943_9
33,452,096
33,452,336
0.000479
suffixes = importlib.machinery.SOURCE_SUFFIXES loader = importlib.machinery.SourceFileLoader lazy_loader = importlib.util.LazyLoader.factory(loader)
Python import one subpackage without others
33452096_33452336_9
1,629,687
1,630,614
0.000477
from xml.dom.minidom import parseString dom = parseString("""<message> <text> Hello! </text> </message>""")
Alter XML while preserving layout
1629687_1630614_19
235,435
242,175
0.000476
from ctypes import CDLL, c_char_p getenv = CDLL('libc.so.6').getenv getenv.restype = c_char_p
Environment Variables in Python on Linux
235435_242175_9
12,661,999
38,500,576
0.000476
SELECT
get raw decimal value from mysqldb query
12661999_38500576_0
7,249,488
7,254,337
0.000476
module_name = module.__name__ import_line = 'from %s import (%%s)' % module_name
Tool to help eliminate wildcard imports
7249488_7254337_12
24,485,932
24,486,079
0.000475
def first_item(aList): return aList[0] sorted(list(kwargs.items()), key=first_item) from operator import itemgetter
Understand lambda usage in given python code
24485932_24486079_12
2,814,609
2,815,796
0.000475
import imp sm.MyClass.kind imp.reload(sm) sm.MyClass.kind
reloading module, need to re-compile sub modules?
2814609_2815796_17
22,400,801
22,401,623
0.000475
import sys sys.maxsize type(2 ** 63)
Getting OverflowError: math range error(trying to calculate power of a number)
22400801_22401623_13
12,556,309
19,903,276
0.000472
def count_click(requests): from collections import Counter count = Counter(request.kwargs['url'] for request in requests)
Celery Task Grouping/Aggregation
12556309_19903276_16
4,711,179
4,711,886
0.000472
import dis def test(): """This is a standard doc string""" a = 3
Auto expanding blocks of comments in emacs
4711179_4711886_17
26,003,718
26,024,255
0.000471
from oauth2client.appengine import CredentialsModel from oauth2client.appengine import StorageByKeyName
User info using OAuth with Google App Engine
26003718_26024255_8
2,308,247
2,308,327
0.000471
pyximport.install() import limits print(limits.shrt_max)
Find maximum signed short integer in python
2308247_2308327_8
29,349,607
29,350,541
0.00047
ScheduleConn = SqlConnection(Conn_string) ScheduleConn.Open()
pymssql windows authentication
29349607_29350541_10
24,386,947
24,390,629
0.000469
import scipy.stats as ss unknown = np.random.normal(loc=1.1, scale=2.0, size=100) Loc, Scale = ss.norm.fit_loc_scale(unknown) unknown_cdf = lambda x: ss.norm.cdf(x, loc=Loc, scale=Scale)
Is there a method to do arithmetic with SciPy's random variables?
24386947_24390629_19
1,959,210
6,657,771
0.000469
import fortranformat as ff line = ff.FortranRecordReader('(F10.0)')
Python scientific notation using D instead of E
1959210_6657771_5
31,164,568
31,165,089
0.000469
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)) 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)) print(timeit(setup= "import re; regex = re.compile(r'(\\d{1,2}/\\w{3}/[2][0]\\d{2}:\\d{2}:\\d{2}:\\d{2}\\s[+][0]{4})')" , stmt='r = regex.search("[23/Jun/2015:11:10:57 +0000]")', number=1000000))
Python Regex slower than expected
31164568_31165089_5
21,366,290
21,366,908
0.000468
import re, sre_parse pattern = ( '(?P<DEF_FUNC>def (?P<NAME_FUNC>\\w+)\\s*\\((.*?)\\):)|(?P<OTHERS>\\w+)') v = sre_parse.parse(pattern) print(v.pattern.groupdict)
Pattern associated to a named group
21366290_21366908_13
31,730,627
31,730,891
0.000468
VALUE
Append two multiindexed pandas dataframes
31730627_31730891_2
34,455,749
34,457,983
0.000466
cd
nltk : How to prevent stemming of proper nouns
34455749_34457983_5
18,372,952
18,373,060
0.000466
domain level url
Python, split tuple items to single stuff
18372952_18373060_14
14,009,148
14,046,303
0.000466
from PIL import Image from PIL.ExifTags import TAGS img = Image.open('test.jpg')
Exif reading library
14009148_14046303_15
31,164,568
31,165,089
0.000465
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)) print(timeit(setup= "import re; regex = re.compile(r'(\\d{1,2}/\\w{3}/[2][0]\\d{2}:\\d{2}:\\d{2}:\\d{2}\\s[+][0]{4})')" , stmt='r = regex.search("[23/Jun/2015:11:10:57 +0000]")', number=1000000))
Python Regex slower than expected
31164568_31165089_7
18,236,123
29,428,352
0.000464
from mock import Mock m = Mock(spec=[])
Python PropertyMock side effect with AttributeError and ValueError
18236123_29428352_5
22,839,934
27,987,379
0.000463
then
autoenv executes even in subfolder
22839934_27987379_5
11,021,130
29,618,322
0.000463
redis
Parallel Pip install
11021130_29618322_11
16,594,564
16,594,638
0.000462
import collections class MyDict(collections.Mapping): pass
Tests for Basic Python Data Structure Interfaces
16594564_16594638_11
8,876,553
8,876,748
0.000461
FROM
Searching for items in a many-to-many relationship
8876553_8876748_1
42,683,518
42,712,569
0.00046
import sys from pprint import pprint as p remove = ['/usr/lib/python2.7']
pip in virtualenv cannot find ctypes
42683518_42712569_15
6,347,588
6,347,650
0.000459
import re re import_re() re
Is it possible to import to the global scope from inside a function (Python)?
6347588_6347650_14
38,425,519
38,599,156
0.000459
import ansible.inventory inventory_file = 'ansible_inventory'
Monitor a cluster of nodes
38425519_38599156_19
3,584,945
3,585,432
0.000458
RETURN
non-technical benefits of having string-type immutable
3584945_3585432_3
6,918,069
6,919,566
0.000458
import Text.XML.HXT.Core import Data.Map
How do reimplement this Python XML-parsing function in Haskell?
6918069_6919566_2
2,813,227
2,813,384
0.000457
import inspect def pv(name): record = inspect.getouterframes(inspect.currentframe())[1] frame = record[0] val = eval(name, frame.f_globals, frame.f_locals)
Printing Variable names and contents as debugging tool; looking for emacs/Python shortcut
2813227_2813384_19
35,721,503
40,512,757
0.000456
import numpy as np 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_16
1,870,871
3,987,901
0.000456
import tables as t
efficient way to compress a numpy array (python)
1870871_3987901_3
17,099,556
17,099,566
0.000455
pair, members pair
Why do int keys of a python dict turn into strings when using json.dumps?
17099556_17099566_7
27,790,415
41,891,285
0.000453
import bs4 from functools import partial
Set lxml as default BeautifulSoup parser
27790415_41891285_11
12,166,819
12,166,860
0.000452
app book.py ccg chat chunk classify
Use NLTK without installing
12166819_12166860_14
7,015,203
7,015,431
0.000452
import subprocess def add_to_jar(file2add, jar_file): pass
Edit jar files with python
7015203_7015431_12
358,225
358,641
0.000452
log4j.rootLogger = INFO, stdout, logfile log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j with timestamp per log entry
358225_358641_8
32,172,125
32,172,225
0.000452
test2
Numpy index, get bands of width 2
32172125_32172225_15
16,055,403
16,055,603
0.000452
import platform setup_requires = ['foo', 'bar'] if platform.system() == 'Windows': setup_requires.append('pyreadline')
Setuptools platform specific dependencies
16055403_16055603_13
35,721,503
40,512,757
0.000451
from gensim.models import Word2Vec from gensim.models.word2vec import LineSentence np.savetxt('train_data.txt', arr, delimiter=' ', fmt='%s') sentences = LineSentence('train_data.txt') model = Word2Vec(sentences)
Gensim word2vec on predefined dictionary and word-indices data
35721503_40512757_15
23,740,880
23,745,571
0.000451
from djcelery.models import PeriodicTask, CrontabSchedule every_hours_crontab = CrontabSchedule(minute=0) every_hours_crontab.save() periodic_task = PeriodicTask(name='Call my task every hour', task= 'myproject.tasks.mytask', crontab=every_hours_crontab, args=json.dump([ arg1, arg2]), kwargs=json.dump({'foo': 'bar'}))
Add, modify, remove celery.schedules at run time
23740880_23745571_15
1,556,554
10,063,883
0.000451
import jinja2 jinja2.__version__ a jinja2.escape(a)
jinja2: html escape variables
1556554_10063883_14
40,257,152
40,538,541
0.000451
from oauth2client.client import GoogleCredentials from googleapiclient import discovery projectID = 'projects/<your_project_id>'
Is there anyway Google App Engine apps can communicate or control Machine Learning models or tasks?
40257152_40538541_19
3,050,298
3,050,359
0.000451
TWO
Parsing email with Python
3050298_3050359_4
20,268,396
20,269,033
0.00045
import selenic.util util = selenic.util.Util(driver) foo = util.find_element((By.CSS_SELECTOR, '...'))
Mixing implicit and explicit waits
20268396_20269033_9
22,386,580
22,708,479
0.00045
from appconf import AppConf class MyAppConf(AppConf): pass
django settings per application - best practice?
22386580_22708479_19
670,442
9,799,520
0.00045
from queued_storage.backends import QueuedStorage queued_s3storage = QueuedStorage('django.core.files.storage.FileSystemStorage', 'storages.backends.s3boto.S3BotoStorage', task= 'queued_storage.tasks.TransferAndDelete')
Asynchronous File Upload to Amazon S3 with Django
670442_9799520_10
11,021,130
29,618,322
0.00045
awscli bottle
Parallel Pip install
11021130_29618322_10
25,104,154
40,746,017
0.000449
import requests from pkg_resources import parse_version def versions(name): url = 'https://pypi.python.org/pypi/{}/json'.format(name) return sorted(requests.get(url).json()['releases'], key=parse_version)
pypi see older versions of package
25104154_40746017_13
33,689,721
33,740,817
0.000449
import bitarray as bt tp = (bt.bitarray(p) & bt.bitarray(g)).count() tn = (~bt.bitarray(p) & ~bt.bitarray(g)).count()
Calculating Precision, Recall and F-score in one pass - python
33689721_33740817_13
39,582,192
39,582,241
0.000448
1111
Python: Search a string for a variable repeating characters
39582192_39582241_17
20,297,858
20,297,892
0.000447
from celery.task import PeriodicTask class InitialTasksStarter(PeriodicTask): starttime = datetime.now() + timedelta(minutes=1) run_every = crontab(month_of_year=starttime.month, day_of_month=starttime. day, hour=starttime.hour, minute=starttime.minute)
Django celery task run at once on startup of celery server
20297858_20297892_13
29,588,595
29,588,596
0.000447
EOF
How do I install Hadoop and Pydoop on a fresh Ubuntu instance
29588595_29588596_7
10,949,388
10,979,509
0.000447
from ThrdPartyDjangoLib import djangoTagIWantToUse register = template.Library() register.tag('djangoTagIWantToUse', djangoTagIWantToUse)
Django : How to use 3rd party app templatetags with Jinja 2?
10949388_10979509_6
32,593,155
32,593,392
0.000446
none python26 - apple python27(active)
psycopg2 installed successfully, but cannot be imported into python
32593155_32593392_18
42,683,518
42,712,569
0.000445
remove = ['/usr/lib/python2.7'] sys.path = [path for path in sys.path if path not in remove] import ctypes
pip in virtualenv cannot find ctypes
42683518_42712569_13
11,021,130
29,618,322
0.000445
python - slugify python - bcrypt arrow
Parallel Pip install
11021130_29618322_13
12,166,819
12,166,860
0.000445
chunk
Use NLTK without installing
12166819_12166860_13
22,011,481
26,852,052
0.000444
lngDiv.id = 'extractedLng' lngDiv.innerHtml = lng
Get the parameters of a JavaScript function with Scrapy
22011481_26852052_10
18,634,844
18,635,666
0.000442
from contextlib import contextmanager BLUE = 34
Colored output from fabric script
18634844_18635666_9
1,201,115
1,201,244
0.000442
import __init__ re = __init__.re
Importing files in Python from __init__.py
1201115_1201244_9
47,701
550,795
0.000442
gdb > pystack gdb > detach
Is there a way to attach a debugger to a multi-threaded Python process?
47701_550795_3
10,767,736
10,771,055
0.000441
import Control.Monad.ST.Lazy import Data.Array.ST
How to make ST computation produce lazy result stream (or operate like a co-routine)?
10767736_10771055_5
13,180,861
13,181,061
0.000441
""" Assuming all lists have the same length >>> zip_lists([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) [[1, 4, 7], [2, 5, 8], [3, 6, 9]] >>> zip_lists([[1, 2], [3, 4], [5, 6], [7, 8]]) [[1, 3, 5, 7], [2, 4, 6, 8]] """
Zip as a list comprehension
13180861_13181061_4
34,529,542
34,542,318
0.000441
dout
Create open bounds indicators from pandas get_dummies on discretized numerical
34529542_34542318_15
24,000,729
24,001,029
0.000439
from werkzeug.routing import PathConverter class EverythingConverter(PathConverter): regex = '.*?' app.url_map.converters['everything'] = EverythingConverter
Flask route using path with leading slash
24000729_24001029_9
12,556,163
18,394,030
0.000439
import org.openqa.selenium.Capabilities import org.openqa.selenium.HasCapabilities import org.openqa.selenium.remote.RemoteWebDriver import org.openqa.selenium.support.events.EventFiringWebDriver
Get browser version using selenium webdriver
12556163_18394030_12
5,086,922
5,087,482
0.000438
from tidylib import tidy_document document, errors = tidy_document(your_xml_str, options={'output_xml': 1, 'indent': 1, 'input_xml': 1})
Python pretty XML printer with lxml
5086922_5087482_14
21,123,473
21,127,663
0.000438
147 ipdb > 1 n = 4 1
How do I manipulate a variable whose name conflicts with PDB commands?
21123473_21127663_8
16,232,292
16,235,950
0.000438
end end
split array to sub array by step in Ruby
16232292_16235950_8
35,721,503
40,512,757
0.000437
from gensim.models.word2vec import LineSentence np.savetxt('train_data.txt', arr, delimiter=' ', fmt='%s') sentences = LineSentence('train_data.txt') model = Word2Vec(sentences)
Gensim word2vec on predefined dictionary and word-indices data
35721503_40512757_14
42,712,340
42,718,405
0.000437
7.5
Interpretation regarding session in tensorflow
42712340_42718405_11
10,390,927
10,391,047
0.000436
import web from web.wsgiserver import CherryPyWSGIServer from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter ssl_cert = 'path/to/ssl_certificate' ssl_key = 'path/to/ssl_private_key'
bottle on cherrypy server + ssl
10390927_10391047_15
38,779,705
38,779,764
0.000435
nan = float('NaN') nan is nan nan == nan
Comparison of collections containing non-reflexive elements
38779705_38779764_8
3,285,443
5,647,140
0.000435
root <<= 1 rem = (rem << 2) + (a >> 30) a <<= 2
Improving pure Python prime sieve by recurrence formula
3285443_5647140_15
10,121,861
10,121,989
0.000435
fmin N - fmin * f2
Dividing large numbers in Python
10121861_10121989_10
10,767,736
10,771,055
0.000434
import Data.Array.ST import Control.Monad
How to make ST computation produce lazy result stream (or operate like a co-routine)?
10767736_10771055_6
11,021,130
29,618,322
0.000434
requests
Parallel Pip install
11021130_29618322_12
27,878,157
27,878,536
0.000434
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)
how to adjust # of ticks on Bokeh axis (labels are overlapping on small figures)
27878157_27878536_13
12,556,163
18,394,030
0.000434
import org.openqa.selenium.Capabilities import org.openqa.selenium.HasCapabilities import org.openqa.selenium.remote.RemoteWebDriver
Get browser version using selenium webdriver
12556163_18394030_13
358,225
358,641
0.000433
log4j.rootLogger = INFO, stdout, logfile
log4j with timestamp per log entry
358225_358641_7
10,857,924
10,859,883
0.000433
Parameters
Remove NULL columns in a dataframe Pandas?
10857924_10859883_2
2,764,055
2,765,556
0.000433
three four
How to pdb Python code with input?
2764055_2765556_14
42,683,518
42,712,569
0.000432
from pprint import pprint as p remove = ['/usr/lib/python2.7'] sys.path = [path for path in sys.path if path not in remove]
pip in virtualenv cannot find ctypes
42683518_42712569_14
18,173,983
18,174,097
0.000432
from lxml import etree tree = etree.fromstring(templateXml).getroottree() xmlFileOut = '/Users/User1/Desktop/Python/Done.xml'
XML Declaration standalone="yes" lxml
18173983_18174097_12
6,348,011
6,350,538
0.000432
Loop
Scripting changes to multiple excel workbooks
6348011_6350538_2
10,900,852
38,482,056
0.00043
import random myrandom = random.SystemRandom x = myrandom.random
Near seeds in random number generation may give similar random numbers?
10900852_38482056_11
42,528,763
42,529,196
0.000429
from collections import OrderedDict newdict = OrderedDict() for idx, el in enumerate(y): newdict[str(var[idx])] = el
call lambdify in a loop, avoid explicitly call
42528763_42529196_15
31,967,170
33,519,170
0.000428
12 131 21
How to structure a program to work with minesweeper configurations
31967170_33519170_17
9,232,568
10,319,754
0.000428
nose figleaf
Identifying the dependency relationship for python packages installed with pip
9232568_10319754_5
14,646,336
14,648,211
0.000428
from io import BytesIO from pandas import * text = """1999-08-09 12:30:00-04:00 -0.000486 1999-08-09 12:31:00-04:00 -0.000606 1999-08-09 12:32:00-04:00 -0.000120 1999-08-09 12:33:00-04:00 -0.000037 1999-08-09 12:34:00-04:00 -0.000337 1999-08-09 12:35:00-04:00 0.000100 1999-08-09 12:36:00-04:00 0.000219 1999-08-09 12:37:00-04:00 0.000285 1999-08-09 12:38:00-04:00 -0.000981 1999-08-09 12:39:00-04:00 -0.000487 1999-08-09 12:40:00-04:00 0.000476 1999-08-09 12:41:00-04:00 0.000362 1999-08-09 12:42:00-04:00 -0.000038 1999-08-09 12:43:00-04:00 -0.000310 1999-08-09 12:44:00-04:00 -0.000337"""
Pandas - grouping intra day timeseries by date
14646336_14648211_13