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
14,840,243
14,841,631
0.000798
sp_mat zero_mat
Bulk zeroing of elements in a scipy.sparse_matrix
14840243_14841631_6
9,112,071
11,835,763
0.000798
import bpython bpython.embed(locals_=locals())
bpython configuration - importing numpy and matplotlib by default
9112071_11835763_9
19,824,639
19,824,843
0.000798
from kombu import BrokerConnection conn = BrokerConnection(hostname='producerbroker')
Celery configure separate connection for producer and consumer
19824639_19824843_5
3,747,679
8,805,645
0.000798
oldmods = set(sys.modules.keys()) import script
reload (update) a module file in the interpreter
3747679_8805645_12
14,080,041
14,091,739
0.000797
import sublime, sublime_plugin class PydevCommand(sublime_plugin.WindowCommand): pass
Running Python interactively from within Sublime Text 2
14080041_14091739_14
35,353,639
42,161,453
0.000797
from eve import Eve app = Eve(__name__, settings=os.path.abspath('settings.py')) if __name__ == '__main__': pass
gunicorn fails to launch python-eve
35353639_42161453_14
7,514,093
7,514,513
0.000797
from pprint import pprint li = [] for i in range(5): pass
lambda function don't closure the parameter in Python?
7514093_7514513_15
2,894,946
2,894,979
0.000796
import PyV8 class Global(PyV8.JSClass): pass with PyV8.JSContext(Global()) as ctxt: pass
Passing JavaScript variable to Python
2894946_2894979_10
15,382,807
30,091,395
0.000796
bars bars[2].date
How to make ordered dictionary from list of lists?
15382807_30091395_9
1,452,489
1,452,492
0.000796
None == False 1 == True 0 == False 2 == False
Evaluation of boolean expressions in Python
1452489_1452492_14
13,998,492
25,082,467
0.000795
import six d = dict(foo=1, bar=2)
iteritems in Python
13998492_25082467_13
32,606,294
32,607,349
0.000794
from pyspark.ml.feature import VectorAssembler ignore = ['id', 'label', 'binomial_label'] assembler = VectorAssembler(inputCols=[x for x in df.columns if x not in ignore], outputCol='features')
Create feature vector programmatically in Spark ML / pyspark
32606294_32607349_15
35,792,422
35,793,409
0.000794
import numpy.random numpy
Further confusion with imports in Python
35792422_35793409_1
18,102,392
18,102,579
0.000794
import contextlib
Of scraping data, headless browsers, and Python
18102392_18102579_17
42,517,545
42,517,642
0.000794
import io txt = io.String( """location date temp NY 2014-02-01 60 NY 2014-02-02 40 LA 2014-01-28 70 LA 2014-02-02 80""" )
Python dataframe add a column that selects prev date's data
42517545_42517642_15
4,679,323
4,679,363
0.000793
c = 1.2 d = 1.2 c is d
Python strings references
4679323_4679363_13
21,414,639
37,592,789
0.000793
from datetime import timedelta, datetime time_d = datetime_1 - datetime_2
Convert timedelta to floating-point
21414639_37592789_5
28,288,871
28,289,253
0.000793
def error(): return next(i for i in range(3) if i == 10)
next() doesn't play nice with any/all in python
28288871_28289253_8
741,950
741,961
0.000792
import inspect def add(a, b=0): return a + b inspect.getargspec(add)
Programatically determining amount of parameters a function requires - Python
741950_741961_19
14,332,141
14,546,930
0.000792
b c d e
Dumping subprcess output in a file in append mode
14332141_14546930_18
18,942,096
18,945,825
0.000791
from pattern.en import conjugate as conjugate_en verb = 'go' conjugate_en(verb, tense='future')
How to conjugate a verb in NLTK given POS tag?
18942096_18945825_16
1,452,489
1,452,492
0.000791
None == False 1 == True 0 == False
Evaluation of boolean expressions in Python
1452489_1452492_13
1,609,460
14,227,168
0.000791
import os os.chdir([p for p in os.environ['PYTHONPATH'].split(os.pathsep) if p. startswith('D')][0]) pwd()
How import Pydev project into interactive console?
1609460_14227168_13
9,369,899
9,369,936
0.000791
import sys sys.getwindowsversion() sys.version_info
Does Dividing by Zero in Python Crash Windows 98, et al?
9369899_9369936_9
9,360,103
9,360,450
0.00079
from numpy import arange, reshape, array_str M = arange(10).reshape(2, 5) M array_str(M)
How to print a numpy array without brackets
9360103_9360450_14
10,944,047
10,944,136
0.00079
insertIntoMysqlDatabase(arrowDt) dbDatetimeNoTz = getFromMysqlDatabase() dbDatetimeNoTz == arrowDt dbDatetimeNoTz == arrowDt.replace(tzinfo=None)
remove pytz timezone
10944047_10944136_19
16,055,403
16,055,603
0.00079
import platform setup_requires = ['foo', 'bar']
Setuptools platform specific dependencies
16055403_16055603_11
2,612,257
2,613,168
0.000789
import cmath dir(cmath) cmath.atan
Python: Is there a way to reflectivly list all attributes of a class
2612257_2613168_5
358,225
358,641
0.000789
log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j with timestamp per log entry
358225_358641_5
8,793,877
30,530,535
0.000789
return end
how to copy modules from one virtualenv to another
8793877_30530535_5
7,701,855
28,090,741
0.000789
from distutils.core import setup import py2exe wd_base = ( 'C:\\Python27\\Lib\\site-packages\\selenium-2.44.0-py2.7.egg \\selenium\\webdriver' ) RequiredDataFailes = [('selenium/webdriver/firefox', [ '%s\\firefox\\webdriver.xpi' % wd_base, '%s\\firefox\\webdriver_prefs.json' % wd_base])]
Python - Trouble in building executable
7701855_28090741_14
19,566,555
19,577,968
0.000788
blogService.js blogView.html
Folder Structure for Python Django-REST-framework and Angularjs
19566555_19577968_17
2,494,468
2,540,589
0.000788
sizeof(pycmd), "import sys; sys.path = ['%s/pylib-2.6.4.zip','%s']", applicationDirectory,
How to create an application which embeds and runs Python code without local Python installation?
2494468_2540589_18
14,297,741
35,914,923
0.000788
[Install] WantedBy = multi - user.target
How to start ipython notebook server at boot as daemon
14297741_35914923_10
14,775,040
14,775,453
0.000788
from matplotlib import ticker scale_pow = 2 def my_formatter_fun(x, p): return '%.2f' % (x * 10 ** scale_pow) ax1.get_xaxis().set_major_formatter(ticker.FuncFormatter(my_formatter_fun))
matplotlib axis label format
14775040_14775453_15
1,675,943
1,676,000
0.000788
import textwrap
Computing article abstracts
1675943_1676000_9
9,070,708
31,890,160
0.000788
import MySQLdb from sshtunnel import SSHTunnelForwarder with SSHTunnelForwarder(('sshhost.domain.com', 22), ssh_password= 'sshpasswd', ssh_username='sshusername', remote_bind_address=( 'mysqlhost.domain.com', 3306)) as server: pass
ssh first with mysqldb in python
9070708_31890160_7
40,819,846
40,819,897
0.000788
from address import AddressBook a = Addressbook() a.insert('Jenny', '867-5309')
Using my Python program
40819846_40819897_8
20,268,396
20,269,033
0.000788
from selenium.webdriver.common.by import By import selenic.util
Mixing implicit and explicit waits
20268396_20269033_7
6,347,588
6,347,650
0.000788
def import_re(): global re import re re import_re()
Is it possible to import to the global scope from inside a function (Python)?
6347588_6347650_13
23,531,145
23,531,475
0.000787
from collections import defaultdict tree = lambda : defaultdict(tree) d = tree() for _, (region, type, name, value) in df.iterrows(): pass
Pandas to D3. Serializing dataframes to JSON
23531145_23531475_14
2,494,468
2,540,589
0.000787
"import sys; sys.path = ['%s/pylib-2.6.4.zip','%s']", applicationDirectory,
How to create an application which embeds and runs Python code without local Python installation?
2494468_2540589_17
21,866,036
21,866,201
0.000787
linesep = '\r\n' from nt import * try: from nt import _exit except ImportError: pass import ntpath as path import nt __all__.extend(_get_exports_list(nt)) del nt
import a.b also imports a?
21866036_21866201_17
19,566,555
19,577,968
0.000787
blogService.js blogView.html app.module.js app.routes.js
Folder Structure for Python Django-REST-framework and Angularjs
19566555_19577968_18
2,813,227
2,813,384
0.000786
import inspect def pv(name): record = inspect.getouterframes(inspect.currentframe())[1]
Printing Variable names and contents as debugging tool; looking for emacs/Python shortcut
2813227_2813384_17
6,837,514
27,949,639
0.000786
fi PS1 = 'whatever $VENV_NOTICE else'
Displaying virtualenv
6837514_27949639_4
15,570,099
15,570,546
0.000785
"""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_16
4,256,145
6,423,192
0.000785
import django def django_version(request): pass
Django template tag to display Django version
4256145_6423192_8
4,868,880
31,158,272
0.000785
help(CM) from garlicsim.general_misc.context_manager import ContextManager
How do I import a third party module in Python?
4868880_31158272_11
40,208,006
40,208,071
0.000784
from transliterate import translit cy = '\u041c\u0410\u041c\u0410' en = 'MAMA' cy == en
Detect same words using different alphabets?
40208006_40208071_18
41,946,927
41,947,061
0.000784
reshaped
Getting pandas dataframe from list of nested dictionaries
41946927_41947061_3
5,370,762
5,506,230
0.000784
EndIf
How to hide Firefox window (Selenium WebDriver)?
5370762_5506230_3
1,762,306
1,770,581
0.000784
import os from PyQt4.QtCore import QUrl html_path = resource_filename(sphinx.__name__, os.path.join('build', 'html')) return QUrl(os.path.join(html_path, 'index.html'))
force unpacking of certain egg directories
1762306_1770581_14
40,208,006
40,208,071
0.000783
cy == en cy_converted = translit(cy, 'ru', reversed=True)
Detect same words using different alphabets?
40208006_40208071_16
18,173,983
18,174,097
0.000783
xmlFileOut = '/Users/User1/Desktop/Python/Done.xml' with open(xmlFileOut, 'w') as f: pass
XML Declaration standalone="yes" lxml
18173983_18174097_11
1,011,337
1,011,491
0.000783
from twisted.python.modules import getModule moduleDirectory = getModule(__name__).filePath.parent()
Relative file paths in Python packages
1011337_1011491_6
34,899,733
34,900,927
0.000783
import ast tree = ast.parse('import a; from b import c') tree.body tree.body[0].names[0].name tree.body[1].module
List all third party packages and theirselves functions used in a Python file
34899733_34900927_18
18,236,123
20,249,402
0.000782
import mock m = mock.MagicMock()
Python PropertyMock side effect with AttributeError and ValueError
18236123_20249402_11
6,019,192
6,019,460
0.000781
import signal def SigIntHand(SIG, FRM): pass
How to prevent termination of a running program using "ctrl+c" in Linux using python?
6019192_6019460_10
29,479,872
29,627,654
0.00078
import numpy from pyspark.sql.functions import UserDefinedFunction from pyspark.sql.types import DoubleType udf = UserDefinedFunction(numpy.random.normal, DoubleType())
Functions from Python packages for udf() of Spark dataframe
29479872_29627654_14
34,899,733
34,900,927
0.00078
import ast tree = ast.parse('import a; from b import c') tree.body tree.body[0].names[0].name
List all third party packages and theirselves functions used in a Python file
34899733_34900927_17
14,025,879
14,060,360
0.00078
paste
Assertion Error in columns in DataFrame with hierarchical indexing
14025879_14060360_2
2,860,563
20,708,090
0.000779
from Chessnut import Game chessgame = Game(fen= 'rnbq1rk1/ppppp1bp/5np1/5p2/2PP4/2NBPN2/PP3PPP/R1BQK2R b KQ - 4 6') print(chessgame) print(chessgame.get_moves()) chessgame.apply_move(chessgame.get_moves()[1])
python: Chess moves validation
2860563_20708090_17
1,025,145
1,025,258
0.000779
T(0 * F + 10 * C) 0 * F + T(10 * C) 0 * F + 10 * C T(0 * F) + T(10 * C) T(0 * F) - T(10 * C) 0 * F - 10 * C
Units conversion in Python
1025145_1025258_18
2,485,719
2,485,804
0.000779
import win32com.client as com folderPath = 'D:\\Software\\Downloads' fso = com.Dispatch('Scripting.FileSystemObject') folder = fso.GetFolder(folderPath)
very quickly getting total size of folder
2485719_2485804_19
25,497,519
25,497,723
0.000778
import myModule as myModule myModule.printY() print(myModule.variableY) myModule.variableX = 10 print(myModule.variableX)
How to declare global variable that is visible to imported module functions
25497519_25497723_19
2,764,055
2,765,556
0.000778
cont one
How to pdb Python code with input?
2764055_2765556_10
16,905,028
16,926,243
0.000778
import matplotlib as mpl mpl.rcParams['figure.figsize'] = 8.0, 6.0 mpl.rcParams['font.size'] = 12 mpl.rcParams['savefig.dpi'] = 100
Why is matplotlib plot produced from ipython notebook slightly different from terminal version?
16905028_16926243_14
42,381,902
42,639,502
0.000777
def similarity(self, w1, w2): """ Compute cosine similarity between two words. Example:: >>> trained_model.similarity('woman', 'man') 0.73723527 >>> trained_model.similarity('woman', 'woman') 1.0 """
Interpreting negative Word2Vec similarity from gensim
42381902_42639502_3
18,428,600
29,651,354
0.000777
Lib
Unable to get python embedded to work with zip'd library
18428600_29651354_2
1,395,913
1,396,190
0.000777
from IPython.Shell import IPShellEmbed ipshell = IPShellEmbed()
How to drop into REPL (Read, Eval, Print, Loop) from Python code
1395913_1396190_8
25,826,180
25,826,320
0.000777
from mock import MagicMock lst = [1, 2] mock = MagicMock(side_effect=lst) mock(), mock() mock.side_effect = lst
Can a mock side_effect iterator be reset after it has been exhausted?
25826180_25826320_19
21,879,424
21,882,128
0.000777
20 30
Do something every n iterations without using counter variable
21879424_21882128_13
42,169,390
42,182,518
0.000777
""" function (tick) { var mapping = {1.25: "20 000 $", 5.25: "50 000 $"}; return mapping[tick]; }; """
A deployed bokeh server displays a blank plot, but everything is fine locally
42169390_42182518_3
12,166,819
12,166,860
0.000775
book.py ccg chat chunk
Use NLTK without installing
12166819_12166860_12
11,385,590
11,450,909
0.000775
char * shapename char * color
Passing arguments to tp_new and tp_init from subtypes in Python C API
11385590_11450909_7
32,974,166
32,974,354
0.000775
INDEX
How do I find 5 minutes gaps in a Pandas dataframe?
32974166_32974354_3
9,402,324
9,538,781
0.000775
import datetime now = datetime.datetime.now(created_at) five_minutes_ago = now - datetime.timedelta(minutes=5) q = model.all()
How to minimize datastore writes initiated by the mapreduce library?
9402324_9538781_13
845,926
848,611
0.000774
import win32api filelist = win32api.FindFiles('F:/recovery/My Music/*.*') filelist = [(i[9] if i[9] else i[8]) for i in filelist]
Rename invalid filename in XP via Python
845926_848611_13
29,074,414
29,074,669
0.000774
binary
Representing Coordinates in GeoAlchemy2
29074414_29074669_16
41,650,832
41,650,866
0.000774
abc
How can I remove the duplicated consecutive chars and reserve the first one using regex?
41650832_41650866_8
12,172,791
12,173,406
0.000774
def sin_degrees(x): from math import *
Changes in import statement python3
12172791_12173406_10
323,763
32,869,639
0.000774
from production import models as production_models
Foreign key from one app into another in Django
323763_32869639_9
13,773,862
13,774,565
0.000773
import traceback @app.route('/route1') def api_route1(): if user_id in request.args: pass
API in Flask--returns JSON but HTML exceptions break my JSON client
13773862_13774565_10
21,476,554
37,647,375
0.000773
from configobj import ConfigObj config = ConfigObj(path_to_ini) config['TestSettings']['environment'] = 'some_other_value'
Update INI file without removing comments
21476554_37647375_8
1,037,406
1,037,423
0.000773
from urlgrabber.keepalive import HTTPHandler keepalive_handler = HTTPHandler() opener = urllib.request.build_opener(keepalive_handler) urllib.request.install_opener(opener)
Python urllib2 with keep alive
1037406_1037423_17
23,639,355
25,835,028
0.000772
from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop if __name__ == '__main__': pass
Extremely long wait time when loading REST resource from angularjs
23639355_25835028_19
386,753
386,763
0.000772
from array import array response = 0, 0, 117, 143, 6 bytes = array('B', response[:-1])
How do I convert part of a python tuple (byte array) into an integer
386753_386763_15
37,270,999
37,453,849
0.000771
grammar = """ NBAR: {<NN.*|JJ>*<NN.*>} NP: {<NBAR>} {<NBAR><IN><NBAR>} """
SyntaxNet creating tree to root verb
37270999_37453849_13
6,296,055
6,296,774
0.00077
import ctypes from ctypes.util import find_library sqlite_lib = ctypes.CDLL(find_library('sqlite3'))
Serializing Sqlite3 in Python
6296055_6296774_14
34,315,778
34,327,364
0.000769
import json json_keyboard = json.dumps({'keyboard': [['A button'], ['B button']], 'one_time_keyboard': False, 'resize_keyboard': True})
Telegram bot api keyboard
34315778_34327364_5
4,848,566
4,850,603
0.000768
fi
Check for existence of Python dev files from bash script
4848566_4850603_0
6,827,834
6,827,857
0.000768
aa
How to filter a dict to contain only keys in a given list?
6827834_6827857_10
21,866,036
21,866,201
0.000767
import ntpath as path import nt __all__.extend(_get_exports_list(nt)) del nt
import a.b also imports a?
21866036_21866201_18
2,957,013
2,957,181
0.000767
Blue Yellow
BeautifulSoup: just get inside of a tag, no matter how many enclosing tags there are
2957013_2957181_4
21,344,938
21,344,965
0.000767
positive
creating sets of tuples in python
21344938_21344965_2
2,814,609
2,815,796
0.000767
import imp imp.reload(sm) sm.MyClass.kind
reloading module, need to re-compile sub modules?
2814609_2815796_15
20,060,096
21,151,777
0.000767
ln - s / usr / lib / i386 - linux - gnu / libfreetype.so / usr / lib ln - s / usr / lib / i386 - linux - gnu / libjpeg.so / usr / lib ln - s / usr / lib / i386 - linux - gnu / libz.so / usr / lib
Installing PIL with pip
20060096_21151777_5
35,882,501
35,882,849
0.000766
conditions
Selecting data from Pandas dataframe based on criteria stored in a dict
35882501_35882849_9
8,868,580
8,868,632
0.000766
import bcrypt
Best hashing method before saving password into database table for django
8868580_8868632_19