text stringlengths 226 34.5k |
|---|
Getting very high values in linear regression
Question: I am trying to make a simple MLP to predict values of a pixel of an image -
[original blog](http://evolvingstuff.blogspot.in/2012/12/generating-mona-lisa-
pixel-by-pixel.html) . Here's my earlier attempt using Keras in python -
[link](https://github.com/goelakash/... |
Python: Accessing array elements
Question: I have the following array (list?). I need to access each number of this
array. What is the syntax for this?
[[-0.04376741 0.03017034 0.0315476 ]
[ 0.01211464 0.03405497 -0.04028852]
[ 0.00958469 0.00675439 -0.02219515]
[-0.00708102 -0.0096356... |
Python: weird rounding behavior of math.sqrt()
Question: Using Python 2.7.10, I have found quite by accident that 5*math.sqrt(3) and
math.sqrt(5**2*3) are not the same float:
import math
import decimal
print decimal.Decimal(5*math.sqrt(3))
print decimal.Decimal(math.sqrt(5**2*3))
pri... |
How to find point of intersection of two line segments in Python?
Question: I have data with one independent variable x and two dependent variables y1 and
y2 as shown below:
x y1 y2
-1.5 16.25 1.02
-1.25 17 1.03
-1 15 1.03
-0.75 9 1.09
-0.5 ... |
cv2.createBackgroundSubtractorMOG2() error
Question: Could anyone help me on this one? I'm trying for a background Subtracting
method and used to perfectly run fine while using the
cv2.BackgroundSubtractorMOG() method in previous opencv versions.
import cv2
backsub = cv2.createBackgroundSubtractorMOG... |
python - regex parsing log
Question: i have the following log line i want to parse
<log pos_start="40652288" end_position="40689664" log_type="1" length="37376" block_id="4024" block_position="18"/>
i am using python regex, this is what i did so far
regexParse = re.match(".*pos_start... |
Execute shell command from Python Script
Question: I want to execute this command from a python script:
iw wlan0 scan | sed -e 's#(on wlan# (on wlan#g' | awk -f > scan.txt
I tried like the following
from subprocess import call
call(["iw wlan0 scan | sed -e 's#(on wlan# (on wlan#g... |
Translations with Django 1.5.11 and Apache
Question: I am using django 1.5.11 with translations having the locale folder not in the
site directory. I used the LOCALE_PATHS variable to set the correct folder.
When I start my application using runserver, either in my machine or the
server, the translation work correctly.... |
How to use Flask-Migrate with Google App Engine?
Question: Since I moved to Google App Engine I cannot run the Flask-Migrate command
`python manage.py db migrate` because I have exceptions regarding some GAE
related imports (`No module named google.appengine.ext` for example).
Is there a way to run this, or an alterna... |
Error fireware on centos 7
Question: I'm using the code below to open port 80 on my sever:
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
but I get this error:
Traceback (most recent call last):
File "/bin/firewall-cmd", line 24, in <module>
from gi.repos... |
Script returns output in IDLE not when executed at CLI
Question: I have a script that runs a few external commands and returns their values. I
am able to run the script within IDLE just fine, and I get the expected
results.
When I execute the script in a Linux shell (Bash), it runs, but with no
output.
The exit statu... |
Grabbing a number from Entry and doing calculations using Tkinter
Question: I'm working on my final project for my Intro to Programming classes and I'm
having the hardest time working with Tkinter and Python.
Here is my task: Have a user enter their income from their paycheck. The
program will then do the following ca... |
Shared pool map between processes with object-oriented python
Question: (**python2.7**)
I'm trying to do a kind of scanner, that has to walk through CFG nodes, and
split in different processes on branching for parallelism purpose.
The scanner is represented by an object of class Scanner. This class has one
method **t... |
Find Average Of a key with multiple values
Question: I have a dictionary e.g:
Jhon: 3, 4, 5
Mark: 5, 5, 5
Matthew: 7, 8 , 9
This is my code:
from statistics import mean
class1 = {}
for line in f:
columns = line.split(":")
if len(columns... |
How to properly make taggit use in wagtail
Question: Here is my code in wagtail, and I am not sure why Taggable gives me an error
when trying to add new content based on the page.
class BlogPage(Page):
body = StreamField([
('heading', blocks.CharBlock(classname="full title")),
... |
Python docstrings templated
Question: Why doesn't dynamically formatting docstrings work? Is there an acceptable
workaround for doing this _at function definition time_?
>>> DEFAULT_BAR = "moe's tavern"
>>> def foo(bar=DEFAULT_BAR):
... """
... hello this is the docstring
... ... |
Python (2.7) Operation on a closed file error
Question: Another user here recently helped me refine the code below. I have the sorted
list of the integers, but I don't know how to get the original list since the
with statement closes the file it is reading from. I have already returned the
variable "List" and have a pr... |
Connect QPushButton Jambi
Question: I'm pretty new to Java programming. I wrote the application listed below, but
I can't connect the button to my function. Any idea what I'm doing wrong?
package com.teat;
import com.trolltech.qt.gui.*;
public class Application
{
public sta... |
Sympy and lambda functions
Question: I want to generate a list of basic monomial from x^0 to x^n (in particular,
n=9) using Sympy. My quick solution is a simple list comprehension combined
with Python's lambda function syntax:
import sympy as sym
x = sym.symbols('x')
monomials = [lambda x: x... |
How to get media_url from tweets using the Tweepy API
Question: I am using this code:
import tweepy
from tweepy.api import API
import urllib
import os
i = 1
consumer_key="xx"
consumer_secret="xx"
access_token="xx"
access_token_secret="xx"
auth = tweepy.OAuthHandle... |
Error handling in Django REST framework - empty file returned instead of Error view
Question: I have a piece of code in a Django REST framework that looks like the
following. It works if the request arguments are valid, but if I specify a
non-valid search keyword, the browser returns an empty python file with length
of... |
Appending a Numpy array to a list
Question: I am new to Python and even newer to Numpy so apologies if I've made a blunder
somewhere.
Essentially I am taking a list of angles (of indeterminate length) calculating
an array based on trig functions of those values, and then creating a new list
where at each index is a "t... |
psycopg2 OperationalError: invalid connection option
Question: I am using
[records](https://github.com/kennethreitz/records/blob/master/records.py)
library to connect to redshift database. My db_url is something like
postgresql://xxxxx.us-east-1.redshift.amazonaws.com:5439/customer?user=xxxxx&password=xx... |
Python, selenium and catching specific text in div outside any span or something
Question: I came across a page i want to scrap a bit - and i cried a lot looking at the
structure of address details section. But let's be specific:
I have a result structure like this:
<div class="A">
<div class="B">... |
How can I get an oauth2 access_token using Python
Question: For a project someone gave me this data that I have used in Postman for
testing purposes:
In Postman this works perfectly.
Auth URL: <https://api.example.com/oauth/access_token>
Access Token URL: <https://api.example.com/access_token>
client ID: abcde
... |
Fiji (ImageJ) cannot run any script : java.lang.NoClassDefFoundError
Question: I'm trying to run some python scripts on Fiji, but it seems it cannot run a
simple code such as: `print("something")`. It always throw this
`java.lang.NoClassDefFoundError`, and a weirder thing is that the error always
points at some random ... |
Draggable Matplotlib Subplot using wxPython
Question: I'm attempting to expand on a draggable plot tutorial by creating a subplot
that can be dragged (the matplotlib curve, not the whole window). I feel like
I'm close but just missing a critical detail.
Most of the code is just creating cookie cutter subplots, figure ... |
python How can I parse html and print specific output inside html tag
Question:
#!/usr/bin/env python
import requests, bs4
res = requests.get('https://betaunityapi.webrootcloudav.com/Docs/APIDoc/APIReference')
web_page = bs4.BeautifulSoup(res.text, "lxml")
for d in web_pag... |
Retrieve a single item from DynamoDB using Python
Question: I want to retrieve single item from DynamoDB but I'm unable to do that. I
think I am missing something. I am able to scan the table using scan()
function of boto but the fetching of a single item is not working. So it would
be great if someone can tell me the ... |
Python on Apache: Internal Server Error
Question: I'm getting `Internal Server Error` from my Python script on Apache.
The script has `chmod 755` and is in a directory different from `cgi-bin`.
Its content is
#!/usr/bin/python
print "Content-Type: text/html\n"
print "test"
I'm on shared h... |
Sending corrupted csv line over the socket in Python 3
Question: I build a sensor unit where data are gathered at one Raspberry Pi and send to
another's over the network. My first Pi creates a line with multiple readings
from different sensors. It supposed to create a server and send it to clients.
The client Pis needs... |
Python - Import CSV file and save it into Database SQLAlchemy
Question: i have a prblem with importing CSV-file into Database... Im using SQLAlchemy
in Python and wanted to open a CSV-File than show it in QTableWidget to maybe
change the values and after write it to DB (New Table).
def setinTable(self):
... |
How to automatically load data from json file on startup with kivy
Question: I am making an android app with python and kivy that keeps track of diabetes
entries and has a basic profile page. I figured out how to save input from
textinput widgets into a json file which works fine. However I cannot figure
out how to aut... |
Analysing URL's using Google Cloud Vision - Python
Question: Is there anyway I can analyse URL's using Google Cloud Vision. I know how to
analyse images that I store locally, but I can't seem to analyse jpg's that
exist on the internet:
import argparse
import base64
import httplib2
from googl... |
Python worker crashes when loading CSV file with many columns
Question: I'm trying to load
[this](https://www.dropbox.com/s/ltwg63jpm55845m/pivot.csv?dl=0) CSV file with
many columns and calculate the correlation between columns using Spark.
from pyspark import SparkContext, SparkConf
from pyspark.ml... |
unregistered task type import errors in celery
Question: I'm having headaches with getting celery to work with my folder structure.
Note I am using virtualenv but it should not matter.
cive /
celery_app.py
__init__.py
venv
framework /
tasks.py
__ini... |
How to merge xArray datasets with conflicting coordinates
Question: Let's say I have two data sets, each containing a different variable of
interest and with incomplete (but not conflicting) indices:
In [1]: import xarray as xr, numpy as np
In [2]: ages = xr.Dataset(
{'ages': (['kid_ids... |
why pool.map in python doesn't work
Question:
import multiprocessing as mul
def f(x):
return x**2
pool = mul.Pool(5)
rel = pool.map(f,[1,2,3,4,5,6,7,8,9,10])
print(rel)
When I run the program above, the application is stuck in a loop and can't
stop. I am using python 3... |
Linux command equivalent of hash() in python
Question: In my program In have a log directory. Name of the log directory is very long
so in my python script I used hash function to get the unique code and append
it to fixed string ie:
LOG_DIR = "abcdefghijklmnopqrstuvwxyz"
log_dir_hashed = hash(LOG_D... |
Python Tkinter multiple frames with some animation on each frame
Question: inspired by Bryan Oakley post [question] [Switch between two frames in
tkinter](http://stackoverflow.com/questions/7546050/switch-between-two-frames-
in-tkinter) I wrote this program with three pages, each page having an
animation: a clock, a me... |
I need help in python2 to making a counter that can count up and store the count data into a file
Question: This is my code, I have to add a counter into my code so that every time the
button is pressed it will count up once and i would like to to keep on
counting up every time the button is pressed. I searched online ... |
spark-submit python file ‘home/.python-eggs’ permission denied
Question: I had a problem when I use spark-submit to run a python file.When the 'map'
code run in 'executor', the problem like this :
Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 151, in _run_module_as_mai... |
Python3 lxml builder
Question: I'm trying to create XML-file with python lxml builder lke below:
<entityset>
<entity>
<temp code="1stCode"/>
<attr code="2ndCode">
<value>PythonIsFun</value>
</attr>
<attr code="3rdCode">
<value>PythonIsSt... |
How to get the equation of the boundary line in Linear Discriminant Analysis with sklearn
Question: I classified some data being split in 2 categories, with
LinearDiscriminantAnalysis classifier from sklearn, and it works well, so I
did this:
from sklearn.cross_validation import train_test_split
from... |
How do I extract a row of a file in python?
Question: I have an rfid reader hooked up to a raspberry pi. When i scan a card, I get a
UID number stored in my python file as "backData" I would like to store all of
my users in a separate file (IE: csv or txt file), instead of at the top of my
code and then read that file ... |
1 producer, 1 consumer, only 1 piece of data to communicate, is queue an overkill?
Question: This question is related to **Python Multiprocessing**. I am asking for a
suitable interprocess communication data-structure for my specific scenario:
### My scenario
I have one producer and one consumer.
1. The producer p... |
Retrieving information from Instagram using an unauthenticated request?
Question: I'm attempting to use the Instagram with Python and I'm running into an issue
just using the stock examples on their [GitHub
page.](https://github.com/facebookarchive/python-instagram) I'm following the
steps exactly in the first unauthen... |
I need to connect to a single IP using multiple telnet sessions, is there a way to do it? Below is my code in python
Question: This is one session of telnet, I want such multiple sessions to be connected.
import telnetlib
import time
tn = telnetlib.Telnet("10.13.135.3",23)
time.sleep(10)... |
How to handle different exceptions raised in different Python version
Question: Trying to parse a malformed XML content with xml.etree.ElementTree.parse()
raises different exception in Python 2.6.6 and Python 2.7.5
Python 2.6: xml.parsers.expat.ExpatError
Python 2.7: xml.etree.ElementTree.ParseError
I'm writing code... |
Wrapping all possible method calls of a class in a try/except block
Question: I'm trying to wrap all methods of an existing Class (not of my creation) into
a try/except suite. It could be any Class, but I'll use the
**pandas.DataFrame** class here as a practical example.
So if the invoked method succeeds, we simply mo... |
Querying a remote API from a Python script
Question: I would like to integrate the `reviews API` from Zomato in my Python script.
I know basic programming in Python, but as for API integration, I want to know
* how to proceed with the API
* what steps should be taken to query the API from Python
* how to integr... |
Python XML Grab IP from File Between CDATA
Question: I have an XML dump file that I want to parse for the first occurrence of
'ETH0_IP'. However, the cdata field is throwing me. It ends up returning
'None'. There are other IPs that appear further in the file but I don't care
about those.
I have something like this so ... |
a function that modifies its class's data objects
Question: I want to define a function, call it `test_controller()`, and I want to pass
this function to a constructor: `my_thing = TestClass(test_controller)`. This
function needs to be able to modify its class's data objects. I've heard of
the `nonlocal` keyword for Py... |
MNIST Python numpy eigen vectors visualization error
Question: I am trying to perform PCA on [MNIST](http://yann.lecun.com/exdb/mnist/)
dataset, as part of the process I need to generate the eigen vectors and
visualize the top features. Following is my algorithm:
1. Load images
2. Subtract mean
3. Generate Cova... |
How to open a file through python with folder name a regular expression?
Question: I want to open a file ex: xyz.txt which is in a folder named ex:
abc_4564536_01_r4897934. Now let suppose I only know that folder name consist
of "4564536_01" and there is no other folder with the same string in its name.
Answer: Your ... |
How do I search for a word within repository?
Question: For e.g. I am looking for all the words "import" and I can use the search box
that returns something like this...
[https://github.com/charlesdaniel/s3_uploader/search?l=python&q=import&utf8=%E2%9C%93](https://github.com/charlesdaniel/s3_uploader/search?l=python&q... |
Server not working for multiple clients
Question: Please tell me what is the problem with my server code. It is not working for
the two clients simultaneously. It is running only for the client that I run
first. I am new to python and socket programming. Kindly help me out here.
import socket
import ... |
Interactive countinuous plotting of an ODE model in Python
Question: I would like to create a script that integrates an ode model, such that I can
change one of the parameters and see the response of the systems to this
change. If for, for example, I have a Lotka-Volterra model (as taken from this
[example](http://scip... |
Using Python Flask-restful with mod-wsgi
Question: I am trying to use mod-wsgi with Apache 2.2
I have the following directory structure:
scheduling-algos
-lib
-common
-config
-config.json
resources
-Optimization.py
optimization.wsgi
optimization_app.py
My `optimi... |
Python only find string with specific length numbers
Question: I am trying to create a script that search for strings of numbers with only
specific length numbers from an output.txt.
Example output.txt:
12345678
77777
12123887
When I use:
import re
f = open('output.txt'... |
Cosine similarity using TFIDF
Question: There are several questions on SO and the web describing how to take the
`cosine similarity` between two strings, and even between two strings with
TFIDF as weights. But the output of a function like scikit's
[`linear_kernel`](http://scikit-
learn.org/stable/modules/generated/skl... |
How to get a method called (decorator?) after every object method
Question: This is a question similar to [How to call a method implicitly after every
method call?](http://stackoverflow.com/questions/33075283/how-to-call-a-
method-implicitly-after-every-method-call) but for python
Say I have a crawler class with some ... |
Python matplotlib animation randomly jumping to initial position
Question: I'm adapting code from [this matplotlib
example](http://matplotlib.org/1.4.1/examples/animation/simple_3danim.html)
but am finding that within my animation each particle seems to jump back to
it's initial position, but not all at the same time? ... |
Extracting selected columns from a datafile using python
Question: I have a data file like this
0.000 1.185e-01 1.185e-01 3.660e-02 2.962e-02 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
0.001 1.185e-01 1.185e-01 3.660e-02 2.962e-02 -1.534e-02 -1.534e-02 8.000e-31 8.00... |
How to schedule a periodic task that is immune to system time change using Python
Question: I am using python's sched module to run a task periodically, and I think I
have come across a bug.
I find that it relies on the time of the system on which the python script is
run. For example, let's say that I want to run a t... |
how to find right version of bson from pip for pymongo/mongoengine
Question: I am working on a (python 2.7) flask-mongoengine application which uses bson's
ObjectId. The project requires bson in one or another way. I don't have root
access on the host i'm trying to deploy the application and pip install bson
fails:
... |
How to save information in json file without deleting previous information python
Question: I am making an app using python and kivy that allows the user to make a new
entry for their glucose readings. Right now it saves into the json file but
another new entry deletes the previous data. How can I make it so that each
... |
Python Requests Not Returning Same Header as Browser Request/cURL
Question: I'm looking to write a script that can automatically download `.zip` files
from the [Bureau of Transportation Statistics Carrier
Website](http://www.transtats.bts.gov/DL_SelectFields.asp?Table_ID=293), but
I'm having trouble getting the same re... |
saving multiple dicts and variables in disk
Question: My code typically runs for several days and spews out intermediate results as
Python dicts and float variables. I cannot afford to append all intermediate
values to a Python list and save all outputs to a physical file using pickle
etc in one go after the run. This ... |
searching for a word in a file using command argument? in python3, popping up no answers
Question: trying to write a program that searches the dictionary file for words which
start with the first command line argument, which is their stem but I'm
getting nothing.
here's my code, what am I doing wrong?
i... |
How to use boto3 (or other Python) to list the contents of a _RequesterPays_ S3 bucket?
Question: You can download a file via boto3 from a RequesterPays S3 bucket, as follows:
s3_client.download_file('aws-naip', 'md/2013/1m/rgbir/38077/{}'.format(filename), full_path, {'RequestPayer':'requester'})
... |
Python - control application started by the different user in Windows
Question: I am making application that controls a browser with SendKeys. But as SendKeys
get the full control over the keyboard, I want to run this app under the
different user. This way I will be working, the application will do what it
have to do, ... |
Delete NaNs and Infs in Numpy array
Question: Recently I got a problem when learning Python numpy. Actually I was testing a
self-defined function on a remote server, and this function uses
_numpy.linalg.eig_ :
import numpy
from numpy import *
def myfun(xAr,yAr) #xAr, yAr are Matrices
f... |
Unable to print logs in default color, when no color is specified explicitly using Colorama
Question: I am trying to get colored logs using colorama and logging module in python.
If I am not giving any color then it should print default terminal color, but
in my logs I am getting color of previously set logs if no colo... |
How do I print tables from an SQLite databse in python?
Question: So I have a database of information that I would like to print in a nice table
format, held as an SQLite db file.
The only print statements I have seen print the information in a confusing
manner, not aligning the attributes of different entities, no co... |
Error while installing flask framework on ubuntu 15.04
Question: I am trying to install flask framework on my ubuntu 15.04. It is giving me
this error and I am unable to figure it out. It would be great if someone
could help
Error:
pragati@pragati-ubuntu:~/Python-2.7.11$ sudo pip install flask
[sudo... |
Multi body animation in python returns static picture
Question: Here is a program that I have written to do an animation in `matplotlib`. The
program concerns a system of 18 particles arranged initially in a hexagonal
lattice. The initial configuration is given under the definition of
`simPoints(simData)`.
The system ... |
How do I set axes to add text outside a plot?
Question: (Using python3.4)
This is the code I'm using to plot. I'm trying to add additional text which
can help explain what this plot is about.
import matplotlib.pyplot as plt
import numpy as np
somecode.....
somecode.....
xv=np.array(x1)
... |
How to make an equivalent to Fortran's 'access=stream' in python
Question: Let's say i'm making a loop, and after each iteration, y want to extend some
array.
iter 1 ------------> iter 2 --------------> iter 3-------------->....
shape=[2,4]---->shape=[2,12]----->shape=[2,36]---->....
in fortran i used to do this by ... |
What is the fastest way to check if a number is in specific range in python?
Question: I have 5 ranges:
1-50 ---> "range1"
51-100 ---> "range2"
101-150 ---> "range3"
151-200 ---> "range4"
201-250 ---> "range5"
Ranges do not overlap, each range has lower and upper bound, next range s... |
CherryPy and CORS
Question: I have an nginx server set up where I would like to set up a service that
receives a string and returns a result. I plan to use Python to do the
processing, with CherryPy as an interface. I've tested the CherryPy part, and
know it receives properly. When I try to connect to the CherryPy serv... |
Unpack Python URL Request
Question: I'm using:
import requests
data = 'text=great'
print(requests.post('http://text-processing.com/api/sentiment/', data=data).text)
which returns:
{"probability": {"neg": 0.30135019761690551, "neutral": 0.27119050546800266, "pos": 0.... |
How to fetch paragraphs from html using Python
Question: How to fetch paragraphs from bad-structured html?
I have this original html text:
This position is responsible for developing and implementing age appropriate lesson and activity plans for preschool children, ages 4-5 years-old. Maintain a fun and... |
Can't get true/false value from command line in python 2.7
Question: I'm trying to incorporate a flag in to a program:
python2.7 hello.py --showxy
and `argparse` is giving me trouble.
this is my example test code:
import os
import sys
import argparse
print (os.getcw... |
shadowing a site module by my own module in Python
Question: I have a script `foo.py`, which tries to `from bar import baz`: basically the
hierarchy is the following:
/
foo.py
bar/
__init__.py
baz.py
The problem is that the system ships its own version of `ba... |
This error while downloading datasets: ValueError: I/O operation on closed file
Question: I have started with deep learning with Theano and Keras. However, for any
program, I will have to load the dataset, and i'm not able to load any
dataset.
Even if I run these two lines:-
from keras.datasets import c... |
Python3 Rename files in a directory importing the new names from a txt file
Question: I have a directory containing multiple files. The name of the files follows
this pattern 4digits.1.4digits.[barcode] The barcode specifies each file and
it is composed by 7 leters. I have a txt file where in one column I have that
bar... |
Can't start Mercurial
Question: When I put “hg —version” in my mac terminal, it shows below Error…
Traceback (most recent call last):
File "/usr/local/bin/hg", line 41, in <module>
mercurial.util.setbinary(fp)
File "/Library/Python/2.7/site-packages/mercurial/demandimport.py", line 10... |
How do I plot a 2D array graph in Python using matplotlib
Question: I'm having a little bit of trouble in creating a graph using 2D array data in
python.
I have a txt file which holds data like this:
0 2 4 6 8
-1 -2 -1 2 4
0 1 0 -1 0
1 3 5 7 6
0 1 -1 -3 2
1 -1 1 1 0
(this is sh... |
Create python array from first element of array 1, first element of array 2, second element of array 1, second element of array 2, etc
Question: I am attempting to create a state vector representing the positions and
velocities of a series of particles at a given time, for a simulation. I have
created individual vector... |
Opening other Python 3 files using tkinter
Question: I am currently working on making a program using tkinter that when pressing a
button it opens the Python program, however I am having some problems with it.
I have tried using `os.system('filename.py')`. That opens the file, but then
crashes the GUI, making the user ... |
How to handle with Django HTTP.Request, request content-type, query parameters
Question: Hi all I'm new in Python and Django actually also in Coding.
I would like to build an app, that can receive a POST-Request with the
Content_Type 'application/xml'.
I don't understand how to handle with the HTTP.Request.META in dj... |
Python openpyxl select sheet
Question: I am writing some data into an Excel file, but I dont know how to adjust the
code in order to be able to control which sheet I am writing into:
wb= load_workbook(filename)
active_ws=wb.active
Instead of `wb.active`, how can I say something like `Sheets('Da... |
using an array in python
Question: I am currently trying to figure out how to store two sets of values, t and y,
in my program so that I can plot these data points on a graph. I believe the
correct method is to use an array, but I am not sure how to proceed.
import numpy as np
import matplotlib.pyplo... |
Interrupting a Queue.get
Question: How can I interrupt a blocking `Queue.get()` in Python 3.X?
In Python 2.X [setting a long
timeout](http://stackoverflow.com/q/212797/1658617) seems to work but the same
cannot be said for Python 3.5.
Running on Windows 7, CPython 3.5.1, 64 bit both machine and Python. Seems
like it ... |
Categorize data into n category with same interval size in python
Question: Assume I want to categorize data below in 12 category:
no. grades
0 9.08
1 8.31
2 7.42
3 7.42
4 7.42
5 7.46
6 9.67
7 11... |
Convert datetime (e.g. 2016-01-01, 2016-01-11) to integer days (e.g. 0, 11) in Python
Question: **Is it possible to convert a timestamp object in the format "2016-01-01"
(year month day) into number of days from new years?**
I'm getting my timestamp object by `str(pandas.to_datetime('today')).split("
")[0]`
I would p... |
accessing a list of urls via Multi-processing in Python2.7
Question: I've been playing with multiprocessing and my code works when looking at
smaller numbers but when I want to run a larger sample 2 things happen: Either
the code locks up or I get the following error message: "urlopen error [Errno
10054] An existing co... |
Python bs4 removes br tag
Question: I use bs4 to manipulate some rich-text. but it removes br tag inside where i
did character conversion. below is the simple form of the code.
import re
from bs4 import BeautifulSoup
#source_code = self.textInput.toHtml()
source_code = """.......<p styl... |
Python geoip find country using json
Question:
from urllib2 import urlopen
from contextlib import closing
import json
import time
import os
while True:
url = 'http://freegeoip.net/json/'
try:
with closing(urlopen(url)) as response:
location = jso... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.