text stringlengths 226 34.5k |
|---|
Python class not working after copying it
Question: I copied some code from `nltk` directly into my project (with crediting
sources) because my school computers don't allow me to install libraries.
I copied the `PorterStemmer` class and `StemmerI` interface from
[here](http://www.nltk.org/_modules/nltk/stem/porter.htm... |
Cannot use os functions after having imported it
Question: I'm using Python (actually IronPython) with Visual Studio 2015 to make a WPF
application. I imported os but I cannot access its methods.
This is what I did:
import os
class Utils(object):
def fcn(self, arg):
... |
Convert byte string to base64-encoded string (output not being a byte string)
Question: I was wondering if it is possible to convert a byte string which I got from
reading a file to a string (so `type(output) == str`). All I've found on
Google so far has been answers like [How do you base-64 encode a PNG image for
use ... |
Install NCurses on python3 for Ubuntu
Question: I'm having issues installing `ncurses` for `Python3`. When I did the normal
`sudo apt-get install ncurses-dev`, it appeared to install for `Python2` but
when I try to run my script for `Python3`, it says.
ImportError: No module named curses
How would ... |
select based on timestamp and update timestamp with zero
Question: How do I select records from a date field which has time (HH:MM:SS.Milisecond)
value greater than zero from Mongodb collection and update it with time
(HH:MM:SS) value as zero by keeping date value as same as existing in python
script.
Current data wou... |
How to create a VM with a custom image using azure-sdk-for-python?
Question: I'm using the "new" azure sdk for python: <https://github.com/Azure/azure-sdk-
for-python>
Linked is a usage example to serve as documentation: <https://azure-sdk-for-
python.readthedocs.org/en/latest/resourcemanagementcomputenetwork.html>
I... |
SSH paramiko Azure
Question: I have usually no problems ssh'ing in python with paramiko (version
paramiko==1.15.3). Doing:
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('mylinodebox.com', key_filename='key_filename='... |
Tkinter entry getting text entered by user
Question: I am very new to Tkinter ( I find it very difficult to learn). I have a python
script working based on user input. I would like to wrap a GUI around it and
eventually put it on web. In any case for user input I would like to get this
from the GUI with a combination o... |
Understanding about data type python
Question: Today I've started learn about reverse engineering. I met struc.pack(), but I
dont know what \x12 meaning.
from struct import pack
pack('>I', 0x1337)
'\x00\x00\x137'
So \x137 is equal to 0x1337 (hex) in big-edian?
Answer: `'0x137'` is not a s... |
ipython 'no module named' error
Question: I am trying to use a Python module called **Essentia** which is used for audio
analysis. In order to use that, it has to be built in Ubuntu Environment as
explained [here](http://essentia.upf.edu/documentation/installing.html). I did
all the things to install `Essentia` in a fo... |
Python - Transliterate German Umlauts to Diacritic
Question: I have a list of unicode file paths in which I need to replace all umlauts
with an English diacritic. For example, I would ü with ue, ä with ae and so
on. I have defined a dictionary of umlauts (keys) and their diacritics
(values). So I need to compare each k... |
right way to use eval statement in pandas dataframe map function
Question: I have a pandas dataframe where one column is 'organization', and the content
of such column is a string with a list inside the string :
data['organization'][0]
Out[6] "['loony tunes']"
data['organization'][1]
Out... |
Python 2.7 Invalid syntax when running script from .csv file using pandas
Question: I am running a script with Python 2.7 using pandas to read from 2 csv files. I
keep getting "invalid syntax" error messages, particularly on line 6 and 8. I
can't figure out where is the problem, since line 6 is almost identical to
line... |
Sending a file from local to server using python - the correct way
Question: Probably a simple question for those who used to play with `socket` module.
But I didn't get to understand so far why I can't send a simple file.
As far as I know there are four important steps when we send an info over a
socket:
* open a ... |
emacs 24.5 python-mode (stock version Vs 6.2.1)
Question: I have discovered an issue with python-mode in emacs. I generally c++ develop
and seldom do python.
I have recently discovered this issue:
I emacs –Q
I open a python file
It contains:
import re as myre
Var = [
%
The % repres... |
Reading gzipped text file line-by-line for processing in python 3.2.6
Question: I'm a complete newbie when it comes to python, but I've been tasked with
trying to get a piece of code running on a machine which has a different
version of python (3.2.6) than that which the code was originally built for.
I've come across... |
UnsupportedOperation: fileno - How to fix this Python dependency mess?
Question: I'm building quite an extensive Python backend and things were working quite
good on server A. I then installed the system on a new (development) server B
on which I simply installed all pip packages again from scratch. Things seemed
to wo... |
Concatenate .txt files. Write content in one .txt file
Question: I have some .txt files in a folder. I need to collect their content all in one
.txt file. I'm working with Python and tried:
import os
rootdir = "\\path_to_folder\\"
for files in os.walk(rootdir):
with open ("out.t... |
Python comparing XML output to a list
Question: I have an XML that looks something like this:
<Import>
<spId>1234</spId>
<GroupFlag>false</GroupFlag>
</Import>
I want to extract the value of spId and compare it with a list and I have the
following script:
import xml.e... |
Extracting URL parameters into Pandas DataFrame
Question: There is a list containing URL adresses with parameters:
http://example.com/?param1=apple¶m2=tomato¶m3=carrot
http://sample.com/?param1=banana¶m3=potato¶m4=berry
http://example.org/?param2=apple¶m3=tomato¶m4=carrot
... |
Python: Save pickled object in the python script
Question: I have a class instance which I dump in a .pickle file using
`pickle.dump(instance,outputfile)` . I can distribute the script and the
pickle file and ask users to run the python script with the pickle file as an
argument, and then I can load that instance using... |
Asynchronous cmd or readline in Python
Question: I would like to write a simple program that both (1) produces lines of output
simultaneously, and (2) accepts input from the user via a command line (via
readline). (Think of a text-mode chat client, for example. I want to be able
to compose my chat messages while still ... |
Error while converting webp image file to jpg in python
Question: I have written small program to convert **webp** to jpg in python
import imghdr
from PIL import Image
im = Image.open("unnamed.webp").convert("RGB")
im.save("test.jpg","jpeg")
when executing it gives me following err... |
UnboundLocalError: local variable 'event' referenced before assignment [PYGAME]
Question: I am currently trying to create a game for a school assignment setting up
timers for some events in one of my levels, but the "UnboundLocalError" keeps
appearing and I'm not sure how to fix it. I've read some other posts where you... |
Error when migrating: django.db.utils.IntegrityError: column "primary_language_id" contains null values
Question: I am working on a Django project and made a model with several instances of a
models.ForeignKey with the same Model.
class Country(models.Model):
name = models.CharField(max_length=10... |
How to obtain current instance ID from boto3?
Question: Is there an equivalent of
curl http://169.254.169.254/latest/meta-data/instance-id
with boto3 to obtain the current running instance instance-id in python?
Answer: There is no api for it, no. There is
[`InstanceMetadataFetcher`](https://gith... |
Python multiprocessing.Pool.map dying silently
Question: I have tried to put a for loop in parallel to speed up some code. consider
this:
from multiprocessing import Pool
results = []
def do_stuff(str):
print str
results.append(str)
p = Pool(4)
p.map(do_stuf... |
Python Twitter Api: AttributeError: module 'twitter' has no attribute 'trends'
Question:
import twitter
import json
OAUTH_TOKEN='aaa'
OAUTH_SECRET='bbb'
CONSUMER_KEY='ccc'
CONSUMER_SECRET='ddd'
auth=twitter.oauth.OAuth(OAUTH_TOKEN,OAUTH_SECRET,CONSUMER_KEY,CONS... |
Training a new Stanford part-of-speech tagger from within the NLTK
Question: I've trained a part-of-speech tagger for an uncommon language (Uyghur) using
the Stanford POS tagger and some self-collected training data. I've been using
the NLTK's `nltk.tag.stanford.POSTagger` interface to tag individual sentences
in Pytho... |
Create new screen buffer with win32api in Python
Question: I want to draw a specific image to my second screen in Windows 7 using Python
3.4. I can get the handle and screen dimensions using pywin32 :
import win32api
screens = win32api.EnumDisplayMonitors()
I get the handles,dimensions of my sc... |
How to prevent automatic assignment of values to missing data imported from SPSS
Question: Let's say I have an spss file named "ab.sav" which looks like this:
gender value value2
F 433 329
. . 787
. . .
M 121 .
F 311 120
. ... |
Image subtraction using opencv and python
Question: I'm want to subtract one image from other.
This is what I have done so far.
import cv2
import numpy as np
img1 = cv2.imread('template.jpg',0)
img2 = cv2.imread('shot_one.jpg',0)
img3 = img1-img2
cv2.imshow('result',im... |
Python printing inline with a sleep command
Question: Why is the following code
from __future__ import print_function
from time import sleep
def print_inline():
print("Hello ", end='')
sleep(5)
print("World")
print_inline()
waits until the sleep is done... |
How to check the classpath where Jython ScriptEngine looks for python module?
Question: I have this `Java` code which I am using to run a `python script` using
`Jython` `ScriptEngine`:
StringWriter writer = new StringWriter();
ScriptEngineManager manager = new ScriptEngineManager();
ScriptContext... |
How can I draw diagrams from database in python
Question: How can I visually model items in a database using python?
I have a [Django](https://www.djangoproject.com/) project that currently
models my home network in the admin views. It currently describes what devices
there are and what they are connected to. For exam... |
Can't move up and down while holding left or right
Question: I am starting an RPG and when the character is running against a wall to
either side, I can't get the player to move up and down smoothly. Also, the
character can't move left or right smoothly while holding down the up and down
key and running against a wall ... |
Difference between Bytearray and List in Python
Question: I am curious to know how memory management differs between Bytearray and list
in Python.
I have found a few questions like [Difference between bytearray and
list](http://stackoverflow.com/questions/30145490/difference-between-
bytearray-and-list) but not exactl... |
Python error - setting an array element with a sequence
Question: I have been trying to run the provided code to make a color map.
The data set has `x` and `y` coordinates, and each coordinate is to have it's
own color.
However, when I run the code, I get an error saying `setting an array element
with a sequence`.
... |
load txt file containing string in python as matrix
Question: I have a .txt file containing int, string and floats. How can I import this
.txt file as a matrix while keeping strings?
Dataset contains:
16 disk 11 10.29 4.63 30.22 nan
79 table 11 20.49 60.60 20.22 nan
17 disk ... |
error: command 'x86_64-linux-gnu-gcc' when installing mysqlclient
Question: I installed django 1.8.5 in virtualenv and using python 3.4.3 the worked
displayed the **it works** page when using sqlite
I wanted to use mysql and I'm trying to install mysqlclient using
`pip install mysqlclient`
and I'm getting the follow... |
Matplotlib even frequency binned by month bar chart
Question: I want to create a bar chart where the `x-axis` represents months and the
height of the bars are proportional to the amount of days entered into a list
of dates that fall in this month. I want to dynamically update the list and
the program should then update... |
Read out definitions of a text file based dictionary
Question: I'm trying to write a Python function that takes as an input a text file based
dictionary, for example Webster's free dictionary. The function
"webster_definition" will then search through the text file and print the
definition for a specific word, e.g. "Ca... |
Python lxml's XPath not finding <ul> in <p> tags
Question: I have a problem with the XPath function of pythons lxml. A minimal example is
the following python code:
from lxml import html, etree
text = """
<p class="goal">
<strong>Goal</strong> <br />
<ul... |
Converting a nested loop calculation to Numpy for speedup
Question: Part of my Python program contains the follow piece of code, where a new grid
is calculated based on data found in the old grid.
The grid i a two-dimensional list of floats. The code uses three for-loops:
for t in xrange(0, t, step):
... |
Python: Have an action happen within every single function of a python file
Question: Sorry the title isn't very clear but it is kind of hard to explain. So I am
wondering how you can have a certain action happen within every single
function of a python file. I want a user to type 'paper' inside any function
in the ent... |
How to make tkintertable Table resizable
Question: I am creating a GUI using pythons Tkinter (I am using python 2.7 if it makes a
difference). I wanted to add a table and so am using the tkintertable package
as well. My code for the table is:
import Tkinter as tk
from tkintertable.Tables import Table... |
Python Test inheritance with multiple subclasses
Question: I would like to write a Python test suite in a way that allows me to inherit
from a single TestBaseClass and subclass it multiple times, everytime changing
some small detail in its member variables.
Something like:
import unittest
class... |
Python : sklearn svm, providing a custom loss function
Question: The way I use sklearn's svm module now, is to use its defaults. However, its
not doing particularly well for my dataset. Is it possible to provide a custom
loss function , or a custom kernel? If so, what is the way to write such a
function so that it matc... |
Python - Using a List, Dict Comprehension, and Mapping to Change Plot Order
Question: I am relatively new to Python, Pandas, and plotting. I am looking to make a
custom sort order in a pandas plot using a list, mapping, and sending them
through to the plot function.
I am not "solid" on mapping or dict comprehensions. ... |
converting a recursion to iteration in python
Question: I wrote the below python script that sorts the elements of an array using
divide-and-conquer (recursive calls). One of my friend suggested that
recursion is slower than iteration. Is there a way to convert the below
program to a 'for' loop and still leverage divid... |
'LinearSVC' object has no attribute 'classes_'
Question: I have several samples of images and I would like to predict if those images
contain text/characters.
I get an error when I try running my code at this step :
model = cPickle.load(f)
is_text = model.predict(image_samples)
image_samples a... |
Finding letter bigrams in text using Python regex
Question: I am trying to use `re.findall` to find all the sets of two letters following
each other in a text (letter bigrams). How do I get the regex not to consume
the last letter of the previously found bigram, so that it can be used again
in the following?
The follo... |
Python GUI - 2.7 to 3.5
Question:
from tkinter import *
#Create the window
root = Tk()
#Modify root window
root.title("Simple GUI")
root.geometry("200x50")
app = frame(root)
label = Label(app, text = "This is a label")
label.grid()
#kick of the event loo... |
ImportError: No module named bs4 in Windows
Question: I am trying to create a script to download the captcha from my website. I
think the code works except from that error, when I run it in cmd (I am using
windows not Linux) I receive the following:
from bs4 import BeautifulSoup
ImportError: No modul... |
Django NoReverseMatch error with namespacing, Error during template rendering
Question: I have been looking at this all day now and I am not able to figure this out.
When loading hotel/index.html at this moment I get an error:
NoReverseMatch at /hotel/
Reverse for 'activities' with arguments '(... |
Python throws an Attribute error
Question: I simply can't get my Code to work in python
it gives me this error:
Traceback (most recent call last):
File "C:/Users/Patrick/Desktop/SummonerGui/__main__.py", line 10, in <module>
main()
File "C:/Users/Patrick/Desktop/SummonerGui/__main__.... |
Extract Numbers and Size Information (KB, MB, etc) from a String in Python
Question: I have a string like this
"44MB\n" (it can be anything ranging from 44mb, 44 MB, 44 kb, 44 B)
I want to separate `44` and `MB` from the above string. I have written this
code to extract the number
im... |
Reverse a string in Python but dont reverse alphanumerics
Question: I want to reveres a string but not alphanumeric characters and spaces in it.
How we can achieve it?
input : "This is Testing! The email-id is testing@my.com"
output : "sihT si gnitseT! ehT di-liame si gnitset@ym.moc"
how can I ... |
Can a regular expression be used as a key in a dictionary?
Question: I want to create a dictionary where the keys are regular expressions:
d = {'a.*': some_value1, 'b.*': some_value2}
Then, when I look into the dictionary:
d['apple']
I want apple `'apple'` to be matched against... |
Optimal framework to distribute a Python program across n cores
Question: I'm new to distributed systems and have been tasked with the objective of
distributing a piece of existing Python code. The goal is to treat the code as
a binary or a library and author two different kinds of wrappers:
* **Wrapper 1:** Receive... |
Empirical cdf in python similiar to matlab's one
Question: I have some code in matlab, that I would like to rewrite into python. It's
simple program, that computes some distribution and plot it in double-log
scale.
The problem I occured is with computing cdf. Here is matlab code:
for D = 1:10
de... |
how can i run RandomRowFilter in happybase
Question: I want to sample rowkey in hbase by happybase(because of memory limit) So I
search and implemet
import happybase
"""~ """"
table = connection.table('drivers')
a=list(table.scan(filter="RandomRowFilter (chance=0.1f)" ))
or a=list(ta... |
Using ExtractMsg in a loop?
Question: I am trying to write a script that will extract details from Outlook .msg
files and append then to a .csv file. ExtractMsg
(<https://github.com/mattgwwalker/msg-extractor>) will process the messages
one at a time, at the command line with 'python ExtractMsg.py message' but I
can't ... |
Python read a txt file into a list of lists of numbers
Question: My txt file looks like this:
[[1,3,5],[1,4,4]]
[[1,4,7],[1,4,8],[2,4,5]]
And I was trying to convert it into a list, which include all the lists in the
txt file. So the desired output for my example would be:
[[[1,3... |
How do I import Zbar into my Python 3.4 script?
Question: I am pretty new to programming, and have never used Zbar before. I am trying
to write a simple script that will allow me to import Zbar and use it to
decode a barcode image. I already have a script set up to decode text from
images that uses Pytesseract and Tess... |
User Defined Function breaks pyspark dataframe
Question: My spark version is 1.3, I am using pyspark.
I have a large dataframe called df.
from pyspark import SQLContext
sqlContext = SQLContext(sc)
df = sqlContext.parquetFile("events.parquet")
I then select a few columns of the dataframe an... |
Python multiprocessing with arrays and multiple arguments
Question: So I am trying to read in a bunch of very large data files and each one takes
quite some time to load. I am trying to figure out how to load them in the
quickest way and without running into memory problems. Once the data files are
loaded into the arra... |
Convert string to integer python CGI
Question: I'm stuck on a part of my code where I need to convert the value of a radio
button from a string into a int because the function the value goes into takes
an integer. When the radio button is selected and the user presses submit, I
get a string of that value when I need an... |
how to convert a text file (with unneeded double quotes) into pandas DataFrame?
Question: I need to import web-based data (as posted below) into Python. I used
`urllib2.urlopen` ([data available
here](https://raw.githubusercontent.com/QuantEcon/QuantEcon.py/master/data/test_pwt.csv)).
However, the data was imported as ... |
Export data from Google App Engine to csv
Question: This [old answer](http://stackoverflow.com/questions/2810394/export-import-
datastore-from-to-google-app-engine) points to a link on [Google App Engine
documentation](http://code.google.com/appengine/docs/python/tools/uploadingdata.html),
but that link is now about ba... |
Python implementing Singleton as metaclass , but for abstract classes
Question: I have an abstract class and I would like to implement Singleton pattern for
all classes that inherit from my abstract class. I know that my code won't
work because there will be metaclass attribute conflict. Any ideas how to
solve this?
... |
How to add chain id in pdb
Question: By using biopython library, I would like to add chains ids in my pdb file. I'm
using
p = PDBParser()
structure=p.get_structure('mypdb',mypdb.pdb)
model=structure[0]
model.child_list=["A","B"]
But I got this error:
Traceback (most recen... |
How to correctly load Flask app module in uWSGI?
Question: [EDIT]
I managed to load the flask app module by starting uwsgi from within the
project folder. I now have a problem with nginx not having permission to the
socket file though (scroll down to the end of the question). If anybody can
help with that..?
[/EDIT]
... |
email address not recognised in XML-RPC interface to Neos Server
Question: I am using the XML-RPC submission API to the Neos Server (optimization, AMPL,
MILP, Cplex) and am receiving an error message to say that "CPLEX will not run
unless you provide a valid email address."
Am I misinterpreting what I should do with t... |
What does newArray = myNumpyArray[:,0] mean?
Question: Not too familiar with Python and need to translate some code. Here is the gist
of what I am having a problem with:
import numpy
myNumpyArray = numpy.array([1,2,3,4])
newArray = myNumpyArray[:,0]
I don't know what `myNumpyArray[:,0]` mea... |
Pair strings in list based on containing text in Python
Question: I'm looking to take a list of strings and create a list of tuples that groups
items based on whether they contain the same text.
For example, say I have the following list:
MyList=['Apple1','Pear1','Apple3','Pear2']
I want to pair t... |
Python - Using Fabric with Sudo
Question: I'm pretty new to python and fabric and I am trying to do a simple code where
I can get the output on two hosts that uses sudo, although I keep getting an
error.... Can anyone help me out with what I might be missing ?
My code:
from fabric.api import *
from ... |
How to store predicted classes matching the pre-vectorized X in Python Scikit-learn?
Question: I would like to use name to predict gender. And not just name but name
features like extracting the "last name" as a feature derived from a name. My
code's flow is as such, get data into df > specify lr classifier and dv
dict... |
Histogram with Boxplot above in Python
Question: Hi I wanted to draw a histogram with a boxplot appearing the top of the
histogram showing the Q1,Q2 and Q3 as well as the outliers. Example phone is
below. (I am using Python and Pandas) [](http://i.stack... |
python set seems to hold two identical objects
Question: I have two sets with custom objects in them. I take the objects from one set
and add them to the other set with set.update.
Afterwards, it appears that one set contains two identical objects: their hash
is identical, they are == to each other and not != to each ... |
Using cross-correlation to detect an audio signal within another signal
Question: I am trying to write a script in python to detect the existence of a simple
alarm sound in any given input audio file. I explain my solution and I
appreciate it if anyone can confirm it is a good solution. Any other solution
implementable... |
python call parent method from child widget
Question: I am trying to call parent method `printName` from child widget `treeView` but
Get error like
1. AttributeError: 'QSplitter' object has no attribute 'printName'
2. QObject::startTimer: QTimer can only be used with threads started with QThread
why parent is ref... |
Building a Tilemap in Python/Pygame and testing for mouse position
Question: Hey i appreciate any help you can provide
I am creating a tile-map for a test of a possible project. I have found a
tutorial which produced the tile-map effectively. I then tried to implement my
own code by making it loop through each X and Y... |
jQuery AJAX call works if and only if debugging in FF/Chrome
Question: I'm facing a strange issue with a Flask single app and a jQuery AJAX call I'm
making via a form in the view. Basically, the endpoint (/register) is called
correctly when I debug the JS code, but when I try to run normally, the
endpoint is never call... |
Python equivalent to Perls END block to cleanup after exit
Question: I have a script that may take a while to run. I would like it to save some
details to a file if it exits with an error.
In Perl, the END block would be the place to do something like that.
What is the Python way to clean up after exiting?
Answer: ... |
Getting Spark, Python, and MongoDB to work together
Question: I'm having difficulty getting these components to knit together properly. I
have Spark installed and working succesfully, I can run jobs locally,
standalone, and also via YARN. I have followed the steps advised (to the best
of my knowledge) [here](https://gi... |
Getting the path to changed file with QFileSystemWatcher?
Question: From the snippet in [How do I watch a file for changes using
Python?](http://stackoverflow.com/questions/182197/how-do-i-watch-a-file-for-
changes-using-python/5339877#5339877):
...
@QtCore.pyqtSlot(str)
def file_changed(path):
... |
Consume Redis messages with a pool of workers
Question: I have a Redis list where a publisher pushes some messages (JSON serialized).
On the other side the subscriber can fetch each JSON blob and do something.
The simplest way is to do this serially. But I'd like to make it a little bit
faster; I'd like to maintain a ... |
Embed "Bokeh created html file" into Flask "template.html" file
Question: I have a web application written in Python - Flask. When the user fill out
some settings in one of the pages (POST Request), my controller calculates
some functions and plot an output using Bokeh with following command and then
I redirect to that... |
Is it possible to make a "pyc only" "distribution"?
Question: Say I have a python code base organized like so:
./mod/:
./__init__.py
./main/main.py
./main/__init__.py
./mytest/__init__.py
The file
mod/main/__init__.py
is empty. And
... |
Python while loop not stopping?
Question: I'm trying to make a dice 21 game (look up if you need to, it's too long to
type out here) on Python. It's not finished yet, but for now I'm going through
and fixing any mistakes I made. I'm having some issues with a while loop that
won't turn off. After the player chooses to s... |
Most efficient way to convert a multidimensional numpy array to ctypes array
Question: Hello, I am using ctypes module in python to run some image processing C code
from python, for the purpose of optimisation of my code, and reducing the
execution time.
For this purpose, I am reading an image into a numpy array and t... |
Python dictionary keys to csv file with column match
Question: I'm trying to push multiple dictionaries (keys and values) to a csv file by
matching the key to a column in the csv header. Example:
import csv
d1 = {'a':1, 'b':2, 'c': 3}
d2 = {'d':4, 'e':5, 'f': 6}
with open('my_data.csv','wb') ... |
Python Lottery number and checker
Question: I am attempting to create a random number generator for any number of numbers
in a line and then repeating those random numbers until a "target" number is
reached. The user will enter both the number of numbers in the sequence and
the sequence they are shooting for. The progr... |
Bokeh dynamically changing BoxAnnotation
Question: Is there possible to update bokeh figure's renderes in IPython's interact
function. I have code which looks like:
x = [0, 1, 2, 3, 4]
y = [0, 1, 2, 3, 4]
source = ColumnDataSource(data=dict(x=x, y=y)
f = figure()
f.line(x, y, source=sourc... |
Rendering csv data line-by-line without writing file
Question: I want to change a large CSV-file and write result into new file.
My python script `run.py`:
import csv
writer = csv.writer(open(..., 'w'))
for l in csv.reader(open(...)):
l[0] = 'foo' if l[1] else 'bar'
writer.writer... |
Execute shell command and retrieve stdout in Python
Question: In Perl, if I want to execute a shell command such as `foo`, I'll do this:
#!/usr/bin/perl
$stdout = `foo`
In Python I found this very complex solution:
#!/usr/bin/python
import subprocess
p = subprocess.Popen(... |
Django AppRegistryNotReady Error
Question: Migrating my project from 1.8.5 to 1.9b1 cause next traceback
Traceback (most recent call last):
File "/Users/.../manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/.../env3/lib/python3.5/site-packages/django/co... |
Iterate over a column containing keys from a dict. Return matched keys from second dict keeping order of keys from first dict
Question: I have been stack with a problem for a couple of days with Python (2.7). I
have 2 data sets, A and B, from 2 different populations, containing ordered
positions along the chromosomes (... |
Why is Parsimonious rejecting my input with an IncompleteParseError?
Question: I've been trying to work out the basic skeleton for a language I've been
designing, and I'm _attempting_ to use
[Parsimonious](https://github.com/erikrose/parsimonious) to do the parsing for
me. As of right now, I've, declared the following ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.