text
stringlengths 4
1.08k
|
|---|
Sorting a list of tuples with multiple conditions,"sorted_by_length = sorted(list_, key=lambda x: (x[0], len(x[1]), float(x[1])))"
|
how to open a url in python,webbrowser.open('http://example.com')
|
"How to print +1 in Python, as +1 (with plus sign) instead of 1?",print('{0:+d}'.format(score))
|
How to obtain values of request variables using Python and Flask,first_name = request.form.get('firstname')
|
python pandas extract unique dates from time series,df['Date'].map(lambda t: t.date()).unique()
|
Confusing with the usage of regex in Python,"re.findall('([a-z])*', '123abc789')"
|
Confusing with the usage of regex in Python,"re.findall('(?:[a-z])*', '123abc789')"
|
Google App Engine - Request class query_string,self.request.get_all()
|
"Python, lambda, find minimum","min([1, 2, 3])"
|
Convert a JSON schema to a python class,"sweden = Country(name='Sweden', abbreviation='SE')"
|
How to use `numpy.savez` in a loop for save more than one array?,"np.savez(tmp, *[getarray[0], getarray[1], getarray[8]])"
|
Sorting dictionary keys based on their values,"[k for k, v in sorted(list(mydict.items()), key=lambda k_v: k_v[1][1])]"
|
How can I solve system of linear equations in SymPy?,"linsolve(Matrix(([1, 1, 1, 1], [1, 1, 2, 3])), (x, y, z))"
|
Python: Getting rid of \u200b from a string using regular expressions,'used\u200b'.strip('\u200b')
|
python - How to format variable number of arguments into a string?,"function_in_library('Hello %s' % ', '.join(['%s'] * len(my_args)), my_args)"
|
Create 2d Array in Python Using For Loop Results,"[[0, 0], [1, 10], [2, 20], [3, 30], [4, 40], [5, 50]]"
|
Efficiently grab gradients from TensorFlow?,sess.run(tf.initialize_all_variables())
|
Don't understand this python For loop,"[('pos1', 'target1'), ('pos2', 'target2')]"
|
"In Python, how to compare two lists and get all indices of matches?","list(i[0] == i[1] for i in zip(list1, list2))"
|
How to get alternating colours in dashed line using matplotlib?,plt.show()
|
How to get object from PK inside Django template?,"return render_to_response('myapp/mytemplate.html', {'a': a})"
|
Pandas: Fill missing values by mean in each group faster than transfrom,df[['value']].fillna(df.groupby('group').transform('mean'))
|
Python lambda function,"lambda x, y: x + y"
|
Merging data frame columns of strings into one single column in Pandas,"df.apply(' '.join, axis=0)"
|
How to check if a character is upper-case in Python?,print(all(word[0].isupper() for word in words))
|
python: sort a list of lists by an item in the sublist,"sorted(li, key=operator.itemgetter(1), reverse=True)"
|
"how to get around ""Single '}' encountered in format string"" when using .format and formatting in printing","print('{0}:<15}}{1}:<15}}{2}:<8}}'.format('1', '2', '3'))"
|
Output data from all columns in a dataframe in pandas,"pandas.set_option('display.max_columns', None)"
|
How to swap a group of column headings with their values in Pandas,"pd.DataFrame([{val: key for key, val in list(d.items())} for d in df.to_dict('r')])"
|
Matplotlib ColorbarBase: delete color separators,mpl.use('WXAgg')
|
How to make python gracefully fail?,sys.exit(main())
|
How to I load a tsv file into a Pandas DataFrame?,"DataFrame.from_csv('c:/~/trainSetRel3.txt', sep='\t', header=0)"
|
python - convert datetime to varchar/string,datetimevariable.strftime('%Y-%m-%d')
|
parsing a complex logical expression in pyparsing in a binary tree fashion,"['A', 'and', 'B', 'and', 'C']"
|
Python: How to generate a 12-digit random number?,"int(''.join(str(random.randint(0, 9)) for _ in range(12)))"
|
How to use ax.get_ylim() in matplotlib,plt.show()
|
Find max since condition in pandas timeseries dataframe,df['b'].cumsum()
|
Pandas: How to plot a barchar with dataframes with labels?,"df.set_index(['timestamp', 'objectId'])['result'].unstack()"
|
"""TypeError: string indices must be integers"" when trying to make 2D array in python","[Boardsize, Boardsize]"
|
Matplotlib - How to plot a high resolution graph?,plt.savefig('filename.png')
|
Getting system status in python,time.sleep(0.1)
|
Django - Multiple apps on one webpage?,"url('home/$', app.views.home, name='home')"
|
Google App Engine: Webtest simulating logged in user and administrator,os.environ['USER_IS_ADMIN'] = '1'
|
How can I place a table on a plot in Matplotlib?,plt.show()
|
Converting a dict into a list,print([y for x in list(dict.items()) for y in x])
|
Removing characters from string Python,""""""""""""".join(c for c in text if c not in 'aeiouAEIOU')"
|
Pandas: Mean of columns with the same names,"df = df.set_index(['id', 'name'])"
|
Selecting positive certain values from a 2D array in Python,"[[0.0, 3], [0.1, 1]]"
|
Find maximum value of a column and return the corresponding row values using Pandas,df.loc[df['Value'].idxmax()]
|
How do I add custom field to Python log format string?,"logging.info('Log message', extra={'app_name': 'myapp'})"
|
"Does filter,map, and reduce in Python create a new copy of list?",[x for x in list_of_nums if x != 2]
|
How to blend drawn circles with pygame,pygame.display.flip()
|
How to subset a data frame using Pandas based on a group criteria?,df.groupby('User')['X'].transform(sum) == 0
|
Python copy a list of lists,new_list = [x[:] for x in old_list]
|
what would be the python code to add time to a specific timestamp?,"datetime.strptime('21/11/06 16:30', '%d/%m/%y %H:%M')"
|
Delete digits in Python (Regex),"s = re.sub('^\\d+\\s|\\s\\d+\\s|\\s\\d+$', ' ', s)"
|
"Plotting a list of (x, y) coordinates in python matplotlib",plt.scatter(*zip(*li))
|
How can I plot hysteresis in matplotlib?,"ax.scatter(XS, YS, ZS)"
|
Multiplying Rows and Columns of Python Sparse Matrix by elements in an Array,"numpy.dot(numpy.dot(a, m), a)"
|
How to create nested list from flatten list?,"[['a', 'b', 'c'], ['d', 'e', 'f', 'g'], ['d', 's', 'd', 'a']]"
|
Python - Find the greatest number in a set of numbers,"print(max(1, 2, 3))"
|
Splitting a string based on a certain set of words,"re.split('_(?:for|or|and)_', 'sad_pandas_and_happy_cats_for_people')"
|
Using BeautifulSoup to search html for string,soup.body.findAll(text='Python Jobs')
|
Working with set_index in Pandas DataFrame,"rdata.set_index(['race_date', 'track_code', 'race_number'])"
|
Switch every pair of characters in a string,"print(''.join(''.join(i) for i in zip(a2, a1)) + a[-1] if len(a) % 2 else '')"
|
How can I tell if a string only contains letter AND spaces,"""""""a b"""""".replace(' ', '').isalpha()"
|
creating list of random numbers in python,randomList = [random.random() for _ in range(10)]
|
add value to each element in array python,"[(a + i.reshape(2, 2)) for i in np.identity(4)]"
|
How to plot a wav file,plt.show()
|
Why I can't convert a list of str to a list of floats?,"C = row[1].split(',')[1:-1]"
|
What is the simplest way to swap char in a string with Python?,""""""""""""".join([s[x:x + 2][::-1] for x in range(0, len(s), 2)])"
|
How do I draw a grid onto a plot in Python?,plt.show()
|
Best / most pythonic way to get an ordered list of unique items,sorted(set(itertools.chain.from_iterable(sequences)))
|
Python/Matplotlib - Is there a way to make a discontinuous axis?,ax.spines['right'].set_visible(False)
|
How to convert numpy datetime64 into datetime,datetime.datetime.fromtimestamp(x.astype('O') / 1000000000.0)
|
Find the root of the git repository where the file lives,"os.path.abspath(os.path.join(dir, '..'))"
|
Python/Matplotlib - How to put text in the corner of equal aspect figure,plt.show()
|
How do I print bold text in Python?,print('\x1b[0m')
|
How to check if any value of a column is in a range in Pandas?,df[(x <= df['columnX']) & (df['columnX'] <= y)]
|
gnuplot linecolor variable in matplotlib?,plt.show()
|
Why I can't convert a list of str to a list of floats?,"0, 182, 283, 388, 470, 579, 757"
|
String encoding and decoding from possibly latin1 and utf8,print(str.encode('cp1252').decode('utf-8').encode('cp1252').decode('utf-8'))
|
"How to use regular expression to separate numbers and characters in strings like ""30M1000N20M""","re.findall('(([0-9]+)([A-Z]))', '20M10000N80M')"
|
Django redirect to root from a view,redirect('Home.views.index')
|
How to check if a dictionary is in another dictionary in python,set(L[0].f.items()).issubset(set(a3.f.items()))
|
How to add more headers in websocket python client,"self.sock.connect(self.url, header=self.header)"
|
How can I speed up fetching pages with urllib2 in python?,return urllib.request.urlopen(url).read()
|
Finding common rows (intersection) in two Pandas dataframes,"s1 = pd.merge(df1, df2, how='inner', on=['user_id'])"
|
Convert a list to a dictionary in Python,"a = ['bi', 'double', 'duo', 'two']"
|
Convert a string to datetime object in python,"dateobj = datetime.datetime.strptime(datestr, '%Y-%m-%d').date()"
|
Django get all records of related models,Activity.objects.filter(list__topic__user=my_user)
|
How do I sort a list of strings in Python?,mylist.sort(key=str.lower)
|
Plot Histogram in Python,plt.show()
|
remove None value from a list without removing the 0 value,[x for x in L if x is not None]
|
Removing backslashes from a string in Python,"result.replace('\\', '')"
|
Convert a Pandas DataFrame to a dictionary,"df.set_index('ID', drop=True, inplace=True)"
|
Generate all possible strings from a list of token,"print([''.join(a) for a in combinations(['hel', 'lo', 'bye'], 2)])"
|
Convert string to numpy array,"np.array(map(int, '100110'))"
|
"Remove repeating tuples from a list, depending on the values in the tuples","[(i, max(j)) for i, j in list(d.items())]"
|
How can I sum the product of two list items using for loop in python?,"sum(i * j for i, j in zip(a, b))"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.