text stringlengths 226 34.5k |
|---|
Optionally replacing a substring python
Question: My list of replacement is in the following format.
lstrep = [('A',('aa','aA','Aa','AA')),('I',('ii','iI','Ii','II')),.....]
What I want to achieve is optionally change the occurrence of the letter by
all the possible replacements. The input word sho... |
Python Help | Read data from text file from the bottom
Question: Can someone have a look at my program? There's an error which I cannot
identify and it's really confusing me. Also, please explain to me the problem
so that I can understand how to use the function and program in another
situation.
input_na... |
'AttributeError: 'NoneType' object has no attribute 'to_dict'
Question: I am developing an API using Google App Engine in Python. I am having trouble
sending a GET request to a particular url. I get the 'NoneType' object has no
attribute `to_dict` error. The trouble comes in at `out = client.to_dict()` in
the apiClient... |
K-means clustering using sklearn.cluster
Question: I came across this tutorial on K-means clustering on [Unsupervised Machine
Learning: Flat Clustering](https://pythonprogramming.net/flat-clustering-
machine-learning-python-scikit-learn/), and below is the code:
import numpy as np
import matplotlib.p... |
from scipy.integrate import odeint returns error
Question: I ran this command `from scipy.integrate import odeint` but I get the errors
below. I am new to python. I have installed `scipy` and `numpy` but I don't
have any idea what more is missing to run this. Please help.
Traceback (most recent call la... |
Django 1.8: django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet
Question: I have read other questions about this issue, but cannot fix from that
answers.
What I am doing: on my local PC I have Django 1.8.5 and several apps, all is
working properly. To 1.8.5 I was upgraded from 1.6.10 some time ago. Bu... |
filter strings by regex in a list
Question: I'd like to filter a list of strings in python by using regex. In the
following case, keeping only the files with a '.npy' extension.
The code that doesn't work:
import re
files = [ '/a/b/c/la_seg_x005_y003.png',
'/a/b/c/la_seg_x005_y003... |
HDF5 library and header mismatch error
Question: I am using Anaconda on Ubuntu x64. When I run a simple python program, I get
this error message and a [python] kernel dump. I have seen other questions
with similar problems, but all the answers I see don't resolve my issue. I
have tried removing and reinstalling h5py wi... |
Python using numpy ~isnan()
Question: I'm new to Python. I'm trying to reduce the following peace of code.
import numpy as np
data = np.loadtxt('logfilename.txt')
x = data[:,0]
x = x[~np.isnan(x)]
to something like that:
import numpy as np
data = np.loadtxt('logfilena... |
TypeError when importing Python's decimal module
Question: What causes the TypeError when importing the decimal module?
[Michael@devserver MyScripts]$ cat decTest.py
from decimal import *
#item = Decimal( 0.70 )
[Michael@devserver MyScripts]$ python3.3 decTest.py
Traceback (most rece... |
Pickling method descriptor objects in python
Question: I am trying to pickle a `method_descriptor`.
Pickling with `pickle` or `cloudpickle` fails:
Python 2.7.10 |Continuum Analytics, Inc.| (default, Oct 19 2015, 18:04:42)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyri... |
Random values in dictionary- python
Question: I have this `OrderedDict`:
(
[
('Joe', ['90', '0']),
('Alice', ['100', '0']),
('Eva', ['90', '5']),
('Clare', ['100', '10']),
('Bob', ['100', '5'])
]
)
I have to create a function that takes the `O... |
I am trying to edit a function to accept user input options 1,2,3,or 4 through pygame interaction based on python 3 knowledge
Question: i was wondering if anyone had an example of code that shows basically the game
asking a question and the user has to input 1,2,3,or 4. I am not sure how to
accept user input on pygame ... |
PyCharm ImportError
Question: New to Python3.5 (and MacOS) and have begun by using the PyCharm IDE. I'm
using an example from [Download file from web in Python
3](http://stackoverflow.com/questions/7243750/download-file-from-web-in-
python-3) to download a file, but it fails at the first statement:
impor... |
how to handle command line input options in python?
Question: I need a script which can take input via command line. Input will be a file
name and It will take a default input if no input is provided. The script will
also check the existence of the file.
Name of the script is : **wrapper.py**
input example :
... |
Why is running a .compute() in dask causing "Fatal Python error: GC object already tracked"
Question: I am running Windows 10 with Jupyter notebook version 4.0.6 with Python 2.7.10
and Anaconda 2.4.0 (64-bit)
I am following a blog/tutorial at
<https://jakevdp.github.io/blog/2015/08/14/out-of-core-dataframes-in-python/... |
how can I add field in serializer?
Question: Below is my `serializer.py` file:
from rest_framework import serializers
class TaskListSerializer(serializers.Serializer):
id = serializers.CharField()
user_id = serializers.CharField()
status = serializers.CharField()
... |
install pyshark on python 3.5
Question: I've installed python 3.5 on mac os x (el capitan). I want to import pyshark
module in python, but I get error. I installed the pyshark requirement such as
(logbook, lxml,trollies, py) but I couldn't import pyshark module.
pip3 list >>
syncio (3.4.3)
future... |
how to check whether raw_input is integer, string and date in python
Question: I want to check my user input whether it is integer, string or date.
data1 = raw_input("data = ")
print(data1)
if isinstance(data1, datetime.datetime.strptime(data1, '%Y-%m-%d')):
print("d... |
Merging duplicate lists and deleting a field in each list depending on the value in Python
Question: I am still a beginner in Python. I have a tuple to be filtered, merged and
sorted. The tuple looks like this:
id, ts,val
tup = [(213,5,10.0),
(214,5,20.0),
(2... |
Python: appending a counter to a csv file
Question: I am working on a project with data(csv) i gathered from last.fm. In the
dataset there are four columns, the first is the artist, second the album, the
3th is the songname and the fourth is the date at which i scrobbled the track
to last.fm. I already have found a way... |
struct.pack is much slower in python 2.6 when working with numpy arrays
Question: # The basic question
Hello everyone. I believe that I found an issue with python 2.6, struct.pack,
and numpy arrays. The issue is that the following code is incredibly slow when
I run it using python 2.6 (but it is sufficiently fast when... |
For list of dicts: merge same key values, sum another diff. values, count each merge iteration +1
Question: I have list of dicts(or tuples), where:
if tuples:
comment_id, user_id, comment_date, comment_time, comment_likes
('51799', '112801710', '2015-12-07', '00:03:21', '0'),
('51761',... |
Accessing and altering a global array using python joblib
Question: I am attempting to use joblib in python to speed up some data processing but
I'm having issues trying to work out how to assign the output into the
required format. I have tried to generate a, perhaps overly simplistic, code
which shows the issues that... |
how to save pil cropped image to image field in django
Question: I am trying to save a cropped image to a model. I am getting the following
error:
> Traceback (most recent call last): File "/mypath/lib/python2.7/site-
> packages/django/core/handlers/base.py", line 132, in get_response response =
> wrapped_callback(req... |
loop a range() Function with a time delay- Python
Question: How to loop a range() Function x number of times with a time delay in Python?
for example, for i in range(4,9) repeat it for 3 times and each time stop 5
second before starting the new count. The answer should be like this:
"0 second delay" (4,... |
SQLite triggers & datetime defaults in SQL DDL using Peewee in Python
Question: I have a SQLite table defined like so:
create table if not exists KeyValuePair (
key CHAR(255) primary key not null,
val text not null,
fup timestamp default current_timestamp n... |
NameError in Python 3.4.3
Question: When I'm trying this with the following configuration :
* VirtualEnv with python3.4.3
* Running on an online IDE
When I'm trying this :
from urllib.request import urlopen
from urllib.error import HTTPError
from bs4 import BeautifulSoup
try:
ht... |
python get-pip.py return invalid syntax form shutil.py
Question: Ok I need help here.
I have windows 7, and i'm stuck with Python 3.3 because my company sucks I
have been trying to install pip via
> python get-pip.py
I am using the get-pip.py from <https://bootstrap.pypa.io/get-pip.py> which is
the re-direct from th... |
Is there a way to redirect stderr to file in Jupyter?
Question: There was a redirect_output function in IPython.utils, and there was a
%%capture magic function, but these are now gone, and [this
thread](http://stackoverflow.com/questions/14571090/ipython-redirecting-
output-of-a-python-script-to-a-file-like-bash) on th... |
Determining if data in a txt file obeys certain statistics
Question: I'm working with a Geiger counter which can be hooked up to a computer and
which records its output in the form of a .txt file, NC.txt, where it records
the time since starting and the 'value' of the radiation it recorded. It looks
like
... |
Classifying numbers in python
Question: I have tried to classify numbers in python from 0.0 to 1.0. However, all
numbers are getting the else condition. I need each number to get the
appropriate condition, but even when the number is 0.3 or 0.2 is getting the
last bin. What I am doing wrong?
#!/usr/bin/p... |
ArrayField returns wrong value
Question: I am using PostgreSQL with Django and am trying to use
ArrayField(CharField())
Neither storing values nor retrieving raises any exceptions, but attepmting to
store `["string", "another_string", "string with whitespaces", "str"]` and
then retrieve it returns
... |
selenium facebook comment reply
Question: Trying to reply to facebook comments using selenium and python. I've been able
to select the field using
find_elements_by_css_selector(".UFIAddCommentInput")
But I can't post text using the send_keys method. Heres a simplified structure
of the comment html... |
Python find text in file between quotation marks
Question: I'm trying to capture the text within quotation marks and set them as
variables for me to change them at a later stage. I know how to do this in
bash shell, but I'm at a loss how to do this in Python.
I've started with this, but I was hoping someone can point ... |
python, matplotlib: specgram data array values does not match specgram plot
Question: I am using matplotlib.pyplot.specgram and matplotlib.pyplot.pcolormesh to make
spectrogram plots of a seismic signal.
_Background information -The reason for using pcolormesh is that I need to do
arithmitic on the spectragram data ar... |
Leave dates as strings using read_excel function from pandas in python
Question: **Python 2.7.10**
**Tried pandas 0.17.1 -- function read_excel**
**Tried pyexcel 0.1.7 + pyexcel-xlsx 0.0.7 -- function get_records()**
When using pandas in Python is it possible to read excel files (formats:
_xls|xlsx_) and leave col... |
if statement for a subprocess python not working
Question: I've tried to create a little app that plays a sound when you lose
connectivity for an extended period and plays another when the connection is
established. Useful for wireless connections.
I'm still new to Python :) trying little projects to improve my knowle... |
Connecting docker instance with python notebook to docker instance with Neo4J
Question: I am running a Jupyter notebook docker instance
(<https://github.com/jupyter/docker-stacks/tree/master/all-spark-notebook>)
and I've installed py2neo on it.
I am also running a docker container with Neo4J installed with port 7474
e... |
Merging PDF's with PyPDF2 with inputs based on file iterator
Question: I have two folders with PDF's of identical file names. I want to iterate
through the first folder, get the first 3 characters of the filename, make
that the 'current' page name, then use that value to grab the 2 corresponding
PDF's from both folders... |
Numpy Matrix extension such as below:
Question: My question interesed in matrix manuplations in numpy;
A=([[2, 3, 4, 2, 1, 3, 4, 1, 3, 2 ]])
In this matrix the biggest value is 4 as you see. I want obtain a matrix as
below, this matrix have 4 column and 10 rows (10x4) because I have 10
observation
... |
Train departures board ticker Tkinter
Question: I have created a full screen departures board for my local train station using
python and the Tkinter GUI and I have hooked it up to a raspberry pi.
I have limited the number of characters for the display of the train's
destination to 13 to save space. I would like to ma... |
Unable to install openfst python library on Mac OS X Yosemite
Question: I have been trying to install openfst python library for the last week,
however I am stuck. I have read all similar questions on stack overflow and
other websites but none of the instructions work. I have the latest Xcode
installed, using
... |
Can't find Numpy in Windows 8
Question: I tried to run a code that imports Numpy, but it shown
Traceback (most recent call last):
File "C:\Users\MarcosPaulo\Dropbox\Marcos\Desacelerador Zeeman\Simulação da desaceleração atômica\Programa\Dy_deceleration.py", line 4, in <module>
import numpy as np
... |
NameError name 'request' is not defined when trying to check for cookie -Python
Question: I'm encountering the following problem when I'm trying to check if a cookie
exists.
import requests
username = raw_input('Please enter your username: ')
password = raw_input('Please enter... |
Passing a variable from Excel to Python with XLwings
Question: I am trying write a simple user defined function in Python that I pass a value
to from `Excel` via `Xlwings`. I ran across some examples with an Add-in that
you need to import user defined functions, but that seems overly complex.
Why isn't my example work... |
PythonPath and Python Config Scripts
Question: I need some major help and am a bit scared since I do not want to mess up my
computer!I am on a Macbook Air running OSX 10.10.5. So I was following a
tutorial to help me learn Django. The tutorial isn't important. What is
important is that when doing it I changed my $PYTHO... |
Running a python script from another script repeats forever
Question: I am having trouble running a second script from a first script in python. To
simplify what I'm doing the following code illustrates what I'm submitting
file1.py:
from os import system
x = 1
system('python file2.py')
fil... |
Argparse suggests nonsensical order in help text usage line
Question: This program:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('files', metavar='INPUT', nargs='*',
help='File(s) containing words to include. If none given, stdin will be used.')
parser.a... |
Python code not deleting record from database
Question: This is the code I have to delete a record from two tables in my database that
share the same ID code and I'm not too sure where I've gone wrong. Anything
missing? I've checked this a million times
def deletePhoto(photoID):
"""
... |
PyQt4: How to pause a Thread until a signal is emitted?
Question: I have the following pyqtmain.py:
#!/usr/bin/python3
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from pyqtMeasThread import *
class MainWindow(QMainWindow):
def __init__(self, paren... |
Select records based on the specific index string value and then remove subsequent fields by python
Question: I have a .csv file named `file01.csv` that contains many records. Some records
are required and some are not. I find that the required records has a string
variable “Mi”, but it is not exist into the unnecessar... |
Python gaussian fit on simulated gaussian noisy data
Question: I need to interpolate data coming from an instrument using a gaussian fit. To
this end I thought about using the `curve_fit` function from `scipy`. Since
I'd like to test this functionality on fake data before trying it on the
instrument I wrote the followi... |
Using class attributes/methods across different threads - Python
Question: I'll do my best to explain this issue in a clear way, it's come up as part of
a much larger piece of software I'm developing for an A level project - a
project that aims to create a simple version of a graphical programming system
(think scratch... |
tsplot out of bounds error in Python seaborn
Question: i'm trying to plot time series data as points in seaborn, colored by
condition. i tried the following:
import matplotlib
import matplotlib.pylab as plt
import seaborn as sns
import pandas
df = pandas.DataFrame({"t": [0, 1],
... |
print json object nested in an array using python
Question: I am working with a JSON file and am using Python. I am trying to print an
object that is nested in an array. I would like to print select objects (e.g.
"name", "thomas_id") from the following array (is it considered a 'list' of
'objects' in an array? would th... |
Temporal statistics from command line in paraview linux
Question: I'm running paraview on a linux server with poor graphics so I'm limited to
command line approach.
I'd very much like to be able to read in a CFD results file into paraview.
Average them at each point by: `Filter`>`Temporal Statistics` Then plot a line
... |
Fast random weighted selection across all rows of a stochastic matrix
Question: `numpy.random.choice` allows for weighted selection from a vector, i.e.
arr = numpy.array([1, 2, 3])
weights = numpy.array([0.2, 0.5, 0.3])
choice = numpy.random.choice(arr, p=weights)
selects 1 with probabilit... |
Python/Django: creating parent model that all models will inherit from
Question: I am attempting to create a model class that all models will inherit from when
they are created (in django). I want any model class, with any attributes to
be able to inherit from this class and read from the appropriate database
table. I ... |
Efficiently testing if strings are present in 2D numpy arrays
Question: I have a list of sentences that I want to convert into a Pandas MultiIndex
(but don't worry, this question can probably be answered purely using numpy).
For example, lets say the sentences are:
sentences = ['she went', 'I went', 'she... |
Why won't start_transaction set the transaction isolation level?
Question: The [start_transaction](https://dev.mysql.com/doc/connector-
python/en/connector-python-api-mysqlconnection-start-transaction.html) method
of the MySQLConnection class of `mysql-connector-python` doesn't seem to work
as expected.
... |
psycopg2 installation error: Unable to find vcvarsall.bat
Question: I'm trying connect my django 1.9 project to postgresql database. First of all
i need to install psycopg2. I got my psycopg file from
<http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg> . However I could not
install, I have an "Unable to find vcvarsall... |
Sentiment analysis for sentences- positive, negative and neutral
Question: I'm designing a text classifier in Python using NLTK. One of the features
considered in every sentence is it's sentiment. I want to weight sentences
with either positive or negative sentiments more that those without any
sentiment(neutral senten... |
Update variable in python after each loop
Question: Been struggling with this for a little while, I want the variable "result" to
be updated after each loop of the function so that next time it steps through
the function it will return something new. I have tried assigning result
outside of my function then attempting ... |
How do I distribute fonts with my python package?
Question: I have created a package called
[clearplot](http://clearplot.readthedocs.org/en/latest/index.html) that wraps
around matplotlib. I have also created a nice font that I want to distribute
with my package. I consulted [this section](https://python-packaging-user... |
random generated math quiz
Question: i am trying to make a random generated math quiz on python and i keep
encountering a syntax error but i cant find out whats wrong with my code?
print ("what is your username")
name = input () .title()
print (name, "welcome")
import random
score = 0
... |
Python:Errno 10053 when both the server and the client are in the same system
Question: I'm just beginning to code using Python and Python Networking is a whole new
topic for me!I couldn't find out what the problem was and I say, I have tried
all the solutions provided by the user!
Please help me with this code!
Serv... |
Python open file and delete a line
Question: I need a program that imports a file. My file is:
1 abc
2 def
3 ghi
4 jkl
5 mno
6 pqr
7 stu.
I want to delete lines 1, 6 and 7.
Iv tried the following to import the file:
f = open("myfile.txt","r")
lines = f.re... |
Check word frequency of imported file against vocabulary python
Question: I want to create bag of words representation of text file in form of vector
(.toarray()) . I am using code :
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer(input="file")
f = op... |
html form error in django project
Question: I'm rather new to programming. I followed a tutorial about building a
**_django project_**. I've gotten an error that looks like this while running
the server and launching the site (error):
TemplateSyntaxError at /
Variables and attributes may not beg... |
How do I override a decorated method in Python?
Question: Let's say I want to extend the following Python class, which includes a
decorator that I don't know much about:
from somewhere import some_decorator
class One(object):
@some_decorator
def some_method(self):
do_... |
Python - merge two lists of tuples into one list of tuples
Question: What's the pythonic way of achieving the following?
from:
a = [('apple', 10), ('of', 10)]
b = [('orange', 10), ('of', 7)]
to get
c = [('orange', 10), ('of', 17), ('apple', 10)]
Answer: You essentially ha... |
What am I getting wrong in my pandas lambda map?
Question: I'm trying to find the percentile of a dataframe which observations in a
second dataframe would belong to, and I thought a lambda function would do the
trick here like so:
df1.var1.map(lambda x: np.percentile(df2.var1, x))
which I read as f... |
Generation of multidimensional Grid in Python
Question: I have a N dimensional array of points that represents the sampling of a
function. Then I am using the numpy histogramdd to create a multi dimensional
histogram :
histoComp,edges = np.histogramdd(pointsFunction,bins = [np.unique(pointsFunction[:,i]... |
I'm having an invalid syntax error with the socket module
Question:
#!/bin/python
import socket
HOST = "localhost"
PORT = 30002
list = []
passwd = "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ"
for i in range(1000, 9999):
list.append(i)
s = socket.socket(socket.AF_INET, s... |
Not able to Import in NLTK - Python
Question: When I run this command in a file or in a shell
import nltk
I get the following error :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/nltk/__init__.py", line 83, ... |
Python code to pick out all possible permutations of a n-digit number using x-y numbers only?
Question:
__author__ = 'Mark'
import itertools
def power(num, x=1):
result = 1;
for x in range(x):
result = result * num
return result
print power(4,7)
count = 0
for... |
Python Apscheduler - Schedule Jobs dynamically (nested)
Question: We have a requirement to schedule multiple jobs dynamically while current job
is executing.
Approximate Scenario is:
* There should be a scheduler to go through a table of application daily basis (assume at 6 AM UTC).
* Find the users who has toda... |
python split statement for two string expressions
Question: I have to parse a file in which there are some expressions such as:
(COMM_MINFULLCOMTIMEOFCHANNEL == "STD_ON" || COMM_NMLIGHTDURATIONOFCHANNEL == "STD_ON" || COMM_NMLIGHTSILENTDURATIONOFCHANNEL == "STD_ON")
i have parsed the expressions se... |
Eclipse Plugin + Jython - Unhandled event loop exception
Question: Just in case anybody else tries to use Jython inside a self-build eclipse-
plug-in. I suffered 2 days on the following error, which occured as soon as I
try to import my python scripts via `interpreter.exec("from myScript import
*\n");`:
... |
merging loop produces and giving a name
Question:
import numpy as np
A=([ 3.,1.], [1.,4.], [1.,0.], [2., 1.])
for i in A:
y=i*1
print y
This python loop produces four lists as shown:
[3.0, 1.0]
[1.0, 4.0]
[1.0, 0.0]
[2.0, 1.0]
But it should be as shown... |
How to start with linkedIn API?
Question: Being new to API, I am currently trying to use linkedIn information for my
application. For that I'm using [python-
linkedin](https://pypi.python.org/pypi/python-linkedin/4.0) interface for
accessing linkedIn API. I installed this module by using following command:
`pip instal... |
python check output find command not working
Question: I am trying to find the path to a file named 'config.txt' from a usb flash
drive plugged into a raspberry pi. The physical drive that is used may not
always be the same, so the path may not always be the same. So I use
'find /media/pi/*/config.txt'
... |
Find a word in a string python using regex or other methods
Question: I am trying to go through an array of words and check if they exist in a
string. I understand there are many options for doing this such as using
re.search but I need to differ between some words (ie. Java vs Javascript)
An example:
i... |
Saleor Django Apache mod_wsgi will not serve /static/admin/
Question: I am running the saleor django app under a virtualenv with apache as a non-
privileged user.
Actually getting everything going was fairly straightforward, but one bit is
confusing me.
The /static/admin/ portion of the site is not being served.
I h... |
How to trigger something on the close of a loop?
Question: Is this possible? I want to print lines in my file 5 at a time (to send to an
API in a batch). But when I get to the last few lines they never print because
there are less than 5, never triggering my if statement to print. SO I figured
one way to tackle this is... |
Plotting a function in Python 2.7
Question: I am trying to plot f in this program but I am screwing something up. Can
someone have a look and inform me as to where I am messing up. Thanks.
import math
#x is the horizontal distance that the ball has traveled
g=9.81
v=raw_input('Enter an initia... |
"No module named 'osmium._osmium'" error when trying to use PyOsmium
Question: I am trying to use [PyOsmium](https://github.com/osmcode/pyosmium) but it will
not import. `python3 setup.py install` appears to complete just fine but when
I `import osmium` I get the error:
Traceback (most recent call last):... |
SymPy symbolic integration returns error
Question: I am trying to use Sympy's symbolic integration to find a closed form for a
definite integral. In particular, I run
from sympy import *
x, s, H = symbols('x s H', real=True, nonnegative=True)
integrate(1/((1-s)**(1/2-H)*(x-s)**(1/2-H)),(s,0,1))
... |
python - How to get high and low envelope of a signal?
Question: I have quite a noisy data, and I am trying to work out a high and low envelope
to the signal. It is kinda of like this example in MATLAB:
<http://uk.mathworks.com/help/signal/examples/signal-smoothing.html>
in "Extracting Peak Envelope". Is there a simi... |
XMPPPY unable to connect to the server
Question: I am using xmpppy python library to connect with XMPP server(ejabberd2) but
unable to connect and actually don't have clarity on how to connect,
authenticate and send a message to the server.
Please help me to make it working
If possible please provide some code snippe... |
JSON response in Google App Engine with Python
Question: I want to build a REST service with Python and Google App Engine and have the
following code:
Edited Code:
import webapp2
from google.appengine.ext import db
from google.appengine.api import users
import json
class Item(db.Mod... |
Optimize python for Connected Component Labeling Area of Subsets
Question: I have a binary map on which I do Connected Component Labeling and get
something like this for a 64x64 grid - <http://pastebin.com/bauas0NJ>
Now I want to group them by label, so that I can find their area and their
center of mass. This is what... |
How can I turn my python script off from the terminal?
Question: I have just made a script that I want to turn off from the terminal, but
instead of just ending it I want it to pickle a file. Is there a correct way
to do this?
Answer: Have a look at how [signals](https://docs.python.org/2/library/signal.html)
works.
... |
Using NLTK's universalt tagset with non-English corpora
Question: I'm using NLTK (3.0.4-1) in Python 3.4.3+ and I'd like to proccess some of the
tagged corpora using the universal tagset (which I had to install), [as
explained in NLTK book, chapter 5](http://www.nltk.org/book/ch05.html).
I can access any of these corp... |
Python: remove strings with same words
Question: I have a list of strings like this:
string_list = ['this is a string', 'and this', 'also this', 'is this a string']
What I want to do is remove strings that have the same words in them, which in
this case would be 'this is a string' and 'is this a st... |
Raspberry Pi background program runs but doesnt work
Question: SOLVED: For some reason making CRON run a bash script that runs the python
script solved the problem.
I have a python script "temperature.py" which is an infinite loop that checks
values from a GPIO pin, adds the values to a file which it uploads to google... |
Using while loop in Pycharm and Kivy
Question: how can i use while loop in this code to read serial every 2 second and show
it in a Label? this application will hanged in run and i'm new to python to
solve this.
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from time... |
How to parse strings into time ranges in Python?
Question:
time_ranges = ['Sunday-Thursday: 5:00 pm - 8:00 pm', 'Friday - Saturday: 1:00 pm - 2:00 pm']
Is there a simple way to turn the likes of a list of strings shown above into
datetime ranges? Is there a package or library that would make this task easy?
... |
Extract number from a website using beautifulsoup in Python
Question: I am trying to use urllib to grab a html page, then use beautifulsoup to
extract data out. I want to get all the number from comments_42.html and print
out the sum of them, then display the numbers of data. Here is my code, I am
trying to use regex, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.