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
5,285,181
27,211,338
0.000766
import sys, os def getScriptPath(): pass
IO Error while storing data in pickle
5285181_27211338_17
18,093,183
18,093,217
0.000765
target = """ LINCOLN STREET CHESTNUT ST CHISHOLM TR LAKE TRAIL CHISHOLM TRAIL COVERED WAGON TRL """ import re
regex match and replace multiple patterns
18093183_18093217_5
21,148,655
25,011,466
0.000765
107
Python PySerial with Auto RTS through Half-Duplex RS-485 breakout board using Beaglebone Black Angstrom
21148655_25011466_2
13,773,862
13,774,565
0.000765
import traceback @app.route('/route1') def api_route1(): pass
API in Flask--returns JSON but HTML exceptions break my JSON client
13773862_13774565_9
6,378,673
8,085,647
0.000764
data_files = [('VC90', glob( 'C:\\Windows\\winsxs\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\\*.*' )), ('VC90', glob( 'C:\\Windows\\winsxs\\Manifests\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest' ))]
executable made with py2exe doesn't run on windows xp 32bit
6378673_8085647_4
17,791,481
41,110,107
0.000764
from setuptools import setup import re def get_property(prop, project): result = re.search('{}\\s*=\\s*[\\\'"]([^\\\'"]*)[\\\'"]'.format(prop), open(project + '/__init__.py').read()) return result.group(1) project_name = 'YOUR PROJECT'
Creating a __version__ attribute for python packages without getting into trouble
17791481_41110107_15
4,996,589
38,400,558
0.000764
def run(self): __builtins__.__NUMPY_SETUP__ = False import numpy
In setup.py or pip requirements file, how to control order of installing package dependencies?
4996589_38400558_8
6,627,635
6,628,265
0.000764
true = True false = False
Is JSON syntax a strict subset of Python syntax?
6627635_6628265_5
30,757,439
31,182,969
0.000764
from pyspark.sql import SQLContext sqlContext = SQLContext(sc) df = sqlContext.read.format('com.databricks.spark.csv').options(header='true' ).load('file.csv')
How to add any new library like spark-csv in Apache Spark prebuilt version
30757439_31182969_9
879,173
1,640,777
0.000763
import md5, sha
How to ignore deprecation warnings in Python
879173_1640777_12
16,244,200
16,244,324
0.000763
def MyIter(): yield 1 yield 2 yield 3
Preventing exceptions from terminating Python iterator
16244200_16244324_18
31,967,170
33,519,170
0.000763
12 131
How to structure a program to work with minesweeper configurations
31967170_33519170_15
16,994,174
31,764,294
0.000763
from werkzeug.local import LocalProxy from flask import current_app logger = LocalProxy(lambda : current_app.logger) from core import logger @mod.route('/') def index(): logger.info('serving index')
In Flask: How to access app Logger within Blueprint
16994174_31764294_15
2,738,473
3,931,799
0.000763
tmp = str(os.path.expandvars('$TMP')) import ctypes GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW buffer = ctypes.create_unicode_buffer(GetLongPathName(tmp, 0, 0))
compare two windows paths, one containing tilde, in python
2738473_3931799_19
7,346,434
10,603,830
0.000763
md5Hash = md5.new
python subprocess read stdout as it executes
7346434_10603830_7
31,096,151
31,102,374
0.000762
self.packet_regex = re.compile( '(\xaa)([\x04-\xff]{1})([\x00-\xff]{1})([\x10-\xff]{1})([\x00-\xff]*)([\x00-\xff]{1})(D)' ) match = self.packet_regex.search(self.buffer)
python regex use capture group to define another groups length { }
31096151_31102374_18
2,957,013
41,140,750
0.000762
Red
BeautifulSoup: just get inside of a tag, no matter how many enclosing tags there are
2957013_41140750_2
24,152,420
24,153,431
0.000762
pieFact *= 0.9 updatePieFact()
Pass Dynamic Javascript Variable to Django/Python
24152420_24153431_18
904,928
904,954
0.000761
y
Python strftime - date without leading 0?
904928_904954_5
5,793,149
5,793,240
0.000761
import myprog myprog.x from myprog import x
How to reload my Python source file, when interactively interpreting it with "python -i"
5793149_5793240_16
31,288,085
31,299,219
0.000761
SET
How to append a value to list attribute on AWS DynamoDB?
31288085_31299219_0
39,367,246
39,386,341
0.000761
monitor_n_geo = screen.get_monitor_geometry(n) x = monitor_n_geo.x
select certain monitor for going fullscreen with gtk
39367246_39386341_19
1,556,554
10,063,883
0.000761
a
jinja2: html escape variables
1556554_10063883_12
32,606,369
33,159,982
0.000761
from functools import reduce def cheaper_set_union(s): pass
pandas concat arrays on groupby
32606369_33159982_8
7,114,849
7,155,061
0.000761
from redis import Redis r0 = Redis(db=0)
General techniques to work with huge amounts of data on a non-super computer
7114849_7155061_13
28,397,473
28,397,561
0.00076
import time max_execution_time = 10000000 start_time = time.clock() elapsed_time = 0 while elapsed_time < max_execution_time: pass
Stop Sublime Text from executing infinite loop
28397473_28397561_17
9,979,358
9,982,832
0.00076
from Crypto import Random random_generator = Random.new().read
PyCrypto: Generate RSA key protected with DES3 password
9979358_9982832_12
21,483,959
42,764,917
0.00076
start, end quote_currency = quote_currency, base_currency = base_currency
How can get ' USDJPY'(currency rates) with pandas and yahoo finance?
21483959_42764917_5
7,825,263
7,832,437
0.00076
from sphinx.ext import autodoc class SimpleDocumenter(autodoc.MethodDocumenter): objtype = 'simple' content_indent = ''
Including docstring in Sphinx Documentation
7825263_7832437_16
6,296,055
6,296,774
0.00076
import ctypes
Serializing Sqlite3 in Python
6296055_6296774_13
8,645,956
9,511,949
0.000758
from calendar2 import * old_hindu_solar_from_absolute(absolute_from_gregorian(3, 1, 2012))
Converting to and from Hindu calendar
8645956_9511949_5
14,925,905
14,930,238
0.000758
interactive end - of - line
Emacs set spacing for inline (end of line) comments
14925905_14930238_2
11,021,130
29,618,322
0.000758
wheel twine
Parallel Pip install
11021130_29618322_7
6,024,116
6,024,155
0.000758
world
How to print file contents with filename before each line?
6024116_6024155_10
21,483,959
42,764,917
0.000758
start, end quote_currency = quote_currency,
How can get ' USDJPY'(currency rates) with pandas and yahoo finance?
21483959_42764917_4
35,721,503
40,512,757
0.000758
import numpy as np from gensim.models import Word2Vec
Gensim word2vec on predefined dictionary and word-indices data
35721503_40512757_13
26,839,925
26,841,129
0.000758
from django import template register = template.Library() @register.filter(name='abs') def abs_filter(value): pass
Convert negative number to positive number in django template?
26839925_26841129_11
1,258,712
1,378,134
0.000757
today tomorrow yesterday
fuzzy timestamp parsing with Python
1258712_1378134_5
6,209,094
27,737,092
0.000757
from localconfig import config config.read("""[one] key = 42 key2 = None""")
Converting ConfigParser values to python data types
6209094_27737092_12
5,506,651
33,448,999
0.000757
from converter import Converter c = Converter()
How to rip the audio from a video?
5506651_33448999_10
10,394,517
10,395,983
0.000756
return zDir
Setting sqlite temp store directory
10394517_10395983_16
1,446,347
1,446,411
0.000756
Py_UNICODE PyUnicode_GetMax(void)
How to find out if Python is compiled with UCS-2 or UCS-4?
1446347_1446411_4
5,474,514
5,474,796
0.000756
zero = 0 or 1 zero = False or 1
Use of OR as branch control in FP
5474514_5474796_9
11,856,293
11,856,667
0.000755
import inspect import numpy as np
Numpy dot product very slow using ints
11856293_11856667_5
2,622,994
2,623,098
0.000755
bar
Python: finding lowest integer
2622994_2623098_11
35,746,074
35,748,727
0.000754
import cufflinks as cf import plotly
Cufflinks for plotly: setting cufflinks config options launches
35746074_35748727_9
1,259,219
1,259,378
0.000754
from django import template register = template.Library() @register.filter def epoch(value): pass
django Datefield to Unix timestamp
1259219_1259378_14
4,449,110
5,129,085
0.000754
from sympy import Eq, Symbol, solve y = Symbol('y') eqn = Eq(y * (8.0 - y ** 3), 8.0)
Python solve equation for one variable
4449110_5129085_9
320,929
8,851,191
0.000754
import babel.numbers import decimal
Currency formatting in Python
320929_8851191_5
20,617,600
20,621,143
0.000754
-3.2 -3.3
Travis special requirements for each python version
20617600_20621143_9
27,759,407
27,759,940
0.000751
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter class SocialAccountAdapter(DefaultSocialAccountAdapter): def get_login_redirect_url(self, request): pass
Django allauth Redirect after social signup
27759407_27759940_10
5,524,027
5,524,103
0.000751
import yaml data = {'field1': 'value1', 'field2': 'value2'} serializedData = yaml.dump(data, default_flow_style=False)
Store a file metadata in an extra file
5524027_5524103_9
14,588,098
14,590,233
0.00075
"""Command. Usage: command start ID command finish ID FILE command (-h | --help) command (-v | --version) Arguments: ID FILE input file Options: -h --help Show this screen. -v --version Show version. """ from docopt import docopt
docopt + schema validation
14588098_14590233_18
14,588,098
14,590,233
0.000749
from schema import Schema, Use, Or, SchemaError if __name__ == '__main__': args = docopt(__doc__, version='command alpha')
docopt + schema validation
14588098_14590233_17
29,997,274
32,294,172
0.000749
44
Python is very slow to start on Windows 7
29997274_32294172_16
36,262,748
36,376,371
0.000748
from plotly.offline.offline import _plot_html data_or_figure = [{'x': [1, 2, 3], 'y': [3, 1, 6]}] plot_html, plotdivid, width, height = _plot_html(data_or_figure, False, '', True, '100%', 525)
python save plotly plot to local file and insert into html
36262748_36376371_9
20,753,782
20,768,282
0.000747
import matplotlib as mpl font_paths = mpl.font_manager.findSystemFonts() font_objects = mpl.font_manager.createFontList(font_paths)
Default fonts in Seaborn statistical data visualization in iPython
20753782_20768282_14
7,701,855
28,090,741
0.000747
import py2exe wd_base = ( 'C:\\Python27\\Lib\\site-packages\\selenium-2.44.0-py2.7.egg \\selenium\\webdriver' )
Python - Trouble in building executable
7701855_28090741_15
7,117,143
7,141,077
0.000747
import timeit 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_2
18,747,555
18,747,872
0.000747
MarkupSafe == 0.18
Packaging single Python module with dependencies
18747555_18747872_4
9,324,554
9,324,569
0.000745
import foo def import_foo_when_called(): pass
django models recursive imports - how to resolve
9324554_9324569_4
27,486,589
27,487,021
0.000745
from setuptools import setup imp_spam = 'spam' try: import spam except: imp_spam = 'pyspam'
Python any of many dependencies
27486589_27487021_12
1,007,488
1,007,770
0.000745
parts = mypython [mypython] recipe = zc.recipe.egg
How to tell Buildout to install a egg from a URL (w/o pypi)
1007488_1007770_15
29,349,607
29,350,541
0.000744
import clr clr.AddReference('System.Data') from System.Data.SqlClient import *
pymssql windows authentication
29349607_29350541_8
8,478,137
8,478,633
0.000744
alpha
How redirect a shell command output to a Python script input ?
8478137_8478633_7
40,208,006
40,208,071
0.000743
en = 'MAMA' cy == en cy_converted = translit(cy, 'ru', reversed=True)
Detect same words using different alphabets?
40208006_40208071_19
29,631,504
29,631,641
0.000743
s2 = """ import numpy as np a=np.random.randint(0,200,100) b1=np.random.randint(0,100,50) a[np.in1d(a, b1)] """ print(' first: ', timeit(stmt=s1, number=100000)) print('second : ', timeit(stmt=s2, number=100000))
Return values from array based on indices of common values in two other arrays
29631504_29631641_16
22,386,580
22,708,479
0.000743
from appconf import AppConf class MyAppConf(AppConf): SETTING_1 = 'one' SETTING_2 = 'two',
django settings per application - best practice?
22386580_22708479_18
34,572,177
34,697,479
0.000742
cg.dendrogram_col.linkage cg.dendrogram_row.linkage
Labels for clustermap in seaborn?
34572177_34697479_7
31,164,568
31,165,089
0.000742
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_4
32,593,155
32,593,392
0.000741
python26 - apple python27(active) python27 - apple python33
psycopg2 installed successfully, but cannot be imported into python
32593155_32593392_15
13,628,791
20,623,994
0.000741
3 in r 4 in r 5 in r
How do I check whether an int is between the two numbers?
13628791_20623994_17
21,123,473
21,127,663
0.000741
2 ipdb > n
How do I manipulate a variable whose name conflicts with PDB commands?
21123473_21127663_7
12,556,309
19,903,276
0.000741
@app.task(base=Batches, flush_every=100, flush_interval=10) def count_click(requests): from collections import Counter count = Counter(request.kwargs['url'] for request in requests)
Celery Task Grouping/Aggregation
12556309_19903276_13
4,843,493
5,082,394
0.000741
create_dirs pull_sources gen_vim_config
Any pointers on using Ropevim? Is it a usable library?
4843493_5082394_8
2,511,222
2,511,244
0.000741
import uuid uid = uuid.uuid4()
Efficiently generate a 16-character, alphanumeric string
2511222_2511244_5
40,318,163
40,418,387
0.000741
from django.db.models import Max, Case, When, IntegerField qs = MyObject.objects.all()
Maximum of an annotation after a group by
40318163_40418387_8
9,002,982
40,115,296
0.00074
import elasticsearch as ES import elasticsearch.helpers as ESH
Elasticsearch bulk index in chunks using PyEs
9002982_40115296_13
25,918,514
26,347,358
0.00074
python bin libs
Project directory structure for a multi-language application
25918514_26347358_9
20,696,479
20,697,069
0.00074
import io, pkgutil wells = pkgutil.get_data('pymc.examples', 'data/wells.dat') type(wells)
pandas.read_csv from string or package data
20696479_20697069_19
6,849,357
6,865,060
0.00074
pyramid
Unable to include static package files in egg via setuptools
6849357_6865060_0
18,425,012
38,165,423
0.000738
from pyfirebase import Firebase f = Firebase('https://xxxxx.firebaseio.com/') ref = firebase.ref('syncedValue')
Firebase + Angularjs + Python
18425012_38165423_10
10,390,927
10,391,047
0.000738
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' CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(ssl_cert, ssl_key, None)
bottle on cherrypy server + ssl
10390927_10391047_12
29,233,888
29,590,495
0.000738
def euclidean_distance(a, b): X = (keyboard_cartesian[a]['x'] - keyboard_cartesian[b]['x']) ** 2 Y = (keyboard_cartesian[a]['y'] - keyboard_cartesian[b]['y']) ** 2 return sqrt(X + Y)
Edit distance such as Levenshtein taking into account proximity on keyboard
29233888_29590495_18
25,104,154
40,746,017
0.000738
import requests from pkg_resources import parse_version
pypi see older versions of package
25104154_40746017_9
15,109,548
15,109,660
0.000737
import time while True: pass
set pythonpath before import statements
15109548_15109660_12
41,178,532
41,184,789
0.000737
0.3333333333333333
Percentage match in pandas Dataframe
41178532_41184789_8
29,148,488
37,267,495
0.000737
gimpfu.register('file-svg-save', 'save an SVG (.svg) file', 'save an SVG (.svg) file', 'Dylan Grafmyre', 'Dylan Grafmyre', '2016', 'SVG', '*', [(gimpfu.PF_IMAGE, 'image', 'Input image', None), (gimpfu. PF_DRAWABLE, 'drawable', 'Input drawable', None), (gimpfu.PF_STRING, 'filename', 'The name of the file', None), (gimpfu.PF_STRING, 'raw-filename', 'The name of the file', None)], [], save_svg, on_query= register_save_handlers, menu='<Save>')
Export all SVG paths with Gimp Python plugin
29148488_37267495_17
4,905,368
22,600,827
0.000737
from textblob.classifiers import NaiveBayesClassifier
How to incrementally train an nltk classifier
4905368_22600827_16
26,541,968
41,477,808
0.000737
import string test = ( '\n\n\n\n\n\n\n\n\n\n\n\n\n\nHi <<First Name>>\nthis is filler text \xa325 more filler.\nadditilnal filler.\n\nyet more\xa0still more\xa0filler.\n\n\xa0\n\n\n\n\nmore\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfiller.\x03\n\t\t\t\t\t\t almost there \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nthe end\n\n\n\n\n\n\n\n\n\n\n\n\n' )
Delete every non utf-8 symbols froms string
26541968_41477808_6
10,868,530
10,868,550
0.000737
import mod2 var = mod2.var fun_of_mod2 = mod2.fun_of_mod2
Understanding global variable in Python
10868530_10868550_10
37,206,459
37,379,419
0.000737
from tensorflow.contrib import learn train = pandas.read_csv('dbpedia_csv/train.csv', header=None)
Tensorflow examples all fail due to AttributeError: 'module' object has no attribute 'datasets'
37206459_37379419_13
13,781,519
13,781,665
0.000736
from itertools import count prefixes = {'aa': 4, 'ca': 6, 'ja': 9, 'du': 10, 'zz': 1} bar(*zip(*zip(count(), list(prefixes.values()))))
Histogram of common string prefixes
13781519_13781665_9
34,627,757
34,830,833
0.000736
""" takes a date, and a "coordinates" value (representing a date range), and a date as inputs, returns True if the date is within that date range, else returns False """
Apply function to column before filtering
34627757_34830833_4
16,465,490
16,679,663
0.000735
from sphinx.setup_command import BuildDoc cmdclass = {'build_sphinx': BuildDoc} name = 'My project' version = '1.2' release = '1.2.0'
Python package: how to avoid redefining author version etc?
16465490_16679663_19
6,509,856
6,517,725
0.000734
from paste.deploy.loadwsgi import appconfig config = appconfig('config:development.ini', 'myapp', relative_to='.') if config['env'] == 'production': api_endpoint_uri = 'http://api.external.com/?{0}'
How to get Registry().settings during Pyramid app startup time?
6509856_6517725_13
4,950,637
39,077,524
0.000734
import ipdb
setting breakpoints with nosetests --pdb option
4950637_39077524_2
12,338,544
12,377,741
0.000734
import time from subprocess import check_call, check_output DIR = '/directory/to/watch/'
Track folder changes / Dropbox changes
12338544_12377741_15
11,589,682
11,589,983
0.000733
def vote_up(this_record): if already_voted_for(this_record): return ( """<script type="text/javascript"> alert('You can only vote once'); </script>{0}""" .format(count_votes_for(this_record)))
AJAX for updating Flask template after data goes from link action or form to mongodb collection
11589682_11589983_15
21,476,554
37,647,375
0.000733
from configobj import ConfigObj config = ConfigObj(path_to_ini)
Update INI file without removing comments
21476554_37647375_9