text stringlengths 226 34.5k |
|---|
conditional product in numpy
Question: I have a list which controls what terms in the data list have to be multiplied
control_list = [1, 0, 1, 1, 0]
data_list = [5, 4, 5, 5, 4]
I need to find product of elements in the `data_list` for which the
`control_list` has `1`. My current attempt is naiv... |
Python regex dealing with "?"
Question: I know it's a pretty simple question. I happened to look at a regex example.
import re
pattern = r'^M?M?M?$'
s = "MDM"
re.search(pattern, s)
May I know why it doesn't match the string `s`? AFAIK, `?` is to specify 0 or
1 occurence. It ma... |
Flask-PyMongo and init_app()
Question: I'm doing a clean-up of my development environment. I have code that was
running fine, but I wanted to remove any conflict between the various mongo
drivers. However now I'm perplexed by the error generated from the following
set-up
<app.py>
from database i... |
Are there any Kimonolabs alternatives?
Question: Recently kimonolabs announced they will be shutting down which is a major let
down as my app heavily relies on this service in terms of getting data. It's
really dissapointing that they're just shutting this service. I've been using
import.io in the mean time but it's no... |
Cannot transfer Pixel to image in correct in right shape from cv code to cv2 code
Question: Recently I trying to do some image processing for my work. Unfortunately that
I keep trying to apply my old C++ code with cv support to python code with cv2
support. It cannot work very well... Can anyone help me?
Original C++ ... |
Configuring either threading or multiprocessing to run multiple scripts python
Question: I trying to run multiple scripts, I have one master script which I just
replace the name with and run.
The threading method i'm trying looks like this
from threading import Thread
import sys
sys.path.ap... |
Python changing file name
Question: My new application offers the ability to user to export the results. My
application exports text files with name Exp_Text_1, Exp_Text_2 etc. I want if
a file with the same file name pre-exists in Desktop to start counting from
this number and upwards. For example if a file with name ... |
mysqldb: error with Select/execute/escape_string
Question: **executing this code on Python 2.7.10 [GCC 5.2.1 20151010] on linux2**
import flask
from MySQLdb import escape_string as thwart
username="abc"
conn = MySQLdb.connect(host="localhost",user="root", passwd="xxxxxxx", db="pythonprog... |
Either the websocket or the tornado goes down everytime.
Question: I am new to asynchronous programming. I have been using python 3.5 asyncio for
a few days. I wanted to make a server capable of receiving data from a
websocket machine client (GPS) as well as rendering a html page as the browser
client for the websocket... |
MultiThreading with a python loop
Question: I an trying to run this Python code on several threads of my processor, but I
can't find how to allocate multiple threads. I am using **python 2.7** in
Jupyter (formerly IPython). The initial code is below (all this part works
perfectly). It is a web parser which takes `x` i.... |
My typing simulator runs in the python shell but not in real life?
Question: I am writing a program to simulate typing and it runs in the python shell but
not when double clicked any ideas?
My code is as follows:
import sys,time
def slow_text(str):
for letter in str:
sys.stdout.w... |
cv2.FeatureDetector_create('SIFT') causes segmentation fault
Question: I am using opencv 2.4.11 and python 2.7 for a computer vision project. I am
trying to obtain the SIFT descriptors:
ima = cv2.imread('image.jpg')
gray = cv2.cvtColor(ima,cv2.COLOR_BGR2GRAY)
detector = cv2.FeatureDetector_c... |
Keeping socket connection alive with Python client and Node.js server
Question: I'm trying to combine a Node.js with Python to create a socket connection.
The problem is that I can send data, but I can't maintain the connection.
This is my server in Node.js
var net = require('net');
var HOST =... |
Multiprocesing pool.join() hangs under some circumstances
Question: I am trying to create a simple producer / consumer pattern in Python using
`multiprocessing`. It works, but it hangs on `poll.join()`.
from multiprocessing import Pool, Queue
que = Queue()
def consume():
wh... |
Making POST request in Python
Question: This is the form I am working with.
<form name="form1" method="post" action="http://lumbininet.com.np/eservice/index.php/login/processLogin" id="login_form">
<input type="hidden" name="logout" value=0>
<table>
<tr>
<td... |
Python: How to revolve a surface around z axis and make a 3d plot?
Question: I want to get 2d and 3d plots as shown below.
The equation of the curve is given.
How can we do so in python?
I know there may be duplicates but at the time of posting I could not fine any
useful posts.
My initial attempt is like this:
... |
what's the difference between rdd from PythonRDD and ParallelCollectionRDD
Question: I am learning how to program with Spark in Python and struggle with one
problem.
The problem is that I have a PythonRDD loaded as id and description:
pythonRDD.take(1)
## [('b000jz4hqo', ['clickart', '950', '000', '... |
Python Counter() adding value to existing keys
Question:
developer_base = Counter({
'user1': {'XS': 0, 'S': 0, 'M': 0, 'L': 0, 'XL': 0},
'user2': {'XS': 0, 'S': 0, 'M': 0, 'L': 0, 'XL': 0},
'user3': {'XS': 0, 'S': 0, 'M': 0, 'L': 0, 'XL': 0},
'user4': {'XS': 0, 'S': ... |
How do I get the entire selected row in a Qt proxy model?
Question: The code below is a working QTableView, which is using a QAbstractTableModel,
which is using a QSortFilterProxyModel. I've managed to figure out how to get
data out of a _single_ _cell_ of a selected row, but not the entire row at
once (e.g. as a list ... |
Example for setting (multiple) parameters in Python LXML XSLT
Question: Looked for the solution to this problem for a while since [the
documentation](http://lxml.de/xpathxslt.html#xslt) isn't really clear on it.
I ended up using the method below, and thought I'd share back.
Answer: Apparently you can [chain paramete... |
Python: the fastest way to translate numpy string array to a number array
Question: anyone can tell me what is the fastest way to translate this string array into
a number array as below:
import numpy as np
strarray = np.array([["123456"], ["654321"]])
to
numberarray = np.array... |
Python 3.4.3 & Bottle with CGI - environ['REQUEST_METHOD']
Question: I am trying to use Python 3.4.3 and Bottle 0.12.8 to run a simple web service
using cgi. I am running the below script from my Linux system. I was able to
run the the same service without CGI.
======================================
... |
Running Django 1.9 on CentOS 7/Apache 2.4/Python 3.4
Question: I have successfully created my Django (1.9) site on my computer. And is now
trying to move it to a web server (CentOS 7). After sitting a whole day,
searching the web, I have found many guides on how to do this. But in the
midst of all of this, probably con... |
python's ggplot does not use year number as label on axis
Question: In the following MWE, my `year` variable is shown on the x-axis as 0 to 6
instead of the actual year number. Why is this?
import pandas as pd
from pandas_datareader import wb
from ggplot import *
dat = wb.download(
... |
Pyinstaller compile to exe
Question: I am trying to compile a Kivy application to a windows exe, but I keep
receiving an attribute error: AttributeError: 'str' object has no attribute
'items'
I have compiled other applications, and followed the instructions line for
line per the [kivy page](https://kivy.org/docs/guide... |
Spyder crashes with error: "It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console"
Question: I have a 64 bit Windows 7 machine I am using Spyder 2.3.8 with Python 2.7 and
Matplotlib 1.4.2 ( I tried Matplotlib 1.5.1 and got the same error)
Every time I import matplotlib and then try... |
Removing punctuation except intra-word dashes Python
Question: There already is an approaching
[answer](http://stackoverflow.com/questions/24550620/removing-punctuation-
except-for-apostrophes-and-intra-word-dashes-in-r) in R
`gsub("[^[:alnum:]['-]", " ", my_string)`, but it does not work in Python:
my_s... |
Convert json to python list
Question: I'm new to JSON and trying to save the results of the following json response
into lists, in order to make some stats.Specifically, i'd like to save the
'results'.
{u'draws':
{u'draw':
[{u'drawTime': u'22-02-2016T09:00:00', u'drawNo': 542977, u'results': [7... |
subprocess error in python
Question: I am trying to run a praat file from python itself with subprocess but
python(subprocess) can't seem to find the directory. I don't understand why
since when I run the command in terminal, it works perfectly fine. Cant anyone
guide me to where I am going wrong? This is the subproces... |
How to get DLLs, function names, and addresses from the Import Table with PortEx?
Question: I'm using the [PortEx Java library for PE32
parsing](https://github.com/katjahahn/PortEx "PortEx") with the Capstone
disassembler, and I'd like to be able to have the disassembly replace the
appropriate `call 0x404040` lines to ... |
Django StaticCompilationError, extend ' .clearfix' has no matches
Question: I'm working on a Django application and all of a sudden I'm getting the error
`extend ' .clearfix' has no matches` and this occurs at `Exception Location:
/Library/Python/2.7/site-packages/static_precompiler/compilers/less.py in
compile_file, l... |
When does the order of multiplication matter in python?
Question: I wrote a program using dynamic programming and it took me quite a long time
to find that something is wrong with the different versions of my code. It is
as follows:
#the old version
if probs[i][k]*probs[k+1][j]*prob > tmp_prob:
... |
How to accept twitter stream using tweepy in streamparse spout and pass the tweets to bolt?
Question: Recently, I started working on storm and being more comfortable with python, I
decided to use streamparse for working with storm. I am planning to accept a
twitter stream in spout and perform some computations in bolt.... |
How to crawl pagination pages? There is no url change when I Click next page
Question: I use python3.5 and window10.
When I crawl some pages, I usually used url changes using urlopen and 'for'
iteration. like below code.
from bs4 import BeautifulSoup
import urllib
f = open('Slave.txt','w')
... |
Getting python2.7 path in django app for subprocess call
Question: I am using linux. I am trying to run daemon from function in django views. I
want to run shell command from a view in Djangp app. I am using python 2.7.
Command needs python2.7 path.
My app will be like plug n play. So on system on which it is going to... |
Convert images drawn by turtle to PNG in Python
Question: I'm making a abstract art template generator in Python that takes inputs of
minimum radius, maximum radius, and number of circles. It draws random circles
in random places, also meeting the user's specifications. I want to convert
the Turtle graphics into a PNG ... |
Getting SyntaxError while using pdfcrowd with python
Question: I am trying to learn pdfcrowd with Python 3.4, so I checked out their website
and copied the following example:
import pdfcrowd
try:
# create an API client instance
client = pdfcrowd.Client("username", "apikey")
... |
Python Flask cannot get element from form
Question: Im having trouble getting anything from the shown HTML form
I always get "ValueError: View function did not return a response"
Can somebody help me out here please? I have tried every variation of
request.get that I can find on the web. Also if I specify my form sho... |
Python Object Property Sharing
Question: I have a class that keeps track of several other classes. Each of these other
classes all need to access the value of a particular variable, and any one of
these other classes must also be able to modify this particular variable such
that all other classes can see the changed va... |
Passing variables in python from radio buttons
Question: I want to set values depends on the selected radio button and to use that
values in other function. Whatever i try, i always get the same answer
# NameError: global name 'tX' is not defined #
import maya.cmds as cmds
from functools import part... |
How do I reload a python submodule?
Question: I'm loading a submodule in python (2.7.10) with `from app import sub` where
`sub` has a `config` variable. So I can run `print sub.config` and see a bunch
of config variables. Not super complex.
If I change the config variables in the script, there must be a way to reload
... |
python lambda can't detect packaged modules
Question: I'm trying to create a lambda function by uploading a zip file with a single
.py file at the root and 2 folders which contain the requests lib downloaded
via pip.
Running the code local works file. When I zip and upload the code I very often
get this error:
`Unabl... |
PyMongo Collection Object Not Callable
Question: I'm trying to create a reddit scraper that takes the first 100 pages from the
reddit home page and stores them into MongoDB. This is my first post on
stackoverflow, so I apologize if my post is not formatted correctly. I keep
getting the error:
TypeError: ... |
Reading in csv file as dataframe from hdfs
Question: I'm using pydoop to read in a file from hdfs, and when I use:
import pydoop.hdfs as hd
with hd.open("/home/file.csv") as f:
print f.read()
It shows me the file in stdout.
Is there any way for me to read in this file as dataframe? I'v... |
Python - Store variables in a list that save each time program restarts
Question: I am stuck on a seemingly simple task with a Python Twitch IRC Bot I'm
developing for my channel. I have a points system all figured out, and I
thought it was working, but I found out that every time I restart the program,
the list that c... |
How to print the complete json array using python?
Question: I have a json array. And need to print only the id using python .How do i do
it ?
This is my json array :
{
"messages":
[
{
"id": "1531cf7d9e03e527",
"threadId": "1531cf7d9e03e527"
},
{
... |
how to upload multiple files using flask in python
Question: Here is my code for multiple files upload:
**HTML CODE:**
Browse <input type="file" name="pro_attachment1" id="pro_attachment1" multiple>
**PYTHON CODE:**
pro_attachment = request.files.getlist('pro_attachment1')
... |
How to remove a specific element from a python list?
Question: I want to remove an A element using a B array of IDs, given the specific
scalar ID 'C'
In matlab I can do this:
A(B == C) = []
This is an example of my code:
boxes = [[1,2,20,20],[4,8,20,20],[8,10,40,40]]
boxIDs = ... |
Looping through scrapped data and outputting the result
Question: I am trying to scrape the BBC football results website to get teams, shots,
goals, cards and incidents. I currently have 3 teams data passed into the URL.
I writing the script in Python and using the Beautiful soup `bs4` package.
When outputting the res... |
How to make python spot a folder and print its files
Question: I want to be able to make python print everything in my C drive. I have
figured out this to print whats on the first "layer" of the drive,
def filespotter():
import os
path = 'C:/'
dirs = os.listdir( path )
for file in dirs:
... |
Update QlistView with python list updated from another thread (pyqt5)
Question: I try to create a GUI for displaying a python a list of 512 values 0/255
It's simple with PyQt to setup a QListWidget or QListView to display this kind
of list
from sys import argv, exit
from PyQt5.QtWidgets import QList... |
Python 2.7 bottle web
Question: I’m trying to figure out how to rename an existing text file when I change the
title of the text file. If I change the title now, it’s going to create a new
text file with the new title. The "old text file" that I wanted to save with a
new name still exists but with the orginal name. So ... |
In AWS, how to create elastic ip with boto3 ? or more generaly with python?
Question: I'd like to create an elastic ip with a python script. It didn't find a way in
the doc.
Answer: Use [Allocate
Address](http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.Client.allocate_address)
> Acquires an El... |
Datalab does not populate bigQuery tables
Question: Hi I have a problem while using ipython notebooks on datalab.
I want to write the result of a table into a bigQuery table but it does not
work and anyone says to use the insert_data(dataframe) function but it does
not populate my table. To simplify the problem I try ... |
os.chdir working once, then not working after called a second time; python script
Question: in the following script, I try to clone all projects except two, then clone
those two into homepath, not my projects dir:
#!/usr/bin/env python
import os, sys, subprocess, time, re
from my_script... |
Python script to parse text file and execute inline python code
Question: I am new to python and trying to create a script that could do the following:
infile = open("input.txt", "r")
outfile = open("output.txt", "w")
print ("Starting file transformation...")
for line in infile:
... |
Python addition math quiz
Question: Just learning python and I'm trying to make an extremely simple math quiz but
when running I get a syntax error please explain what I have done wrong
from random import randint
inf = 0
while inf < 10:
num1 = randint(0,5000)
num2 = randint(0,5000... |
Get the name of the current module that has been failed to import
Question: i need help to get the name of the not imported module while doing that
so the code is:
#!/usr/bin/env python
bla=[]
try:
import os
import sys
import somethings
import blabla
except:
... |
unable to run mongo-connector
Question: I have installed mongo-connector in the mongodb server.
I am executing by giving the command
mongo-connector -m [remote mongo server IP]:[remote mongo server port] -t [elastic search server IP]:[elastic search server Port] -d elastic_doc_manager.py
I also t... |
Problems with installing scikit-learn on Fedora
Question: I have some problems while installing scikit-learn on Fedora 23 using pip
`pip install scikit-learn`
Here's what I get
> Command "/usr/bin/python -u -c "import setuptools, tokenize;**file**
> ='/tmp/pip-build-MPbvR0/scikit-
> learn/setup.py';exec(compile(geta... |
wsgi breaks on ec2 django installation
Question: I'm getting the following error when testing a start django app: ImportError:
No module named django.core.wsgi
[Fri Feb 26 23:23:33 2016] [error] [client 100.9.129.136] mod_wsgi (pid=25312): Target WSGI script '/var/www/html/app_mgmt/app_core/wsgi.py' cann... |
Python: Rock Paper Scissors While Loop Issue
Question: I'm having an issue with my programming of Rock, Paper, Scissors for Python.
My issue occurs when there is a tie. When there is a tie, my program is
supposed to going into a while loop within the if statement of the tie and
reask the player the same question, rock,... |
HTML and Python : How to make variables in a html code written in a python script
Question:
from bs4 import BeautifulSoup
import os
import re
htmlDoc="""
<html>
<body>
<table class="details" border="1" cellpadding="5" cellspacing="2" style="width:95%">
<tr>
<td>Roll ... |
Use string in subprocess
Question: I've written Python code to compute an IP programmatically, that I then want
to use in an external connection program.
I don't know how to pass it to the subprocess:
import subprocess
from subprocess import call
some_ip = "192.0.2.0" # Actually the result... |
Python: How to get rid of the sequences according to the sequence bases rather than their header name?
Question: I would like to deduct two files based on the sequence constituents rather
than using the header name to get rid of the sequences. Is there any other way
I can deduct the sequences? can anyone help me? If th... |
Adding short-hostname into the /etc/hosts file with python
Question: Currently my /etc/hosts file is missing the short-hostname(last column) is
there a way to take the FQDN value in the file remove '.pdp.wdf.ltd' and add
the hostname to the last column. To reach till here I did write a small python
script wrote it to a... |
pass data frame from one function to another in python
Question: I am using two functions, one to load data and another to get a summary of the
same data. However in second function analyze() I get the error df not
defined. How do I pass df from loader() to analyze() ?
from xlwings import Workbook, Range... |
Python Pandas Pivot Table Sort by Date
Question: I have the following code:
data_df = pandas.read_csv(filename, parse_dates = True)
groupings = np.unique(data_df[['Ind']])
for group in groupings:
data_df2 = data_df[data_df['Ind'] == group]
table = pandas.pivot_table(data_df2, valu... |
Python if else statement
Question: My if statement works but else doesn't can anyone help me? this is my code.
Btw if anyone knows how to ask for a retry after one time would be awesome!
import random
print('choose a number between 1 and 10,if you guess right you get 10 points if you guess wrong... |
Implementing a basic graph database engine
Question: I need to implement a simple graph database engine, what are the things should
I consider? First, I am confused between which data structure to use, I mean
graph representation (like adjacency matrix or adjacency list) or the actual
graph itself? I need this to be sc... |
How to exclude multiple columns in Spark dataframe in Python
Question: I found pyspark has a method called `drop` but it seems it can only drop one
column at a time. Any ideas about how to drop multiple columns at the same
time?
df.drop(['col1','col2'])
TypeError ... |
How to add legend/label in python animation
Question: I want to add a legend in a python animation, like the `line.set_label()`
below. It is similar to `plt.plot(x,y,label='%d' %*variable*)`.
However, I find that codes do not work here. The animation only shows lines
changing but no label or legend available. How can ... |
How can I use the value from a spin box (or other Tkinter widget) properly in a calculation?
Question: I am writing a program in Python/Tkinter where I need to get the user's
inputted value from a spin box and use it in a mathematical calculation (to
calculate the cost of an item, more specifically). This is triggered ... |
Python Slicing text file into arrays based on field value
Question: I am new to Python and I want to read a text file that has three fields; `X`,
`Y` and `Time`. I want to form arrays from the x and y fields as long as the
time field is still the constant. For example:
X Y Time
1 2 100
... |
Why copied objects have the same id as previously copied ones in Python?
Question: I am trying to understand one observation. I have an application that loads
various `Canvas` classes which a user can later work with. These classes are
located in several files. For example.
canvas/
bw.py
... |
Python image recognition with pyautogui
Question: When I try to recognize an image with `pyautogui` it just says: `None`
import pyautogui
s = pyautogui.locateOnScreen('Dark.png')
print s
When I ran this code the picture was on my screen but it still failed.
Answer: On my system, I get thi... |
Using Python to use a website's search function
Question: I am trying to use a search function of a website with this code structure:
<div class='search'>
<div class='inner'>
<form accept-charset="UTF-8" action="/gr/el/products" method="get"><div style="margin:0;padding:0;display:inline"><input n... |
Get absolute path of shared library in Python
Question: Let's say I wanted to use libc in Python. This can be easily done by
from ctypes import CDLL
from ctypes.util import find_library
libc_path = find_library('c')
libc = CDLL(libc_path)
Now, I know I could use ldconfig to get lib... |
Getting an empty list as attribute when parsing XML with xml.etree.ElementTree
Question: So I use python 3 to parse an XML.
text = '''
<body>
<list>
<item>
<cmid>16934673</cmid>
<day>29.02.2016</day>
<relay>1</relay>
... |
How to use python 3.5.1 with a MySQL dtabase
Question: I have been trying to use MySQL in a python project I've been working on. I
downloaded the connector: mysql-connector-python-2.1.3-py3.4-winx64
[here.](https://dev.mysql.com/downloads/connector/python/)
I already had python 3.5.1 installed. When i tried to install... |
Python iteration: sorting through a .txt file extract wanted data
Question: I have a sample inputfile.txt:
chr1 34870071 34899867 pi-Fam168b.1 -
chr11 98724946 98764609 pi-Wipf2.1 +
chr11 105898192 105920636 pi-Dcaf7.1 +
chr11 120486441 120495268 pi-Mafg.1 ... |
python left and right arrow key event not working
Question: I am new to Python and trying to create a turtle shape and once the user
clicks the left or right arrow keys on keyboard the shape should move in that
direction, however nothing is happening.
I am trying to move the player using the left and right arrow keys,... |
TclError: can't invoke "destroy" command: application has been destroyed
Question: I am a python beginner. Try to make a new button to close the window. I got
the error message:
> Exception in Tkinter callback Traceback (most recent call last): File
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/pytho... |
Sorting a list alphabetically from a CSV in Python by column
Question: I've written a piece of code that sends data to a .csv file, sorting by name,
and then 3 scores from a quiz. I need to call that data from the .csv file
created and sort the data alphabetically by name, numerically, and by average.
However, when I t... |
Looping in Python
Question: I'm trying to figure a way to loop this code so that it restarts once all
three of the calculations are complete. I have figured a way to restart the
program itself, however I can't manage to restart it so that it returns back
to the first calculation step. Anyone can help a brother out? Tha... |
Are there raw strings in R for regular expressions?
Question: In Python you can use raw strings:
import re
re.sub(r"\\", ":", "back\\slash") # r"\\" instead of "\\\\"
Does this exist in **R** as well? For example, here is an equivalent code
snippet without raw strings in **R** :
... |
Issues with pyinstaller and reportlab
Question: Alright so I have a python project that I want to compile, so I decided to use
pyinstaller (first time compiling python). Now it compiled fine but when I run
the exe it returns -1. So after a bit of messing around I figured out that it
was related to reportlab.platypus.
... |
Running a python script with nose.run(...) from outside of the script's directory results in AttributeError: 'module' object has no attribute 'tests'
Question: I have a python application with a few sub directories. Each subdirectory has
its own `tests.py` file.
I use nose to run all of the unittests across all of the... |
Python constructor
Question: I have this constructor for a line class in python and it takes two points as
a parameter. The problem is my constructor is only copying the references. So
self.point0 and point 0 are pointing to the same object. I am not really sure
how to change that so that I am not just copying the refe... |
Python error: argument -c/--conf is required
Question:
I'm new in python, my native language is C. I'm doing a code in python for a
surveillance system triggered by motion using OpenCV. I based my code in the
one made by Adrian Rosebrock in his blog [
pyimagesearch.com](http://www.pyimagesearch.com/2015/06/01/home-s... |
transform new dataset for prediction in Python
Question: I train model (for ample _linear_model.LinearRegression_) with some iteration
like `*pd.get_dummies*`
and I get new structure of data Now I take a new dataset & want to predict. I
cann't use _`predict`_ because structures are different. `*pd.get_dummies*`for
new... |
AWS S3 policies confusions
Question: I would like to give read (download) right to a single user. I am confused
about what I should use:
Should I use
* The Bucket Policy Editor from the S3 interface
* The inline policies for the user and specify read permissions (from IAM interface)
* Activate "Any Authenticat... |
Python: How to set values of zero in a list/array/pd.Series to be the next non-zero value?
Question: I have a Python list-like structure with more than 1 million elements. Each
element takes one of three possible values, namely `-1`, `0`, or `1`. What I'm
trying to achieve is to replace all the zeros with the next non-... |
MIMEMultipart() in Python
Question: Why do I always get `From nobody` when creating a message with
`MIMEMultipart()` in Python? Is this changeable?
msg2 = MIMEMultipart('csv')
print m... |
About lists in python
Question: I have an excel file with a column in which values are in multiple rows in
this format 25/02/2016. I want to save all this rows of dates in a list. Each
row is a separate value. How do I do this? So far this is my code:
I have an excel file with a column in which values are in multiple ... |
script in python: Template is not defined
Question: I am using the following Python script:
import numpy as np
import matplotlib.pyplot as plt
import nibabel
import os
def collapse_probtrack_results(waytotal_file, matrix_file):
with open(waytotal_file) as f:
wayto... |
Python, is there a easier way to add values to a default key?
Question: The program I am working does the following:
* Grabs stdout from a .perl program
* Builds a nested dict from the output
I'm using the AutoVivification approach found
[here](http://stackoverflow.com/questions/635483/what-is-the-best-way-to-
im... |
Pythonic way to generate a list of a certain size with no duplicates?
Question: I'm trying to generate a list of `(x, y)` tuples of size `num_cities` with the
constraint that no two tuples are the same. Is there a shorter, Pythonic way
to do this using a set comprehension or `itertools`? I currently have:
... |
How to send None with Signals across threads?
Question: I've implemented a version of the worker pattern that is described in the [Qt
Threading docs](http://doc.qt.io/qt-4.8/qthread.html).
I'm using `Signals/Slots` to send data between the worker thread and the main
thread.
When defining the `Signal`, I've set the ar... |
PhantomJS stability when rendering multiple pages
Question: I am running PhantomJS on a big set of pages to scrape some specific JS-
generated content. I am using the Python Selenium bindings with which it's
easy to perform XPath queries on the results. I have noticed that if I try to
instantiate a single `webdriver.Ph... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.