text
stringlengths 4
1.08k
|
|---|
python imaplib - mark email as unread or unseen,"connection.uid('STORE', '-FLAGS', '(\\Seen)')"
|
Print first Key Value in an Ordered Counter,"next((key, value) for key, value in list(c.items()) if value > 1)"
|
Python Pandas: drop rows of a timeserie based on time range,df.loc[(df.index < start_remove) | (df.index > end_remove)]
|
Python: Split string by list of separators,"re.split('\\s*,\\s*|\\s*;\\s*', 'a , b; cdf')"
|
Sort a string in lexicographic order python,"sorted(s, key=str.lower)"
|
Efficient computation of the least-squares algorithm in NumPy,"np.linalg.solve(np.dot(a.T, a), np.dot(a.T, b))"
|
Python Logging - Disable logging from imported modules,logger = logging.getLogger('my_module_name')
|
Using Python to extract dictionary keys within a list,names = [item['name'] for item in data]
|
Representing graphs (data structure) in Python,"[('A', 'B'), ('B', 'C'), ('B', 'D'), ('C', 'D'), ('E', 'F'), ('F', 'C')]"
|
Detecting non-ascii characters in unicode string,"print(set(re.sub('[\x00-\x7f]', '', '\xa3\u20ac\xa3\u20ac')))"
|
How to set the current working directory in Python?,os.chdir(path)
|
How do convert unicode escape sequences to unicode characters in a python string,name.decode('latin-1').encode('utf-8')
|
Remove newline from file in python,"str2 = str.replace('\n', '')"
|
Can Python test the membership of multiple values in a list?,"set(['a', 'b']).issubset(['b', 'a', 'foo', 'bar'])"
|
How to extract numbers from filename in Python?,[int(x) for x in regex.findall(filename)]
|
How to unzip a list of tuples into individual lists?,zip(*l)
|
How to get the N maximum values per row in a numpy ndarray?,"A[:, -2:]"
|
How to produce an exponentially scaled axis?,plt.show()
|
Divide the values of two dictionaries in python,"dict((k, float(d2[k]) / d1[k]) for k in d2)"
|
How to replace empty string with zero in comma-separated string?,""""""","""""".join(x or '0' for x in s.split(','))"
|
How to correctly parse UTF-8 encoded HTML to Unicode strings with BeautifulSoup?,soup = BeautifulSoup(response.read().decode('utf-8'))
|
Finding consecutive consonants in a word,"re.findall('[bcdfghjklmnpqrstvwxyz]+', 'CONCERTATION', re.IGNORECASE)"
|
Grouping Pandas DataFrame by n days starting in the begining of the day,df['date'] = df['time'].apply(lambda x: x.date())
|
Simple way to append a pandas series with same index,a.append(b).reset_index(drop=True)
|
Rotating a two-dimensional array in Python,"original = [[1, 2], [3, 4]]"
|
append multiple values for one key in Python dictionary,"{'2010': [2], '2009': [4, 7], '1989': [8]}"
|
How to use the mv command in Python with subprocess,"subprocess.call('mv /home/somedir/subdir/* somedir/', shell=True)"
|
Filter Pyspark dataframe column with None value,df.filter('dt_mvmt is not NULL')
|
How to print Unicode character in Python?,print('\u0420\u043e\u0441\u0441\u0438\u044f')
|
Unique values within Pandas group of groups,"df.groupby(['country', 'gender'])['industry'].unique()"
|
Subsetting a 2D numpy array,"np.ix_([1, 2, 3], [1, 2, 3])"
|
Can a python script execute a function inside a bash script?,subprocess.call('test.sh otherfunc')
|
Convert string to numpy array,"print(np.array(list(mystr), dtype=int))"
|
is it possible to plot timelines with matplotlib?,ax.get_yaxis().set_ticklabels([])
|
How to get text for a root element using lxml?,print(etree.tostring(some_tag.find('strong')))
|
How to animate the colorbar in matplotlib,plt.show()
|
get path from a module name,imp.find_module('os')[1]
|
Dropping a single (sub-) column from a MultiIndex,"df.drop([('col1', 'a'), ('col2', 'b')], axis=1)"
|
python convert list to dictionary,"dict(zip(l[::2], l[1::2]))"
|
customize ticks for AxesImage?,"ax.set_xticklabels(['a', 'b', 'c', 'd'])"
|
Group by multiple time units in pandas data frame,dfts.groupby(lambda x: x.year).std()
|
Close a tkinter window?,root.destroy()
|
How can I convert a Python dictionary to a list of tuples?,"[(v, k) for k, v in d.items()]"
|
Get a filtered list of files in a directory,"files = [f for f in os.listdir('.') if re.match('[0-9]+.*\\.jpg', f)]"
|
"In Python, how to list all characters matched by POSIX extended regex `[:space:]`?","re.findall('\\s', chrs, re.UNICODE)"
|
List Comprehensions in Python : efficient selection in a list,[f(x) for x in list]
|
"Matplotlib's fill_between doesnt work with plot_date, any alternatives?",plt.show()
|
Parsing string containing Unicode character names,'M\\N{AMPERSAND}M\\N{APOSTROPHE}s'.encode().decode('unicode-escape')
|
How to add the second line of labels in matplotlib plot,plt.show()
|
sorting list of nested dictionaries in python,"sorted(yourdata, key=lambda d: d.get('key', {}).get('subkey'), reverse=True)"
|
Matplotlib: Formatting dates on the x-axis in a 3D Bar graph,plt.show()
|
Finding the minimum value in a numpy array and the corresponding values for the rest of that array's row,"a[np.argmin(a[:, (1)])]"
|
'List of lists' to 'list' without losing empty lists from the original list of lists,[''.join(l) for l in list_of_lists]
|
Python regex split case insensitive in 2.6,"re.compile('XYZ', re.IGNORECASE).split('fooxyzbar')"
|
How to create single Python dict from a list of dicts by summing values with common keys?,"dict((key, sum(d[key] for d in dictList)) for key in dictList[0])"
|
How to find contiguous substrings from a string in python,"['a', 'b', 'c', 'cc', 'd', 'dd', 'ddd', 'c', 'cc', 'e']"
|
Passing the '+' character in a POST request in Python,"f = urllib.request.urlopen(url, urllib.parse.unquote(urllib.parse.urlencode(params)))"
|
Subplots with dates on the x-axis,plt.xticks(rotation=30)
|
How do i visualize a connection Matrix with Matplotlib?,plt.show()
|
Capitalizing non-ASCII words in Python,print('\xc3\xa9'.decode('cp1252').capitalize())
|
Order a list by all item's digits in Python,"sorted(myList, key=dist)"
|
matplotlib: multiple plots on one figure,plt.show()
|
"Python, running command line tools in parallel","subprocess.call('command -flags arguments &', shell=True)"
|
"Python string formatting when string contains ""%s"" without escaping","""""""Day old bread, 50% sale {0}"""""".format('today')"
|
how to extract a subset of a colormap as a new colormap in matplotlib?,plt.show()
|
Removing nan values from an array,x = x[numpy.logical_not(numpy.isnan(x))]
|
How to add different graphs (as an inset) in another python graph,plt.show()
|
"How to capture a video (AND audio) in python, from a camera (or webcam)",cv2.destroyAllWindows()
|
Issue sending email with python?,"server = smtplib.SMTP('smtp.gmail.com', 587)"
|
determine if a list contains other lists,"any(isinstance(el, list) for el in input_list)"
|
Delete groups of rows based on condition,df.groupby('A').filter(lambda g: (g.B == 123).any())
|
How to store os.system() output in a variable or a list in python,os.system('echo X')
|
"how to count the repetition of the elements in a list python, django","[('created', 1), ('some', 2), ('here', 2), ('tags', 2)]"
|
How To Format a JSON Text In Python?,json_data = json.loads(json_string)
|
Python - print tuple elements with no brackets,"print(', ,'.join([str(i[0]) for i in mytuple]))"
|
Obtaining length of list as a value in dictionary in Python 2.7,"[(1, [1, 2, 3, 4]), (2, [5, 6, 7])]"
|
Create a hierarchy from a dictionary of lists,"t = sorted(list(a.items()), key=lambda x: x[1])"
|
Call a function with argument list in python,"func(*args, **kwargs)"
|
Accessing Python dict values with the key start characters,"[v for k, v in list(my_dict.items()) if 'Date' in k]"
|
Writing List of Strings to Excel CSV File in Python,csvwriter.writerow(row)
|
How can I do assignments in a list comprehension?,l = [[x for x in range(5)] for y in range(4)]
|
How to achieve two separate list of lists from a single list of lists of tuple with list comprehension?,"[[y for x, y in sublist] for sublist in l]"
|
matplotlib colorbar formatting,cb.ax.xaxis.set_major_formatter(plt.FuncFormatter(myfmt))
|
Merging data frame columns of strings into one single column in Pandas,"df.apply(' '.join, axis=1)"
|
Python - Create list with numbers between 2 values?,"list(range(11, 17))"
|
How to show matplotlib plots in python,plt.savefig('temp.png')
|
Numpy: How to check if array contains certain numbers?,"numpy.in1d(b, a)"
|
Django ORM query GROUP BY multiple columns combined by MAX,"MM.objects.all().values('b', 'a').annotate(max=Max('c'))"
|
for loop in Python,"list(range(1, 11))"
|
How to determine the order of bars in a matplotlib bar chart,df.ix[list('CADFEB')].plot(kind='barh')
|
How can I generalize my pandas data grouping to more than 3 dimensions?,"pd.concat([df2, df2], axis=1, keys=['tier1', 'tier2'])"
|
matplotlib: how to prevent x-axis labels from overlapping each other,plt.show()
|
Pandas - Plotting a stacked Bar Chart,"df2[['abuse', 'nff']].plot(kind='bar', stacked=True)"
|
Overlay imshow plots in matplotlib,plt.show()
|
How to remove gaps between subplots in matplotlib?,plt.show()
|
Image erosion and dilation with Scipy,"im = scipy.misc.imread('flower.png', flatten=True).astype(np.uint8)"
|
How to get data from R to pandas,"pd.DataFrame(data=[i[0] for i in x], columns=['X'])"
|
How to split up a string using 2 split parameters?,"re.findall('%(\\d+)l\\\\%\\((.*?)\\\\\\)', r)"
|
pandas dataframe groupby datetime month,df.groupby(pd.TimeGrouper(freq='M'))
|
How to fix a regex that attemps to catch some word and id?,'.*?\\b(nunca)\\s+(\\S+)\\s+[0-9.]+[\\r\\n]+\\S+\\s+(\\S+)\\s+(VM\\S+)\\s+[0-9.]+'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.