text
stringlengths 4
1.08k
|
|---|
Regex for removing data in parenthesis,"item = re.sub(' ?\\(\\w+\\)', '', item)"
|
Regex for removing data in parenthesis,"item = re.sub(' ?\\([^)]+\\)', '', item)"
|
How to parse DST date in Python?,"datetime.datetime(2013, 4, 25, 13, 32)"
|
Add SUM of values of two LISTS into new LIST,"[(x + y) for x, y in zip(first, second)]"
|
How to change the face color of a plot using Matplotlib,"ax.plot(x, y, color='g')"
|
Python GTK+ Canvas,Gtk.main()
|
Efficient serialization of numpy boolean arrays,"numpy.array(b).reshape(5, 5)"
|
"python: rstrip one exact string, respecting order","""""""Boat.txt.txt"""""".replace('.txt', '')"
|
Python lxml/beautiful soup to find all links on a web page,urls = html.xpath('//a/@href')
|
How do I pythonically set a value in a dictionary if it is None?,"count.setdefault('a', 0)"
|
How to split a word into letters in Python,""""""","""""".join('Hello')"
|
"how to change [1,2,3,4] to '1234' using python",""""""""""""".join([1, 2, 3, 4])"
|
How to click an element visible after hovering with selenium?,"driver.execute_script('$(""span.info"").click();')"
|
how to make arrow that loops in matplotlib?,plt.show()
|
Control a print format when printing a list in Python,"print('[' + ', '.join('%5.3f' % v for v in l) + ']')"
|
Python dict how to create key or append an element to key?,"dic.setdefault(key, []).append(value)"
|
Adding calculated column(s) to a dataframe in pandas,"df['isHammer'] = map(is_hammer, df['Open'], df['Low'], df['Close'], df['High'])"
|
How to read aloud Python List Comprehensions?,"[(x, y) for x in [1, 2, 3] for y in [3, 1, 4] if x != y]"
|
Most Pythonic Way to Create Many New Columns in Pandas,"df = pd.DataFrame(np.random.random((1000, 100)))"
|
Updating the x-axis values using matplotlib animation,plt.show()
|
python sum the values of lists of list,result = [sum(b) for b in a]
|
Conditionally fill a column of a pandas df with values of a different df,"df1.merge(df2, how='left', on='word')"
|
Convert string date to timestamp in Python,"time.mktime(datetime.datetime.strptime(s, '%d/%m/%Y').timetuple())"
|
python convert list to dictionary,"dict([['two', 2], ['one', 1]])"
|
Python regular expression with codons,"re.findall('TAA(?:[ATGC]{3})+?TAA', seq)"
|
Regular Expression to match a dot,"re.split('\\b\\w+\\.\\w+@', s)"
|
Get date from ISO week number in Python,"datetime.strptime('2011221', '%Y%W%w')"
|
Code to detect all words that start with a capital letter in a string,print([word for word in words if word[0].isupper()])
|
Delete Column in Pandas based on Condition,"df.loc[:, ((df != 0).any(axis=0))]"
|
Pythons fastest way of randomising case of a string,""""""""""""".join(x.upper() if random.randint(0, 1) else x for x in s)"
|
Dictionary to lowercase in Python,"dict((k.lower(), v) for k, v in {'My Key': 'My Value'}.items())"
|
How do you create a legend for a contour plot in matplotlib?,plt.show()
|
How to designate unreachable python code,raise ValueError('invalid gender %r' % gender)
|
How to convert datetime.date.today() to UTC time?,today = datetime.datetime.utcnow().date()
|
how to change the case of first letter of a string?,return s[0].upper() + s[1:]
|
Changing the referrer URL in python requests,"requests.get(url, headers={'referer': my_referer})"
|
Python: sorting a dictionary of lists,"[y[1] for y in sorted([(myDict[x][2], x) for x in list(myDict.keys())])]"
|
How can I get all the plain text from a website with Scrapy?,xpath('//body//text()').extract()
|
How to: django template pass array and use it in javascript?,"['Afghanistan', 'Japan', 'United Arab Emirates']"
|
What's the simplest way to extend a numpy array in 2 dimensions?,"array([[1, 2, 0], [3, 4, 0]])"
|
How to get output of exe in python script?,p1.communicate()[0]
|
"Reading tab-delimited file with Pandas - works on Windows, but not on Mac","pandas.read_csv(filename, sep='\t', lineterminator='\r')"
|
How to use cherrypy as a web server for static files?,cherrypy.quickstart()
|
Django: How to disable ordering in model,People.objects.all().order_by()
|
Fastest way to remove all multiple occurrence items from a list?,list_of_lists = [list(k) for k in list_of_tuples]
|
Python 2.7 : How to use BeautifulSoup in Google App Engine?,"sys.path.insert(0, 'libs')"
|
How to force os.system() to use bash instead of shell,"os.system('GREPDB=""echo 123""; /bin/bash -c ""$GREPDB""')"
|
"how to do a left,right and mid of a string in a pandas dataframe",df['state'].apply(lambda x: x[len(x) / 2 - 1:len(x) / 2 + 1])
|
How to count the number of a specific character at the end of a string ignoring duplicates?,len(my_text) - len(my_text.rstrip('?'))
|
"Regex to match 'lol' to 'lolllll' and 'omg' to 'omggg', etc","re.sub('g+', 'g', 'omgggg')"
|
pandas split string into columns,df['stats'].apply(pd.Series)
|
Python: How to order a list based on another list,"sorted(list1, key=lambda x: keyfun(x.split('-')[1], list2))"
|
How to return the regex that matches some text?,r = re.compile('(?P<int>^\\d+$)|(?P<word>^\\w+$)')
|
django models selecting single field,"Employees.objects.values_list('eng_name', 'rank')"
|
Feeding a Python array into a Perl script,"[1, 2, 3, 4, 5, 6]"
|
How do I add space between two variables after a print in Python,print(str(count) + ' ' + str(conv))
|
How do I merge a list of dicts into a single dict?,dict(pair for d in L for pair in list(d.items()))
|
how to set cookie in python mechanize,"br.addheaders = [('Cookie', 'cookiename=cookie value')]"
|
"Saving dictionary whose keys are tuples with json, python","json.dumps({str(k): v for k, v in data.items()})"
|
Manipulating binary data in Python,print(' '.join([str(ord(a)) for a in data]))
|
How to replace unicode characters in string with something else python?,str.decode('utf-8')
|
How to set environment variables in Python,os.environ['DEBUSSY'] = '1'
|
How to write a cell with multiple columns in xlwt?,"sheet.write(1, 1, 2)"
|
python - regex search and findall,"regex = re.compile('((\\d+,?)+)')"
|
how to export a table dataframe in pyspark to csv?,"df.save('mycsv.csv', 'com.databricks.spark.csv')"
|
Python: How to get PID by process name?,get_pid('chrome')
|
Custom Python list sorting,alist.sort(key=lambda x: x.foo)
|
How to apply a logical operator to all elements in a python list,all(a_list)
|
Substrings of a string using Python,"['a', 'ab', 'abc', 'abcd', 'b', 'bc', 'bcd', 'c', 'cd', 'd']"
|
set multi index of an existing data frame in pandas,"df = df.set_index(['Company', 'date'], inplace=True)"
|
Format the output of elasticsearch-py,"{'count': 836780, '_shards': {'successful': 5, 'failed': 0, 'total': 5}}"
|
Plotting arrows with different color in matplotlib,plt.show()
|
Python/Matplotlib - Is there a way to make a discontinuous axis?,"ax2.plot(x, y, 'bo')"
|
pandas: replace string with another string,df['prod_type'] = 'responsive'
|
Finding words after keyword in python,"re.search('name (\\w+)', s)"
|
Arrows in matplotlib using mplot3d,plt.show()
|
How can I make a scatter plot colored by density in matplotlib?,plt.show()
|
"python, unittest: is there a way to pass command line options to the app",unittest.main()
|
Reading utf-8 characters from a gzip file in python,"gzip.open('file.gz', 'rt', encoding='utf-8')"
|
Convert Python dict into a dataframe,"pd.DataFrame(list(d.items()), columns=['Date', 'DateValue'])"
|
Elegant way to convert list to hex string,"hex(int(''.join([str(int(b)) for b in walls]), 2))"
|
String formatting in Python: can I use %s for all types?,"""""""Integer: {}; Float: {}; String: {}"""""".format(a, b, c)"
|
Recursive delete in google app engine,"db.delete(Bottom.all(keys_only=True).filter('daddy =', top).fetch(1000))"
|
Python: transform a list of lists of tuples,"map(list, zip(*main_list))"
|
Plot only on continent in matplotlib,plt.show()
|
matplotlib large set of colors for plots,plt.show()
|
How to add an extra row to a pandas dataframe,"df.loc[len(df)] = ['8/19/2014', 'Jun', 'Fly', '98765']"
|
Combinatorial explosion while merging dataframes in pandas,"from functools import reduce
|
reduce(lambda x, y: x.combine_first(y), [df1, df2, df3])"
|
Convert date format python,"datetime.datetime.strptime('10/05/2012', '%d/%m/%Y').strftime('%Y-%m-%d')"
|
How to check if a value exists in a dictionary (python),'one' in iter(d.values())
|
Python Pandas: drop rows of a timeserie based on time range,df.query('index < @start_remove or index > @end_remove')
|
How to adjust the size of matplotlib legend box?,plt.show()
|
How can I copy the order of one array into another? [Python],B[np.argsort(A)] = np.sort(B)
|
How to create a DataFrame while preserving order of the columns?,"df = df[['foo', 'bar']]"
|
draw random element in numpy,"np.random.uniform(0, cutoffs[-1])"
|
How do you select choices in a form using Python?,[f.name for f in br.forms()]
|
python convert list to dictionary,"zip(['a', 'c', 'e'], ['b', 'd'])"
|
How can I insert data into a MySQL database?,conn.commit()
|
Replacing characters in a file,"newcontents = contents.replace('a', 'e').replace('s', '3')"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.