text stringlengths 4 1.08k |
|---|
cannot resize image with tkinter,"canvas.create_image(0, 0, anchor=NW, image=displayPlantImage)" |
how to use re match objects in a list comprehension,"return [m.group(1) for m in (re.search(regex, l) for l in lines) if m]" |
"list all files in directory "".""","for (dirname, dirnames, filenames) in os.walk('.'): |
for subdirname in dirnames: |
print(os.path.join(dirname, subdirname)) |
for filename in filenames: |
pass" |
how do i translate a iso 8601 datetime string into a python datetime object?,"datetime.datetime.strptime('2007-03-04T21:08:12', '%Y-%m-%dT%H:%M:%S')" |
intersection of 2d and 1d numpy array,"A.ravel()[np.in1d(A, B)] = 0" |
execute a post request to url `http://httpbin.org/post` with json data `{'test': 'cheers'}`,"requests.post('http://httpbin.org/post', json={'test': 'cheers'})" |
route to worker depending on result in celery?,"my_task.apply_async(exchange='C.dq', routing_key=host)" |
python split consecutive delimiters,"re.split('a+', 'aaa')" |
how to convert a hex string to hex number,"print(hex(int('0xAD4', 16) + int('0x200', 16)))" |
how to check for eof in python?,"return re.split(seperator, f.read())" |
how can i select all dataframe rows that are within a certain distance of a given value in a specific column?,df.iloc[indexers] |
check if all elements in list `lst` are tupples of long and int,"all(isinstance(x, int) for x in lst)" |
"implementing ""starts with"" and ""ends with"" queries with google app engine","MyModel.all().filter('prop >=', prefix).filter('prop <', prefix + '\ufffd')" |
how to remove multiple values from an array at once,"np.delete(1, 1)" |
pandas dataframe: replace nan values with average of columns,"df.apply(lambda x: x.fillna(x.mean()), axis=0)" |
check if array `b` contains all elements of array `a`,"numpy.in1d(b, a).all()" |
creating a matrix of options using itertools,"print(list(itertools.product(*itertools.repeat((False, True), 3))))" |
how do i stack vectors of different lengths in numpy?,"ma.array(np.resize(b, a.shape[0]), mask=[False, False, True])" |
"throw a valueerror with message 'represents a hidden bug, do not catch this'","raise ValueError('represents a hidden bug, do not catch this')" |
tensorflow: how to get a tensor by name?,tf.constant(1) + tf.constant(2) |
merge columns within a dataframe that have the same name,"df.groupby(df.columns, axis=1).agg(numpy.max)" |
"in python, how to compare two lists and get all indices of matches?","list(i[0] == i[1] for i in zip(list1, list2))" |
python - how to delete hidden signs from string?,"new_string = re.sub('[^{}]+'.format(printable), '', the_string)" |
how to make fabric ignore offline hosts in the env.hosts list?,env.skip_bad_hosts = True |
python regex findall,"['Barack Obama', 'Bill Gates']" |
add a tuple with value `another_choice` to a tuple `my_choices`,"final_choices = ((another_choice,) + my_choices)" |
getting system status in python,time.sleep(0.1) |
how to iterate over list of dictionary in python?,"print(str(a['timestamp']), a['ip'], a['user'])" |
how can i convert a binary to a float number,"float(int('-0b1110', 0))" |
url decode with python 3,urllib.parse.unquote('id%3D184ff84d27c3613d&quality=medium') |
numpy: get 1d array as 2d array without reshape,"np.hstack([np.atleast_2d([1, 2, 3, 4, 5]).T, np.atleast_2d([1, 2, 3, 4, 5]).T])" |
python: uniqueness for list of lists,[list(i) for i in set(tuple(i) for i in testdata)] |
"pandas dataframe, how do i split a column 'ab' into two 'a' and 'b' on delimiter ' '","df['A'], df['B'] = df['AB'].str.split(' ', 1).str" |
iterate over matrices in numpy,np.array(list(g)) |
double square brackets side by side in python,"l = ['foo', 'bar', 'buz']" |
how to concatenate element-wise two lists in python?,"['asp10', 'asp11', 'asp15', 'asp16', 'asp210', 'asp211']" |
pandas: get unique multiindex level values by label,df.index.get_level_values('co').unique() |
how can i create a python timestamp with millisecond granularity?,time.time() * 1000 |
how to remove duplicates from python list and keep order?,myList = sorted(set(myList)) |
"updating a list of python dictionaries with a key, value pair from another list","[{'count': 3, 'domain': 'Ratios'}, {'count': 6, 'domain': 'Geometry'}]" |
how to implement jump in pygame without sprites?,pygame.display.update() |
split numpy array into similar array based on its content,"split_curve(np.array([0, 1]), np.array([0, 1]), 3)" |
how to escape single quote in xpath 1.0 in selenium for python,"driver.find_element_by_xpath('//span[text()=""' + cat2 + '""]').click()" |
how to get all variable and method names used in script,print([var for var in list(globals().keys()) if '__' not in var]) |
in django : how to serialize dict object to json?,data = json.dumps({'a': 1}) |
update the fields in django model `book` using dictionary `d`,Book.objects.create(**d) |
counting the amount of occurences in a list of tuples,"Counter({'12392': 2, '7862': 1})" |
find the list in a list of lists `alkaline_earth_values` with the max value of the second element.,"max(alkaline_earth_values, key=lambda x: x[1])" |
getting a list of all subdirectories in the directory `directory`,os.walk(directory) |
splitting unicode string into words,'\u0440\u0430\u0437 \u0434\u0432\u0430 \u0442\u0440\u0438'.split() |
how can i return a default value for an attribute?,"a = getattr(myobject, 'id', None)" |
how do i create a new database in mongodb using pymongo?,collection = db['test-collection'] |
how do i get a selected string in from a tkinter text box?,self.text.pack() |
creating a dictionary from a csv file?,"mydict = dict((rows[0], rows[1]) for rows in reader)" |
"in python, why won't something print without a newline?",sys.stdout.flush() |
mass string replace in python?,""""""""""""".join(myparts)" |
how do i configure spacemacs for python 3?,python - -version |
how to read and write multiple files?,output.close() |
how to make a copy of a 2d array in python?,y = [row[:] for row in x] |
how can i add an additional row and column to an array?,"L = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]" |
read json `elevations` to pandas dataframe `df`,pd.read_json(elevations) |
how to convert a float into hex,"return hex(struct.unpack('<I', struct.pack('<f', f))[0])" |
create a list containing digits of number 123 as its elements,list(str(123)) |
how to query as group by in django?,Members.objects.values('designation').annotate(dcount=Count('designation')) |
sorting pandas dataframe by order of another index,df2.reindex(df.index) |
renaming multiple files in python,"re.sub('.{20}(.mkv)', '\\1', 'unique12345678901234567890.mkv')" |
removing control characters from a string in python,return ''.join(c for c in line if ord(c) >= 32) |
is there a way to poll a file handle returned from subprocess.popen?,sys.stdout.flush() |
modify the width of a text control as `300` keeping default height in wxpython,"wx.TextCtrl(self, -1, size=(300, -1))" |
how to hide output of subprocess in python 2.7,"subprocess.check_output(['espeak', text], stderr=subprocess.STDOUT)" |
printing escaped unicode in python,"print(repr(s.encode('ascii', errors='xmlcharrefreplace'))[2:-1])" |
selecting specific column in each row from array,"a[np.arange(3), (0, 1, 0)]" |
dynamically add subplots in matplotlib with more than one column,fig.tight_layout() |
function that accepts both expanded arguments and tuple,"f(*((1, 4), (2, 5)))" |
convert string to numpy array,"print(np.array(list(mystr), dtype=int))" |
how to order a list of lists by the first value,"sorted([[1, 'mike'], [1, 'bob']])" |
how do i capture sigint in python?,"signal.signal(signal.SIGINT, signal_handler)" |
how to export a table dataframe in pyspark to csv?,df.write.format('com.databricks.spark.csv').save('mycsv.csv') |
how to convert a python numpy array to an rgb image with opencv 2.4?,cv2.waitKey() |
initializing 2d array in python,arr = [[None for x in range(6)] for y in range(6)] |
python format string thousand separator with spaces,"""""""{:,}"""""".format(1234567890.001).replace(',', ' ')" |
counting the number of non-nan elements in a numpy ndarray matrix in python,np.count_nonzero(~np.isnan(data)) |
python: split numpy array based on values in the array,"arr[:, (1)]" |
how can i parse a website using selenium and beautifulsoup in python?,driver.get('http://news.ycombinator.com') |
"print ""please enter something: "" to console, and read user input to `var`",var = input('Please enter something: ') |
integer divsion in python,int(x) / int(y) == math.floor(float(x) / float(y)) |
beautiful soup using regex to find tags?,soup.find_all(re.compile('(a|div)')) |
how do i write json data to a file in python?,"json.dump(data, outfile)" |
python - update a value in a list of tuples,"update_in_alist([('a', 'hello'), ('b', 'world')], 'b', 'friend')" |
python all combinations of subsets of a string,"[['4824'], ['482', '4'], ['48', '24'], ['4', '824'], ['4', '82', '4']]" |
serialize dictionary `data` and its keys to a json formatted string,"json.dumps({str(k): v for k, v in data.items()})" |
numpy: efficiently add rows of a matrix,"np.dot(np.dot(I, np.ones((7,), int)), mat)" |
how to convert a string to a function in python?,"eval('add(3,4)', {'__builtins__': None}, dispatcher)" |
copying data from s3 to aws redshift using python and psycopg2,conn.commit() |
intersection of 2d and 1d numpy array,"A[:, 3:][np.in1d(A[:, 3:], B).reshape(A.shape[0], -1)] = 0" |
how to get the values from a numpy array using multiple indices,"arr[[1, 4, 5]]" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.