text stringlengths 226 34.5k |
|---|
POST JSON with python and reading response
Question: I am trying to make a post request in python and I believe I am doing
everything correct. However it is not returning any response. I can't seem to
figure out if there is anything wrong with my request. It seems like there may
be something wrong with the service if I... |
python opencv SIFT doesn't work for 8 bit images (JPEG)
Question: I used SIFT for all my other 24 bit JPEG images without any problems, however,
the 8 bit one always give me this following error.
image is empty or has incorrect depth (!=CV_8U) in function cv::SIFT::operator
()
Does anyone know how to deal with it?
H... |
python get last 5 elements in list of lists
Question: I have a list of lists like this: `[[1, 2], [4, 5, 6], [], None, [7, 12, 14,
16]]`.
I want to write a function that will return: `[16, 14, 12, 7, 6]`: i.e. the
last 5 elements in the list of lists.
This is the code I have, but it is not very pythonic at all (maste... |
Extracting float numbers from file using python
Question: I have .txt file which looks like:
[ -5.44339373e+00 -2.77404404e-01 1.26122094e-01 9.83589873e-01
1.95201179e-01 -4.49866890e-01 -2.06423297e-01 1.04780491e+00]
[ 4.34562117e-01 -1.04469577e-01 2.83633101e-01 1.00452355... |
Detect if Windows workstation is locked in PyQt5 application
Question: I have a PyQt5 application, which I would like to check if the Windows
workstation is in a locked state or not.
At first, I have tried to use snippet [See if my workstation is
locked](http://timgolden.me.uk/python/win32_how_do_i/see_if_my_workstati... |
Send in async mode data using twisted in python
Question: I want to send data to server in async mode (whenever I type something in
console) not only one time as the below code do. Is there any protocol
function within twisted library that can handle this? In the following find
the code that only send a message where t... |
Mocking __main__
Question: I would like to ensure with tests that: \- the application cannot be imported
\- the application can be started as a real application (i.e: python src.py)
I'm interested about that, why the following is not working:
src.py
class A:
def x(self):
print('this is x')
... |
How to split a csv file on date using python
Question: I have a csv file that contains a date column formatted as "1929-01-10". I
would like to split this huge file into separate files per year. So for every
year in the date column a separate csv file (ideally with the name of the
year).
I would like to do this in Pyt... |
Python - creating subpackage without exposing internal imports
Question: I have following structure:
/api
/v0
api_1.py
api_2.py
/v1
api_1.py
api_2.py
I would like to use it like that:
import api
api.v0.api_1.not... |
Error when trying to import from Database with Pandas and SQLAlchemy
Question: I am using portable python 2.7.6.1 and I want to import a query from an oracle
database into python pandas. I have searched a couple of examples and came up
with the following code:
from sqlalchemy import create_engine
imp... |
Collectstatic configuration error when deploying Django website on to Heroku and S3
Question: I am trying to deploy my Django website onto Heroku and Amazon S3. However,
after I typed `git push heroku master`, I got this:
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing o... |
Seemingly nonsensical runtime increases when switching from pure C to C with Numpy objects
Question: # Introduction
I am trying to realise some number crunching on a one-dimensional array in C
(herafter: _standalone)_ and as a Numpy module written in C (herafter:
_module)_ simultaneously. Since all I need to do with t... |
Bizarre looping in python?
Question: I'm new to python, but I come from a basic java background. There are learning
curves to face, and so I'm having troubles. With this loop particularly...
from random import randint;
class simpleAI:
inputMatter = 0;
inputEnergyString = 0;
inputEnergy = ... |
Calculating the totals of odd and even numbers from a file in Python
Question:
def main():
infile = open('numbers.txt','r')
evenTotal = 0
oddTotal = 0
line = infile.readline()
while line != '':
total += int(line)
line = infile.read... |
Using django variables in Javascript
Question: My model lop is contains a list of programs which I use for varying purposes.
I want to use the name field as an argument for a javascript function.
I modified some of my lops so the modified versions have a "ver2" at the end
of its name. What the Javascript function does... |
How to merge XML string with XML created by objectify?
Question: I am using python 2.7
I currently have a procedure in place that generates orders in XML from csv
data that works. However everything is hardcoded, and I want to make it a bit
more dynamic as I expand the code to fit more clients.
As it stands, I have a... |
How to get turtle graphics to not show turtle while its being drawn?
Question: How do I get the final drawing to display without having to show the process
of drawing? I am using Python 3.4, and this project is to create an archery
game. For example, if I use the following code:
import turtle
screen ... |
Running Twisted on Azure Websites
Question: Can Azure Websites host Twisted applications? e.g. something like:
from twisted.internet import reactor
from twisted.web import server
site = server.Site(myresource)
reactor.listenTCP(80, site)
reactor.run()
From <http://azure.microso... |
How to perform addition and division in python
Question: I want to get the sum of all numbers within a list. My code is shown below;
however, I am getting an error when I try to run it:
c = [795557,757894,711411,556286,477322,426243,361643,350722]
for c1 in c:
x = x + c1
I am also trying... |
Python - how to refer main app's variable in app's modules
Question: I have following files' structure for Flask app (/env is virtual env):
/env
/env/bin/...
/env/include/...
/env/lib/...
/env/lib64/...
/env/myapp.py
/mymodules/__init__.py
/mymodules/users/__init__.py
/mym... |
Python Class: Global/Local variable name not defined
Question: I have two sets of code, one which I use 'Class' (Second piece of code) to
manage my code, and the other I just define functions, in my second piece of
code I get a NameError: global name '...' is not defined. Both pieces of code
are are for the same purpos... |
How to get filename and line number of where a function is called?
Question: When working in Python I always have this simple utility function which
returns the file name and line number from where the function is called:
from inspect import getframeinfo, stack
def d():
""" d stands for Debug... |
Python Installation Troubleshooting
Question: I am struggling to install Python. I am running Windows 8.1 . Python used to
run OK on my PC but I refreshed Windows recently and now have to install it
again. I did delete the Python folder before I attempt installation and also
made sure an older version was not installed... |
Force pyplot.imshow() to produce image with higher resolution
Question: I have an NxN array that I am plotting in Python using
`matplotlib.pyplot.imshow()`. N will be very large and I want my final image
to have resolution to match. However, in the code that follows, the image
resolution doesn't seem to change with inc... |
Why does vars(response) not show response.text? (using Python Requests module)
Question:
import requests
response = requests.get('http://httpbin.org/get')
print vars(response) # no response.text listed
print response.text # value printed
Why does `vars(response)` not list `response.text` when tha... |
In python, why is this (rather messy) code for my simple test base game not working?
Question: This is part of (emphasis on part of) a simple text based adventure that i am
making right now. For some reason every time i run this and say "no" at either
point it still goes ahead and executes the code for "yes". Feel free... |
Calculating factorials with Python
Question: EDIT: I know I can import factorials but I'm doing this as an exercise
Trying to get the factor of a given number with a function in Python.
For example: factorial(4) = 4 * 3 * 2 * 1 = 24
def factorial(x):
n = x
while n >= 0:
x = ... |
How to implement a tree structure in Python using namedtuple
Question: I have a key-word, e.g. friendly. It gives birth to a child-word, e.g. warm,
while descending from a parent-word, e.g. friend.
from collections import namedtuple
keyword = 'friendly'
childword = 'warm'
parentword = 'f... |
XLRD/Python: Encrypte Excel or make exception
Question: I need to go through the subdirectories of a given directory, search for excel
files and then read their sheet names. A problem occurs when the loop finds an
encrypted file. I tried to read files with xlrd and pandas. But I get an
error:
> _xlrd.XLRDError Workboo... |
Displaying an HTML file with a JS inside an iPython notebook
Question: I have a piece of code in an iPython notebook that programmatically generates
a folder named 'sound' containing the following files: index.html, canvas.js,
graph.js and style.css.
If I open index.html in my browser, I can see exactly the output I w... |
Detecting memory leaks & dumping statistics in python
Question: I am looking for python memory debugging techniques? Basically I am looking at
tools available for python and see what data we can look at when a python
process is taking lot of memory? I am aiming to isolate such memory eating
process and **dump statistic... |
coefficient plot in python
Question: I am trying to find a nice way to plot the linear model coefficient in python
and I got the following:
import statsmodels.formula.api as sm
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
f = 'change ~ close_r + clos... |
Cannot import package - "ImportError: No module named _mechanize"
Question: I am using the Anaconda 2.1.0 distribution of Python on Windows 8.
python --version
Python 3.4.1 :: Anaconda 2.1.0 (64-bit)
I used pip to install the mechanize package. pip (v 6.0.8) installed mechaniz... |
Ubuntu and Ironpython: What paths to add to sys.path AND how to import fcntl module?
Question: I have latest IronPython version built and running in Ubuntu 14.04 through
Mono. Building Ironpython and running with Mono seems trivial but I am not
convinced I have proper sys.paths or permissions for Ironpython to import
m... |
how to avoid two socket with same port number python
Question: Now here is sample for the server part of socket. I want to have serverSocket
and connectionSocket with different port number, but for now, they are using
same port number.
from socket import *
serverPort = 12000
serverSocket = socket... |
Quickly determining using Python whether an image is (fuzzily) in a collection
Question: Image that some new image X arrives, and I want to know if X is new or has
already been encountered before. I have code, below, that shrinks the image
and then converts it to a hash code. I can then see via a single hash look-up
if... |
PyQt4 video player crashes when moving window
Question: I've written a simple PyQt4 GUI that plays an OpenCV `VideoCapture`. This
requires converting frames from numpy arrays to `QImages`. I'm using OpenCV so
that I can detect circles using my `findCircles` method.
However, when I pass my frames to `findCircles`, the ... |
Managing users authentication in Google App Engine
Question: I am working on a webapp based on google app engine. The application uses the
google authentication apis. Basically every handler extends from this
BaseHandler and as first operation of any get/post the checkAuth is executed.
class BaseHandler(... |
Django Database engine on Google app engine
Question: I have some problems by trying to change my database engine on my app engine.
right now i use the "google.appengine.ext.django.backends.rdbms" and it works
fine, but it's running slow.
What is the difference in using:
> "google.appengine.ext.django.backends.rdbms... |
Python blobs.BlobResult module import error
Question: After install blobs package on Debian. am getting the error like
libdc1394 error: Failed to initialize libdc1394
Traceback (most recent call last):
File "1.py", line 8, in <module>
from blobs.BlobResult import CBlobResult
ImportE... |
height not working python (3.4)
Question: I'm making my first program with tkinter and height will not work but width is
working.
here is my code:
from tkinter import *
from random import randint
def roll():
text.delete(0.0, END)
text.insert(END, str(randint(1, 6)))
window =... |
python what is the different of size when replacing json.dump by json.load
Question: ### Background:
I am working on python sdk to insert some data to couchbase.
When I tried to insert the data using the `set` method like this:
connection = set(key, document)
I got exception states that the data ... |
python extract text description from large text file
Question: i have bigg text file, and i need extract description message :
#### **Description**
20_Ways_To_Make_100_Dollars_EVERYDAY !!!
High Quality Guide (PDF File)
Here; I will teach you how to make 100 dollars every, or may be e... |
python list - method instead of string
Question: I am playing a bit with AWS via python and boto. I am trying to get modified
date for keys from AWS bucket. After that I am parsing date to 'regular' date
format and try to add every value to list.
Unfortunately, when I append values to list and try to print it's result... |
How to create global lock/semaphore with multiprocessing.pool in Python?
Question: I want limit resource access in children processes. For example - limit **http
downloads** , **disk io** , etc.. How can I achieve it expanding this basic
code?
Please share some basic code examples.
pool = multiprocessin... |
why won't my circle loop work in python
Question:
import turtle
import time
import random
n = int(input("how many circles do you want? "))
radius = int(input("Radius?"))
turtle.forward(radius)
turtle.left(90)
for circle in range(num, 0, -1):90 (num..1)
turtle.begi... |
Implementing Chain of responsibility pattern in python using coroutines
Question: I am exploring different concepts in python and I happened to read upon an
example of coroutines which can be used for the chain of responsibility design
pattern. I wrote the following code:
from functools import wraps
... |
pyvirtualdisplay on Amazon EC2 instance
Question: I am trying to run selenium on Amazon EC2. I am using pyvirtualdisplay as xvfb
wrapper. I ran the following commands in python.
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(1024, 768))
... |
python script to handle uploaded file via http post
Question: I am working on a django project where i try to upload a file via http post
request.
my upload script is :
url=r'http://MYSITEURL:8000/upload'
files={'file':open('1.png','rb')}
r=requests.post(url,files=files)
my receiving side ... |
How to distinguish between multiple shapes in a figure or array?
Question: I have a 2D array in Python containing values of either 0 or 1, arranged to
form various shapes. For my current project I need a method to distinguish
between the shapes in the image.
I am currently attempting to do this by setting the values o... |
Plotting graph using matplotlib
Question: I'm trying to plot train and testing learning learning curves using the code
below :
import numpy as np
from sklearn import cross_validation
import matplotlib.pyplot as plt
from sklearn.feature_extraction.text import TfidfVectorizer
import sklearn... |
Barnsley fern in python language
Question: I need help with this Barnsley fern program. I am not getting the leaf picture
at all and getting an error run time message when I run my code I know I am
close but need some help
#! /usr/bin/env python
import matplotlib.pyplot as plt
import ra... |
Python command line using Cygwin: ImportError
Question: My python files are as follows:
/root/D/main.py
/root/T/test.py
/root/T/__init__.py
My `main.py` imports:
from T import test
I executed the `main.py` from command line:
> export PYTHONPATH=/cygdrive/... |
Get system metrics using PowerShell
Question: I have a Python script which prints 1 if it is running under RDP or 0 if it is
not.
from ctypes import *
SM_REMOTESESSION = 0x1000
print(windll.user32.GetSystemMetrics(SM_REMOTESESSION))
I'd like to get the same information using PowerShell. How... |
dictionary to read 3 values from a csv file in python
Question: I'm trying to create a simple dictionary which gets 3 values from a csv file.
my python code can get 2 values easily from the csv file. But I can't get to
display a 3th value.
Heres my csv file :
ERRORCODE,EVENTKEY,COUNT
109... |
I want to modify this python script to output the modification date of the parsed file along with it's title
Question: So the last programmer left me with this script, that grabs all the old
content and writes it's all out as a "partial' file.. which strips out all the
container html and leave's just the html of the ar... |
From datetime to timestamp python
Question: I need to convert a datetime object with microsecond resolution to a
timestamp, the problem is that I don't get the same timestamp second's
resolution.
For example the timestamp that I pass as an argument is 1424440192 and I get
in return 1424429392.011750, why is this?, I O... |
Creating a django rest API for my python script
Question: I have a JSON file with data as such :
['dbname' : 'A', 'collection' : 'ACollection', 'fields' : ['name', 'phone_no', 'address']}
['dbname' : 'B', 'collection' : 'BCollection', 'fields' : ['name', 'phone_no', 'address', 'class']}
These a... |
sending emails with python - subject of message missing
Question: all. I have encountered a bit of a problem while trying to send emails with
python's `email` package along with `smtplib`. I have set up a function that
send an email and it works well, with the exception that the email always
comes without the subject. ... |
NumPy analog of R's `filter`
Question: What is analog of R's
[`filter`](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/filter.html)
in NumPy?
I have the following R code:
f <- rep(1/9, 9)
smth_x <- filter(x, f, sides=2)
Where `x` is some 1-D timeseries vector which may contain `nan... |
Python's resultant issues
Question: I'm new of Python and i'm stuck on this. I need to check if i can find a
string in a file. I have created the file ContEAN.py
the code:
import sys
for arg in sys.argv:
inputEAN=arg
EAN = open("/home/master/Documenti/Progetti/eanFZ.txt","r")
r... |
Python 3 with Requests trying to use Tumblr API, I get error 401?
Question: I have Python 3 and I am trying to post to Tumblr via API [link to API
documentation](https://www.tumblr.com/docs/en/api/v2). I keep getting an error
401 despite feeling like I am doing everything correctly. There is an official
API client in P... |
how do i get python to print an invoice
Question: parts list array
a =list(["CPU,$150.00","RAM ,$120.00","DVD drive $89.00","Hard Disk Drive,$189.99"])
for letter in a:
print(letter)
this is my parts list I am trying to figure out how to get it to print to a
printer any tips
Answer: F... |
Python 'in' function , pandas dataframe wrongly populated
Question:
from collections import defaultdict
import csv
from bs4 import BeautifulSoup
import urllib2
import pandas as pd
import re
text = open("/Users/dynajose/Desktop/PlayList.rtf").read()
songDom = BeautifulSoup(text)
... |
Robot Framework using Python, Key Press without selecting any button or element in the page
Question: I am automating one application using robot framework using Python. In a
certain situation I need to press enter without selecting any button or
element of the page once the page is loaded.
I have tried with the below... |
Use Line2D to plot line in python
Question: I have the data:
x = [10,24,23,23,3]
y = [12,2,3,4,2]
I want to plot it using
[matplotlib.lines.Line2D(xdata,
ydata)](http://matplotlib.org/api/lines_api.html#module-matplotlib.lines)
I use
import matplotlib.lines
matpl... |
Removing duplicate users from a list using set()
Question: Trying to remove duplicate users from list with set in python. The problem is
that it is not removing the duplicate users:
with open ('live.txt') as file:
for line in file.readlines():
word = line.split()
... |
What's the best way of distinguishing bools from numbers in Python?
Question: I have an application where I need to be able to distinguish between numbers
and bools as quickly as possible. What are the alternatives apart from running
`isinstance(value, bool)` first?
Edit: Thanks for the suggestions. Actually, what I w... |
pylint says "Unnecessary parens after %r keyword"
Question: After my [first CodeReview
Q](http://codereview.stackexchange.com/questions/61798/mysql-class-to-add-
user-database) \- I got tip in answer:
> Your code appears to be for Python 2.x. To be a bit more ready for a
> possible future migration to Python 3.x, I re... |
Python default logger disabled
Question: For some reason, in a Python application I am trying to modify, the logger is
not logging anything. I traced the error to `logging/__init__.py`
def handle(self, record):
"""
Call the handlers for the specified record.
This method is us... |
Python higher order functions usage with str.startswith
Question: I have a file which I want to clean commented lines from. **I'd like to use
python`functools.partial` for the operation**, in something similar to the
following manner:
from functools import partial
f = open(filetoread, "r")
l... |
How I can convert this matlab code to python?
Question: I would like to write the following operation from matlab to python(numpy).
repmat(sum(data,2),1,20);
Answer: have a look at [What is the equivalent of MATLAB's repmat in
NumPy](http://stackoverflow.com/questions/1721802/what-is-the-equivalent-of-
matlabs-repma... |
python / gspread - How to update a range of cells with a data list?
Question: I have a data list (extracted from CSV) and I'm trying to use Python / GSpread
to update a range of cells on a Google Doc. Here is my code sample:
import gspread
def write_spreadsheet(spreadsheet_name, sheet_id, data, start... |
Global name error when importing a function
Question: Trying to kill two birds with one stone I decided to write a bit of code that
would let me practice python and calculus at the same time. I have two
seperate files, Derivative.py and newton_method.py (I know I should get a bit
better about naming my files correctly)... |
Python 2.7 - Having trouble outputting a command line percentage bar for large file download (I want output like: 0%...25%...50%...75%...100%)?
Question: Apologies if this seems a basic question, I have been trying to figure out how
to do this for the past hour with no progress. I have this method in Python
for downloa... |
How to add the OpenCV library to my Python library?
Question: Hey I'm new to python and I have to do a project that requires openCV and
Numpy. I'm currently using both Pycharm and Spyder as my IDE's and Windows as
an operating system. While found a executable for numpy. For the openCV I was
given a folder with about 30... |
Get timezone aware datetime
Question: How would I do the following to get a UTC datetime object, so django doesn't
complain about `/Library/Python/2.7/site-
packages/django/db/models/fields/__init__.py:808: RuntimeWarning:
DateTimeField received a naive datetime (2015-02-11 00:00:00) while time zone
support is active. ... |
How to connect to localhost using Python's paramiko?
Question: I am totally new to implementing client-server communication and am trying to
get started with a very basic example using Python's paramiko module. All I
want to do is to send a simple string to my machine's localhost from one
terminal window and retrieve i... |
Simple development http-proxy for multiple source servers
Question: I developed till now with different webapp-servers (Tornado, Django, ...) and
am encountering the same problem again and again:
I want a simple web proxy (reverse proxy) that allows me, that I can combine
different source entities from other web-serve... |
AttributeError: object has no attribute 'runTest'
Question: I'm am new to `unittest` and I am not sure why I am getting this error:
runTest (__main__.TestTimeInterval)
No test ... Traceback (most recent call last):
File "/Users/bli1/Development/Trinity/qa-trinity/python_lib/qe/tests/test_timest... |
FieldStorage input removes some characters
Question: Putting "c++" in a input box, my Python script just receives "c".
Here's the HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml... |
How to emulate Firefox "Save File" -> OK in Python
Question: My following code:
#!/usr/bin/env python
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
# Define firefox profile
download_dir = "/Users/pduboi... |
Python CSV library returning 1 item instead of a list of items
Question: Im trying to use the CSV library to do some excel processing, but when I use
the code posted below, row returns the entirety of data as 1 item, so row[0]
returns the entire file and row[1] returns index out of range. Is there a way
to make each ro... |
share datastore python between modules in google app engine
Question: Im studying about GAE, Im trying to build a app with 2 module: default module
and count module. Count module increaces value of Count object in datastore by
1 every min. default module access Count object and show its current value.
I ... |
Dictionaries and files in python
Question: Hey guys first time question here.
I'm trying to figure out how to create a dictionary containing keys as ID's,
and values as another dictionary containing scores for homework essays and
exam's for that individuals ID.
Example:
{"173-25-6389":
{
... |
Python subclassing process with parameter
Question: I'm trying to create an object but as a new process. I'm following [this
guide](http://pymotw.com/2/multiprocessing/basics.html#subclassing-process)
and came up with this code.
import multiprocessing as mp
import time
class My_class(mp.Pro... |
Sorting by value in a python dictionary?
Question: I have an assignment in which a series of items and the amount a store carries
of that item is given which I then have to put into a dictionary and display
with the highest amount of stock to the lowest amount of stock. The dictionary
looks a bit like this:
... |
Print string left aligned with fixed width and suffix
Question: Using Pythons string formatting, is there a nice way to add a suffix to a left
aligned string that is padded to a fixed size?
I want to print a list of key-value-pairs in the following formatting:
a_key: 23
another_key: 42
.... |
Matplotlib lines do not join smoothly, Python
Question: I am using matplotlib to draw the outline of a cylindrical body, however the
lines do not want to join up smoothly, as seen in the range x[40,60].

It is really subtle in this image I know, but i... |
pysqlcipher installation - SyntaxError: Missing parentheses in call to 'print'
Question: I have Python 3.4.2, and I try to install **pysqlcipher** on my PC with
windows 8. After having entered the code below in my command prompt:
git clone https://github.com/leapcode/pysqlcipher/
cd pysqlcipher
p... |
python serial error raspberry-pi gps module
Question: I am trying to use python serial (for python 2.7) to read data from a gps
device (ublox EVK-7P). I am using the following code:
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import time
import serial
ser = serial.Serial('/dev/ttyUSB7', ... |
Issue installing Theano in my virtualenv
Question: I'm trying to install Theano in a virtualenv:
(dnouri_tut)[xxx@xxx virtualenvs]$ pip install Theano
but I get the following error:
Installing collected packages: scipy, numpy, Theano
Running setup.py install for scipy
T... |
Explanation of Python doc argument syntax
Question: Is anyone able to help me to understand the syntax of arguments being passed
to some methods in the Python doc?
Examples of the type of things that are confusing me would be from the iter()
function
iter(o[, sentinel])
From my understanding this ... |
Python - FileNotFoundError when dealing with DMZ
Question: I created a python script to copy files from a source folder to a destination
folder, the script runs fine in my local machine.
However, when I tried to change the source to a path located in a server
installed in a DMZ and the destination to a folder in a loc... |
ValueError: too many values to unpack Tkinter Listbox
Question: When writing a simple program to output the values and keys in a dictionary to
a listbox in python using Tkinter I get the following error:
for key, value in mydict.itervalues():
ValueError: too many values to unpack
Please see... |
Python ta-lib with pandas.io.data: candlestick not plotting but other charts are ok
Question: iPython 2.3.1, OS-X Yosemite 10.10.2
Python print (sys.version):
2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
The following code works for data pulled for US stock data ... |
How to calculate word frequency of a string phrase in a column of a csv file using python?
Question: So my problem is that I have a csv file is structured something like this:
"L.Name", "F. Name", "Gender", "School Type", "Subjects"
"Doe", "John", "M", "University", "Chem I, statistics, E... |
Find and replace symbols with regex python
Question: I have such sample:
sample = 'TEXT/xx_271802_1A'
p = re.compile("(/[a-z]{2})")
print p.match(sample)
in position of xx may be any from [a-z] in quantity of 2:
TEXT/qq_271802_1A TEXT/sg_271802_1A TEXT/ut_271802_1A
Ho... |
Finding all roots of an equation in Python
Question: I have a function that I want to find its roots. I could write a program to
figure out its roots but the point is, each time that I want to find the other
root I should give it an initial value manually which I do not want to do
that. I want to have all the roots in ... |
What is the pure Python equivalent to the IPython magic function call %matplotlib inline?
Question: In IPython Notebook, I defined a function that contains a call to the magic
function `%matplotlib`, like this:
def foo(x):
%matplotlib inline
# ... some useful stuff happens in between here... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.