text stringlengths 226 34.5k |
|---|
Pygame doesn't catch keydown events on mac
Question: When I am trying to catch keys pressed, they are printed in Terminal, but not
caught by pygame and the script. Script is executed as follows:
>>>import scriptname
>>>scriptname.wa()
scriptname file: import pygame from pygame.locals import *
... |
Running a loop while a function is true in python
Question: I have a function which returns either `True` or `False`. I'm trying to
perform a loop where that function is called several times until it returns
`False`, and count how many times it ran.
import random as rand
def test_function():
... |
How to pass along username and password to cassandra in python
Question: I'm learning and just setup my cassandra cluster and trying to use python as
the client to interact with it. In the yaml, I set the authenticator to be
PasswordAuthenticator.
So now I plan to provide my username and password over to the connect f... |
How to correctly catch an exception raised by a module?
Question: In a python project I use a module [python-
mpd2](https://github.com/Mic92/python-mpd2) that connects to an (mpd.)server.
The server closes the connection after one minute. Most methods provided by
the module would then result in an `mpd.ConnectionError`... |
functions in python - need explanation
Question: can someone simply explain functions in python? I just can't get my head
around them.
So I have had a go at them, and this is what I've ended up with, but it keeps
saying that character is not a global variable
def char_name():
character = input("... |
instance has no attribute 'sock'
Question: I have a basic server program running in Python using Twisted. I am trying to
reject a user and am trying to use `self.sock.close()`. When that line gets
called I get an exception:
> AttributeError: IphoneChat instance has no attribute 'sock'.
This is strange because before ... |
Two-dimensional arrays in Python
Question: I'm reading in data for three separate cities and I want to keep each set of
data in a two-dimensional array, but as I get past a part of my code, loops
keep writing over things from my first two cities as I only have a one-
dimensional array. Where should I set up these 2-D a... |
Numpy way of appending the data retrieved from for loop
Question: I am looking for the numpy way of appending the data retrieved from for loop
as in the example below:
import glob, gdal, numpy as np
tiff_files = glob.glob('*.tif')
all_data = [] #LOOKING FOR ALTERNATIVE HERE
for f ... |
Python 2.7 Dict with key value pairs of lists is reordered
Question: I'm trying to use a dict of key value pairs to store and access lists based on
the appropriate keys. Below is what I'm using.
newDict = {'mod':[0,2], 'pro':[2,3], 'st':[6,10]}
newDict2 = {'a':[0,2], 'b':[2,3], 'c':[6,10]}
I'm ... |
Read python pickle data stream in Android
Question: I have this file which contains python pickle data stream. I've to read
contents of this file in Android.
For example, if I wanted to read this data stream in python, I'd just use the
following code
queue = pickle.load(open('filename', 'rb'))
I w... |
How does struct.unpack and struct.pack works?
Question: I'm currently trying to to learn how to parse PPM file. I did the following in
a python interpreter:
>>> x = open('file.ppm')
>>> x.readline()
'P6\n'
>>> x.readline()
'2 3\n'
>>> x.readline()
'255\n'
>>> x.readline()
... |
Python copy larger file too slow
Question: I am trying to copy a large file (> 1 GB) from hard disk to usb drive using
`shutil.copy`. A simple script depicting what I am trying to do is:-
import shutil
src_file = "source\to\large\file"
dest = "destination\directory"
shutil.copy(src_file, dest... |
Modification of text files over ssh with Python - performance
Question: I need to replace some lines in text files via ssh, if they contain a certain
key string. I wrote the following simple Python function for that:
def ssh_edit_file(h, u, file_in, file_out, key, new):
import paramiko, string, ... |
xpath works for just one item when add // in it
Question: I have this html page
<page>
<div class="results-list">
<div class="item paid-featured-item"></div>
<div class="item paid-featured-item"></div>
<div class="item paid-featured-item"></div>
<div class="item p... |
Why does my python/pygame application not pop up properly
Question: I have made a program with python and pygame and bundled it into a .app file
using py2app. It just doesn't open up properly when i click the icon, it
doesn't appear on the screen until i click the icon on the dock, by then some
of the code has already ... |
Python Regex - checking for a capital letter with a lowercase after
Question: I am trying to check for a capital letter that has a lowercase letter coming
directly after it. The trick is that there is going to be a bunch of garbage
capital letters and number coming directly before it. For example:
AASKH3... |
Python 3.3 nameerror name not defined
Question: # Main file (robot.py)
from common.delay import PreciseDelay
from common.generic_distance_sensor import GenericDistanceSensor, MB10X3
from common.ez_can_jaguar import EzCANJaguar
igus_can = 1
l_actuator_can = 2
igus_can = EzCan... |
Need Tkinter code for python GUI for implementation of TSP in Branch and bound and dynamic programming methods..
Question: Need Tkinter code for python GUI for implementation of TSP in Branch and bound
and dynamic programming methods.. The below code is working fine and i need a
gui platform for my project presentation... |
Simple Python Echo Server - Wrong Argument
Question:
import select
import socket
import sys
host = ''
port = 50000
backlog = 5
size = 1024
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((host,port))
server.listen(5)
input = [server,sys.stdin]
... |
How do I split this string in python 2.7 keeping spaces?
Question: I am looking for a way to take a string and output it as a list with each
character split?
>>> sentence = 'hello I am cool'
>>> what_i_want(sentence)
['h', 'e', 'l', 'l', 'o', ' ', 'I', ' ', 'a', 'm', ' ', 'c', 'o', 'o', 'l']
... |
django views : passing a dictionarry
Question: I'm starting with Django (coming from CodeIgniter) and everything is very
confusing...
I want to get my blog posts ordered by pub_date, and I want to display them in
the templates grouped by month+year.
I tried this but obviously it's not working... And my knowledge of P... |
Python: file-object conflicts
Question: I'm beginning with python and I created a class of file-object deriving from
the 'file' class to be able to manipulate large datafiles. I have created
specific methods to work on these files that are built like shown below. I
need to return a new instance of MyClass after each me... |
python-print statement :syntax error -invalid syntax;IMPORT ERROR:NO MODULE NAMED PYPARSING
Question:
from __future__ import print_function//////
from pyparsing import *//ERROR IN THIS LINE///////
from copy import deepcopy def convertToCNF(exp):
print("Given formula:", exp, sep="\n", end="\n\n")... |
Python: calling method in the map function
Question: `map()` and list comprehension are roughly equivalent:
map(function, list1)
[function(i) for i in list1]
What if the function we want to use is a method?
[i.function() for i in list1]
map(.function, list1) # error!
map(... |
import behavior when accessing global variables in Python
Question: In **bar.py** :
var = 1
def set_var():
global var
var = 2
In **foo.py** :
from bar import *
print(var)
set_var()
print(var)
In **foo2.py** :
import bar
... |
boto dynamodb batch_write and delete_item -- 'The provided key element does not match the schema'
Question: I'm trying to delete a large number of items in a DynamoDB table using boto
and python. My Table is set up with the primary key as a device ID (think MAC
address.) There are multiple entries in the table for each... |
Python lxml etree check if node exists
Question: I have this XML:
<MasterPage>
<NextPage>
<prefix>
I want to check if the `prefix` node exists; I tried this, but it didn't work:
self.doc=etree.parse(xmlFile)
if hasattr(self.doc, 'MasterPage/NextPage/prefix'):
... |
Converting a function from sympy to numpy (attribute error)
Question:
import numpy as np
import sympy as sym
from numpy import sin
from sympy import symbols, diff
func = lambda x: sin(x)
x = symbols('x')
print diff(func(x),x)
This works if I replace my function with a polynomi... |
Evaluate integral from sympy as lambda function
Question: I'm using the sympy module of python. I do is this:
x= Symbol('x')
integrate(x**2+2,x)
The answer is:
x**3/3 + 2*x
Now, the question is this: Is there a way to make this answer a lambda
function of x?
Answer: Yes, ... |
How does PySerial work?
Question: Say I have the following python script to read in serial data from my Arduino:
import serial
ser = serial.Serial("dev/ttyACM1", 9600)
ser.timeout = 2
ser.readlines()
On the other end I've flashed my Arduino with a program that sends 20 voltage
read... |
regEx works in notepad++ but not in python
Question: let's say we have this:
.................
=== Operation 'abcd::ddca:dsd' ended in 1.234s /1.234s (100.00%) execution time
................
Using notepad++, I am able to identify this with:
^\=* Operation '([\d\D]*)' ended... |
Stitching images in python
Question: I would like to stitch multiple (5 or 6) images using python. I'm new to
python but I want to use this since it runs on the server and is opensource.
OpenCV seems very well capable of doing this and would be my prefered option,
but the functions are mostly in C++ and I can't find an... |
Shebang for compiled Python code
Question: I used to add shebang line at top of Python script as,
#!/usr/bin/python
...
And I can execute the my.py file by,
chmod a+r my.py
./my.py
But after compiled to bytecode, the script can only be executed by python and
the shebang... |
using python WeakSet to enable a callback functionality
Question: I'm investigating if I can implement an easy callback functionality in python.
I thought I might be able to use weakref.WeakSet for this, but there is
clearly something I'm missing or have misunderstood. As you can see in the
code I first tried with a li... |
Disablling scrolling of a scroll bar while keeping it visible in wxPython
Question: I am currently working with wxPython v3.0, python v2.7 on Windows 7 OS. I have
question regarding the scroll bars. In my application I have a GUI which has
many scrolled panels. The scroll bar of these scrolled panels are working fine
t... |
Python create many-to-many relationships from a list
Question: I have a list, say `terms = ['A', 'B', 'C', 'D']`
Which is the best way to create a list-of-lists or list-of-tuples of many-to-
many relationships like this;
[['A','B'],['A','C'],['A','D'],['B','C'],['B','D'],['C','D']]
Answer: Using
... |
Django - test client receives 403 because of csrf
Question: I'm using Django 1.6 and python 3.3.
I'm trying to test POST form with django test client, and it receives 403
after sending request. If I add `@csrf_exempt` at my view method, everything
works perfect. But the Django documentation says that it should work wi... |
How to expose Python callbacks to Fortran using modules
Question: [This scipy documentation page](http://docs.scipy.org/doc/numpy-
dev/f2py/python-usage.html#call-back-arguments) about F2Py states:
> [Callback functions] may also be explicitly set in the module. Then it is
> not necessary to pass the function in the a... |
Python 3 rounding behavior in Python 2
Question: In Python 2.x, the built-in
[`round`](http://docs.python.org/2/library/functions.html#round) has the
following behavior:
> if two multiples are equally close, rounding is done **away from 0** (so.
> for example, round(0.5) is 1.0 and round(-0.5) is -1.0)
In Python 3.x,... |
Python - extending properties like you'd extend a function
Question: ## Question
**How can you extend a python property?**
A subclass can extend a super class's function by calling it in the overloaded
version, and then operating on the result. Here's an example of what I mean
when I say "extending a function":
... |
it is possible to download GitHub repository to my local computer
Question: hello friends i just started to use GitHub and i just want to know it is
possible to download github repository to my local computer through by Using
GitHub Api or Api libraries (ie. python library " pygithub3" for Github api)
Answer: Using [... |
python lxml.html: returns null list for yahoo finance
Question: The following code returns an empty list;
import lxml.html
url = 'http://finance.yahoo.com/q/pr?s=AYR+Profile'
content = lxml.html.parse(url)
sector = content.xpath('//*[@id="yfncsumtab"]/tbody/tr[2]/td[1]/table[2]/tbody/tr/td/ta... |
Using storm in python
Question: I want to make a hello world in python using storm.
My server manager(Linux server) have told me that storm is installed on the
server and I'm seeing the control panel now.
When I'm trying to import storm as this tutorial mentioned:
<https://storm.canonical.com/Tutorial#Importing> an... |
Unable to call python Function in Webkit report Openerp
Question: My report file contains
class AccountInvoice_Report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(AccountInvoice_Report, self).__init__(cr, uid, name, context=context)
... |
How to read hundreds of csv files from a directory and sum a specific column from each of them?
Question: I have around 650 csv files in a directory. Each of them have three columns
with header(#ch# ##kev## ###count###), and 2050 rows.One of the file image is
shown here partly.
ch kev count... |
Error when trying to use pymysql with sqlalchemy sre_constants.error: nothing to repeat
Question: I tried to use pymsql with sqlalchemy using this code :
from sqlalchemy import create_engine
engine = create_engine("mysql+pymsql://root:@localhost/pydb")
conn = engine.connect()
... |
Python backtracking strings lenght n from alphabet {a,b,c} with #a=#b
Question: i want to make an algoritm that finds for a given n the strings made on the
alphabet {a,b,c} in which the number 'a' appears the same times of 'b'
i came out with this
n=3 #length String
h=-1 #length prefix
L=['a','b... |
Importing modules from different directories
Question: I have a problem importing a module: It is under this directory `./dao` and
the code that calls it is here `./core`. Schematically represented as:
rnaspace/
__init__.py
core/
__init__.py
logger.py
dao/
__init__.py
... |
How do I open a text file in TextEdit from Python on Mac?
Question:
else:
tkMessageBox.showinfo('Report Created', 'Your report was sucessfully created')
file = 'Student Report.txt'
os.system('TextEdit'+file)
I am writing a program that creates a report from data from a database, writes
t... |
collect all directories matching criteria from directory tree in python
Question: How can I collect all directories that match a criteria (like 'contain a file
named foo.txt') recursively from a directory tree? something like:
def has_my_file(d):
return ('foo.txt' in os.listdir(d))
walk_t... |
Sorting a list of tuples in python according to an element index
Question: How can I sort a list of tuples according to the int in a certain position?
(without a for loop)
eg. Sorting `l = [(1,5,2),(7,1,4),(1,6,3)]` according to the third element in
each tuple?
Answer: You can use
[`list.sort`](http://docs.python.or... |
multiple argument from terminal using python
Question: I am able to run this properly using os.system. It is writing pcap file into
text.
os.system("tshark -z 'proto,colinfo,tcp.srcport,tcp.srcport' -r filename.pcap > testfile")
But when I tried to give input file from termimal, I got following err... |
python-dpkt: ICMP packet parsing
Question: How can I parse a ICMP packet (using dpkt) to check if it is a request or a
response coming from A to B?
I found some examples for TCP and UDP packets (below) but I can't find
anything for IP packets.
import dpkt
f = open('test.pcap')
pcap = dpkt.p... |
python - pull pdfs from webpage and convert to html
Question: My goal is to have a python script that will access particular webpages,
extract all pdf files on each page that have a certain word in their filename,
convert them into html/xml, then go through the html files to read data from
the pdfs' tables.
So far I h... |
Android Bluetooth Client and Server Won't Connect
Question: I am currently trying to create an app that connects Google Glass(client) to
my computer(python server). I would like to send simple strings. I have tried
multiple ways but haven't had much luck. I am currently using some sample code
I found. After running bot... |
left hand side eigenvector in python?
Question: How do calculate the left hand side eigenvector in python?
>>> import from numpy as np
>>> from scipy.linalg import eig
>>> np.set_printoptions(precision=4)
>>> T = np.mat("0.2 0.4 0.4;0.8 0.2 0.0;0.8 0.0 0.2")
>>> print ... |
Can't import shared.SharedService in thrift tutorial
Question: I seem to be mis-understanding something about Apache Thrift. I have it
installed and generated python bindings using the tutorial.thrift file. I
manipulated my `PYTHONPATH` environmental variable to allow me to import from
the generated files. When I impor... |
Xlsxwriter: TypeError: "expected string or buffer"
Question: I have that exception, as described in the title, when trying to generate an
excel file from a model which is filtered by a query. The query works as
expected and gives me the right and complete results. However, the big deal
occurs when I try to, actually, g... |
Trying to make a shortcut through python
Question: Python 2.7
from Tkinter import *
import os
class App:
def __init__(self, master):
self.frame = Frame(master)
self.b = Button(self.frame, text = 'Open', command = self.openFile)
self.b.grid(row = 1)... |
Struggling with recursive function, what am I doing wrong
Question: I'm fairly new to python and understand that recursion is an important concept
to grasp. I've been dabbling with various scripts to exercise my knowledge and
have come up with the following script to simulate a lottery draw, where you
simply draw six f... |
Cython: How to expose void* and function pointer in struct?
Question: I have a C header with:
typedef struct
{
<normal members>
void (*cb_func)(glp_tree *T, void *info);
void *cb_info;
<normal members>
} glp_iocp;
Currently, in my pxd file:
... |
Creating a specific python dictionary
Question: Re-asking clearly my question : I want to produce this json output using
flask.jsonify, how can I build the corresponding dictionary to do so ?
{
"cluster": {
"members": [
{
"name": "host1",
"disks": [
... |
How do i output a single digit as a double digit in python 2.7
Question: I just started to play around with python and decided to make a random number
generator for my lotto numbers and so far so good it works, and even got it to
work in Tkinter.
But i can't seem to figure out where and how to format the output so tha... |
What combination of python-mode, ipython, (ipython.el) versions/releases and init.el/.emacs.d code work?
Question: My goal is to use Emacs 24 as my python editor ( also has a Matlab and R
editor but that's not what my question is about ).
(Please let me know if I left out any information or if I did not state
somethin... |
How can I test the actual resolution of my camera when I acquire a frame using OpenCV?
Question: I am working in Python/OpenCV, acquiring frames from a USB webcam (Logitech
C615 Camera, supposedly HD 1080p). 1080p has a 16:9 aspect ratio and thus I
should be able to acquire images at all of these resolutions:
... |
Simple π(x) in Haskell vs C++
Question: I'm learning Haskell. My interest is to use it for personal computer
experimentation. Right now, I'm trying to see how fast Haskell can get. Many
claim parity with C(++), and if that is true, I would be very happy (I should
note that I will be using Haskell whether or not it's fa... |
Getting "package R does not exist" when building from command-line
Question: I created an activity on a separate project using Eclipse. When I imported it
into my cocos2d-x android project and built the project using `python
build_native.py` (which is basically building the app using the NDK) and `ant
debug`, I get an ... |
Unable to find virtualenv or django after installing with pip
Question: I installed virtualenv using pip and now receive the following error whenever
I actually try and use it:
% virtualenv
Traceback (most recent call last):
File "/bin/virtualenv", line 5, in <module>
from pkg_resource... |
Sort os.listdir files Python
Question: If have downloaded several years of data stored in files with the following
naming convention, year_day.dat. For example, the file named 2014_1.dat has
the data for January 1, 2014. I need to read these data files ordered by day,
2014_1.dat, 2014_2.dat, 2014_3.dat until the end of... |
Understanding Cython "typedness" report
Question: I'm using Cython to make my Python code more efficient. I have read about the
Cython's function `cython -a filename.pyx` to see the "typedness" of my cython
code. Here is the short
[reference](http://docs.cython.org/src/quickstart/cythonize.html#determining-
where-to-ad... |
Cannot use django-mssql provider
Question: Does anyone know how to use the django-mssql provider? I've installed the
requirements but I cannot get it to work.
Without sqlserver_ado in settings.py it imports fine:
(testenv) C:\Users\Robin\test>python manage.py shell
Python 2.7.2 (default, Jun 12 2011... |
No module named _struct ironpython
Question: I've trying to use IronPython 2.7.4 with .net 3.5. I've create a new project
and added needed references:
IronPython.dll
IronPython.Modules.dll
Microsoft.Dynamic.dll
Microsoft.Scripting.dll
Microsoft.Scripting.Core.dll
Then in my c# code ... |
python: getting output from `print` inside a function
Question: Im using a library of functions that some of them print data I need:
def func():
print "data"
How can I call this function and get the printed data into a string?
Answer: If you can't change those functions, you will need to r... |
How to return a more meaningful 500 error in a python-eve app
Question: I have some code in a python-eve app that retrieves some data from a device
and populates a resource when that resource is requested for the first time.
Sometimes the code can't successfully connect to the device. In this case, I
would like to retu... |
remove empty last line from string (output from pipe)
Question: I like to remove the empty line after my output:
#!/usr/bin/python
os.system("find /home/pi/bsp/musik/musik/ -name ""*.mp3"" | shuf -n 1 > /home/pi/bsp/musik/musik/track")
What I get is:
>>>cat track
/home/p... |
Why does IPython notebook only output one DIV from this code?
Question: In an IPython notebook I input this code in a cell:
from IPython.display import HTML
HTML("""<div>One</div>""")
HTML("""<div>Two</div>""")
How come the output cell only contains the second div?
EDIT. @Dunno has shown h... |
create a matrix out of a dictionary in python with labeled columns and rows
Question: currently i have a dictionary that looks something like this:
{'a':[1,2,3,0,0],'b':[1,5,2,1,4], 'c':[1,2,4,12,1]}
I'm trying to create a covariance matrix out of this dictionary. i already
have a defined covarianc... |
Nested Tags/Table in BeautifulSoup Python scraping
Question: I've pored over Google for half a day looking for the right answer to this.
The closest thing I've come to is this StackOverflow post: [Nested tags in
BeautifulSoup - Python](http://stackoverflow.com/questions/15749354/nested-
tags-in-beautifulsoup-python)
E... |
Getting completely wrong fit from python scipy.optimize.curve_fit
Question: Update: solved! It is producing parameters with the correct signs now, and
they do fit the curve. The problem was defining func(a,b,c,x) but curve_fit
needs to read x first: func(x,a,b,c). Thanks everyone for all the help! I'll
have quantitativ... |
python context sensitive regex for parsing hierchical text structure
Question: I have a string like this:
Group 1:
Line A
Line B
Line C
Group 2:
Line A
Line B
I am wondering if it is possible to parse this with a regex with the results
being something like:
Gr... |
Passing a Custom Switch class to Mininet topology
Question: This is a topology file for a popular network simulator called mininet
I have created a class MultiSwitch() below which I want to be passed to my
Topology class to be used as the default switch is there a way to do that? I
am not very proficient in Python
... |
How to calculate RMSE using IPython/NumPy?
Question: I'm having issues trying to calculate root mean squared error in IPython using
NumPy. I'm pretty sure the function is right, but when I try and input values,
it gives me the following TypeError message:
TypeError: unsupported operand type(s) for -: 'tu... |
Networkx: Nodes as Objects OR Nodes as ID's with Dictionary Attribute Tables
Question: Which is the most efficient in terms of memory management and computation
speed?
The simple test below suggests it is slightly better to store attributes
within nodes as a python object vs. dictionary lookups through attribute
table... |
Dice generator, Picking number of sides in PYTHON 3.3.4
Question: Just wondering howto make a dice program:
A game uses dice with 4, 6 and 12 sides to determine various outcomes. Design,
code and test a program that will simulate throwing dice with these numbers of
sides. The user should be able to input which dice is... |
Unable to make enemy move towards player
Question: I'm struggling to get this working. Basically, I want my enemy sprite to chase
my player sprite. At the moment, it moves away diagonally to the bottom right
edge of the screen.
I'm learning python my making a game and am still new so I apologise if this
is a very simp... |
Unexpected indentation errors
Question: Pretty new to python/programming in general, been working on a script but have
run into indentation errors around line `for line in csv.reader(
open(filename), delimiter="\t"):` been trying a few things but could use a
little help sorting it out, any ideas?
Could you explain any... |
Run function from the command line and pass arguments to function
Question: I'm using similar approach to call python function from my shell script:
python -c 'import foo; print foo.hello()'
But I don't know how in this case I can pass arguments to python script and
also is it possible to call func... |
Cross-platform way to get default directory for Python console scripts?
Question: Is there cross-platform way to get default directory for console scripts the
same way one can use `sys.executable` to get path to the Python's interpreter
in cross-platform way?
Context:
There's Python script which runs various tools l... |
Simulate windows drag and drop with code?
Question: I think I may have asked a similar question in the past, but I am still
stuck...
As part of an automated process, I must "import" a specific subset of media
files into a closed-source third-party application (Dartfish, incase it
matters). **Here is the situation:**
... |
QuTiP Python: Another version of PIL
Question: I try to install QuTip (<http://qutip.org/docs/2.2.0/installation.html>) on
Windows using Python(x,y). After the installation I cannot import qutip
from qutip import *
it gives the error message
C:\Python27\lib\site-packages\PIL\Image.py... |
'NoneType' object is not callable beautifulsoup error while using get_text
Question: I wrote this code for extracting all text from a web page:
from BeautifulSoup import BeautifulSoup
import urllib2
soup = BeautifulSoup(urllib2.urlopen('http://www.pythonforbeginners.com').read())
print(s... |
Error by doing Copy Paste with win32com (Glade GTK Python)
Question: I have a simple function "Copy", for copy and paste with win32com. It runs
several times without problems.
But if i use a button(GUI GTK Glade) to trigger the function "Copy()", it runs
only once. The second time i get the following Error:
... |
Pandas DataFrame column another DataFrame when I'm expecting a Series
Question: I have a DataFrame object called "design" which I construct from a DataFrame
object called "df" like so:
design = df.loc[year, [DV] + IVs + controls].copy(deep=True)
where
"DV" = a string
"IVs" =... |
Calling a local python script from javascript
Question: I have the following requirement:
1.Need to call a python script which resides locally, from javascript. It will
carry out some operations and return a xml file.
2.Then I need to return the xml file to the javascript.
3.The javascript will carry out the parsing... |
How do I package/distribute a Python 2.7 application with selenium?
Question: I am fairly new to Python and I have developed a program that has a Tkinter
GUI and uses selenium WebDriver to scrape information. I need to find a way to
package all of this so that it can be used on other computers. I call three
extra modul... |
How to convert raw images into png using python
Question: I'm trying to convert raw image data into png with python. I'm pretty new to
python and especially to image processing...
The raw file is a 16 bit greyscale image.
As I already scanned the forums I came up with the following solution:
from PIL i... |
weird python indexing with CSV file
Question: I have simple phenomena that I'm having trouble understanding. I load in a csv
file
import csv
with open('Salaries.csv', 'rb') as csvfile:
Salaries = csv.reader(csvfile, delimiter=',')
Salaries = [row for row in Salaries]
I query it, and see... |
Python newbie exercise: Rock Paper Scissors
Question: I've been trying to code a simple game of RPS where the user plays against the
computer. There's just 1 iteration at this point (because I got stuck...) and
no validation whether the user's input is valid. The problem I got stuck with
is that whatever I tried to do ... |
How to write a mssql database with Python's SQLAlchemy?
Question: Does anyone know a tutorial for making a MSSql database from python using
SQLAlchemy. The reason for using MSsql is that some of my co-workers prefer
Excel as the way to access the data.
I looked around but I could not find a simple example for a newcom... |
reading *.his (image) file in Python
Question: I am trying to read an image file which is in *.his format. Honestly, I do not
know much about this format, on spending some time on google I figured out
that its a binary format and it can be read in ImageJ software as a raw format
import. On further inquiry, I found the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.