text
stringlengths 4
1.08k
|
|---|
convert unicode cyrillic symbols to string in python,a.encode('utf-8')
|
writing a binary buffer to a file in python,myfile.write(c_uncompData_p[:c_uncompSize])
|
python: a complete list of modules,list(sys.modules.keys())
|
how to print variables without spaces between values,"print('Value is ""{}""'.format(value))"
|
python pandas: how to move one row to the first row of a dataframe?,"df = pd.DataFrame(np.random.randn(10, 5), columns=['a', 'b', 'c', 'd', 'e'])"
|
best way to find first non repeating character in a string,[a for a in s if s.count(a) == 1][0]
|
how can i set the mouse position in a tkinter window,root.mainloop()
|
"if i have this string in python, how do i decode it?",urllib.parse.unquote(string)
|
convert 3652458 to string represent a 32bit hex number,"""""""0x{0:08X}"""""".format(3652458)"
|
print leading zeros of a floating point number,"print('%02i,%02i,%05.3g' % (3, 4, 5.66))"
|
python pandas: how to run multiple univariate regression by group,"df.grouby('grp').apply(ols_res, ['x1', 'x2'], 'y')"
|
sub matrix of a list of lists (without numpy),"[[2, 3, 4], [2, 3, 4], [2, 3, 4]]"
|
python: how to count overlapping occurrences of a substring,"len([_ for s in re.finditer('(?=aa)', 'aaa')])"
|
valueerror: setting an array element with a sequence,"numpy.array([[1, 2], [2, [3, 4]]])"
|
problems trying to format currency with python (django),"locale.setlocale(locale.LC_ALL, '')"
|
replacing characters in a file,"newcontents = contents.replace('a', 'e').replace('s', '3')"
|
check if a value exists in pandas dataframe index,'g' in df.index
|
how to use the user_passes_test decorator in class based views?,"return super(UserSettingsView, self).dispatch(*args, **kwargs)"
|
python/matplotlib - is there a way to make a discontinuous axis?,ax2.spines['left'].set_visible(False)
|
conversion of bytes to string,binascii.b2a_hex('\x02P\x1cA\xd1\x00\x00\x02\xcb\x11\x00').decode('ascii')
|
pandas dataframe to list,df['a'].tolist()
|
python: a4 size for a plot,"f.set_size_inches(11.69, 8.27)"
|
"python, print delimited list",""""""","""""".join(map(str, a))"
|
remove list of indices from a list in python,"[element for i, element in enumerate(centroids) if i not in index]"
|
selecting from multi-index pandas,df.iloc[df.index.get_level_values('A') == 1]
|
converting integer to list in python,list(str(123))
|
how to check if type of a variable is string?,"isinstance(s, str)"
|
splitting on last delimiter in python string?,"s.rsplit(',', 1)"
|
python beautifulsoup extract specific urls,"soup.find_all('a', href=re.compile('^(?!(?:[a-zA-Z][a-zA-Z0-9+.-]*:|//))'))"
|
matching 2 regular expressions in python,"re.match('^(a+)+$', 'a' * 24 + '!')"
|
generating a csv file online on google app engine,"writer.writerow(['Date', 'Time', 'User'])"
|
replace console output in python,sys.stdout.write('\rDoing thing %i' % i)
|
setting a clip on a seaborn plot,"sns.kdeplot(x=points['x_coord'], y=points['y_coord'], ax=ax)"
|
generate a random integer between 0 and 9,"randint(0, 9)"
|
replace extension '.txt' in basename '/home/user/somefile.txt' with extension '.jpg',print(os.path.splitext('/home/user/somefile.txt')[0] + '.jpg')
|
read and overwrite a file in python,f.close()
|
django rest framework - using detail_route and detail_list,"return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)"
|
how to remove rows with null values from kth column onward in python,subset = [x for x in df2.columns if len(x) > 3]
|
check if string 'a b' only contains letters and spaces,"""""""a b"""""".replace(' ', '').isalpha()"
|
python: intersection indices numpy array,"numpy.in1d(a, b)"
|
internals for python tuples,"1, 5, None, (1, 5), (1, 5)"
|
finding superstrings in a set of strings in python,"['136 139 277 24', '246']"
|
get a list of of elements resulting from splitting user input by commas and stripping white space from each resulting string `s`,"[s.strip() for s in input().split(',')]"
|
"check if tuple (2, 3) is not in a list [(2, 3), (5, 6), (9, 1)]","((2, 3) not in [(2, 3), (5, 6), (9, 1)])"
|
making a list of evenly spaced numbers in a certain range in python,"np.linspace(0, 5, 10)"
|
numpy: sorting a multidimensional array by a multidimensional array,"a[[[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]]]"
|
how to run an applescript from within a python script?,os.system(cmd)
|
python list sorting dependant on if items are in another list,"sorted([True, False, False])"
|
removing white space from txt with python,"print(re.sub('(\\S)\\ {2,}(\\S)(\\n?)', '\\1|\\2\\3', s))"
|
get the last element in list `alist`,alist[(-1)]
|
how to filter by sub-level index in pandas,df[df.index.map(lambda x: x[1].endswith('0630'))]
|
how to write to an existing excel file without overwriting data (using pandas)?,"writer = pd.ExcelWriter(excel_file, engine='openpyxl')"
|
"how do i convert all strings (like ""fault"") and into a unique float?",(s.factorize()[0] + 1).astype('float')
|
python mysql escape special characters,sql = 'UPGRADE inventory_server set server_mac = %s where server_name = %s'
|
python regex to match multiple times,"pattern = re.compile('review: (http://url.com/(\\d+)\\s?)+', re.IGNORECASE)"
|
find rows with non zero values in a subset of columns where `df.dtypes` is not equal to `object` in pandas dataframe,"df.loc[(df.loc[:, (df.dtypes != object)] != 0).any(1)]"
|
sort dictionary of dictionaries `dic` according to the key 'fisher',"sorted(list(dic.items()), key=lambda x: x[1]['Fisher'], reverse=True)"
|
replace non-ascii chars from a unicode string u'm\xfasica',"unicodedata.normalize('NFKD', 'm\xfasica').encode('ascii', 'ignore')"
|
pandas - fillna with another column,df['Cat1'].fillna(df['Cat2'])
|
best way to format integer as string with leading zeros?,str(1).zfill(2)
|
sort tuples based on second parameter,my_list.sort(key=lambda x: x[1])
|
unescaping escaped characters in a string using python 3.2,s.encode('utf8')
|
how do i detect if python is running as a 64-bit application?,platform.architecture()
|
how to get a max string length in nested lists,max(len(word) for word in i)
|
how to replace each array element by 4 copies in python?,"[[1, 1, 2, 2], [1, 1, 2, 2], [3, 3, 4, 4], [3, 3, 4, 4]]"
|
pythonic way to write a for loop that doesn't use the loop index,"['_', 'empty', 'unused', 'dummy']"
|
how to read multiple files and merge them into a single pandas data frame?,dfs = pd.concat([pd.read_csv('data/' + f) for f in files])
|
how do i parse xml in python?,print(atype.get('foobar'))
|
python- find unmatched values from multiple lists,eliminated.append(x)
|
issue with pandas boxplot within a subplot,"df.pivot('val', 'day', 'val').boxplot(ax=ax)"
|
how to remove single space between text,"""""""S H A N N O N B R A D L E Y"""""".replace(' ', ' ')[::2]"
|
wxpython: how to make a textctrl fill a panel,self.SetSizerAndFit(bsizer)
|
editing the xml texts from a xml file using python,"open('output.xml', 'wb').write(dom.toxml())"
|
format timedelta using string variable,"'timedelta(%s=%d)' % ('days', 2)"
|
is there a reason for python regex not to compile r'(\s*)+'?,"re.compile('(\\s{0,})+')"
|
convert list of tuples to list?,list(chain.from_iterable(a))
|
read an excel file 'componentreport-dji.xls',"open('ComponentReport-DJI.xls', 'rb').read(200)"
|
i'm looking for a pythonic way to insert a space before capital letters,"re.sub('(?<=\\w)([A-Z])', ' \\1', 'WordWordWWWWWWWord')"
|
pandas: pivoting with multi-index data,"res.pivot(index='Own', columns='Brand', values='Rating')"
|
how to calculate a column in a row using two columns of the previous row in spark data frame?,df.show()
|
finding consecutive segments in a pandas data frame,df.reset_index().groupby('A')['index'].apply(np.array)
|
numpy: find index of elements in one array that occur in another array,"np.where(np.in1d(A, B))[0]"
|
transposing part of a pandas dataframe,df.fillna(0)
|
how can i sum the product of two list items using for loop in python?,"list(zip(a, b))"
|
python: find in list,"3 in [1, 2, 3]"
|
how to check if a file is a directory or regular file in python?,os.path.isfile('bob.txt')
|
convert a list to a dictionary in python,"a = ['bi', 'double', 'duo', 'two']"
|
json in python: how do i get specific parts of an array?,[1505]
|
convert unicode/utf-8 string to lower/upper case using pure & pythonic library,print('\xc4\x89'.decode('utf-8').upper())
|
python string to list best practice,"ast.literal_eval('""hello""+"" world""')"
|
python how do you sort list by occurrence with out removing elements from the list?,"sorted(lst, key=lambda x: (-counts[x], firstidx[x]))"
|
store different datatypes in one numpy array?,"array([('a', 0), ('b', 1)], dtype=[('keys', '|S1'), ('data', '<i8')])"
|
viewing the content of a spark dataframe column,df.select('zip_code').collect()
|
accessing dictionary by key in django template,{{json.key1}}
|
extracting date from a string in python,"dparser.parse('monkey 20/01/1980 love banana', fuzzy=True)"
|
"copy file ""/dir/file.ext"" to ""/new/dir/newname.ext""","shutil.copy2('/dir/file.ext', '/new/dir/newname.ext')"
|
"call a python script ""test1.py""","subprocess.call('test1.py', shell=True)"
|
clear text from textarea 'foo' with selenium,driver.find_element_by_id('foo').clear()
|
for loop in python,list(range(10))
|
python pandas: how to get the row names from index of a dataframe?,list(df.index)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.