text
stringlengths 4
1.08k
|
|---|
is it possible to plot timelines with matplotlib?,ax.spines['top'].set_visible(False)
|
numpy array of python objects,"numpy.array(['hello', 'world!'], dtype=object)"
|
how should i take the max of 2 columns in a dataframe and make it another column?,df['C'] = df.max(axis=1)
|
syntax for creating a dictionary into another dictionary in python,{'dict2': {}}
|
matplotlib: draw a series of radial lines on polaraxes,ax.axes.get_xaxis().set_visible(False)
|
ranking of numpy array with possible duplicates,"array([0, 1, 4, 5, 6, 1, 7, 8, 8, 1])"
|
find all n-dimensional lines and diagonals with numpy,"array[(i[0]), (i[1]), (i[2]), ..., (i[n - 1])]"
|
how do i get a website's ip address using python 3.x?,socket.gethostbyname('cool-rr.com')
|
python: how can i run python functions in parallel?,p1.start()
|
best way to get the nth element of each tuple from a list of tuples in python,[x[0] for x in G]
|
"extract first two substrings in string `phrase` that end in `.`, `?` or `!`","re.match('(.*?[.?!](?:\\s+.*?[.?!]){0,1})', phrase).group(1)"
|
append a path `/path/to/main_folder` in system path,sys.path.append('/path/to/main_folder')
|
create array `a` containing integers from stdin,a.fromlist([int(val) for val in stdin.read().split()])
|
python: most efficient way to convert date to datetime,"datetime.datetime.combine(my_date, datetime.time.min)"
|
repeating elements in list comprehension,[i for i in range(3) for _ in range(2)]
|
trying to use hex() without 0x,"""""""{0:06x}"""""".format(int(line))"
|
python - way to recursively find and replace string in text files,"findReplace('some_dir', 'find this', 'replace with this', '*.txt')"
|
how do i disable the security certificate check in python requests,"requests.get('https://kennethreitz.com', verify=False)"
|
"serialize dictionary `d` as a json formatted string with each key formatted to pattern '%d,%d'","simplejson.dumps(dict([('%d,%d' % k, v) for k, v in list(d.items())]))"
|
how can i get the current contents of an element in webdriver,driver.quit()
|
how do i right-align numeric data in python?,"""""""a string {0:>{1}}"""""".format(foo, width)"
|
how do i merge a 2d array in python into one string with list comprehension?,""""""","""""".join(map(str, li2))"
|
"check if tuple (2, 3) is not in a list [(2, 7), (7, 3), ""hi""]","((2, 3) not in [(2, 7), (7, 3), 'hi'])"
|
reverse list `s`,s[::(-1)]
|
download a remote image and save it to a django model,image = models.ImageField(upload_to='images')
|
list comprehension with an accumulator,list(accumulate(list(range(10))))
|
extract digits in a simple way from a python string,"map(int, re.findall('\\d+', s))"
|
open a text file `data.txt` in io module with encoding `utf-16-le`,"file = io.open('data.txt', 'r', encoding='utf-16-le')"
|
urlencode a querystring 'string_of_characters_like_these:$#@=?%^q^$' in python 2,urllib.parse.quote_plus('string_of_characters_like_these:$#@=?%^Q^$')
|
how can i write a binary array as an image in python?,img.save('/tmp/image.bmp')
|
how do i increase the timeout for imaplib requests?,"urlfetch.fetch(url, deadline=10 * 60)"
|
sort a string in lexicographic order python,"sorted(s, key=str.lower)"
|
python split string based on regular expression,"re.findall('\\S+', str1)"
|
is there a multi-dimensional version of arange/linspace in numpy?,"X, Y = np.mgrid[-5:5:21j, -5:5:21j]"
|
convert alphabet letters to number in python,print([(ord(char) - 96) for char in input('Write Text: ').lower()])
|
python: lambda function in list comprehensions,[(lambda x: x * x) for x in range(10)]
|
how do you select choices in a form using python?,[f.name for f in br.forms()]
|
check if a key exists in a python list,mylist[1:] == ['comment']
|
"decode a double url encoded string
|
'fireshot3%2b%25282%2529.png' to
|
'fireshot3+(2).png'",urllib.parse.unquote(urllib.parse.unquote('FireShot3%2B%25282%2529.png'))
|
how to add an integer to each element in a list?,"map(lambda x: x + 1, [1, 2, 3])"
|
how to subtract one from every value in a tuple in python?,"holes = [(table[i][1] + 1, table[i + 1][0] - 1) for i in range(len(table) - 1)]"
|
how to make python format floats with certain amount of significant digits?,print('{:.6f}'.format(i))
|
how to split an array according to a condition in numpy?,"[array([[1, 2, 3], [2, 4, 7]]), array([[4, 5, 6], [7, 8, 9]])]"
|
selenium wait for driver `driver` 60 seconds before throwing a nosuchelementexceptions exception,driver.implicitly_wait(60)
|
print string `t` with proper unicode representations,print(t.decode('unicode_escape'))
|
sum the 3 largest integers in groupby by 'stname' and 'county_pop',df.groupby('STNAME')['COUNTY_POP'].agg(lambda x: x.nlargest(3).sum())
|
how to make a button using the tkinter canvas widget?,root.mainloop()
|
how to remove multiple indexes from a list at the same time?,del my_list[index]
|
pyqt - how to detect and close ui if it's already running?,sys.exit(app.exec_())
|
flatten list `x`,x = [i[0] for i in x]
|
how to create a menu and submenus in python curses?,self.window.keypad(1)
|
what's the recommended way to return a boolean for a collection being non-empty in python?,return bool(coll)
|
generate a sequence of numbers in python,""""""","""""".join(str(i) for i in range(100) if i % 4 in (1, 2))"
|
plotting a 2d heatmap with matplotlib,plt.show()
|
reading a text file and splitting it into single words in python,[line.split() for line in f]
|
get the ascii value of a character 'a' as an int,ord('a')
|
compare contents at filehandles `file1` and `file2` using difflib,"difflib.SequenceMatcher(None, file1.read(), file2.read())"
|
summing elements in a list,sum(int(i) for i in data)
|
rename file from `src` to `dst`,"os.rename(src, dst)"
|
creating a python dictionary from a line of text,"fields = tuple(field.strip() for field in line.split(','))"
|
filter a json from a key-value pair as `{'fixed_key_1': 'foo2'}` in django,Test.objects.filter(actions__contains=[{'fixed_key_1': 'foo2'}])
|
create list of 'size' empty strings,strs = ['' for x in range(size)]
|
merge pandas dataframe `x` with columns 'a' and 'b' and dataframe `y` with column 'y',"pd.merge(y, x, on='k')[['a', 'b', 'y']]"
|
django models selecting single field,"Employees.objects.values_list('eng_name', flat=True)"
|
best way to add an environment variable in fabric?,run('env | grep BAR')
|
get list of keys in dictionary `my_dict` whose values contain values from list `lst`,"[key for item in lst for key, value in list(my_dict.items()) if item in value]"
|
python implementation of jenkins hash?,"print('""%s"": %x' % (hashstr, hash))"
|
load the url `http://www.google.com` in selenium webdriver `driver`,driver.get('http://www.google.com')
|
sqlalchemy dynamic mapping,session.commit()
|
make a 2d pixel plot with matplotlib,plt.show()
|
quick way to upsample numpy array by nearest neighbor tiling,"np.kron(a, np.ones((B, B), a.dtype))"
|
polar contour plot in matplotlib,plt.show()
|
condensing multiple list comprehensions,"[[9, 30, 'am'], [5, 0, 'pm']]"
|
create a list containing the digits values from binary string `x` as elements,[int(d) for d in str(bin(x))[2:]]
|
splitting a string by list of indices,print('\n'.join(parts))
|
how to merge two python dictionaries in a single expression?,"z = merge_dicts(a, b, c, d, e, f, g)"
|
python: sort an array of dictionaries with custom comparator?,"key = lambda d: (d['rank'] == 0, d['rank'])"
|
extracting values from a joined rdds,list(joined_dataset.values())
|
adding two items at a time in a list comprehension,"print([y for x in zip(['^'] * len(mystring), mystring.lower()) for y in x])"
|
how to test if all rows are equal in a numpy,(arr == arr[0]).all()
|
python split string in moving window,"[''.join(x) for x in window('7316717', 3)]"
|
how to replace empty string with zero in comma-separated string?,"[(int(x) if x else 0) for x in data.split(',')]"
|
scikit learn hmm training with set of observation sequences,model.fit([X])
|
how to find the groups of consecutive elements from an array in numpy?,"[array([0]), array([47, 48, 49, 50]), array([97, 98, 99])]"
|
how do i plot hatched bars using pandas?,"df.plot(ax=ax, kind='bar', legend=False)"
|
get list of all unique characters in a string 'aaabcabccd',list(set('aaabcabccd'))
|
"python: convert ""5,4,2,4,1,0"" into [[5, 4], [2, 4], [1, 0]]","[l[i:i + 7] for i in range(0, len(l), 7)]"
|
how to uniqify a list of dict in python,[dict(y) for y in set(tuple(x.items()) for x in d)]
|
map two lists into one single list of dictionaries,"return [dict(zip(keys, values[i:i + n])) for i in range(0, len(values), n)]"
|
create list of dictionaries from pandas dataframe `df`,df.to_dict('records')
|
reshaping array into a square array python,"x.reshape(2, 2, 5)"
|
how can i efficiently move from a pandas dataframe to json,aggregated_df.reset_index().to_json(orient='index')
|
how to check null value for userproperty in google app engine,"query = db.GqlQuery('SELECT * FROM Entry WHERE editor > :1', None)"
|
how to sort by length of string followed by alphabetical order?,"the_list.sort(key=lambda item: (-len(item), item))"
|
print results in mysql format with python,conn.commit()
|
how to sort by a computed value in django,"sorted(Profile.objects.all(), key=lambda p: p.reputation)"
|
python merging two lists with all possible permutations,"[[[x, y] for x in list1] for y in list2]"
|
how does this function to remove duplicate characters from a string in python work?,"OrderedDict([('a', None), ('b', None), ('c', None), ('d', None), ('e', None)])"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.