text
stringlengths 4
1.08k
|
|---|
combining two sorted lists in python,"[2.860386848449707, 2.758984088897705, 2.768254041671753]"
|
how to convert current date to epoch timestamp?,"t = time.mktime(time.strptime('29.08.2011 11:05:02', '%d.%m.%Y %H:%M:%S'))"
|
how should i take the max of 2 columns in a dataframe and make it another column?,"df[['A', 'B']].max(axis=1)"
|
single line nested for loops,"[50.1, 50.2, 50.3, 50.4, 60.1, 60.2, 60.3, 60.4, 70.1, 70.2, 70.3, 70.4]"
|
python: how do i convert an array of strings to an array of numbers?,"map(int, ['1', '-1', '1'])"
|
deleting mulitple columns in pandas,"yourdf.drop(['columnheading1', 'columnheading2'], axis=1, inplace=True)"
|
decode a urllib escaped url string `url` with `utf8`,url = urllib.parse.unquote(url).decode('utf8')
|
"python, encoding output to utf-8",content.decode('utf8')
|
wxpython: making something expand,self.SetSizer(sizer)
|
how to round each item in a list of floats to 2 decmial places,"myRoundedList = [round(elem, 2) for elem in myList]"
|
sorting dictionary keys in python,"my_list = sorted(list(dict.items()), key=lambda x: x[1])"
|
python - verifying if one list is a subset of the other,"set([1, 2, 2]).issubset([1, 2])"
|
print a big integer with punctions with python3 string formatting mini-language,"format(x, ',').replace(',', '.')"
|
using extensions with selenium (python),driver.get('http://stackoverflow.com')
|
calcuate mean for selected rows for selected columns in pandas data frame,"df.iloc[:, ([2, 5, 6, 7, 8])]"
|
how to find overlapping matches with a regexp?,"re.findall('(?=(\\w\\w))', 'hello')"
|
group by interval of datetime using pandas,"df['data'] = pd.to_datetime(df['data'], format='%d/%b/%Y:%H:%M:%S')"
|
what is the difference between a string and a byte string?,"""""""I am a string"""""".decode('ASCII')"
|
find row or column containing maximum value in numpy array,"np.argmax(np.max(x, axis=0))"
|
replace percent-encoded code in request `f` to their single-character equivalent,"f = urllib.request.urlopen(url, urllib.parse.unquote(urllib.parse.urlencode(params)))"
|
how do i update an instance of a django model with request.post if post is a nested array?,form.save()
|
python right click menu using pygtk,menu = gtk.Menu()
|
how can i add an additional row and column to an array?,"L.append([7, 8, 9])"
|
compare multiple columns in numpy array,"y[:, (cols)].sum()"
|
writing a list of sentences to a single column in csv with python,writer.writerow([item])
|
update all models at once in django,Model.objects.all().order_by('some_field').update(position=F(some_field) + 1)
|
how to create nested list from flatten list?,"[['a', 'b', 'c'], ['d', 'e', 'f', 'g'], ['d', 's', 'd', 'a']]"
|
sorting or finding max value by the second element in a nested list. python,"max(alkaline_earth_values, key=lambda x: x[1])"
|
add scrolling to a platformer in pygame,pygame.display.set_caption('Use arrows to move!')
|
python - arranging words in alphabetical order,sentence = [word.lower() for word in sentence]
|
"pandas sum by groupby, but exclude certain columns","df.groupby(['Country', 'Item_Code'])[['Y1961', 'Y1962', 'Y1963']].sum()"
|
"in python, is there a concise way to use a list comprehension with multiple iterators?","list(itertools.product(list(range(1, 3)), list(range(1, 5))))"
|
how to remove ^m from a text file and replace it with the next line,"somestring.replace('\\r', '')"
|
"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 make a simple cross-platform webbrowser with python?,sys.exit(app.exec_())
|
request url 'https://www.reporo.com/' without verifying ssl certificates,"requests.get('https://www.reporo.com/', verify=False)"
|
how to create a comprehensible bar chart with matplotlib for more than 100 values?,"plt.savefig('foo.pdf', papertype='a2')"
|
find an element in a list of tuples,[item for item in a if item[0] == 1]
|
"how to do an inverse `range`, i.e. create a compact range based on a set of numbers?","['1-5', '7', '9-10']"
|
django: redirect to previous page after login,"return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))"
|
write a comment `# data for class a\n` to a file object `f`,f.write('# Data for Class A\n')
|
showing a gtk.calendar in a menu?,gtk.main()
|
how to extract information between two unique words in a large text file,"re.findall('alpha(.*?)bravo', st)"
|
combinatorial explosion while merging dataframes in pandas,"from functools import reduce
|
reduce(lambda x, y: x.combine_first(y), [df1, df2, df3])"
|
how can i generate a list of consecutive numbers?,"[0, 1, 2, 3, 4, 5, 6, 7, 8]"
|
how to get all the keys with the same highest value?,"['e', 'd']"
|
python: changing idle's path in win7,sys.path.append('.')
|
pythonic way to create a long multi-line string,"""""""this is a verylong string toofor sure ..."""""""
|
boxplot with variable length data in matplotlib,plt.show()
|
read file 'myfile.txt' using universal newline mode 'u',"print(open('myfile.txt', 'U').read())"
|
how to download to a specific directory with python?,"urllib.request.urlretrieve('http://example.com/file.ext', '/path/to/dir/filename.ext')"
|
assigning a value to python list doesn't work?,l.append(input('e' + str(i) + '='))
|
get data from matplotlib plot,gca().get_lines()[n].get_xydata()
|
lxml removes spaces and line breaks in <head>,"etree.tostring(e, pretty_print=True)"
|
how can i extract only text in scrapy selector in python,"site = ''.join(hxs.select(""//h1[@class='state']/text()"").extract()).strip()"
|
drop rows of dataframe `df` whose index is smaller than the value of `start_remove` or bigger than the value of`end_remove`,df.query('index < @start_remove or index > @end_remove')
|
sum a list of numbers `list_of_nums`,sum(list_of_nums)
|
delete file `filename`,os.remove(filename)
|
sum of squares values in a list `l`,sum(i * i for i in l)
|
i want to create a column of value_counts in my pandas dataframe,df['Counts'] = df.groupby(['Color'])['Value'].transform('count')
|
how to get the size of a string in python?,print(len('abc'))
|
how to execute a command prompt command from python,os.system('dir c:\\')
|
applying regex to a pandas dataframe,df['Season'].apply(split_it)
|
detecting non-ascii characters in unicode string,"print(re.sub('[ -~]', '', '\xa3100 is worth more than \u20ac100'))"
|
is there a way to disable built-in deadlines on app engine dev_appserver?,urlfetch.set_default_fetch_deadline(60)
|
is it possible to make an option in optparse a mandatory?,"parser.add_option('-f', '--file', dest='filename', help='foo help')"
|
insert a new field 'geoloccountry' on an existing document 'b' using pymongo,"db.Doc.update({'_id': b['_id']}, {'$set': {'geolocCountry': myGeolocCountry}})"
|
fit kmeans function to a one-dimensional array `x` by reshaping it to be a multidimensional array of single values,"km.fit(x.reshape(-1, 1))"
|
sort dict by value python,"sorted(list(data.items()), key=lambda x: x[1])"
|
write a regex pattern to match even number of letter `a`,re.compile('^([^A]*)AA([^A]|AA)*$')
|
hex string to character in python,binascii.unhexlify('437c2123')
|
making an image from the list,img.save('Image2.png')
|
how to find a missing number from a list,a[-1] * (a[-1] + a[0]) / 2 - sum(a)
|
log message of level 'info' with value of `date` in the message,logging.info('date={}'.format(date))
|
replace value in any column in pandas dataframe,"df.replace('-', 'NaN')"
|
sorting dictionary keys in python,"sorted(mydict, key=lambda key: mydict[key])"
|
longest strings from list,longest_strings = [s for s in stringlist if len(s) == maxlength]
|
how do i plot a step function with matplotlib in python?,plt.show()
|
url encoding in python,urllib.parse.quote_plus('a b')
|
how to remove more than one space when reading text file,"reader = csv.reader(f, delimiter=' ', skipinitialspace=True)"
|
python parse comma-separated number into int,"int(a.replace(',', ''))"
|
"check if string `s` contains ""is""","if (s.find('is') == (-1)):
|
print(""No 'is' here!"")
|
else:
|
print(""Found 'is' in the string."")"
|
how to intergrate python's gtk with gevent?,gtk.main()
|
new column in pandas - adding series to dataframe by applying a list groupby,"df.join(df.groupby('Id').concat.apply(list).to_frame('new'), on='Id')"
|
python spliting a list based on a delimiter word,"[['A'], ['WORD', 'B', 'C'], ['WORD', 'D']]"
|
efficient feature reduction in a pandas data frame,df['Features'] = df['Features'].apply(frozenset)
|
"in python, how can i get the correctly-cased path for a file?",win32api.GetLongPathName(win32api.GetShortPathName('stopservices.vbs'))
|
execute raw sql queue '<sql here>' in database `db` in sqlalchemy-flask app,result = db.engine.execute('<sql here>')
|
boolean indexing that can produce a view to a large pandas dataframe?,idx = (df['C'] != 0) & (df['A'] == 10) & (df['B'] < 30)
|
how to get a response of multiple objects using rest_framework and django,"url('^combined/$', views.CombinedAPIView.as_view(), name='combined-list')"
|
how to convert hex string to integer in python?,"y = str(int(x, 16))"
|
make python program wait,time.sleep(1)
|
return http status code 204 from a django view,return HttpResponse(status=204)
|
spawning a thread in python,t.start()
|
django get all records of related models,Activity.objects.filter(list__topic=my_topic)
|
converting integer to binary in python,bin(6)[2:].zfill(8)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.