text
stringlengths 4
1.08k
|
|---|
How can i create the empty json object in python,data = json.loads(request.POST['mydata']) if 'mydata' in request.POST else {}
|
Search a list of strings for any sub-string from another list,any(k in s for k in keywords)
|
Adding element to a dictionary in python?,"print((name, 'has been sorted into', ransport))"
|
How can I convert a tensor into a numpy array in TensorFlow?,"print(type(tf.constant([1, 2, 3]).eval()))"
|
Pythonic way to eval all octal values in a string as integers,"re.sub('\\b0+(?!\\b)', '', '012 + 2 + 0 - 01 + 204 - 0')"
|
Remove the newline character in a list read from a file,"grades.append(lists[i].rstrip('\n').split(','))"
|
How to efficiently compare two unordered lists (not sets) in Python?,len(a) == len(b) and all(a.count(i) == b.count(i) for i in a)
|
Converting a java System.currentTimeMillis() to date in python,print(date.fromtimestamp(1241711346274 / 1000.0))
|
Django request get parameters,"request.GET.get('MAINS', '')"
|
Change values in a numpy array,a[a == 2] = 10
|
How to change Tkinter Button state from disabled to normal?,self.x.config(state='normal')
|
Atomic increment of a counter in django,Counter.objects.filter(name=name).update(count=F('count') + 1)
|
Add columns in pandas dataframe dynamically,"df[[0, 2, 3]].apply(','.join, axis=1)"
|
Python Sort Multidimensional Array Based on 2nd Element of Subarray,"sorted(lst, key=operator.itemgetter(1), reverse=True)"
|
How to change the order of DataFrame columns?,cols = list(df.columns.values)
|
How to put the legend out of the plot,ax.legend()
|
A simple way to remove multiple spaces in a string in Python,"re.sub('\\s\\s+', ' ', s)"
|
Remove all elements of a set that contain a specific char,[x for x in primes if '0' not in str(x)]
|
How to unfocus (blur) Python-gi GTK+3 window on Linux,Gtk.main()
|
Python : Getting the Row which has the max value in groups using groupby,df[df['count'] == df.groupby(['Mt'])['count'].transform(max)]
|
How to change font properties of a matplotlib colorbar label?,"plt.colorbar().set_label(label='a label', size=15, weight='bold')"
|
json query that returns parent element and child data?,"dict((k, v['_status']['md5']) for k, v in list(json_result.items()))"
|
Using a global dictionary with threads in Python,global_dict['baz'] = 'world'
|
SyntaxError when trying to use backslash for Windows file path,os.path.isfile('C:\\Users\\xxx\\Desktop\\xxx')
|
debianzing a python program to get a .deb,myscript.py
|
Slice a string after a certain phrase?,"s.split('fdasfdsafdsa', 1)[0]"
|
"Python, networkx",nx.draw(G)
|
How do I capture SIGINT in Python?,"signal.signal(signal.SIGINT, signal_handler)"
|
How to create a timer using tkinter?,root.mainloop()
|
Convert datetime object to a String of date only in Python,"'%s/%s/%s' % (dt.month, dt.day, dt.year)"
|
Appending to a Pandas Dataframe From a pd.read_sql Output,"df = df.append(pd.read_sql(querystring, cnxn, params=[i]))"
|
How do I combine two columns within a dataframe in Pandas?,df['c'] = df['b'].fillna(df['a'])
|
how to draw directed graphs using networkx in python?,"nx.draw_networkx_edges(G, pos, edgelist=red_edges, edge_color='r', arrows=True)"
|
Python requests: get attributes from returned JSON string,print(resp['headers']['Host'])
|
Update json file,json_file.write('{}\n'.format(json.dumps(data)))
|
How to get the symbolic path instead of real path?,os.path.abspath('link/file')
|
How to map 2 lists with comparison in python,"[{'y': 2, 'location': 2}, {'z': 3, 'location': 2}]"
|
How to perform custom build steps in setup.py?,cmdclass = {'install': install_}
|
Embed bash in python,"os.system(""bash -c 'echo $0'"")"
|
Get the number of all keys in a dictionary of dictionaries in Python,"n = sum([(len(v) + 1) for k, v in list(dict_test.items())])"
|
"Python, print delimited list",""""""","""""".join(map(str, a))"
|
customize BeautifulSoup's prettify by tag,print(soup.prettify())
|
Random list with replacement from python list of lists,[random.choice(list_of_lists) for _ in range(sample_size)]
|
creating sets of tuples in python,"mySet = set((x, y) for x in range(1, 51) for y in range(1, 51))"
|
Using bisect in a list of tuples?,"bisect(list_of_tuples, (3, None))"
|
Splitting a list into uneven groups?,"[[1, 2], [3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]"
|
group multi-index pandas dataframe,"s.groupby(level=['first', 'second']).sum()"
|
Python: Alter elements of a list,bool_list = [False] * len(bool_list)
|
Python - How to sort a list of lists by the fourth element in each list?,"sorted(unsorted_list, key=lambda x: int(x[3]))"
|
Python: intersection indices numpy array,"numpy.intersect1d(a, b)"
|
how to display a numpy array with pyglet?,"label3 = numpy.dstack((label255, label255, label255))"
|
Index confusion in numpy arrays,"A[np.ix_([0, 2], [0, 1], [1, 2])]"
|
Pandas Dataframe to RDD,spDF.rdd.first()
|
How to find the indexes of matches in two lists,"[i for i, (a, b) in enumerate(zip(vec1, vec2)) if a == b]"
|
Calling a .py script from a specific file path in Python interpreter,"exec(compile(open('C:\\X\\Y\\Z').read(), 'C:\\X\\Y\\Z', 'exec'))"
|
Is it possible to get widget settings in Tkinter?,root = Tk()
|
How to show raw_id value of a ManyToMany relation in the Django admin?,"return super(MyAdmin, self).formfield_for_dbfield(db_field, **kwargs)"
|
Converting a String into Dictionary python,json.loads(s)
|
Accessing JSON elements,wjdata = json.load(urllib.request.urlopen('url'))
|
How do I get the whole content between two xml tags in Python?,"tostring(element).split('>', 1)[1].rsplit('</', 1)"
|
How do I merge a list of dicts into a single dict?,dict(j for i in L for j in list(i.items()))
|
python split string on whitespace,line = line.split('\t')
|
"In Python, how to change text after it's printed?",sys.stdout.write('hello')
|
How to convert decimal string in python to a number?,Decimal('1.03')
|
Add a vertical slider with matplotlib,ax.set_xticks([])
|
Remove and insert lines in a text file,outfile.write(line)
|
Joining two DataFrames from the same source,"df_one.join(df_two, df_one['col1'] == df_two['col1'], 'inner')"
|
Match start and end of file in python with regex,"print(re.findall('^.*\\.$\\Z', data, re.MULTILINE))"
|
"Slicing of a NumPy 2d array, or how do I extract an mxm submatrix from an nxn array (n>m)?","x[[[1], [3]], [1, 3]]"
|
Duplicate numpy array rows where the number of duplications varies,"numpy.repeat([1, 2, 3, 4], [3, 3, 2, 2])"
|
How to add an integer to each element in a list?,"map(lambda x: x + 1, [1, 2, 3])"
|
Update Pandas Cells based on Column Values and Other Columns,"df = pd.DataFrame(data=matrix.toarray(), columns=names, index=raw)"
|
How do I print this list vertically?,print(' '.join(i))
|
Arrow on a line plot with matplotlib,plt.show()
|
Python Inverse of a Matrix,"A = matrix([[2, 2, 3], [11, 24, 13], [21, 22, 46]])"
|
Create List of Dictionary Python,"[{'data': 0}, {'data': 1}, {'data': 2}]"
|
How to filter (or replace) unicode characters that would take more than 3 bytes in UTF-8?,"pattern = re.compile('[^\\u0000-\\uFFFF]', re.UNICODE)"
|
How to add a string to every even row in a pandas dataframe column series?,print(df['New_Col'])
|
Two subplots in Python (matplotlib),"df[['Adj Close', '100MA']].plot(ax=axarr[0])"
|
How do you edit cells in a sparse matrix using scipy?,"A.indptr = np.array([0, 0, 0, 1, 1, 1, 2], dtype=np.int32)"
|
How to store indices in a list,print([s[i] for i in index])
|
Color Range Python,"print((i, [round(255 * x) for x in rgb]))"
|
Identify groups of continuous numbers in a list,"[-2, -2, -2, -2, -8, -8, -8, -8, -8, -8]"
|
x11 forwarding with paramiko,ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
How to get all the keys with the same highest value?,"['e', 'd']"
|
How can I plot a mathematical expression of two variables in python?,plt.show()
|
Assigning a function to a variable,silly_var()
|
"How to do ""if-for"" statement in python?",do_stuff()
|
Python - Write to Excel Spreadsheet,"df.to_excel('test.xlsx', sheet_name='sheet1', index=False)"
|
"Detect holes, ends and beginnings of a line using openCV?",cv2.waitKey(0)
|
Updating json field in Postgres,"{'some_key': 'some_val', 'other_key': 'new_val'}"
|
How to get pdf filename with Python requests?,r.headers['content-disposition']
|
Prettier default plot colors in matplotlib,plt.style.use('seaborn-dark-palette')
|
Python - Create list with numbers between 2 values?,"list(range(11, 17))"
|
Spawning a thread in python,Thread(target=fct).start()
|
is it possible to plot timelines with matplotlib?,ax.spines['left'].set_visible(False)
|
is it possible to plot timelines with matplotlib?,ax.spines['top'].set_visible(False)
|
How to get the length of words in a sentence?,[len(x) for x in s.split()]
|
Using Django models in external python script,sys.path.append('/var/www/cloudloon')
|
List comprehension with if statement,[y for y in a if y not in b]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.