text
stringlengths 4
1.08k
|
|---|
"get the <a href=""http://en.wikipedia.org/wiki/ASCII"" rel=""nofollow noreferrer"">ASCII</a> value of a character as an int",ord('a')
|
"get the <a href=""http://en.wikipedia.org/wiki/ASCII"" rel=""nofollow noreferrer"">ASCII</a> value of a character as an int",ord('\u3042')
|
"get the <a href=""http://en.wikipedia.org/wiki/ASCII"" rel=""nofollow noreferrer"">ASCII</a> value of a character as an int",ord()
|
decode JSON,json.load(u)
|
Deleting mulitple columns in Pandas,"yourdf.drop(['columnheading1', 'columnheading2'], axis=1, inplace=True)"
|
How to read formatted input in python?,"[s.strip() for s in input().split(',')]"
|
Convert binary to list of digits Python,[int(d) for d in str(bin(x))[2:]]
|
How to get a max string length in nested lists,max(len(word) for word in i)
|
How to get a max string length in nested lists,"len(max(i, key=len))"
|
Python: How to Redirect Output with Subprocess?,os.system(my_cmd)
|
How do I sort a list of strings in Python?,mylist.sort(key=lambda x: x.lower())
|
How do I sort a list of strings in Python?,mylist.sort(key=str.lower)
|
How do I sort a list of strings in Python?,mylist.sort()
|
How do I sort a list of strings in Python?,list.sort()
|
set multi index of an existing data frame in pandas,"df.set_index(['Company', 'date'], inplace=True)"
|
How can I use a string with the same name of an object in Python to access the object itself?,"getattr(your_obj, x)"
|
Remove the first word in a Python string?,"s.split(' ', 1)[1]"
|
How to save Xlsxwriter file in certain path?,workbook = xlsxwriter.Workbook('app/smth1/smth2/Expenses01.xlsx')
|
How to save Xlsxwriter file in certain path?,workbook = xlsxwriter.Workbook('C:/Users/Steven/Documents/demo.xlsx')
|
How to change legend size with matplotlib.pyplot,"pyplot.legend(loc=2, fontsize='x-small')"
|
How to change legend size with matplotlib.pyplot,"plot.legend(loc=2, prop={'size': 6})"
|
How do you split a list into evenly sized chunks?,"[l[i:i + n] for i in range(0, len(l), n)]"
|
How do you split a list into evenly sized chunks?,"[l[i:i + n] for i in range(0, len(l), n)]"
|
How to check if character exists in DataFrame cell,df['a'].str.contains('-')
|
Python Regex - Remove special characters but preserve apostraphes,"re.sub(""[^\\w' ]"", '', ""doesn't this mean it -technically- works?"")"
|
find all digits between a character in python,"print(re.findall('\\d+', '\n'.join(re.findall('\xab([\\s\\S]*?)\xbb', text))))"
|
Use index in pandas to plot data,"monthly_mean.reset_index().plot(x='index', y='A')"
|
How to get data from command line from within a Python program?,"subprocess.check_output('echo ""foo""', shell=True)"
|
Easy way to convert a unicode list to a list containing python strings?,[x.encode('UTF8') for x in EmployeeList]
|
pandas: combine two columns in a DataFrame,"pandas.concat([df['foo'].dropna(), df['bar'].dropna()]).reindex_like(df)"
|
How can I generate a list of consecutive numbers?,list(range(9))
|
"How to make a Python string out of non-ascii ""bytes""",""""""""""""".join(chr(i) for i in myintegers)"
|
Using inheritance in python,"super(Executive, self).__init__(*args)"
|
Removing items from unnamed lists in Python,[item for item in my_sequence if item != 'item']
|
randomly select an item from a list,random.choice(foo)
|
Python Check if all of the following items is in a list,"set(['a', 'b']).issubset(['a', 'b', 'c'])"
|
Python Check if all of the following items is in a list,"set(['a', 'b']).issubset(set(l))"
|
pass a string into subprocess.Popen,"p = Popen(['grep', 'f'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
|
grep_stdout = p.communicate(input='one\ntwo\nthree\nfour\nfive\nsix\n')[0]"
|
Most pythonic way to convert a list of tuples,[list(t) for t in zip(*list_of_tuples)]
|
Most pythonic way to convert a list of tuples,zip(*list_of_tuples)
|
simple/efficient way to expand a pandas dataframe,"pd.merge(y, x, on='k')[['a', 'b', 'y']]"
|
Splitting string and removing whitespace Python,"[item.strip() for item in my_string.split(',')]"
|
Get all object attributes,print((obj.__dict__))
|
Get all object attributes,dir()
|
Get all object attributes,dir()
|
How to center a window with PyGObject,window.set_position(Gtk.WindowPosition.CENTER)
|
how to change the size of the sci notation above the y axis in matplotlib?,"plt.rc('font', **{'size': '30'})"
|
Python pandas: check if any value is NaN in DataFrame,df.isnull().values.any()
|
Python - use list as function parameters,some_func(*params)
|
How to decode encodeURIComponent in GAE (python)?,urllib.parse.unquote(h.path.encode('utf-8')).decode('utf-8')
|
Percentage match in pandas Dataframe,(trace_df['ratio'] > 0).mean()
|
How to convert a tuple to a string in Python?,emaillist = '\n'.join(item[0] for item in queryresult)
|
How to convert a tuple to a string in Python?,[item[0] for item in queryresult]
|
How to convert a tuple to a string in Python?,emaillist = '\n'.join([item[0] for item in queryresult])
|
Python get focused entry name,"print(('focus object class:', window2.focus_get().__class__))"
|
How to declare an array in python,a = [0] * 10000
|
How can I remove duplicate words in a string with Python?,"print(' '.join(sorted(set(words), key=words.index)))"
|
How to generate random numbers that are different?,"random.sample(range(1, 50), 6)"
|
How to generate random numbers that are different?,"random.sample(range(1, 50), 6)"
|
Dictionary to lowercase in Python,"{k.lower(): v.lower() for k, v in list({'My Key': 'My Value'}.items())}"
|
Dictionary to lowercase in Python,"dict((k.lower(), v) for k, v in {'My Key': 'My Value'}.items())"
|
Dictionary to lowercase in Python,"dict((k.lower(), v.lower()) for k, v in {'My Key': 'My Value'}.items())"
|
sorting list of list in python,[sorted(item) for item in data]
|
Is there a way to get a list of column names in sqlite?,"names = list(map(lambda x: x[0], cursor.description))"
|
finding out absolute path to a file from python,os.path.abspath(__file__)
|
how to sort 2d array by row in python?,"sorted(matrix, key=itemgetter(1))"
|
Finding index of the same elements in a list,"[index for index, letter in enumerate(word) if letter == 'e']"
|
How to print container object with unicode-containing values?,print(str(x).decode('raw_unicode_escape'))
|
Python regular expressions - how to capture multiple groups from a wildcard expression?,"re.findall('\\w', 'abcdefg')"
|
check whether a file exists,os.path.isfile(fname)
|
check whether a file exists,os.path.exists(file_path)
|
check whether a file exists,print(os.path.isfile('/etc/password.txt'))
|
check whether a file exists,print(os.path.isfile('/etc'))
|
check whether a file exists,print(os.path.exists('/does/not/exist'))
|
check whether a file exists,print(os.path.isfile('/does/not/exist'))
|
check whether a file exists,print(os.path.exists('/etc'))
|
check whether a file exists,print(os.path.exists('/etc/password.txt'))
|
Split Strings with Multiple Delimiters?,"""""""a;bcd,ef g"""""".replace(';', ' ').replace(',', ' ').split()"
|
"Why can you loop through an implicit tuple in a for loop, but not a comprehension in Python?",list(i for i in range(3))
|
Pythonically add header to a csv file,writer.writeheader()
|
How to flatten a tuple in python,"[(a, b, c) for a, (b, c) in l]"
|
Python - how to convert int to string represent a 32bit Hex number,"""""""0x{0:08X}"""""".format(3652458)"
|
How can I convert a Python dictionary to a list of tuples?,"[(v, k) for k, v in list(d.items())]"
|
How can I convert a Python dictionary to a list of tuples?,"[(v, k) for k, v in d.items()]"
|
How can I convert a Python dictionary to a list of tuples?,"[(v, k) for k, v in a.items()]"
|
How can I convert a Python dictionary to a list of tuples?,"[(k, v) for k, v in a.items()]"
|
What's the easiest way to convert a list of hex byte strings to a list of hex integers?,"[int(x, 16) for x in ['BB', 'A7', 'F6', '9E']]"
|
What's the easiest way to convert a list of hex byte strings to a list of hex integers?,"[int(x, 16) for x in L]"
|
Two values from one input in python?,"var1, var2 = input('Enter two numbers here: ').split()"
|
Django filter JSONField list of dicts,Test.objects.filter(actions__contains=[{'fixed_key_1': 'foo2'}])
|
Is there a cleaner way to iterate through all binary 4-tuples?,"itertools.product(list(range(2)), repeat=4)"
|
Python - Get Yesterday's date as a string in YYYY-MM-DD format,(datetime.now() - timedelta(1)).strftime('%Y-%m-%d')
|
Python 3: Multiply a vector by a matrix without NumPy,"np.dot([1, 0, 0, 1, 0, 0], [[0, 1], [1, 1], [1, 0], [1, 0], [1, 1], [0, 1]])"
|
Parse_dates in Pandas,"df['date'] = pd.to_datetime(df['date'], format='%d%b%Y')"
|
Importing files from different folder,"sys.path.insert(0, '/path/to/application/app/folder')
|
import file"
|
How can a pandas merge preserve order?,"x.reset_index().merge(y, how='left', on='state', sort=False).sort('index')"
|
How can i create the empty json object in python,"json.loads(request.POST.get('mydata', '{}'))"
|
Slicing a list into a list of sub-lists,"list(zip(*((iter([1, 2, 3, 4, 5, 6, 7, 8, 9]),) * 3)))"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.