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
20,268,396
20,269,033
0.000344
from selenium.webdriver.common.by import By 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_12
22,213,298
22,213,400
0.000344
import rpy2.robjects as robjects data = robjects.r(""" set.seed(1) x <- runif(5) """)
Creating same random number sequence in Python, NumPy and R
22213298_22213400_14
18,173,983
18,174,097
0.000343
from lxml import etree tree = etree.fromstring(templateXml).getroottree() xmlFileOut = '/Users/User1/Desktop/Python/Done.xml' with open(xmlFileOut, 'w') as f: pass
XML Declaration standalone="yes" lxml
18173983_18174097_13
4,988,297
5,019,817
0.000342
ls scrapy
Trying to get Scrapy into a project to run Crawl command
4988297_5019817_3
3,797,746
3,798,790
0.00034
from re import compile as _Re _unicode_chr_splitter = _Re('(?s)((?:[\\ud800-\\udbff][\\udc00-\\udfff])|.)' ).split
How to do a Python split() on languages (like Chinese) that don't use whitespace as word separator?
3797746_3798790_9
21,366,290
21,366,908
0.000338
import re, sre_parse pattern = ( '(?P<DEF_FUNC>def (?P<NAME_FUNC>\\w+)\\s*\\((.*?)\\):)|(?P<OTHERS>\\w+)') v = sre_parse.parse(pattern)
Pattern associated to a named group
21366290_21366908_14
20,639,363
20,640,550
0.000337
from werkzeug.routing import FloatConverter as BaseFloatConverter class FloatConverter(BaseFloatConverter): regex = '-?\\d+(\\.\\d+)?'
Flask route giving 404 with floating point numbers in the URL
20639363_20640550_7
42,038,788
42,038,879
0.000337
Name
Merge multiple rows into 1 row
42038788_42038879_15
31,164,568
31,165,089
0.000335
print(timeit(setup='import re', stmt= "r = re.search(r'(\\d{1,3}\\.\\d{1,3}.\\d{1,3}.\\d{1,3})', '192.168.1.1 999.999.999.999')" , number=1000000)) 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_10
39,840,323
41,769,005
0.000334
enqueue_many_size = SOME_ENQUEUE_MANY_SIZE reader = tf.TFRecordReader(options=tf.python_io.TFRecordOptions(tf. python_io.TFRecordCompressionType.ZLIB)) _, queue_batch = reader.read_up_to(filename_queue, enqueue_many_size)
Benchmark of HowTo: Reading Data
39840323_41769005_9
24,187,248
24,187,326
0.000332
420 python3 420 420
Python 2to3 tool adds a vowel to my integer
24187248_24187326_10
14,682,466
14,682,555
0.000331
myapp
Relative importing python module from a subfolder from a different subfolder
14682466_14682555_2
3,058,374
16,182,764
0.000331
python import tarfile
is_tarfile() returns True for a blank file
3058374_16182764_8
4,636,976
4,637,082
0.000331
from . import echo from .. import formats
Python: Importing a file from a parent folder
4636976_4637082_5
7,117,143
7,141,077
0.000331
""" pygame.surfarray.blit_array(screen, pixels) pygame.display.flip() """
Setting Pixels Quickly
7117143_7141077_6
4,573,995
5,643,540
0.000331
from os.path import join _PYSIDEDIR = 'C:\\Python27\\Lib\\site-packages\\PySide' data_files = [('imageformats', [join(_PYSIDEDIR, 'plugins\\imageformats\\qico4.dll')]), ('.', [join(_PYSIDEDIR, 'shiboken-python2.7.dll'), join(_PYSIDEDIR, 'QtCore4.dll'), join( _PYSIDEDIR, 'QtGui4.dll')])]
PyQt/PySide - icon display
4573995_5643540_8
2,612,257
2,613,168
0.00033
import cmath dir(cmath)
Python: Is there a way to reflectivly list all attributes of a class
2612257_2613168_6
15,570,099
15,570,546
0.000329
import io incsv = io.StringIO( """Date,State,City,SalesToday,SalesMTD,SalesYTD 20130320,stA,ctA,20,400,1000 20130320,stA,ctB,30,500,1100 20130320,stB,ctC,10,500,900 20130320,stB,ctD,40,200,1300 20130320,stC,ctF,30,300,800""" )
Pandas Pivot tables row subtotals
15570099_15570546_18
8,356,501
24,301,608
0.000329
from tabulate import tabulate
Python format tabular output
8356501_24301608_5
7,249,488
7,254,337
0.000328
import foo as module module_name = module.__name__ import_line = 'from %s import (%%s)' % module_name
Tool to help eliminate wildcard imports
7249488_7254337_15
2,409,472
2,409,523
0.000328
return import dis
Python: How expensive is to create a small list many times?
2409472_2409523_16
18,167,669
18,180,954
0.000328
from networkx.utils import powerlaw_sequence pl_sequence = powerlaw_sequence(1000, exponent=2.5) fitted_pl = powerlaw.Fit(pl_sequence) fitted_pl.alpha
Fit a power law to empirical data in Python
18167669_18180954_9
7,249,488
7,254,337
0.000328
import_line = 'from %s import (%%s)' % module_name length = len(import_line) - 3
Tool to help eliminate wildcard imports
7249488_7254337_16
39,970,703
39,970,921
0.000326
category
Identifying closest value in a column for each filter using Pandas
39970703_39970921_7
2,764,055
2,765,556
0.000326
two three four
How to pdb Python code with input?
2764055_2765556_15
12,166,819
12,166,860
0.000325
app book.py ccg chat chunk
Use NLTK without installing
12166819_12166860_16
39,840,323
41,769,005
0.000325
enqueue_many_size = SOME_ENQUEUE_MANY_SIZE reader = tf.TFRecordReader(options=tf.python_io.TFRecordOptions(tf. python_io.TFRecordCompressionType.ZLIB))
Benchmark of HowTo: Reading Data
39840323_41769005_8
40,666,466
40,666,520
0.000325
import random
multiple row selection in multi indexed dataframe
40666466_40666520_9
10,767,736
10,768,103
0.000325
import Data.STRef.Lazy
How to make ST computation produce lazy result stream (or operate like a co-routine)?
10767736_10768103_4
37,893,755
37,901,914
0.000324
import notebook_util notebook_util.pick_gpu_lowest_memory()
Tensorflow set CUDA_VISIBLE_DEVICES within jupyter
37893755_37901914_14
10,949,388
10,979,509
0.000324
from coffin import template from ThrdPartyDjangoLib import djangoTagIWantToUse
Django : How to use 3rd party app templatetags with Jinja 2?
10949388_10979509_7
17,127,922
17,225,665
0.000324
6.0
Can't delete row from SQLAlchemy due to wrong session
17127922_17225665_7
25,918,514
26,347,358
0.000324
bin libs
Project directory structure for a multi-language application
25918514_26347358_10
13,893,227
13,893,632
0.000323
prices orders
Vectorized look-up of values in Pandas dataframe
13893227_13893632_5
29,631,504
29,631,641
0.000322
s1 = """ import numpy as np a=np.random.randint(0,200,100) b1=np.random.randint(0,100,50) np.intersect1d(b1,a) """
Return values from array based on indices of common values in two other arrays
29631504_29631641_18
6,837,514
27,949,639
0.000322
fi
Displaying virtualenv
6837514_27949639_5
40,753,863
40,754,041
0.00032
OrderNum
Pandas cumulative sum of partial elements with groupby
40753863_40754041_8
22,400,801
22,401,623
0.000319
import sys sys.maxsize type(2 ** 63) type(2 ** 62)
Getting OverflowError: math range error(trying to calculate power of a number)
22400801_22401623_14
4,994,638
7,303,734
0.000319
from pyftpdlib import servers from pyftpdlib.handlers import FTPHandler address = '0.0.0.0', 21 server = servers.FTPServer(address, FTPHandler)
One line ftp server in python
4994638_7303734_14
13,308,498
13,320,020
0.000317
lxml
How to add a bootstrap script to tox's virtualenv?
13308498_13320020_18
30,726,956
31,022,959
0.000317
import yagmail yag = yagmail.SMTP(from_add, password) contents = ['See my attachment below', '/home/bsingh/python_files/file_dict.txt']
Attachments getting attached twice using smptplib in python
30726956_31022959_9
10,949,388
10,979,509
0.000316
from coffin import template from ThrdPartyDjangoLib import djangoTagIWantToUse register = template.Library()
Django : How to use 3rd party app templatetags with Jinja 2?
10949388_10979509_8
2,308,247
2,308,327
0.000315
pyximport.install() import limits
Find maximum signed short integer in python
2308247_2308327_11
42,683,518
42,712,569
0.000315
from pprint import pprint as p remove = ['/usr/lib/python2.7']
pip in virtualenv cannot find ctypes
42683518_42712569_16
15,454,174
15,454,475
0.000312
fi fi fi
How can a shell function know if it is running within a virtualenv?
15454174_15454475_5
10,767,736
10,771,055
0.000311
import Data.Array.ST import Control.Monad import Data.List
How to make ST computation produce lazy result stream (or operate like a co-routine)?
10767736_10771055_7
47,701
550,795
0.00031
gdb > bt gdb > pystack
Is there a way to attach a debugger to a multi-threaded Python process?
47701_550795_4
34,294,742
40,599,486
0.00031
movies
NumPy: mismatch in size of old and new data-descriptor
34294742_40599486_2
11,021,130
29,618,322
0.00031
python - bcrypt arrow redis
Parallel Pip install
11021130_29618322_15
6,610,606
6,610,973
0.000308
import dis dis.dis(literal) dis.dis(constructor)
Is there a difference between using a dict literal and a dict constructor?
6610606_6610973_18
20,268,396
20,269,033
0.000307
from selenium.webdriver.common.by import By import selenic.util util = selenic.util.Util(driver) foo = util.find_element((By.CSS_SELECTOR, '...'))
Mixing implicit and explicit waits
20268396_20269033_13
9,153,473
42,738,894
0.000306
from sphinx.ext.autodoc import ClassLevelDocumenter, InstanceAttributeDocumenter def iad_add_directive_header(self, sig): pass
Sphinx values for attributes reported as None
9153473_42738894_7
14,652,826
14,653,833
0.000305
import java.io.IOException import java.util.ArrayList import org.apache.commons.io.FileUtils
Comparing two documents using regex
14652826_14653833_19
654,499
656,289
0.000305
flags |= O_CREAT append = 1 break
Python file modes detail
654499_656289_12
17,926,746
26,980,850
0.000305
Parameters
How do I inner join two array in numpy?
17926746_26980850_1
1,258,712
1,378,134
0.000304
midnight
fuzzy timestamp parsing with Python
1258712_1378134_9
20,250,130
20,251,772
0.000303
from IPython.core.magic import register_line_magic @register_line_magic def p(line): print(eval(line))
from past import print_statement
20250130_20251772_12
4,869,121
4,869,496
0.000301
mk
How to make python autocompletion display matches?
4869121_4869496_9
31,164,568
31,165,089
0.000301
print(timeit(setup='import re', stmt= "r = re.search(r'(\\d{1,3}\\.\\d{1,3}.\\d{1,3}.\\d{1,3})', '192.168.1.1 999.999.999.999')" , number=1000000)) 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))
Python Regex slower than expected
31164568_31165089_11
11,021,130
29,618,322
0.0003
python - slugify python - bcrypt arrow redis
Parallel Pip install
11021130_29618322_16
19,627,445
19,636,739
0.0003
import spyne.const spyne.const.REQUEST_SUFFIX = 'RQ'
Changing Spyne constants
19627445_19636739_5
24,011,399
39,538,451
0.000297
python import django django.VERSION
Activating a virtual env not working
24011399_39538451_6
15,071,786
23,681,828
0.000297
Node * next Node * pre
vector assign in Cython
15071786_23681828_14
39,970,703
39,970,921
0.000295
print(idx) category
Identifying closest value in a column for each filter using Pandas
39970703_39970921_8
27,710,350
27,945,932
0.000295
uniq
how to control the import paths in Python?
27710350_27945932_5
6,209,094
27,737,092
0.000294
from localconfig import config config.read("""[one] key = 42 key2 = None""") config.one.key, type(config.one.key) config.one.key2, type(config.one.key2)
Converting ConfigParser values to python data types
6209094_27737092_14
11,021,130
29,618,322
0.000293
python - slugify python - bcrypt arrow redis psutil
Parallel Pip install
11021130_29618322_17
2,860,563
20,708,090
0.000292
from Chessnut import Game chessgame = Game(fen= 'rnbq1rk1/ppppp1bp/5np1/5p2/2PP4/2NBPN2/PP3PPP/R1BQK2R b KQ - 4 6')
python: Chess moves validation
2860563_20708090_19
12,166,819
12,166,860
0.000292
ccg chat chunk
Use NLTK without installing
12166819_12166860_17
1,884,327
1,884,369
0.000292
void
Named parameters with Python C API?
1884327_1884369_17
10,767,736
10,771,055
0.000291
import Control.Monad.ST.Lazy import Data.Array.ST import Control.Monad
How to make ST computation produce lazy result stream (or operate like a co-routine)?
10767736_10771055_8
47,701
550,795
0.000288
gdb > bt gdb > pystack gdb > detach
Is there a way to attach a debugger to a multi-threaded Python process?
47701_550795_5
20,268,396
20,269,033
0.000288
from selenium.webdriver.common.by import By import selenic.util util = selenic.util.Util(driver)
Mixing implicit and explicit waits
20268396_20269033_14
42,683,518
42,712,569
0.000285
from pprint import pprint as p 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_17
23,703,870
23,704,655
0.000285
from Selenium2Library import Selenium2Library class CustomSeleniumLibrary(Selenium2Library): pass
Pass existing Webdriver object to custom Python library for Robot Framework
23703870_23704655_18
5,474,514
5,474,796
0.000285
zero = 1 == 0 and 0 or 1 zero = False and 0 or 1 zero = 0 or 1
Use of OR as branch control in FP
5474514_5474796_13
38,779,705
38,779,764
0.000283
nan is nan nan == nan
Comparison of collections containing non-reflexive elements
38779705_38779764_9
20,639,363
20,640,550
0.000283
from werkzeug.routing import FloatConverter as BaseFloatConverter class FloatConverter(BaseFloatConverter): pass
Flask route giving 404 with floating point numbers in the URL
20639363_20640550_8
14,542,145
14,543,051
0.000281
Parameters
Reductions down a column in Pandas
14542145_14543051_4
42,690,970
42,691,232
0.000281
INITIALIZATION = ( """import numpy;numpy.random.seed(0);a=numpy.random.randn(1000,200);b=numpy.random.rand(200,1000)""" )
Row Sum of a dot product for huge matrix in python
42690970_42691232_5
18,327,790
24,312,648
0.00028
derp_r1_sum_select = """ select sum(`derp_related_1`.`amount`) from `derp_related_1` where `derp_related_1`.`fk` = `derp`.`pk` """ 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_17
654,499
656,289
0.000279
flags |= O_CREAT append = 1
Python file modes detail
654499_656289_13
358,225
358,641
0.000279
log4j.rootLogger = INFO, stdout, logfile log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j with timestamp per log entry
358225_358641_9
40,318,163
40,418,387
0.000278
from django.db.models import Max, Case, When, IntegerField qs = MyObject.objects.all() a_priority = Case(When(a='A', then=1), When(a='S', then=2), When(a='Q', then=3), output_field=IntegerField())
Maximum of an annotation after a group by
40318163_40418387_9
9,153,473
42,738,894
0.000278
from sphinx.ext.autodoc import ClassLevelDocumenter, InstanceAttributeDocumenter def iad_add_directive_header(self, sig): ClassLevelDocumenter.add_directive_header(self, sig)
Sphinx values for attributes reported as None
9153473_42738894_8
9,762,193
9,762,583
0.000277
idf
Pandas rolling median for duplicate time series data
9762193_9762583_5
31,164,568
31,165,089
0.000276
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))
Python Regex slower than expected
31164568_31165089_12
1,369,089
1,369,357
0.000275
++p continue
Default encoding of exception messages
1369089_1369357_8
35,491,426
35,491,719
0.000273
import matplotlib.mlab as mlab regions = mlab.contiguous_regions(ser_orig == manual_mode) for i, (start, end) in enumerate(regions): pass
Finding contiguous, non-unique slices in Pandas series without iterating
35491426_35491719_10
4,843,493
5,082,394
0.000273
check_vim create_dirs pull_sources
Any pointers on using Ropevim? Is it a usable library?
4843493_5082394_11
10,949,388
10,979,509
0.000272
from ThrdPartyDjangoLib import djangoTagIWantToUse register = template.Library()
Django : How to use 3rd party app templatetags with Jinja 2?
10949388_10979509_9
17,424,516
17,424,702
0.00027
from types import NoneType class InvalidKeyNone(NoneType): pass foo = InvalidKeyNone()
How to inherit from Python None
17424516_17424702_10
27,901,211
27,901,437
0.000269
python << _EOF_ import vim print('arg is ' + vim.eval('a:arg')) _EOF_
How to pass arguments from vimscript functions to python interface?
27901211_27901437_13
1,884,327
1,884,369
0.000268
void initthemodule(void)
Named parameters with Python C API?
1884327_1884369_18
8,953,844
41,893,589
0.000267
Parent
Import module from subfolder
8953844_41893589_0
7,249,488
7,254,337
0.000266
module_name = module.__name__ import_line = 'from %s import (%%s)' % module_name length = len(import_line) - 3
Tool to help eliminate wildcard imports
7249488_7254337_17
6,290,222
6,293,302
0.000265
import cmath, math z = -1 + 0j cmath.phase(z)
Numpy - square root of -1 leaves a small real part
6290222_6293302_9
22,011,481
26,852,052
0.000264
lngDiv.innerHtml = lng
Get the parameters of a JavaScript function with Scrapy
22011481_26852052_12
6,610,606
6,610,973
0.000262
import dis dis.dis(literal)
Is there a difference between using a dict literal and a dict constructor?
6610606_6610973_19
35,491,426
35,491,719
0.000262
import matplotlib.mlab as mlab regions = mlab.contiguous_regions(ser_orig == manual_mode) for i, (start, end) in enumerate(regions): ser_orig[start:end] = new_manual_mode_text.format(i)
Finding contiguous, non-unique slices in Pandas series without iterating
35491426_35491719_11