Tagged Questions
Python is a dynamic and strongly typed programming language designed to emphasize usability. Two similar but 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 python tag.
0
votes
0answers
6 views
Convert iteration to map
I've got the following code:
@classmethod
def load(self):
with open('yaml/instruments.yaml', 'r') as ymlfile:
return {v['name']: Instrument(**v) for (v) in list(yaml.load_all(ymlfile))}
...
-4
votes
0answers
15 views
Using split function with two delimiters
I have a string [0.4, 0.39, 0.4, 0.4, 0.4, 0.41] How do I convert this into a list of just numbers?
0
votes
0answers
8 views
how to convert a string representation of an ip to the string representation of a int32 in python
I am creating a database of usernames and iPs using sqlite. I want to be able to write the iPs as int32's not string for more efficient storage.
import sqlite3 as sql
database = sql.connect("ips")
...
0
votes
0answers
11 views
Python Overflow Error: iter index too large
I have a problem with big iterator in for loop in the code below:
def float_generator(tekstowe):
x = ''
for c in tekstowe:
if c != ' ':
x += c
...
0
votes
0answers
2 views
Matplotlib is ignoring the given colourmap
This is my plot:
This is supposed to be a surface plot. As you can see that has somewhat failed. Particularly it is ignoring passed colour map.
It gets called as so:
from mpl_toolkits.mplot3d ...
0
votes
0answers
3 views
VMWare pyvmomi 6.0.0 : Operation not supported
I am using VMWare's pyvmomi to manage my ESXI's virtual machines
I'm using :
pyvmomi-6.0.0 with python 2.7.5 to clone a VM on
VMWare ESXi 6.0.0 Update 1 which is managed by
vCenter Server 6
...
1
vote
2answers
12 views
Install Python 3.5.2, but pip for Python 2.6
VPS-server was a version Python 2.6, I installed version Python 3.5.2.
When I try to install some packages with help pip, I got errors.
During installation packages:
DEPRECATION: Python 2.6 is no ...
0
votes
0answers
11 views
Numpy in1D multiple evaluation statements
I'm trying to use numpy as opposed to use nested for loops and trying to find if a value is within a particular tolerance.
The code in python using the nested loops works fine and I do get the ...
0
votes
0answers
5 views
spark-submit.sh can not find --files
I am running a spark service on IBM Bluemix using the spark-submit.sh. I am uploading several python pickles to the service using the --files parameter of the shell script.
The files are correctly ...
0
votes
0answers
6 views
Multiple Mixins and properties
I am trying to create a mixin class that has it's own properties, but as the class has no init to initialize the "hidden" variable behind the property.
class Software:
__metaclass__ = ABCMeta
...
0
votes
0answers
33 views
I can print a local variable but not return it (python 2.7)
I am having a problem with a for loop seemingly being unable to retain variables when trying to return these variables, even though I can print the variables.
If I define the function as follows, when ...
0
votes
0answers
3 views
Use Fake Media Stream With Appium
I am actually trying to automate tests between a website and an Android application for an Internship.
The concept is like Skype, both of them use the camera and the microphone. So to automate my ...
0
votes
1answer
18 views
TypeError: expected string or bytes-like object pandas variable
I have dataset like this
import pandas as pd
df = pd.DataFrame({'word': ['abs e learning ', 'abs e-learning', 'abs e&learning', 'abs elearning']})
I want to get
word
0 abs elearning
...
-1
votes
3answers
18 views
Python - merge repeating characters (ins sequence) in string? [duplicate]
When I have specific character that repeats more than once in a sequence, I want to merge it, so there won't be same adjacent characters.
For example:
s = 'aa.bc.a.d.aaa.z'
# after merging repeating ...
0
votes
0answers
17 views
store complex dictionary in pandas dataframe
This question follows my previous one.it's a mother dictionary of the one before
store dictionary in pandas dataframe
I have a dictionary
dictionary_example={'New York':{1234:{'choice':0,'city':'...
0
votes
1answer
9 views
Allow only one flask request for a particular route
I have a flask app which uses angularjs front end. I make the http request through $http service. As shown in the code below.
$http.post('/updateGraph', $scope.graphingParameters).success(function(...
-1
votes
0answers
26 views
You have 3 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth
I've just created Django project and ran server.
It works fine but showed me warnings like
You have 14 unapplied migration(s)...
Then I ran
python manage.py migrate
in the terminal. It worked ...
0
votes
1answer
7 views
Tensorflow - shape error when reading data from file
I am trying to train a single layer perceptron (basing my code on this) on the following data file in tensor flow:
1,1,0.05,-1.05
1,1,0.1,-1.1
....
where the last column is the label (function of 3 ...
-1
votes
4answers
24 views
Adding the header to a csv file
I have a csv file with the dimensions 100*512 , I want to process it further in spark. The problem with the file is that it doesn't contain header i.e column names . I need these column names for ...
0
votes
0answers
7 views
Cannot set Allow quoted newlines property in bigquery using python?
I cannot able to enable property "Allow quoted newlines" in google bigquery load job.
configuration = {
'load': {
'createDisposition': create_disposition,
'...
0
votes
0answers
13 views
python: package doesn't install correctly, setup.py and __init__.py
I have written the beginnings of a package that I would like to distribute, but I am having issues. When I place the sample_test.py in the primary directory, the script runs just fine. When I ...
1
vote
1answer
37 views
Convert date from yyyymmddHHMMSS format
I would like to read two columns (columns 0, 4) of the following ascii file and plot them. One contains the date in yyymmddHHMMSS format which I would like to covert to a date number.
# Date ...
-2
votes
0answers
7 views
Intersection between plt.contour and a shapely Line with Python sahpely is very slow
This is a function that return the coordinates X and Y of the intersection points between a plt.contour and a shapely line. It works but is very very slowly. How can it work faster?
def ...
-4
votes
2answers
28 views
list search obj with index number
stations = ['Schagen', 'Heerhugowaard', 'Alkmaar', 'Castricum', 'Zaandam', 'Amsterdam Sloterdijk', 'Amsterdam Centraal', 'Amsterdam Amstel', 'Utrecht Centraal', '’s-Hertogenbosch', 'Eindhoven', 'Weert'...
0
votes
1answer
7 views
Accessing ReferenceProperty values in a one to many relation from a referenced key in Appengine?
I am using AppEngine in Python and I have two Models using ndb :
# Post model
class WikiPost(ndb.Model) :
url = ndb.StringProperty(required = True)
content = ndb.TextProperty(required = ...
1
vote
1answer
35 views
Easiest way to parallelise a call to map?
Hey I have some code in Python which is basically a World Object with Player objects. At one point the Players all get the state of the world and need to return an action. The calculations the players ...
-5
votes
0answers
39 views
How to detect type of files which dont have any extension in python
I need to run a code for all the json files in a folder,but the files doesnt not have '.json' extension?
0
votes
0answers
12 views
Python/MYSQLdb memory issues
I am running a script that is writing to a mysql database in the rough form of:
import MYSQLdb
import pandas as pd
def mysql_function():
db = MySQLdb.connect(host=something, user=something, ...
1
vote
1answer
9 views
Match Current date with CSV file and print the matches
hi so im writing a python script to send a birthday mail kind of thing . But im stuck in middle . i Have a csv file containing names and there birthdays and already wrote a code to get the current ...
-2
votes
3answers
30 views
Python - Convert string with numbers into a list of integers [duplicate]
I've read several questions about this on SO, however, none of them worked out for me - I guess I'm doing something wrong.
I have a string with numbers separated with commas and spaces which looks ...
0
votes
0answers
21 views
Figure out if called from function without main guard
If a module is imported from a script without a main guard (if __name__ == '__main__':), doing any kind of parallelism in some function in the module will result in an infinite loop on Windows. Each ...
0
votes
0answers
5 views
TensorFlow freeze_graph.py: The name 'save/Const:0' refers to a Tensor which does not exist
I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the freeze_graph.py script.
I exported my model ...
0
votes
0answers
4 views
ttk label doesn't behave properly
A ttk Label which contains a bitmap image doesn't behave properly when I change the image's foreground color. Only ttk Labels have this problem. Tkinter labels works properly.
Here is the code:
...
-2
votes
3answers
42 views
Memory allocation in python
I create a list with three elements named l after that I copy all the content of the list into the list y. But when I print the address of them in the memory I don't understand why this is not the ...
0
votes
1answer
7 views
Assign group name to kivy graphic instruction
This seems like it should be really simple, yet I have failed to find a way to do it.
In order to iterate over the instructions on my canvas, I am supposed to use canvas.get_group() method. In order ...
-1
votes
0answers
14 views
graph data structure with x,y and find intersection python
I have data from SVG file. ( set of x,y from element like path,rectpolygon,polyline and set of center,radius from element like circle,ellipse )
I want to store them together ,find ALL intersection ...
2
votes
1answer
27 views
Program hang with asyncio
Here is my code:
import asyncio, socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('', 1234))
sock.setblocking(False)
queue = asyncio.Queue()
def sock_reader():
print(...
1
vote
3answers
33 views
rolling mean with increasing window
I have a range
np.arange(1,11) # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
and for each element, i, in my range I want to compute the average from element i=0 to my current element. the result would be ...
0
votes
0answers
14 views
Spark performance issue (likely caused by “basic” mistakes)
I'm relatively new to Apache Spark (version 1.6), and I feel I hit a wall: I looked through most of the Spark-related question on SE, but I found nothing that helped me so far. I believe I am doing ...
0
votes
1answer
12 views
Crop overlapping images with pillow
I need help, please.
I'm trying to select and crop the overlapping area of two images with the Python Pillow library.
I have the upper-left pixel coordinate of the two pictures. With these, I can ...
-1
votes
0answers
16 views
Design options to loop by month between 2 dates and refer to those values with foreign key?
I have 2 dates of beginning and end of rent and I have to collect rent for each month.What is the best way to do it if I want to refer to each of those values as to foreign key , since if you paid ...
0
votes
1answer
22 views
How to compare two different pandas dataframe whose lengths are not equal?
I'm having two dataframes i.e. df1 and df2
df1: df2:
Column1 Column2 ColumnA ColumnB
0 abc a 0 stu aaa
1 pqr b ...
0
votes
0answers
11 views
Is it possible to use pango markup text on a Gtk+ 3 toolbutton label using Glade and PyDev?
I have put together a Gtk+ interface in Glade and part of the UI is a tool palette with several toolbuttons using utf-8 characters as labels. They work fine in the default font, but I would like to ...
-4
votes
1answer
13 views
How can I redirect the output to be put into a file in python (version 3.3.3)?
sentence = "ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ASK WHAT YOU CAN DO FOR YOUR COUNTRY"
s = sentence.split()
another = [0]
print(sentence)
for count, i in enumerate(s):
if s.count(i) < 2:
...
1
vote
0answers
10 views
Numba TypeError: 'output_dir' must be a string or None
I'm trying to work out how to use the Compiling code ahead of time feature of Numba (version 0.28.1+0.gfe99fbc.dirty on Python 2.7.12 |Anaconda custom (64-bit) ). I try to run the example code from ...
1
vote
1answer
14 views
Passing Series with dtype= 'category' as categories for Pandas Categorical function
when I run this code I get the following error :
import pandas as pd
car_colors = pd.Series(['Blue', 'Red', 'Green'],
dtype='category')
car_data = pd.Categorical(['Yellow', 'Green', 'Red'...
0
votes
1answer
28 views
How to change variable of main class from inherited class?
I need to change object variable directly from inherited class.
Here is my code example:
class A(object):
def __init__(self,initVal=0):
self.myVal = initVal
def worker(self):
...
0
votes
2answers
40 views
How to convert a list of strings into a list of integers
In the below part of code v is a list of characters.
import collections
import csv
import sys
with open("prom output.csv","r") as f:
cr = csv.reader(f,delimiter=",")
d=collections....
1
vote
1answer
12 views
tkinter “Class” has no attribute “button” even though is set in an instance
I'm trying run example from this tutorial and getting an error:
self.startBtn.config(state=tk.DISABLED) AttributeError: 'Example' object has no attribute 'startBtn'
I rewrite my code for simplicity ...
0
votes
0answers
16 views
How to solve the error like “IndexError : too many indices for array”
from __future__ import print_function
import os
import sys
import timeit
import numpy
import theano
import theano.tensor as T
import cv2
import numpy as np
from theano.tensor.signal import ...