text
stringlengths 4
1.08k
|
|---|
How do I print out just the word itself in a WordNet synset using Python NLTK?,[synset.name.split('.')[0] for synset in wn.synsets('dog')]
|
Take data from a circle in python,plt.show()
|
How to print particular JSON value in Python?,"{'X': 'value1', 'Y': 'value2', 'Z': [{'A': 'value3', 'B': 'value4'}]}"
|
Parsing a tweet to extract hashtags into an array in Python,"re.findall('#(\\w+)', s)"
|
How to make a simple command-line chat in Python?,sys.exit(0)
|
Make subprocess find git executable on Windows,"proc = subprocess.Popen(['git', 'status'], stdout=subprocess.PIPE)"
|
reverse mapping of dictionary with Python,"revdict = dict((v, k) for k, v in list(ref.items()))"
|
How can I add the corresponding elements of several lists of numbers?,zip(*lists)
|
Conditional removing of duplicates pandas python,"df.drop_duplicates(['Col1', 'Col2'])"
|
MatPlotLib: Multiple datasets on the same scatter plot,plt.show()
|
Convert an RFC 3339 time to a standard Python timestamp,"dt.datetime.strptime('1985-04-12T23:20:50.52', '%Y-%m-%dT%H:%M:%S.%f')"
|
How can I convert a unicode string into string literals in Python 2.7?,"print(re.sub('\u032f+', '\u032f', unicodedata.normalize('NFKD', s)))"
|
creating a matplotlib scatter legend size related,plt.show()
|
Convert a list to a dictionary in Python,"dict((k, 2) for k in a)"
|
How to redirect 'print' output to a file using python?,f.close()
|
sum parts of numpy.array,"a[:, ::2] + a[:, 1::2]"
|
Iterate over matrices in numpy,np.array(list(g))
|
Creating a screenshot of a gtk.Window,win.show_all()
|
Box around text in matplotlib,plt.show()
|
How to determine a numpy-array reshape strategy,"arr = np.arange(3 * 4 * 5).reshape(3, 4, 5)"
|
Sorting in python - how to sort a list containing alphanumeric values?,list1.sort(key=convert)
|
Best way to find first non repeating character in a string,[a for a in s if s.count(a) == 1][0]
|
Removing backslashes from string,"print(""\\I don't know why ///I don't have the right answer\\"".strip('/'))"
|
Python: intersection indices numpy array,"numpy.nonzero(numpy.in1d(a, b))"
|
How do I run Selenium in Xvfb?,browser.quit()
|
Pythonic way to print list items,print(''.join([str(x) for x in l]))
|
Implementing a popularity algorithm in Django,Link.objects.all().order_by('-popularity')
|
"Matplotlib subplot title, figure title formatting",plt.subplots_adjust(top=0.75)
|
Disabling committing object changes in SQLAlchemy,session.commit()
|
How can I get the name of an object in Python?,"dict([(t.__name__, t) for t in fun_list])"
|
Cheapest way to get a numpy array into C-contiguous order?,"x = numpy.asarray(x, order='C')"
|
Can I get JSON to load into an OrderedDict in Python?,"data = json.load(open('config.json'), object_pairs_hook=OrderedDict)"
|
How to remove single space between text,"""""""S H A N N O N B R A D L E Y"""""".replace(' ', ' ')[::2]"
|
Difference between these array shapes in numpy,"np.squeeze(np.array([[1], [2], [3]])).shape"
|
sort a list of tuples alphabetically and by value,"sorted(temp, key=itemgetter(1), reverse=True)"
|
How to do a regex replace with matching case?,"re.sub('\\bfoo\\b', cased_replacer('bar'), 'this is foo', flags=re.I)"
|
Pandas DataFrame to list,list(set(df['a']))
|
Remove strings containing only white spaces from list,l = [x for x in l if x.strip()]
|
How to find elements by class,"soup.find_all('a', class_='sister')"
|
how to get user email with python social auth with facebook and save it,SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
|
argsort for a multidimensional ndarray,"a[np.arange(np.shape(a)[0])[:, (np.newaxis)], np.argsort(a)]"
|
Split an array dependent on the array values in Python,"array([[1, 6], [2, 6], [3, 8], [4, 10], [5, 6], [5, 7]])"
|
Drawing a correlation graph in matplotlib,plt.gcf().savefig('correlation.png')
|
Write to UTF-8 file in Python,file.write('\ufeff')
|
Building up an array in numpy/scipy by iteration in Python?,"array([0, 1, 4, 9, 16])"
|
selecting attribute values from lxml,print(customer.xpath('./@NAME')[0])
|
An elegant way to get hashtags out of a string in Python?,set([i[1:] for i in line.split() if i.startswith('#')])
|
Adding up all columns in a dataframe,df['sum'] = df.sum(axis=1)
|
Convert scientific notation to decimal - python,print('Number is: %.8f' % float(a[0] / a[1]))
|
"Python: date, time formatting",time.strftime('%x %X %z')
|
Best way to structure a tkinter application,root.mainloop()
|
"copy 2D array into 3rd dimension, N times (Python)","c = np.array([1, 2, 3])"
|
Python : How to remove duplicate lists in a list of list?,b.sort(key=lambda x: a.index(x))
|
How do I set cell values in `np.array()` based on condition?,"np.put(arr, np.where(~np.in1d(arr, valid))[0], 0)"
|
How to subset a data frame using Pandas based on a group criteria?,df.groupby('User')['X'].filter(lambda x: x.sum() == 0).index
|
Python numpy 2D array indexing,"b[a[1, 1]]"
|
How can I increase the frequency of xticks/ labels for dates on a bar plot?,plt.show()
|
How to use opencv (python) to blur faces?,"cv2.imwrite('./result.png', result_image)"
|
Python match a string with regex,"re.search('sample', line)"
|
How do you split a string at a specific point?,"[1, 2, 3, 4, 5, 4, 3, 2, 6]"
|
Sum one row of a NumPy array,"z = arr[:, (5)].sum()"
|
Change permissions via ftp in python,ftp.quit()
|
How to do Pearson correlation of selected columns of a Pandas data frame,data[data.columns[1:]].corr()['special_col'][:-1]
|
Python: Shifting elements in a list to the right and shifting the element at the end of the list to the beginning,"[5, 1, 2, 3, 4]"
|
How to add a new div tag in an existing html file after a h1 tag using python,htmlFile = open('path to html file').read()
|
Python: Value of dictionary is list of strings,ast.literal_eval(reclist)
|
"Sort a list of tuples by second value, reverse=True and then by key, reverse=False","sorted(d, key=lambda x: (-x[1], x[0]))"
|
How to get names of all the variables defined in methods of a class,"['setUp', 'bar', 'baz', 'var1', 'var2', 'var3', 'var4']"
|
How to append a dictionary to a pandas dataframe?,"df.append(new_df, ignore_index=True)"
|
How can I join a list into a string (caveat)?,"print(""that's interesting"".encode('string_escape'))"
|
Pandas changing cell values based on another cell,df.sort_index(inplace=True)
|
How can i extract only text in scrapy selector in python,"site = hxs.select(""//h1[@class='state']/text()"")"
|
Comparing elements between elements in two lists of tuples,set(x[0] for x in list1).intersection(y[0] for y in list2)
|
change the number of colors in matplotlib stylesheets,"plt.plot([10, 11, 12], 'y')"
|
use xml.etree.elementtree to write out nicely formatted xml files,"print(etree.tostring(root, pretty_print=True))"
|
python3 datetime.datetime.strftime failed to accept utf-8 string format,strftime('%Y{0}%m{1}%d{2}').format(*'\xe5\xb9\xb4\xe6\x9c\x88\xe6\x97\xa5')
|
"In Python, how can I get the correctly-cased path for a file?",win32api.GetLongPathName(win32api.GetShortPathName('stopservices.vbs'))
|
String formatting named parameters?,"print('<a href=""%(url)s"">%(url)s</a>' % {'url': my_url})"
|
Slice a string after a certain phrase?,"string.split(pattern, 1)[0]"
|
How do I order fields of my Row objects in Spark (Python),"rdd.toDF(['foo', 'bar'])"
|
Capturing group with findall?,"re.findall('(1(23))45', '12345')"
|
Creating a Browse Button with TKinter,root.mainloop()
|
How can I order a list of connections,"[4, 6, 5, 3, 7, 8], [1, 2]"
|
pymongo sorting by date,"db.posts.find().sort('date', -1)"
|
Find out if there is input from a pipe or not in Python?,sys.stdin.isatty()
|
Load module from string in python,sys.modules['mymodule'] = mymodule
|
"In python 2.4, how can I execute external commands with csh instead of bash?",os.system('echo $SHELL')
|
How to terminate process from Python using pid?,"os.kill(pid, signal.SIGTERM)"
|
Proxies with Python 'Requests' module,"r = requests.get(url, headers=headers, proxies=proxyDict)"
|
Validate a filename in python,"return os.path.join(directory, filename)"
|
What is a good size (in bytes) for a log file?,"RotatingFileHandler(filename, maxBytes=10 * 1024 * 1024, backupCount=5)"
|
Splitting a list into uneven groups?,"[[1, 2], [3, 4, 5, 6], [], []]"
|
Regenerate vector of randoms in Python,"np.random.normal(0, 1, (100, 3))"
|
How to run webpage code with PhantomJS via GhostDriver (selenium),driver.get('http://stackoverflow.com')
|
Insert variable into global namespace from within a function?,globals()['var'] = 'an object'
|
Label data when doing a scatter plot in python,plt.legend()
|
sorted() with lambda function,lambda x: int(x.partition('/')[0][2:])
|
How do I reverse Unicode decomposition using Python?,"print(unicodedata.normalize('NFC', 'c\u0327'))"
|
How to find a missing number from a list,a[-1] * (a[-1] + a[0]) / 2 - sum(a)
|
Python: How to sort a list of dictionaries by several values?,"sorted(your_list, key=itemgetter('name', 'age'))"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.