text stringlengths 226 34.5k |
|---|
What does the underscore mean in python
Question: Hi everyone as it obvious from my question I am like a brand new to python. I
am so confused when I am reading the documentation on python or even here in
the Stackoverflow forum...
Why do they write like that
from __future__ import division
What d... |
Make clear button backspace by one in python tkinter calculator
Question: I am making a calculator in python using tkinter. The calculator works very
well apart from one thing. At the moment I have set the calculator to clear
the display. I want to make it so that it clears the last number on the
display. For example 5... |
combine two charts into the single PDF using ReportLab?
Question: I'm using Django and Reportlabs to generate reports in PDF. I'm referring to
[this tutorial](https://code.djangoproject.com/wiki/Charts).
I read [this thread](http://stackoverflow.com/questions/9339572/how-to-
combine-two-charts-into-the-single-pdf-usin... |
Intellij python no recoginiize lib
Question: I use intellij with python plugin. when I want to import python libs like
import random I got editor error. No module named random less... (Ctrl+F1)
This inspection detects names that should resolve but don't. Due to dynamic
dispatch and duck typing, this is possible in a li... |
Interpret java strings containing integer literals (dec, hex & oct notation) as integer values
Question: I'd like to convert string representations of integers to actual integer
values. I do not know which radix/base is being used beforehand, so I cannot
simply rely on methods/constructors that take the radix as an arg... |
fexpect breaks fabric scripts
Question: I hot upon an requirement where I needed to automatically answer the prompt on
remote machine and then I found fexpect after reading different stackoverflow
questions. But the moment I include fexpect in my script it breaks the whole
script!
Traceback (most recent ... |
python support vector machines
Question: My question is related to this one -
[How do I install libsvm for python under windows
7?](http://stackoverflow.com/questions/12877167/how-do-i-install-libsvm-for-
python-under-windows-7)
I'm basically trying to get the svm library to work in python. So, I
downloaded and unzip... |
Python search path wrong, but only in Windows
Question: I am creating a larger logical package spread out over many directories, like
so:
[projects root]/projectname1/lib/python/logicalpackage/__init__.py
[projects root]/projectname1/lib/python/logicalpackage/projectname1/__init__.py
[projects ro... |
How to use Bulk API to store the keywords in ES by using Python
Question: I have to store some message in ElasticSearch integrate with my python
program. Now what I try to store the message is:
d={"message":"this is message"}
for index_nr in range(1,5):
ElasticSearchAPI.addToIndex(ind... |
Why is the URL 404 not found with Django?
Question: I have written a Django script that runs a Python parser to web s*e. I am
sending the request to the Django script via AJAX. However, when the Ajax
runs, it comes back as 404 not found for the URL. Why is this happening?
My code is below:
Ajax (with jQuery):
... |
How to import/sync data to App Engine datastore without excessive datastore reads or timeouts
Question: I am writing an application that uses a remote API that serves up a fairly
static data (but still can update several times a day). The problem is that
the API is quite slow, and I'd much rather import that data into ... |
Python -- Matplotlib redrawing lines without previous lines remaining
Question: This class plots a curve in Matplotlib. The user mouse input section changes
the `set_data()` for several `x,y` coordinates. The `P` and `Q` are resetting
properly, it seems. However, when the `R` is not set with calculations using
those sa... |
How to implement session.add on this code:
Question: So, I need some help to make this script run faster, below is my script.
#!/usr/bin/env python
import glob,os, csv
from sqlalchemy import *
count = 0
served_imsi = []
served_imei = []
served_msisdn = []
sgsn_address = [... |
Python Server on different IP address
Question: So I have a web server that I can run using python, but I have a question. Can
I change the IP address where the server runs the only one I can get to work
is 127.0.0.1 which is the localhost address? I have already tried with no luck
I want to use a unused one on my netw... |
Python Help: Creating a dict of {str:list of str} from csv file
Question: I have to create a table in the format: `{str: list of str}`
Opening a .csv file using the following code, I get:
import csv
cr = csv.reader(open("name.csv","r"))
for row in cr:
print(row)
output:
... |
Struggling to understand Twisted in general and pb in particular
Question: Could someone explain the difference between the following please. I am really
struggling to grasp Deferred concept, I thought I had it as I have been doing
examples all day. But I think i must be code blind. I'm sure its really
simple.
This wo... |
Factory method of a python class returning implementation based on system and design issues
Question: # 1) Introduction
I have started the implementation of a tool in Python that gathers several
system metrics (e.g. cpu utilisation, cpu saturation, memory errors etc.) and
presents them to the end-user. This tool shoul... |
python: square backet in character class
Question: I'm trying to match square brackets (using character class) in python. But the
following code is not successful. Does anybody know what is the correct way to
do?
#!/usr/bin/env python
import re
prog = re.compile('[\[]+')
print prog.match... |
Mastermind minimax algorithm
Question: I am trying to implement in python Donald Knuth's algorithm for codebreaking
mastermind in not more than 5 moves. I have checked my code several times, and
it seems to follow the algorithm, as its stated here:
<http://en.wikipedia.org/wiki/Mastermind_(board_game)#Five-guess_algori... |
Sprite outline and save
Question: I am making a python script that can cut out sprites from a transparent
background spritesheet. I want to cut out the sprites in a square or a
rectangle. So far my idea is to:
**1\. Get all pixel data from sheet.**
**2\. Search for non-transparent pixels.**
**3\. When such a pixel i... |
How to move your code in codeskulptor from the browser to python 2.7?
Question: I am learning a course on Coursera: "An Introduction to Interactive
Programming in Python".
I have written the whole of the code in the course in the browser and I have
used a library called `simplegui` for all the GUI functionality.
I wa... |
Why does dir of a module show no __dict__? (python)
Question: For example:
>>> import os
>>> '__dict__' in dir(os)
False
But `os.__dict__` shows there is a `__dict__` attribute.
Answer: Because `dir` uses a [specialized
implementation](http://hg.python.org/cpython/file/30b3798782f1/Object... |
"Invalid tag name" error when creating element with lxml in python
Question: I am using lxml to make an xml file and my sample program is :
from lxml import etree
import datetime
dt=datetime.datetime(2013,11,30,4,5,6)
dt=dt.strftime('%Y-%m-%d')
page=etree.Element('html')
doc=etree.Ele... |
Python: Unsupported operand type(s) for &: 'NoneType' and 'NoneType' whilst using lambda
Question: I'm currently using lambda to make a tkinter button do two things after each
other:
def classManip():
cManip = tk.Toplevel()
cManip.title('Class Manipulator')
cManip.minsize(400,... |
Removing each element at the value in each key
Question:
sample_dict = {'i.year': ['1997', '1997'], 'i.month': ['March', 'April'], 'j.month': ['March', 'April'], 'j.year': ['1997', '2003']}
How do we compare each element in i.year and j.year, and if the elements are
equal to each other, than delete the eleme... |
Python: Converting a list of sets to a set
Question: I am working on a programming project involving DFAs, and I've come across an
error I can't seem to figure out how to bypass.
In this section of code:
from DFA import *
def DAWG():
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', '... |
Python - merging of csv files with one axis in common
Question: I need to merge two csv files, `A.csv` and `B.csv`, with one axis in common,
extract:
9.358,3.0
9.388,2.0
and
8.551,2.0
8.638,2.0
I want the final file C.csv to have the following pattern:
8.... |
Connect HTTP POST request to an onclick using JavaScript
Question: I am trying to make an HTTP POST request using javascript and connecting it to
an onclick event.
For example, if someone clicks on a button then make a HTTP POST request to
`http://www.example.com/?test=test1&test2=test2`. It just needs to hit the url
... |
Can I put a filepath and then the file name/extension in place of this?
Question: I am making a simple application in Python that downloads a file from a
website. This application has to put said file in a specific location.
import urllib
urllib.urlretrieve ("http://www.example.com/songs/... |
python, "urlparse.urlparse(url).hostname" return None value
Question: After loging in on a website I want to collect its links. This I do with this
function (using mechanize and urlparse libraries):
br = mechanize.Browser()
.
. #logging in on website
.
for link in br.links():
... |
AttributeError: 'DatabaseWrapper' object has no attribute 'Database'
Question: Version numbers are Django 1.6, Python 3.3.2 and Mac OS X 10.9
I create an app with this command
python3 manage.py startapp lists
Then in my lists/tests.py file I put this code
from django.test import Te... |
How to call an ncurses based application using subprocess module in PyCharm IDE?
Question: I would like to launch an ncurses based application from python using
subprocess module.
The ncurses based application is TABARI, an event extraction system. The
result of event extraction is saved to a file. I would like to lau... |
fnmatch does not work with variables but with static strings
Question: The following code does not find any of the patterns defined in the file
`patterns`.
#!/usr/bin/env python
import os
import fnmatch
patternFile = open('patterns', 'r')
patterns = patternFile.readlines()
f... |
Split document into multiple files based on pattern
Question: I'm trying to split a large text document of articles into multiple text files
based on a boundary like this:
`9 of 10 DOCUMENTS`
at the beginning of each chunk. Everything after that pattern but before the
next occurence should be written out to a new fil... |
Unable to loop through JSON output from webservice Python
Question: I have a web-service call (HTTP Get) that my Python script makes in which
returns a JSON response. The response looks to be a list of Dictionaries. The
script's purpose is to iterate through the each dictionary, extract each piece
of metadata (i.e. "Cl... |
Averaging column 2D array python
Question: I have a 2D arraylist data which fills with a loop like this:
data.append([TrueID,rssi])
after 8 times i got this value for data:
data =
[['469420270013002A', -90],
['469420270005000C', -89],
['46942027001300... |
Python, UnicodeEncodeError
Question: Hello I've got this piece of code
import urllib.request
import string
import time
import gzip
from io import BytesIO
from io import StringIO
from zipfile import ZipFile
import csv
import datetime
from datetime import date
import... |
Python Joint Distribution of N Variables
Question: So I need to calculate the joint probability distribution for N variables. I
have code for two variables, but I am having trouble generalizing it to higher
dimensions. I imagine there is some sort of pythonic vectorization that could
be helpful, but, right now my code ... |
pycallgraph with pycharm does not work
Question: I'm using mac os x and trying to setup pycallgraph.
Ive installed pycallgraph with pip and graphviz with homebrew.
Everything works from shell. But not from pycharm.
from pycallgraph import PyCallGraph
from pycallgraph import Config
from pycall... |
Python Server-Client Communication with each other
Question: I am trying to modify a tcp/ip server-client communication. Only the server
can communicate with the client. I am trying to find an easy a way to send a
message back to the server. Not a chat !! Just a server which will send data
to a client and receive data ... |
error when renaming files in python
Question: I am trying to rename some files, and i think python is well suited...
the files have the pattern `xxx000xxx000abcde.jpg` (random numbers and letters
followed by a specific letter sequence, say "abcde")
and need to be renamed `xxx000xxx000.jpg` (without the "abcde" at the... |
Taking an argument from user (URL)
Question: Does anyone know how I would be able to take the the URL as an argument in
Python as page? Just to readline in the script, user inputs into the shell and
pass it through as an argument just to make the script more portable?
import sys, re
import webpage_ge... |
Can't get MySQLDb to work in python on Mac is there other easier DB?
Question: I am looking for a production database to use with python/django for web
development. I've installed MySQL successfully. I believe the python connector
is not working and I don't know how to make it work. Please point me in the
right directi... |
python thread using start_new_thread not working
Question: Im in need of a thread for my python app,
in my test i have a counter with a timer simulating the loop i need to run,
but the problem is that this loop calls fine from a basic python sample on the
thread, but not working on my code, I must be calling the metho... |
error when trying to keep order of dictonary as it was found
Question: I want the dictionary to be kept in the same order that the dates are found so
the dictionary is order by date. I looked at [this python
site](http://docs.python.org/2/library/collections.html#collections.OrderedDict)
but the code does not work I ge... |
Scan a webpage and get the video embed url only
Question: I have a search engine on PHP that have indexed some movie sites., Now i want
to get the video embed url on a given web page URL . and put it in an iframe.
How will i get it ? using python? and integrate it in PHP ? but how will i
pass the url from php to python... |
Get all tagged text under li tags
Question: I have list like:
<ul>
<li><strong>Text 1</strong></li>
<li>Text 2</li>
<li>Text 3</li>
<li><strong>Text 4</strong></li>
</ul>
How i can get only values under strong tag using selenium webdriver in python?
Answer: Assuming the data i... |
How to generate a random graph given the number of nodes and edges?
Question: I am using python with igraph library:
from igraph import *
g = Graph()
g.add_vertices(4)
g.add_edges([(0,2),(1,2),(3,2)])
print g.betweenness()
I would like to generate a random graph with 10000 nodes and... |
Python Traceback: no error, yet no output from script
Question: `enter code here`Im using Eclipse with PyDev and trying to get a simple script
working:
Edited Code:
import time
import os
import json
import tarfile
source_config='/Users/brendanryan/scripting/brendan.json'
backup_dir =... |
How to get the exit status set in a shell script in python
Question: i want to get the exit status set in a shell script which has been called from
python. the code is as below
python script.
result = os.system("/compile_cmd.sh")
print result
(compile_cmd.sh)
javac @source.txt
... |
SOCKET ERROR: [Errno 111] Connection refused
Question: I am using simple python lib for the SMTP But i am getting this error:
import smtplib
smtpObj = smtplib.SMTP('localhost')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/smtplib... |
How to export data (which is as result of Python program) from commmand line?
Question: I am working on a Python program, and I have results on the command line.
Now I need to do analysis on the results, so I need all results as exported in
any format like either SQL, or Excel or CSV format.
Can some tell me how can ... |
shortest path from goal to root in directed graph with cycles python
Question: I want to find the shortest path from `goal` to `root` working backwards
My input for `root` is `{'4345092': ['6570646', '40586', '484']}` My input for
`goal` is `{'886619': ['GOAL']}`
My input for `path_holder` is an input but it gets con... |
Django: Failing at creating tables
Question: I can't change my models and create new tables if the old ones are deleted. I
am using south and when I just added a new model to my models and created a
new one, I used
python manage.py migrate logins --fake
Running migrations for logins:
- Nothi... |
Sympy integrate() does not produce output in the natural form of the common fraction
Question: This code is taken from the Sympy tutorial:
init_printing(use_unicode=False, wrap_line=False, no_global=True)
x = Symbol('x')
r = integrate(x**2 + x + 1, x)
print(r)
The output is: `x**3/... |
Import error when importing python file from same directory
Question: I have the identical problem to the question posed here: [Django custom form
ImportError even though file is in the same
directory](http://stackoverflow.com/questions/20029305/django-custom-form-
importerror-even-though-file-is-in-the-same-directory)... |
unicode error when importing csv file
Question: i am using google app engine to import a csv file and insert it into a
database but its giving me this error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf0' in position 3: ordinal not in range(128)
the file i'm importing is utf-8 the... |
Google App Engine has suddenly stopped working, with error 'you are likely missing the Python "PIL" module'
Question: I've been developing apps on GAE (with Windows/Python) for over a year and
although I'm no expert, I've always been able to get the apps to run!
The app I'm currently working on was working fine on the... |
urllib2.urlopen error on Box API - can't convert to proper string
Question: I am trying to send a POST to the Box API but am having trouble with sending
it through Python. It works perfectly if I use curl:
curl https://view-api.box.com/1/sessions \
-H "Authorization: Token YOUR_API_KEY" \
-H "Con... |
getting error in pos_tag using nltk in python
Question: i am trying to `import nltk library` but getting error while using
`nltk.pos_tag`
nltk.pos_tag(y)
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
nltk.pos_tag(y)
File "C:\Python27\lib\site-... |
Python. i need help programming
Question: I am trying to write a program that i can enter text in to, then it will
display the numbers that each letter in a sentence represents. eventually. i
would like to be able to input a sentence and have it change it to "giberish".
sort of like an encoder or something. any thought... |
Changing python version in Maya
Question: I am trying to update my Maya python version from 2.5 to 2.7. But I am having
problems with it.
I have followed the steps in this response:
[How do I change the python version in Maya
2013?](http://stackoverflow.com/questions/14656593/how-do-i-change-the-python-
version-in-ma... |
Exception display to the right of Command Line for PyQt/PySide callbacks/slots in Autodesk Maya
Question: **Updated: to make it much clearer.**
In the following code snippets, making use of Maya widgets through `pymel`,
there is an error highlight on the right of Command Line.
import pymel.core as pm
... |
TypeError: 'NoneType' object has no attribute '__getitem__'
Question: Hi So I created this function called runloopg(x,y,z) that produces a list but
I can't call an item on the list:
p=runloopg(10,0.1,6)
<generator object rtpairs at 0x000000000BAF1F78>
[(0,0,0,0,0,1), (0.01,0,0,0,0,1), (0.0062349,... |
Explicitly creating a new object in Python
Question: I am trying to create new objects and store them in a dictionary. But it
doesn't seem to be working the way I expect.
class Fruit:
name = ''
facts = []
def __init__(self, FruitName):
self.name = FruitName
fact... |
Importing a Flask-security instance into my views module breaks my webapp
Question: I'm writing the sign up/sign in system for a ecommerce site, and using flask-
security (<http://pythonhosted.org/Flask-Security/>) to handle the signup
feature. Part of the basic setup requires the following signup.py module:
... |
python 2.7's logging.info(string) and newline characters
Question: Does python 2.7's logging.info(string) (import logging) automatically strip
newline characters from the given string? If not, is there a command to make
it behave like that? If so which command is that?
Thank's a lot!
Answer: No, it will not automati... |
Printing out a random string (Python)
Question: I am asked to produce a random string using a previously defined value.
THREE_CHOICES = 'ABC'
FOUR_CHOICES = 'ABCD'
FIVE_CHOICES = 'ABCDE'
import random
def generate_answers(n: int) -> str:
'''Generates random answers from ... |
ImportError: No module named tis_class
Question: I've a Python3 script, normally works great.
But I've this module error message in line 5 :
pi@raspberrypi ~ $ python3 ScriptCompteur.py
Traceback (most recent call last):
File "ScriptCompteur.py", line 5, in <module>
import tis_clas... |
How to call a Python function from Lua?
Question: I want to run a python script from my lua file. How can I achieve this?
Example:
Python code
#sum.py file
def sum_from_python(a,b)
return a+b
Lua code
--main.lua file
print(sum_from_python(2,3))
Answer: Soun... |
Import Error, When I import nltk.corpus.framenet in NLTK Python
Question: I have to use framenet in nltk.corpus. So, I downloaded that corpus by using
the nltk.download(). And the framenet directory is now
C:\nltk_data\corpora\framenet_v15...
But when I import that framenet, I can't. I can't find the reason. I want to... |
I'm trying to time how long a key is held down using vPython
Question: I'm writing a program for my physics final. Throughout the semester we have
used vPython to model situations and get exact answers, etc. Our final project
is to create a game using vPython that includes some type of physics.
I chose to remake Bowma... |
Python 3.3 GUI Program
Question: Celsius to Fahrenheit-- Write a GUI program that converts Celsius temperatures
to Fahrenheit temperatures. The user should be able to enter a Celsius
temperature, click a button, and then see the equivalent Fahrenheit
temperature. Use the following formula to make the conversion: F = 9/... |
Python "Rock, Paper, Scissors" validation
Question: I have been making a rock paper scissors game, and it works like a dream.
However, when I try to add some validation in (shown with the `#`'s) my game
doesn't work. I'm not sure why this is the case.
My code is following:
from random import randint... |
Django Import-Export: Admin interface "TypeError at /"
Question: I am trying to figure out how to use Django Import-Export,
<https://pypi.python.org/pypi/django-import-export>
by reading the docs
<https://django-import-
export.readthedocs.org/en/latest/getting_started.html#admin-integration>
## Admin Integration:
... |
Pygame: Timer For Time Alive
Question: Hello I am currently making a game in python and I am trying to make a timer
which I have never attempted before, hence asking this question. What I really
need to know is how to loop this small area where it says #Timer. Any help
will be appreciated, thank you.
imp... |
Check if namedtuple with value x exists in list
Question: I want to see if a namedtuple exists in a list, similar to:
numbers = [1, 2, 3, 4, 5]
if 1 in numbers:
do_stuff()
is there a pythonic (or not) way to do this? Something like:
namedtuples = [namedtuple_1, namedtu... |
Heroku / gunicorn / flask app says "Connection in use"
Question: I have a Flask app that runs fine on local, but when I push to Heroku I get
the error message:
* Running on http://127.0.0.1:5000/
[INFO] Starting gunicorn 18.0
[ERROR] Connection in use: ('0.0.0.0', 8163)
I tried the solution... |
comparing occurrence of strings in list in python
Question: i'm super duper new in python. I'm kinda stuck for one of my class exercises.
The question goes something like this: You have a file that contains
characters i.e. words. (I'm still at the stage where all the terms get mixed
up, I apologize if that is not the c... |
wxPython: binding wx.EVT_CHAR_HOOK disables TextCtrl backspace
Question: I have a wx.TextCtrl and I want to be able to type in it, but also detect key
presses such as UP, DOWN, RETURN, ESC.
So I binded wx.EVT_KEY_DOWN to recognize any key press, and wx.EVT_CHAR_HOOK
to do the same thing even when TextCtrl has focus.
... |
cannot setup apache 2.2 with mod_wsgi and python 3.3?
Question: This is error log when i'm trying to setup with Python 3.3, Apache 2.2 and use
mod_wsgi-3.4.ap22.win32-py3.3.zip at
<http://www.lfd.uci.edu/~gohlke/pythonlibs/>
mod_wsgi (pid=4940): Target WSGI script 'C:/www/h.wsgi' cannot be loaded as Pyt... |
pyfits not working for windows 64 bit
Question: I am using **windows 7 home basic 64 bit**. I wanted to work with **FITS file
in python 3.3** so downloaded pyfits and numpy for 64 bit. **When I import
pyfits** I get the following error:
> Traceback (most recent call last): File "", line 1, in import pyfits as py
> Fil... |
How do I make stat_smooth work in ggplot-python?
Question: That's my code:
import pandas as pd
import pandas.io.sql as sqlio
from ggplot import *
from db import conn
sql = "SELECT * FROM history WHERE time > (NOW() - INTERVAL '1 day')::date"
df = sqlio.read_frame(sql, conn)
c... |
Python's assert_called_with, is there a wildcard character?
Question: Suppose I have a class in python set up like this.
from somewhere import sendmail
class MyClass:
def __init__(self, **kargs):
self.sendmail = kwargs.get("sendmail", sendmail) #if we can't find it, use... |
decrypt ssl encrypted data in python
Question: I'm analyzing a packet capture with python using dpkt. The application layer
is encrypted with ssl. I'd like to decrypt the ssl data (i.e., the tcp
payload). I have the private key, so I should be able to use the key to
decrypt the data. Here's my script:
#!... |
Scrapy SgmlLinkExtractor - Having trouble with recursively scraping
Question: **Update: Apparently I can't answer my own question within 8 hours, but I got
it to work. Thanks guys!**
I am having trouble getting scrapy to crawl the links on the start_url.
The following is my code below:
from scrapy.sele... |
Can't run PhantomJS in python via Selenium
Question: I have been trying to run PhantomJS via selenium for past 3 days and have had
no success. So far i have tried installing PhantomJS via npm, building it from
source, installing via apt-get and downloading prebuilt executable and placing
it in /usr/bin/phantomjs.
Ever... |
Empty list returned from ElementTree findall
Question: I'm new to xml parsing and Python so bear with me. I'm using lxml to parse a
wiki dump, but I just want for each page, its title and text.
For now I've got this:
from xml.etree import ElementTree as etree
def parser(file_name):
docu... |
tkinter and scrabble solver problems
Question: I have had to learn python 3.3.3 for a logic and design class. I am extremely
new at programming and the code below is the culmination of what ive learned
on my own in 10 weeks. I had my program working fine at a procedural level
with out a GUI. my program was a typical sc... |
Why is `poll.poll` faster than `epoll.poll`?
Question: I thought `epoll` should be faster than `poll`, but when I do the following
experiment, it turns out to be slower.
First I set up 1 server socket with 10 client sockets connected.
import socket
server = socket.socket()
server.bind(('127.0.0.... |
python script for getting some columns of one excel into new one
Question:  I am new
to Python. I have to create another Excel file from my test report Excel file.
I need to create a new excel file as 'test result summery' with columns-values
like `tes... |
Get a text file specific field issue
Question: I am working on python in order to use data mining on social media to analysis
data . Now I have written a code which gives me information about Facebook
most liked pages and I have stored information on a text file called
`"pages.txt"` the following is a snapshot of my te... |
issue using r function with rpy2
Question: Sorry if my question is not clear enaugh. It is my first question on this
site. When I do
from rpy2.robjects import IntVector, Formula
from rpy2 import robjects
rr = Formula('gr_bmr~nationalite_france')
myparams = {'family': 'binomial'}
form... |
Python Pandas plotting title name passing string
Question: How do I make the title name display 'AAPL Stock Price' without converting all
my pandas data to matplotlib and numpy.
import time
from pylab import *
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from... |
Add item to pandas.Series?
Question: I want to add an integer to my `pandas.Series`
Here is my code:
import pandas as pd
input = pd.Series([1,2,3,4,5])
input.append(6)
When i run this, i get the following error:
Traceback (most recent call last):
File "<pyshell#9>", l... |
What does "module object is not callable" mean?
Question: I'm using the .get_data() method with mechanize, which appears to print out
the html that I want. I also check the type of what it prints out, and the
type is 'str'.
But when I try to parse the str with BeautifulSoup, I get the following error:
-... |
What is the exception for this error: httperror_seek_wrapper: HTTP Error 404: Not Found?
Question: I would like to handle the error:
"httperror_seek_wrapper: HTTP Error 404: Not Found"
And instead just return an empty string. But I'm not sure what the except
statement should be. I apologize if there is a duplicate po... |
Read all files in a folder and also the filenames in python?
Question: How to read all files and also the filenames? I am using MAC so is there any
there a different way to give path on MAC in Python?
Answer: Maybe something like this? Or os.listdir() is simpler if you don't need
recursion.
Even on Windows, Python a... |
Subtracting two interleaved, differently based time-series arrays with numpy?
Question: I have two datasets, `a[ts1]` and `b[ts2]`, where `ts1` and `ts2` are
timestamps taken at different times (in different bases?). I wanted to plot
`b[ts2]-a[ts1]`, but I think I made a mistake, in that the plotting software
understoo... |
Right way to write Unit-Tests in module?
Question: I want to write tests for my main file,`calc.py`, with unittest in module
file, `MyTests.py`.
Here is my main python file, `calc.py`:
import myTests
def first(x):
return x**2
def second(x):
return x**3
def main... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.