text
stringlengths 4
1.08k
|
|---|
Python 2.7 Counting number of dictionary items with given value,sum(x == chosen_value for x in list(d.values()))
|
matplotlib bar chart with dates,plt.show()
|
How to change the table's fontsize with matplotlib.pyplot?,plt.show()
|
"Python, running command line tools in parallel","subprocess.call('start command -flags arguments', shell=True)"
|
Finding the average of a list,sum(l) / float(len(l))
|
Python convert decimal to hex,hex(d).split('x')[1]
|
How to run Scrapy from within a Python script,process.start()
|
Python Selenium: Find object attributes using xpath,"browser.find_elements_by_xpath(""//*[@type='submit']/@value"").text"
|
How to convert 'binary string' to normal string in Python3?,"""""""a string"""""".encode('ascii')"
|
Wildcard matching a string in Python regex search,pattern = '6 of(.*)fans'
|
"Python, Encoding output to UTF-8",print(content.decode('utf8'))
|
How to plot a gradient color line in matplotlib?,plt.show()
|
Sort numpy matrix row values in ascending order,"arr[arr[:, (2)].argsort()]"
|
How to analyze all duplicate entries in this Pandas DataFrame?,grouped.reset_index(level=0).reset_index(level=0)
|
psycopg2: insert multiple rows with one query,"cur.executemany('INSERT INTO table VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)', tup)"
|
How to execute a file within the python interpreter?,"exec(compile(open('filename.py').read(), 'filename.py', 'exec'))"
|
How to drop a list of rows from Pandas dataframe?,"df.drop(df.index[[1, 3]], inplace=True)"
|
Most Pythonic Way to Split an Array by Repeating Elements,"nSplit(['a', 'b', 'X', 'X', 'c', 'd', 'X', 'X', 'f', 'X', 'g'], 'X', 2)"
|
"Pandas DataFrame, how do i split a column into two","df['AB'].str.split(' ', 1, expand=True)"
|
How to check if type of a variable is string?,"isinstance(s, str)"
|
Index confusion in numpy arrays,"array([[[1, 2], [4, 5]], [[13, 14], [16, 17]]])"
|
Use index in pandas to plot data,"monthly_mean.reset_index().plot(x='index', y='A')"
|
"How to create ""virtual root"" with Python's ElementTree?",tree.write('outfile.htm')
|
Tricontourf plot with a hole in the middle.,plt.show()
|
How to get a padded slice of a multidimensional array?,arr[-2:2]
|
Best way to encode tuples with json,"{'[1,2]': [(2, 3), (1, 7)]}"
|
Python not able to open file with non-english characters in path,"""""""クレイジー・ヒッツ!"""""""
|
How to use Popen to run backgroud process and avoid zombie?,"signal.signal(signal.SIGCHLD, signal.SIG_IGN)"
|
Finding the minimum value in a numpy array and the corresponding values for the rest of that array's row,"a[np.argmin(a[:, (1)]), 0]"
|
Convert float Series into an integer Series in pandas,"df.resample('1Min', how=np.mean)"
|
How can I convert a Python datetime object to UTC?,datetime.utcnow() + timedelta(minutes=5)
|
Moving x-axis to the top of a plot in matplotlib,ax.xaxis.set_label_position('top')
|
How can I add values in the list using for loop in python?,a = int(eval(input('Enter number of players: ')))
|
How to print backslash with Python?,print('\\')
|
Find the coordinates of a cuboid using list comprehension in Python,"[list(l) for l in it.product([0, 1], repeat=3) if sum(l) != 2]"
|
How to get all sub-elements of an element tree with Python ElementTree?,[elem.tag for elem in a.iter()]
|
Create a list of tuples with adjacent list elements if a condition is true,"[(x, y) for x, y in zip(myList, myList[1:]) if y == 9]"
|
How to set the tab order in a tkinter application?,app.mainloop()
|
Tuple to string,tst2 = str(tst)
|
How to read windows environment variable value in python?,os.getenv('MyVar')
|
How to query for distinct results in mongodb with python?,Students.objects(name='Tom').distinct(field='class')
|
Concatenate rows of pandas DataFrame with same id,df.groupby('id').agg(lambda x: x.tolist())
|
Function to close the window in Tkinter,self.root.destroy()
|
how to export a table dataframe in pyspark to csv?,df.toPandas().to_csv('mycsv.csv')
|
Keep only date part when using pandas.to_datetime,df['just_date'] = df['dates'].dt.date
|
"Getting a sublist of a Python list, with the given indices?","[0, 2, 4, 5]"
|
The truth value of an array with more than one element is ambigous when trying to index an array,"c[np.logical_and(a, b)]"
|
How to execute raw SQL in SQLAlchemy-flask app,result = db.engine.execute('<sql here>')
|
Python regex extract vimeo id from url,"re.search('^(http://)?(www\\.)?(vimeo\\.com/)?(\\d+)', embed_url).group(4)"
|
List of objects to JSON with Python,json_string = json.dumps([ob.__dict__ for ob in list_name])
|
Add scrolling to a platformer in pygame,pygame.display.set_caption('Use arrows to move!')
|
Finding The Biggest Key In A Python Dictionary,"sorted(list(things.keys()), key=lambda x: things[x]['weight'], reverse=True)"
|
Add single element to array in numpy,"numpy.append(a, a[0])"
|
Extract dictionary value from column in data frame,feature3 = [d.get('Feature3') for d in df.dic]
|
How can I replace all the NaN values with Zero's in a column of a pandas dataframe,df.fillna(0)
|
How can i extract only text in scrapy selector in python,"site = ''.join(hxs.select(""//h1[@class='state']/text()"").extract()).strip()"
|
How do I print out the full url with tweepy?,print(url['expanded_url'])
|
creating list of random numbers in python,print('{.5f}'.format(randomList[index]))
|
how to disable the window maximize icon using PyQt4?,win.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint)
|
Remove list of indices from a list in Python,"[element for i, element in enumerate(centroids) if i not in index]"
|
How to check whether a method exists in Python?,"hasattr(Dynamo, 'mymethod') and callable(getattr(Dynamo, 'mymethod'))"
|
Numpy isnan() fails on an array of floats (from pandas dataframe apply),"np.isnan(np.array([np.nan, 0], dtype=np.float64))"
|
Python: How to Redirect Output with Subprocess?,os.system(my_cmd)
|
Get list of XML attribute values in Python,"['a1', 'a2', 'a3']"
|
Pass another object to the main flask application,app.run()
|
"Given two lists in python one with strings and one with objects, how do you map them?",new_list = [d[key] for key in string_list]
|
How should I best store fixed point Decimal values in Python for cryptocurrency?,decimal.Decimal('1.10')
|
"In Python, how to display current time in readable format","time.strftime('%l:%M%p %z on %b %d, %Y')"
|
How to remove tags from a string in python using regular expressions? (NOT in HTML),"re.sub('<[^>]*>', '', mystring)"
|
How do I give focus to a python Tkinter text widget?,root.mainloop()
|
Find a file in python,"return os.path.join(root, name)"
|
multiple axis in matplotlib with different scales,plt.show()
|
Google App Engine: Webtest simulating logged in user and administrator,os.environ['USER_EMAIL'] = 'info@example.com'
|
How to encode a categorical variable in sklearn?,pd.get_dummies(df['key'])
|
"How do I launch a file in its default program, and then close it when the script finishes?","subprocess.Popen('start /WAIT ' + self.file, shell=True)"
|
Finding words after keyword in python,"re.search('name (.*)', s)"
|
Aggregate items in dict,"[{key: dict(value)} for key, value in B.items()]"
|
Hierarhical Multi-index counts in Pandas,df.reset_index().groupby('X')['Y'].nunique()
|
Matplotlib: How to put individual tags for a scatter plot,plt.show()
|
What does the 'b' character do in front of a string literal?,"""""""\\uFEFF"""""".encode('UTF-8')"
|
Any way to properly pretty-print ordered dictionaries in Python?,pprint(dict(list(o.items())))
|
Call external program from python and get its output,"subprocess.check_output(['ls', '-l', '/dev/null'])"
|
How can I send variables to Jinja template from a Flask decorator?,return render_template('template.html')
|
sscanf in Python,"print((a, b, c, d))"
|
Using lxml to parse namepaced HTML?,"print(link.attrib.get('title', 'No title'))"
|
Pandas groupby: How to get a union of strings,df.groupby('A')['B'].agg(lambda col: ''.join(col))
|
"python: convert ""5,4,2,4,1,0"" into [[5, 4], [2, 4], [1, 0]]","[l[i:i + 7] for i in range(0, len(l), 7)]"
|
matplotlib diagrams with 2 y-axis,plt.show()
|
More efficient way to clean a column of strings and add a new column,"pd.concat([d1, df1], axis=1)"
|
how to get the context of a search in BeautifulSoup?,k = soup.find(text=re.compile('My keywords')).parent.text
|
Creating a Pandas dataframe from elements of a dictionary,"df = pd.DataFrame.from_dict({k: v for k, v in list(nvalues.items()) if k != 'y3'})"
|
How do I get the modified date/time of a file in Python?,os.stat(filepath).st_mtime
|
Filter common sub-dictionary keys in a dictionary,(set(x) for x in d.values())
|
How to create unittests for python prompt toolkit?,unittest.main()
|
Python : how to append new elements in a list of list?,a = [[]] * 3
|
How to use map to lowercase strings in a dictionary?,[{'content': x['content'].lower()} for x in messages]
|
Python: get last Monday of July 2010,"datetime.datetime(2010, 7, 26, 0, 0)"
|
Reverse a string in Python two characters at a time (Network byte order),""""""""""""".join(reversed([a[i:i + 2] for i in range(0, len(a), 2)]))"
|
Polar contour plot in Matplotlib,plt.show()
|
"How can I transform this (100, 100) numpy array into a grayscale sprite in pygame?",pygame.display.flip()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.