text stringlengths 226 34.5k |
|---|
Why are the subject and content empty when using python to send Email?
Question: I tried to run the following python script (copied from
<http://www.tutorialspoint.com/python/python_sending_email.htm>) on a remote
server to send an Email. I successfully received the Email in my mailbox, but
unfortunately the content is... |
Keras output looks different than others
Question: When I run the below code :
from keras.models import Sequential
from keras.layers import Dense
import numpy
import time
# fix random seed for reproducibility
seed = 7
numpy.random.seed(seed)
# load dataset
datase... |
Python Django Web Application issue
Question: I have created a user creation page and forget password page. all the fields
are created in models.py and i want to show the forgot password through
HttpResponse when the user clicks of submit button forgot password page.
Please help how to get it.
models.py ... |
How to delete a file with invalid name using python?
Question: I've got a `file` named `umengchannel_316_豌豆荚` I want to delete this file.. I
tried the following: `os.remove()`, `os.unlink()` , `shutil.move()` but
nothing seems to work.. Are there any other approaches to this problem?
Answer: I'm using Unix OS, have b... |
Extract last string between brackets from a string - python
Question: I would like to know the way for extracting the last string between brackets
from a long string. So I need a function, `extract_last`, for example, that
let me get an output like that:
>> extract_last('(hello) my (name) is (Luis)')
... |
Unable to import boto3 library after installation
Question: I installed boto3 library from AWS SDK but when I try to import in python
interpreter, I get error. Here is the traceback:
> > > import boto3 Traceback (most recent call last): File "", line 1, in File
> "/home/rahul/rahul/boto3/boto3/**init**.py", line 16, i... |
Python optimize fmin gives A value in x_new is above the interpolation range error
Question: I am trying to interpolate the minimum of a quadratic function of which I have
three samples. The first test in the code snippet below works. It gives:
[](http://i.stack.imgur.com/tz... |
Fast way to select from numpy array without intermediate index array
Question: Given the following 2-column array, I want to select items from the second
column that correspond to "edges" in the first column. This is just an
example, as in reality my `a` has potentially millions of rows. So, ideally
I'd like to do this... |
How to get http request from curl?
Question: I've got a curl request which looks like:
curl -s http://someurl1.com -H 'Accept: application/json' -u 'emv:LgKrAVkFf2c6mr4DFBQUdjBK' -d grant_type='password' -d scope='offline_access' -d username='datafiles@random.com' -d password='456Qwer()' -d acr_values='t... |
How do I force these ttk apps to resize when I resize the window?
Question: I have comments in a number of places where I've tried to use the
columnconfigure or rowconfigure methods to cause the windows to resize, but
none of it seems to be working. I can also take out mainloop() and my program
runs exactly the same. T... |
Pyspark Handle Ctrl + Z?
Question: When running pyspark, if you do a `Ctrl` \+ `Z` in the middle of a process, it
stops the job from running but does not close SparkContext. This means the
port is not closed either and spark has to jump through several ports to
connect the next time someone runs a spark job. I want to ... |
how can I parse json with a single line python command?
Question: I would like to use python to parse JSON in batch scripts, for example:
HOSTNAME=$(curl -s ${HOST} | python ?)
Where the JSON output from curl looks like:
'{"hostname":"test","domainname":"example.com"}'
How can ... |
jira-python hanging on request on Windows without any kind of failure or notification
Question: My script returns changelog history for `JIRA` tickets, and it seems to work
fine on my dev machine (Mac Pro). It hung a few times when I tried to
implement async to pull the requests faster, but with a single threaded
proce... |
Interactive Python - solutions for relative imports
Question: From [Python relative imports for the billionth
time](http://stackoverflow.com/questions/14132789/python-relative-imports-for-
the-billionth-time):
* For a `from .. import` to work, the module's name must have at least as many dots as there are in the `im... |
unconverted data remains python strptime
Question: I am trying to convert strings to datetime in python, but I am getting an
error "unconverted data remains: 11". The strings I am dealing with have a
form like "Dec\xa031 2011". I think the unicode character is causing a
problem. I have tried splitting on \xa0 which giv... |
Generate an image tag with a Django static url in the view instead of the template
Question: I want to generate an image with a static url in a view, then render it in a
template. I use `mark_safe` so that the HTML won't be escaped. However, it
still doesn't render the image. How do I generate the image tag in Python?
... |
Is it possible to get the name of AWS EMR step currently executing without going to console
Question: If there are 3 steps that are executed in EMR, is it possible to know which
step is currently executing, using shell script.
I am able to get current state of the EMR cluster, using this:
`aws emr descr... |
How can i select a file with python?
Question: [enter image description here](http://i.stack.imgur.com/mMIsq.png)
I can do like this on Java, but i can't do on Python
StringSelection ss = new StringSelection("C:\\Users\\Mert\\Desktop\\hello.png");
Toolkit.getDefaultToolkit().getSystemClipboard().set... |
fail to visualize a network in python - issue with pygraphviz?
Question: As I use some code to visualize a network, I encountered an error
Traceback (most recent call last):
File "networkplot.py", line 21, in <module>
pos = graphviz_layout(G, prog='neato')
File "/opt/conda/lib/python2.7/site-... |
How can I map an ontology components to a relational database?
Question: I already have an owl ontology which contains classes, instances and object
properties. How can I map them to a relational data base such as MYSQL using a
Python as a programming language(I prefer Python) ?
**For example** , an ontology can cont... |
Error when creating Database Tables - CKAN
Question: i'm trying to install CKAN 2.5.2 on Centos 6.8
When i run paster db init -c /etc/ckan/default/development.ini
i get error
Traceback (most recent call last):
File "/usr/lib/ckan/default/bin/paster", line 9, in <module>
load_entry_point('... |
execute script from within python3 interpreter and show interpreter results
Question: I am working inside the python 3 interpreter, and I want to use it for
homework.
first, I have a library called `mylibrary.py` like this
from math import pi
def area_circle(r):
return(r*r*pi))
Second, ... |
read_sql_query returns far more records than actual table rows
Question: I am trying to get the a postgresql table in to python data frame. But the
dataframe size is extremely larger than the actual number of table records
even though I specified an index column. What's causing this issue? Single
quotes/ commas in the ... |
How to input data in a tensorflow learn validation monitor?
Question: I'm trying to use a validation monitor in skflow by passing my validation set
as numpy array.
Here is some simple code to reproduce the problem (I installed tensorflow from
the provided binaries for Ubuntu/Linux 64-bit, GPU enabled, Python 2.7):
... |
Python + OpenCV, change brightness/darkness outside a sliding window?
Question: I'm working with Python and OpenCV and I'm a newbie in both. For my project, I
need to move a sliding window over a picture; for each position of the window
the area outside the window must be shown darker than the area inside the
window.
... |
Python Pandas DataFrame check if string is other string and fill column
Question: I am learning Python and this might be a noob question:
import pandas as pd
A = pd.DataFrame({"A":["house", "mouse", "car", "tree"]})
check_list = ["house", "tree"]
I want to check rowwise if the str... |
Fast calculation of v-disparity with OpenCV-Function calcHist
Question: Based on a disparity matrix from a passive stereo-camera system i need to
calculate a v-disparity representation for obstacle detection with OpenCV.
A working implementation is **not** the problem. The problem is to do it
fast...
(One) Reference ... |
Python: sorting list of lists not functioning as intended
Question: I am trying to sort the following list of lists by the first item of each list
in ascending order:
framenos = [
['1468', '2877', 'Pos.:', 95],
['3185', '4339', 'Pos.:', 96],
['195', '1460', 'Pos.:', 97]
]
... |
How to remove double quotes from index of csv file in python
Question: I'm trying to read multiple `csv` files with python. The index of raw data(or
the first column) has a little problem, the partial csv file looks like this:
NoDemande;"NoUsager";"Sens";"IdVehiculeUtilise";"NoConducteur";"NoAdresse";"Fa... |
How to make a GET call by executing a javascript file and print response in terminal
Question: So I am using python for all needs in my life and have never touched
javascript. Now I might need to learn javascript because of certain reasons.
First thing that came to my mind is to try to make a GET call and print the
re... |
recursing a list of 73033 elements with HTML tags and get context from it
Question: I have a long list of elements with a length of 73,033. I would like to get
the context from it. In the list, each element has the same structure (if the
block of the following code helps), and it looks like this `<div
align="center" cl... |
Python 2.7: Returning a value in a csv file from input
Question: I've got a csv with:
T,8,101
T,10,102
T,5,103
and need to search the csv file, in the 3rd column for my input, and if found,
return the 2nd column value in that same row (searching "102" would return
"10"). I then need to save... |
Django: how to cache a function
Question: I have a web application that runs python in the back-end. When my page loads,
a django function is called which runs a SQL query and that query takes about
15-20 seconds to run and return the response. And that happens every time the
page loads and it would be very annoying fo... |
beautifulsoup with get_text - handle spaces
Question: I using BS4 (python3) for extracting text from html file. My file looks like
this:
<BODY>
<P>Hello World!</P>
</BODY>
</HTML>
When i calling `get_text()` method, the output is "Hello World!". Because it's
HTML, I was expected... |
Error loading a image file into ndarray with scipy.ndimage.imread
Question: Im trying to load a image file into a ndarray with something like this:
image_data = ndimage.imread(image_file).astype(float)
but i get this error:
/home/milos/anaconda3/envs/tensorflow/lib/python3.5/site-pac... |
Difference between a list & a stack in python?
Question: What is the difference between a list & a stack in python?
I have read its explanation in the python documentation but there both the
things seems to be same?
>>> stack = [3, 4, 5]
>>> stack.append(6)
>>> stack.append(7)
>>> stack
... |
How to recognise urls starting with anchor(#) in urls.py file in django?
Question: I have starting building my application in angularJS and django, and after
creating a login page, I am trying to redirect my application to a new url
after successful login. I am using `$location` variable to redirect my page.
Here is my... |
What does ./!$ mean in Linux?
Question: A noobie Linux learner here.
I created a python script and `chmod 700 filename.py`, when I was going to
using `./filename.py`, my instructor came and use `./!$` to run the file.
What does the `./!$` that actually mean? I couldn't google it out. I'd greatly
appreciate for a link... |
Outer addition and subtraction in tensorflow
Question: Is the an equivalent operation (or series of operations) that acts like the
numpy outer functions?
import numpy as np
a = np.arange(3)
b = np.arange(5)
print np.subtract.outer(a,b)
[[ 0 -1 -2 -3 -4]
[ 1 0 -1 -2 -3... |
How to create pandas dataframe from python dictionary?
Question: I have a python dictionary below:
dict = {'stock1': (5,6,7), 'stock2': (1,2,3),'stock3': (7,8,9)};
I want to change dictionary to dataframe like:
[](http://i.stack.im... |
Date field in SAS imported in Python pandas Dataframe
Question: I have imported a SAS dataset in python dataframe using Pandas
`read_sas(path)` function. REPORT_MONTH is a column in sas dataset defined and
saved as DATE9. format. This field is imported as float64 datatype in
dataframe and having numbers which is basica... |
VK API : automatically generate acess token by using python
Question: I am trying to acess VK Api with scope of stats. manually i am able to
generate acess token ,but that is going to be expire in 24 hours. So i wanted
to generate acess token programatcally. i tried in 2 ways mentioned as below.
first way:
... |
wxPython produces no GUI output
Question: Am new to GUI with wxPython.Was trying out this block of code from a book and
it produces the following output but no GUI with the message string.Here's the
code..
[Here's the code ](http://i.stack.imgur.com/RP2Ox.png)
[And Here's the output](http://i.stack.imgur.com/vJSIE.pn... |
How exactly does Python resolve "from X import Y" if there are multiple Ys in X?
Question: I have a package X which contains two different things named Y
One is a module:
# X/Y.py
print 'hello'
The other is a variable:
# X/__init__.py
Y = 'world'
If I execute `from X i... |
how to detect spaces, special characters in html tags in python
Question: For the following input
I/O 1< img > '< input >
I/O 1<' img > '< input >
I want the required output as below and this should happen if `<` followed by
space is present.
I/O 1<img>'<i... |
Submitting a Form using Selenium in Python
Question: I need to scrape some data behind those hyperlinks from [this
Site](http://www.echemportal.org/echemportal/propertysearch/treeselect_input.action?queryID=PROQ3h3n).
However, those hyperlinks are `javascript function calls`, which later submits
a `form` using `post` m... |
Change array shape of an image in python
Question: When I read a colour image in OpenCV, it is showing the dimensions as
256x256x3. But I need to pass it as 3x256x256 array to my neural network. How
do I change the array shape, retaining the pixel locations in BGR.
Answer: You can simply transpose the array. For an e... |
xml.etree.ElementTree.ParseError: not well-formed (invalid token) in Python
Question: I am trying to open an XML file using `ElementTree` but an error occurred:
> xml.etree.ElementTree.ParseError: not well-formed (invalid token)
And here is my code:
# -*- coding: utf-8 -*-
import xml.etree.ElementT... |
Python Pandas v0.18+: is there a way to resample a dataframe without filling NAs?
Question: I wonder if there is a way to up resample a `DataFrame` without having to
decide how NAs should be filled immediately.
I tried the following but got the Future Warning:
> FutureWarning: .resample() is now a deferred operation ... |
write() argument must be str, not bytes
Question: I'm a beginner programmer and am working through the book python for the
absolute beginner. I have come across a problem trying to write a high scoring
function for the trivia game. when the function 'highscore(user, highscore):'
is called on I try to assign the argumen... |
How do I declare Global Variables correctly in Python 3.3 so they can work in multiple functions?
Question: Right now I'm trying to make a little game for my friends for fun in **Python
3.3**. It was all going well until I forgot how to get certain variables (in
my case gold, damage and XP) to carry over through differ... |
How to link yaml key values to json key values in python
Question: Hi I would like to essentially use yaml data inside json for eg.
json file:
{
"Name": "foo",
"Birthdate": "1/1/1991",
"Address": "FOO_ADDRESS",
"Note": "Please deliver package to foo at FOO_ADDRESS using C... |
Python - pip install markupsafe
Question: So i want to install markupsafe and get this following error:
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\
\users\\appdata\\local\\temp\\pip-build-yb_vy0\\markupsafe\\setup.py';ex
ec(compile(getattr(tokenize, 'open', op... |
Is it possible to get all the urls in a chain of redirects for a given link on the client-side using JavaScript?
Question: I am currently working on a JavaScript chrome extension and would like to be
able to send all the redirects for a given link that matches a certain
criteria. I would like to do this client side inv... |
use existing field as _id using elasticsearch dsl python DocType
Question: I have class, where I try to set `student_id` as `_id` field in
[elasticsearch](/questions/tagged/elasticsearch
"show questions tagged 'elasticsearch'"). I am referring [persistent
example](https://elasticsearch... |
python-plotly-boxplot Why not showing the max and minimum value on graph
Question: This is my data:[0, 45, 47, 46, 47,47,43,100]. And picture looks like this:
<https://plot.ly/~zfrancica/8/>
I want to have a picture like this: <https://plot.ly/~zfrancica/9/> (an out
come picture of [0, 45, 47, 46, 100] )
I want to ha... |
Python Inheritance suitability of using subclass to produce plot after setting plot properties in parent
Question: I am trying to write a simple Python matplotlib plotting Class that will set
up formatting of the plot as I would like. To do this, I am using a class and
a subclass. The parent generates an axis and figur... |
How can I debug a connection issue within VOLTTRON?
Question: I am connecting to an external VOLTTRON instance. I am not getting a response
from the connection. What's the issue?
I am writing a simple python script to connect to an external platform and
retrieve the peers. If I get the serverkey, clientkey, and/or pub... |
Stacked Bar Chart in Matplotlib; Series Are Overlaying Instead Of Stacking
Question: Struggling to figure this one out. I have a stacked bar chart that I'm trying
to create with Python / Matplotlib and it seems to be overlaying the data
instead of stacking resulting in different colors (i.e. red+yellow = orange
instead... |
Two python pools, two queues
Question: I am trying to understand how pool and queue work in Python, and the following
example doesn't work as expected. I expect the program to end, but it's stuck
in an infinite loop because the second queue isn't getting emptied.
import multiprocessing
import os
... |
Why do python Subprocess.stdin.write() kill PyQt Gui
Question: I have a PyQt5 app that need to write input for the subprocess to stop.
However it also kills my PyQt5 `Mainwindow`, if input button is used without
using subprocess button first.
If i use subprocess button first, and then use input button , with
`self.bo... |
Caffe always gives the same prediction in Python, but training accuracy is good
Question: I have a trained model with caffe (through the command line) where I get an
**accuracy of 63%** (according to the log files). However, when I try to run a
script in Python to test the accuracy, I get all the predictions in the sam... |
How to generate permutations without generating repeating results but with a fixed amount of characters Python
Question: I am trying to figure out a way to generate all permutations possible of a
string that has a couple repeating characters but without generating repeated
tuples.
Right now I am using `itertools.permu... |
Execution time of multithreaded python program
Question: Considering GIL, I expected this program to finish in 9 seconds, but to my
surprise, it ends in 4 seconds. Looking for probable reasons or am I missing
something?
import time
import threading
def get_data(start, end):
res = []
... |
regular expression match issue in Python
Question: For input string, want to match text which starts with `{(P)` and ends with
`(P)}`, and I just want to match the parts in the middle. Wondering if we can
write one regular expression to resolve this issue?
For example, in the following example, for the input string, I... |
How to iterate over all these possibilities?
Question: Assume we have a python list
list = [[1,2,3],[4,5,6],[7,8,9]]
I define the sum as the following,
sum: is the total sum of single entries (different index) from each of the
sublists.
This sounds complex so I will give an example,
for the abov... |
Selenium Python Script throws no element error exception even though the x path is right?
Question:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
fro... |
Python - Checking whether any of multiple conditions are true
Question: I am trying to modify a list in place to remove entries where the file
extension does not match. I got this working by writing multiple 'or'
conditions
from os import listdir
image_extensions = ['jpg','.png']
files = lis... |
Python logging message not getting output as expected in simplest scenario
Question: I am not getting any output from `logging.debug` in the simplest possible
situation. (I do get output from `logger.warn`.)
import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.war... |
Beautfil Soup Error with simple script
Question: I am running Beautiful Soup 4.5 with Python 3.4 on Windows 7. Here is my
script:
from bs4 import BeautifulSoup
import urllib3
http = urllib3.PoolManager()
url = 'https://scholar.google.com'
response = http.request('GET', url)
... |
No twitter Module error [Mac]
Question: I have a python script that follows/unfollows and favorites tweets. I keep
getting an error:
from twitter import Twitter, OAuth, TwitterHTTPError
ImportError: No module named twitter
I put in all the oauth info in my script and i continue to get this erro... |
How to automate dictionary creation in Python
Question: I am trying to write a python code that solves a Sudoku puzzle. My code starts
by making a list of each row/column combination, or the coordinates of each
box. Next, I want to find a way to, for each box, reference its location. This
is my current code:
... |
Tensorflow memory leak with Recurrent Neural Network
Question: I'm trying to build a simple Recurrent Neural Network model by using
tensorflow on Mac OS X. It is just a toy model and size of input data doesn't
exceed 3MB so it should not consume much of memory. However, when I run model,
the memory usage significantly ... |
Matplotlib: scrolling plot
Question: I'm new to Python and I want to implement a scrolling plot for a very long
time series data. I've found an example from Matplotlib as follows.
<http://scipy-cookbook.readthedocs.io/items/Matplotlib_ScrollingPlot.html>
When I run the example from the link, I found every time I scro... |
ValueError: Found array with dim 3. Estimator expected <= 2
Question: I'am trying to generate my own training data for recognition problem. I have
two folder `s0` and `s1` and the folder containing is `data`. `images`,
`lables` are the two list in which the `labels` contains the names of the
folder.
|—- ... |
python threading: max number of threads to run
Question: let's say i have something similar to:
def worker(name):
time.sleep(10)
print name
return
thrs = []
for i in range(1000):
t1 = threading.Thread(target=worker, args=(i,))
thrs.append(t1)
... |
Python: clear items from PriorityQueue
Question: [Clear all items from the queue
](http://stackoverflow.com/questions/6517953/clear-all-items-from-the-queue)
I read the above answer
Im using python 2.7
import Queue
pq = Queue.PriorityQueue()
pq.clear()
I get the following error:
... |
PyQt MainWindow closes after initialization
Question: I wanted to start a new project using PyQt5 and QtDesigner. To start, I just
copied the code I had from previous projects in PyQt4 and tweaked it to the
changes in PyQt5. So, the code to start the Main Window and a Timer which
updates the application looks like this... |
OpenCV + Python - NameError: name 'imSize' is not defined
Question: I am using `OpenCV` for image processing. In which, I am getting these errors
please suggest what to do, below is my code:
import dicom
import Image
import ImageOps
meta=dicom.read_file("E:\A_SHIVA\ANANADAN\IM_0.dcm")
... |
Regex replacement for strip()
Question: Long time/first time.
I am a pharmacist by trade by am going through the motions of teaching myself
how to code in a variety of languages that are useful to me for things like
task automation at work, but mainly Python 3.x. I am working through the
automatetheboringstuff eBook a... |
django-debug-toolbar: 'Template' object has no attribute 'engine'
Question: I've just tried running an existing Django project on a new computer, and I'm
having trouble with django-debug-toolbar. It seems to be something to do with
Jinja2. Here's the stack trace:
Traceback:
File "/path/to/myrepo/env/... |
Append and Truncating together in Python
Question: So, I am at exercise 16 of Zed Shaw's Python book.
I thought of trying out both append and truncate on the same file. I know,
this does not make sense. But, I am new and I am trying to learn what would
happen if I used both.
So, first I am opening the file in append ... |
Scraping Table With Python/BS4
Question: Im trying to scrape the "Team Stats" table from <http://www.pro-football-
reference.com/boxscores/201602070den.htm> with BS4 and Python 2.7. However Im
unable to get anywhere close to it,
url = 'http://www.pro-football-reference.com/boxscores/201602070den.htm'
... |
What is the proper way to import large amounts data into a Firebase database?
Question: I'm working with a dataset of political campaign contributions that ends up
being an approximately 500mb JSON file (originally a 124mb CSV). It's far too
big to import in the Firebase web interface (trying before crashed the tab on
... |
Error compiling C code for python hmmlearn package
Question: I'm having some trouble getting the `hmmlearn` package to install properly (in
a virtual environment); it seems to have something to do with the underlying C
code. The package installs fine with `pip`, but when I try to import the core
class, I get an error:
... |
How to import a class from a python file in django?
Question: I'm currently using django and putting python code in my views.py to run them
on my webpages. There is an excerpt of code that requires a certain class from
a python file to work sort of like a package but it is just a python file I
was given to use in order... |
How to fix "unexpected keyword argument 'useChardet'" in html5lib
Question: I'm using html5lib and after updating it to the latest version, I keep getting
this error:
Traceback (most recent call last):
File "/home/travis/build/freelawproject/juriscraper/tests/test_everything.py", line 119, in test_... |
How to show image from webcam
Question: I never needed to work with camera before, so I do not know where to start. I
need to display the image of a real-time camera, to capture and save to a
file. I'm using python3 and gtk3.
Does gtk has any feature for this?
Answer: The easiest way to get the image from a webcam i... |
KIVY - Python Keep doing while button is pressed
Question: A few days ago (yesterday actually :D) I started programming in KIVY (which is
a python module -- if I can call it that).
I'm pretty familiar with python itself but I find KIVY pretty problamatic and
difficult in some solutions.
I'm currently trying to make a... |
Invalid ELF header tensorflow
Question: I first tried installing tensorflow via the following:
user@WS1:~/July 2016$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
user@WS1:~/July 2016$ pip install --upgrade $TF_BINARY_URL
... |
Python 3 Dice Sim issue
Question: I am BRAND new to python because my new school requires it. I am used to c++
so I'm still learning the ropes. I'm trying to make a dice rolling simulator
and I thought i was doing everything right but my code just won't work. Any
tips or guides to help me learn would be greatly appreci... |
How to Save file names and their directories path in a text file using Python
Question: I am trying to find a string that is contained in files under a directory.
Then make it to store it's file names and directories under a new text file or
something. I got upto where it is going through a directory and finding a
stri... |
gaierror: [Errno 8] nodename nor servname provided, or not known
Question: Hello I am new to python , I am writing a code which generates dns requests
from socket import error as socket_error
import threading
from random import randint
from time import sleep
def t... |
What version of ‘unittest2’ is needed for Python 3.4 features?
Question: What version of the `unittest2` library do I need for the [new features in
Python 3.4's
`unittest`](https://docs.python.org/3.4/whatsnew/3.4.html#unittest)?
The third-party [`unittest2` library](https://pypi.python.org/pypi/unittest2/)
is a very ... |
How to numpy searchsorted bisect a range of 2 values on 1 column and get min value in 2nd column
Question: So I have a 2 column numpy array of integers, say:
tarray = array([[ 368, 322],
[ 433, 420],
[ 451, 412],
[ 480, 440],
[ 517, 475],
[ 541,... |
Clicking buttons and filling forms with Selenium and PhantomJS
Question: I have a simple task that I want to automate. I want to open a URL, click a
button which takes me to the next page, fills in a search term, clicks the
"search" button and prints out the url and source code of the results page. I
have written the f... |
In place replacement of text in a file in Python
Question: I am using the following code to upload a file on server using FTP after
editing it:
import fileinput
file = open('example.php','rb+')
for line in fileinput.input('example.php'):
if 'Original' in line :
file.... |
Python listing last 10 modified files and reading each line of all 10 files
Question: I need some help listing files in a directory and reading through each file
using Python. I know how to do this using shell commands but is there a
Pythonic way to do it?
I would like to:
1.) List all files in a directory.
2.) Grab... |
Python equivalent of Excel's PERCENTILE.EXC
Question: I am using Pandas to compute some financial risk analytics, including Value at
Risk. In short, to compute Value at Risk (VaR), you take a time series of
simulated portfolio changes in value, and then compute a specific tail
percentile loss. For example, 95% VaR is t... |
Using Python and elasticsearch, how can I loop through the returned JSON object?
Question: My code is as follows:
import json
from elasticsearch import Elasticsearch
es = Elasticsearch()
resp = es.search(index="mynewcontacts", body={"query": {"match_all": {}}})
response = js... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.