text
stringlengths 4
1.08k
|
|---|
Mean line on top of bar plot with pandas and matplotlib,plt.show()
|
Summing across rows of Pandas Dataframe,df2.reset_index()
|
Customize x-axis in matplotlib,ax.set_xlabel('Hours')
|
What is the best way to convert a SymPy matrix to a numpy array/matrix,np.array(g).astype(np.float64)
|
Python pandas dataframe: retrieve number of columns,len(df.index)
|
How to plot error bars in polar coordinates in python?,plt.show()
|
Change timezone of date-time column in pandas and add as hierarchical index,"dataframe.tz_localize('UTC', level=0)"
|
how to vectorise Pandas calculation that is based on last x rows of data,df.shift(365).rolling(10).B.mean()
|
django: Save image from url inside another model,"self.image.save('test.jpg', ContentFile(content), save=False)"
|
Python MySQL connector - unread result found when using fetchone,cursor = cnx.cursor(buffered=True)
|
"Python, Encoding output to UTF-8",f.write(s.encode('utf8'))
|
How can I parse JSON in Google App Engine?,obj = json.loads(string)
|
matplotlib axis label format,"ax1.ticklabel_format(axis='y', style='sci', scilimits=(-2, 2))"
|
Create a permutation with same autocorrelation,"np.corrcoef(x[0:len(x) - 1], x[1:])[0][1]"
|
Print variable line by line with string in front Python 2.7,print('\n'.join(formatted))
|
Delete multiple dictionaries in a list,[i for i in Records if i['Price']]
|
sorting a list of dictionary values by date in python,"rows.sort(key=itemgetter(1), reverse=True)"
|
python How do you sort list by occurrence with out removing elements from the list?,"sorted(lst, key=lambda x: (c[x], x), reverse=True)"
|
Dividing a string at various punctuation marks using split(),""""""""""""".join(char if char.isalpha() else ' ' for char in test).split()"
|
Converting Indices of Series to Columns,pd.DataFrame(s).T
|
Pull Tag Value using BeautifulSoup,"print(soup.find('span', {'class': 'thisClass'})['title'])"
|
Show me some cool python list comprehensions,[i for i in range(10) if i % 2 == 0]
|
Implementing a Kolmogorov Smirnov test in python scipy,"stats.kstest(np.random.normal(0, 1, 10000), 'norm')"
|
Import a module in Python,__init__.py
|
How to draw line inside a scatter plot,ax.set_ylabel('TPR or sensitivity')
|
How to get reproducible results in keras,srng.seed(902340)
|
How to write binary data in stdout in python 3?,sys.stdout.buffer.write('some binary data')
|
"Python, add items from txt file into a list",names = [line.strip() for line in open('names.txt')]
|
Import an image as a background in Tkinter,background_image = Tk.PhotoImage(file='C:/Desktop/logo.gif')
|
PyV8 in threads - how to make it work?,t.start()
|
Element-wise minimum of multiple vectors in numpy,"np.minimum.accumulate([np.arange(3), np.arange(2, -1, -1), np.ones((3,))])"
|
"How to construct relative url, given two absolute urls in Python","os.path.relpath('/images.html', os.path.dirname('/faq/index.html'))"
|
Row-to-Column Transposition in Python,"zip([1, 2, 3], [4, 5, 6])"
|
Parsing JSON with python: blank fields,entries['extensions'].get('telephone')
|
Sending JSON request with Python,"json.dumps(data).replace('""', '')"
|
Python pandas: how to run multiple univariate regression by group,"df.grouby('grp').apply(ols_res, xcols=['x1', 'x2'], ycol='y')"
|
Matplotlib: -- how to show all digits on ticks?,plt.gca().xaxis.set_major_formatter(FixedFormatter(ll))
|
Matching id's in BeautifulSoup,"print(soupHandler.findAll('div', id=re.compile('^post-')))"
|
How can I kill a thread in python,thread.exit()
|
How do I use user input to invoke a function in Python?,"{'func1': func1, 'func2': func2, 'func3': func3}.get(choice)()"
|
Django: Detecting changes of a set of fields when a model is saved,"super(Model, self).save(*args, **kwargs)"
|
Convert sets to frozensets as values of a dictionary,"d = {k: frozenset(v) for k, v in list(d.items())}"
|
How to update the image of a Tkinter Label widget?,root.mainloop()
|
Sort a list of tuples by 2nd item (integer value),"sorted(data, key=itemgetter(1))"
|
"Downloading an image, want to save to folder, check if file exists","urllib.request.urlretrieve('http://stackoverflow.com', filename)"
|
Pandas - make a column dtype object or Factor,df['col_name'] = df['col_name'].astype('category')
|
How do I strftime a date object in a different locale?,"locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')"
|
Python Requests getting SSLerror,"requests.get('https://www.reporo.com/', verify='chain.pem')"
|
Remove all occurrences of words in a string from a python list,""""""" """""".join([i for i in word_list if i not in remove_list])"
|
how to read a csv file in reverse order in python,"print(', '.join(row))"
|
How do I keep the JSON key order fixed with Python 3 json.dumps?,"print(json.dumps(data, indent=2, sort_keys=True))"
|
How can I get the list of names used in a formatting string?,get_format_vars('hello %(foo)s there %(bar)s')
|
Adding custom fields to users in django,"middle_name = models.CharField(max_length=30, null=True, blank=True)"
|
pandas + dataframe - select by partial string,df[df['A'].str.contains('hello')]
|
Making a python program wait until Twisted deferred returns a value,reactor.run()
|
How to use sklearn fit_transform with pandas and return dataframe instead of numpy array?,df.head(3)
|
Is there a python method to re-order a list based on the provided new indices?,L = [L[i] for i in ndx]
|
How can I retrieve the TLS/SSL peer certificate of a remote host using python?,"print(ssl.get_server_certificate(('server.test.com', 443)))"
|
Setting timezone in Python,time.strftime('%X %x %Z')
|
How to pause and wait for command input in a python script,variable = input('input something!: ')
|
How to check if string is a pangram?,is_pangram = lambda s: not set('abcdefghijklmnopqrstuvwxyz') - set(s.lower())
|
Format string - spaces between every three digit,"""""""{:,}"""""".format(12345678.46)"
|
How do I translate a ISO 8601 datetime string into a Python datetime object?,yourdate = dateutil.parser.parse(datestring)
|
How to get first element in a list of tuples?,"[1, 2]"
|
Pandas - Plotting series,"pd.concat([rng0, rng1, rng2, rng3, rng4, rng5], axis=1).T.plot()"
|
Get often occuring string patterns from column in R or Python,"[('okay', 5), ('bla', 5)]"
|
Creating your own contour in opencv using python,cv2.waitKey(0)
|
"Find the maximum x,y value fromn a series of images","x = np.maximum(x, y)"
|
Converting a dictionary into a list,list(flatten(elements))
|
Calcuate mean for selected rows for selected columns in pandas data frame,"df[['b', 'c']].iloc[[2, 4]].mean(axis=0)"
|
Writing UTF-8 String to MySQL with Python,"conn = MySQLdb.connect(charset='utf8', init_command='SET NAMES UTF8')"
|
Pandas - Data Frame - Reshaping Values in Data Frame,"df.set_index(['row_id', 'Game_ID']).unstack(level=0).sortlevel(level=1, axis=1)"
|
How to sort tire sizes in python,"['235/40/17', '285/30/18', '315/25/19', '275/30/19', '285/30/19']"
|
python program to read a matrix from a given file,"l = [map(int, line.split(',')) for line in f if line.strip() != '']"
|
How do I disable log messages from the Requests library?,logging.getLogger('requests').setLevel(logging.WARNING)
|
How do I include unicode strings in Python doctests?,mylen('\xe1\xe9\xed\xf3\xfa')
|
Best way to abstract season/show/episode data,self.__class__.__name__
|
Python: Listen on two ports,time.sleep(1)
|
Writing Unicode text to a text file?,f.close()
|
How do I abort a socket.recvfrom() from another thread in python?,"self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)"
|
Default fonts in Seaborn statistical data visualization in iPython,sns.set(font='Verdana')
|
Python string slice indices - slice to end of string,word[1:]
|
How do I convert LF to CRLF?,"txt.replace('\n', '\r\n')"
|
drop column based on a string condition,"df.drop(df.columns[df.columns.str.match('chair')], axis=1)"
|
Additional empty elements when splitting a string with re.split,"re.findall('\\w+="".*?""', comp)"
|
How to programmatically tell Celery to send all log messages to stdout or stderr?,my_handler = logging.StreamHandler(sys.stdout)
|
Python gzip: is there a way to decompress from a string?,"open(filename, mode='rb', compresslevel=9)"
|
How to Print next year from current year in Python,print(date.today().year + 1)
|
Norm along row in pandas,"df.apply(lambda x: np.sqrt(x.dot(x)), axis=1)"
|
Accessing a decorator in a parent class from the child in Python,"super(otherclass, self).__init__()"
|
Data Frame Indexing,"p_value = pd.DataFrame(np.zeros((2, 2), dtype='float'), columns=df.columns)"
|
Print the concatenation of the digits of two numbers in Python,print(str(2) + str(1))
|
format ints into string of hex,""""""""""""".join('%02x' % i for i in input)"
|
How to filter a query by property of user profile in Django?,designs = Design.objects.filter(author__user__profile__screenname__icontains=w)
|
pythonic way to associate list elements with their indices,"d = dict((y, x) for x, y in enumerate(t))"
|
Getting the first elements per row in an array in Python?,zip(*s)[0]
|
Truth value of numpy array with one falsey element seems to depend on dtype,"np.array(['a', 'b']) != 0"
|
django-rest-swagger: how to group endpoints?,"url('^api/', include('api.tasks.urls'), name='my-api-root'),"
|
how to extract nested lists?,list(chain.from_iterable(list_of_lists))
|
How to disable a widget in Kivy?,MyApp().run()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.