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.

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

0
votes
0answers
4 views

PyGame Install Issues

I've been trying to install pygame but I'm completely confused. I'm running OSX El Capitan 10.11.3. I don't know much about how python is installed or runs when programming, I've just used whatever my ...
0
votes
0answers
4 views

python + sqlite failing to insert on violating unique constraint

ok I have a large body of text and I am trying to count all the words in it to get their frequencies. It is too big to keep a dictionary in memory so I am using sqlite for this task. I wrote a ...
0
votes
0answers
3 views

ValueError: X has a different shape than during fitting when try to use random forest to do a feature selection

I tried to change the categorical variables to bin mode and then use a random forest to do a feature selection. cat_train = df[feature_selected] cat_test = df_test[feature_selected] ...
0
votes
0answers
8 views

Is it possible to use multiple assignment in python to transpose a multidimensional list?

In order to avoid creating a new list of equal dimension, I'm wondering if multiple assignment could allow for an easy transpose function that modifies an exiting array. This function is meant to act ...
0
votes
0answers
12 views

Best practice to implement multiple contructors in python

I'm pretty sure this has been asked many times but I'm still not sure how to implement the multiple constructors in Python. I know that in python, I can only have one constructor unlike in java or C# ...
0
votes
0answers
3 views

How to store field of module tuples in Django model?

Is it possible to store field of tuples of Model in Django? In my case, I have a model Translator. The translator should store information about what languages he can translate. But there may be ...
0
votes
0answers
3 views

Django query that excludes results if id from one table is in another

I am trying to create a Django query where the result is all entries from the Item table where there is not entry for the table item in the Seen table for a given user. My Django models look like ...
0
votes
0answers
6 views

Number of connected components of k-nearest-neighbours using KDTree

Is there an elegant way finding the number of connected components using a pre-calculated KDTree? At the moment I am using the KDTree from scikit-learn and I find the connected components using a ...
0
votes
0answers
3 views

How to query documents in mongodb (pymongo) where all keywords exist in a field?

I have a list of keywords: keywords = ['word1', 'word2', 'word3'] For now I query for only 1 keyword like this: collection.find({'documenttextfield': {'$regex': ' '+keyword+' '}}) I'm in no way ...
2
votes
1answer
5 views

Python subprocess can't find the output of csv writer

I'm ripping some data from Mongo, sanitizing it via Python, and writing it to text file to import to Vertica. Vertica can't parse the python-written gzip (no idea why), so I'm trying to write the data ...
-5
votes
0answers
20 views

Python or PHP for online movie website? [on hold]

Python or PHP for online foreigner movie with active subtitles website (if you hover mouse on word it will be translated) ? Addition: I'm just starting learning programming. No experience at all.
0
votes
1answer
5 views

Having python script save captured video with date and time

I'm trying to have my raspberry pi capture short videos and save them to a file with date and time. I have a short Python script that will capture video but it seems to overwrite the file with the ...
0
votes
0answers
3 views

Find edges of multiplicity larger than 2 in a NetworkX MultiGraph

I have a MultiGraph which can have multiple edges between any two nodes: g = MultiGraph() g.add_nodes_from([1,2,3,4,5,6]) g.add_edges_from([(1,2), (2,1), (1,2), (3,4), (5,6), (6,5), (3,5), (3, 5), ...
0
votes
0answers
18 views

string generation program

following program does a construction of URL from available sample list using itertools package in python with various combinations def url_construct_function(): for i in range(1, ...
0
votes
0answers
3 views

How to change an array to SFrame for GraphLab ItemSimilarityRecommend

I have written my custom pairwise similarity function in python which given a matrix of features X (contains rows of features), find and returns the output as k nearest neighbor to each item given a ...
1
vote
1answer
8 views

Tilemap error pygame

I know questions on subjects like this have been posted before but I have an error I have not seen in any other questions. I am trying to make a tiled background from a 2d array, but when I run it I ...
0
votes
0answers
6 views

PyBluez can't discover a connected device

I have my phone paired with my notebook (Ubuntu 15.04), when I run discover_devices() from PyBluez I can see the phone. But when I connect the phone over bluetooth, then it disappears from the list. ...
0
votes
0answers
29 views

Add rows in array with nested loop

I am new to coding and trying to write a program to calculate sample size, n, in A/B testing. I am stuck in the nested loop in main function below. I want to create an array, n_dist_all, with 3 ...
0
votes
0answers
7 views

Indexing data In Django With Haystack

I have haystack and elasticsearch in my django project. When I have setup the indexes the way the docs say to do. When I add new items to the database the terminal outputs this, PUT ...
0
votes
0answers
9 views

How can i change django admin to rtl style

First of all i'm new to django . and i'm amazing from this cool framework (not in database part and mysql connector) And When i looking to django admin style folder in css folder , i see rtl css , ...
0
votes
0answers
10 views

How do I read ftp data into pandas?

I am looking for help parsing data from the fbo.gov ftp site. The link below is an example a daily data feed: ftp://ftp.fbo.gov/FBOFeed20091012 Is there an easy way to parse this data into a pandas ...
0
votes
0answers
4 views

VISA LAN communication error (VI_ERROR_TMO -1073807339)

In my python code, I am able to send write commands to the PNA over LAN, but whenever I try to send queries to the PNA over LAN, I get error shown in the attachment. I should add that both writes and ...
0
votes
1answer
12 views

ImportError: No module named redis_cache

I am using Django=1.5.4 and I have installed redis properly in ubuntu. I installed django-redis. But I get this error. I put 'redis_cache' in my django settings. But I got this error ImportError: No ...
-1
votes
3answers
23 views

In Python, how can I access an instance created in main module from other module?

I didn't know much about OOP and Python... Here's a example about my questions: I have a class object in my main module # main.py #--------- class myRobot(): def __init__(self): ...
0
votes
0answers
6 views

connect to my sql database via python

i'm trying to insert values in mysql database using python on windows 10. I've downloaded mysql-connector-python-2.0.4-py2.7 . This is my python code : import MySQLdb conn = MySQLdb.connect(host= ...
0
votes
0answers
7 views

Input needs to be in quotes to not get definition error? [duplicate]

I created this program to remove vowels from a word. def vowel_remover(s): vowels = "aeiouAEIOU" newword = "" for i in s: if i not in vowels: newword += i return ...
0
votes
0answers
9 views

Calculating median using Hadoop streaming and Python

I've read through various variants of this question and their associated answers, but having no luck gaining a sense of how to address my particular problem. I believe an answer to this would also be ...
0
votes
1answer
11 views

Validating US phone number in wtfforms

I'm working with a flask app and am using wtforms: class RegisterForm(Form): username = StringField('Username', validators=[DataRequired(), Length(min=3, max=25)]) email = ...
0
votes
0answers
7 views

Update Python 2 and 3 with Conda

I am running Ubuntu and have installed Anaconda2 and Anaconda3 (before I knew about environments). I'd like to update both versions using, say: conda update anaconda # or conda update --all ...
0
votes
2answers
23 views

How do I find the sum of prime numbers in a given range in Python 3.5?

I managed to create a list of prime numbers in a given range using this: import numpy as np num = int(input("Enter a number: ")) for a in range(2,num+1): maxInt=int(np.sqrt(a)) + 1 ...
0
votes
2answers
18 views

Django First Tutorial: ImportError: No module named 'polls'

I've set up Django on my Windows 10 PC, and was working through the first tutorial: https://docs.djangoproject.com/en/1.9/intro/tutorial01/ I can't seem to do the first part, because of an import ...
0
votes
0answers
5 views

Get more than 50 members of a group from Soundcloud

I'm trying to get all the members of a SoundCloud group using the Python API. So far I can get the first 50 but providing the mentioned "linked_partitioning=1" argument doesn't seem to be move on to ...
-1
votes
1answer
13 views

Why isnt this code deleting the old file?

I am trying to create a programme that records the score and name of each user from a text file and only keeps the last three. This is what I have so far: if userclass=="1": filefordataclass1 = ...
0
votes
0answers
5 views

Inserting Bold Text into a Folium / Leaflet Marker Popup

I'm trying to insert a bold text into a Folium marker popup. I'm using Folium version 0.2.0. If my code looks like this: html="add <b>popup</b> here" poppin = folium.Popup(html=html) ...
0
votes
2answers
21 views

Chi square and t test error in python

I need to process some data and have written these short python scripts. However when I attempt to run them i receive this error: SyntaxError: can't assign to operator. Here is the code for both the ...
0
votes
0answers
7 views

How can I plot the trajectory of many particles in a molecular dynamics simulation?

I have a simulation that tracks initial position and velocity of N many particles over time. I would like a 3D plot of initial position for each particle and the path it travels. Right now I'm using ...
0
votes
1answer
6 views

Pyspark - Aggregation on mutiple columns

I have data like below. Filename:babynames.csv. year name percent sex 1880 John 0.081541 boy 1880 William 0.080511 boy 1880 James 0.050057 boy I need to sort the ...
8
votes
4answers
125 views

Return self in python

I have a class that represents object. And I have a bunch of methods which modify this object state with no obvious return or obviously without any return. In C# I would declare all these methods as ...
0
votes
1answer
12 views

limit() and sort() order pymongo and mongodb

Despite reading peoples answers stating that the sort is done first, evidence shows something different that the limit is done before the sort. Is there a way to force sort always first? views = ...
0
votes
0answers
4 views

How to auto categorize incoming data of a website?

I'm building an ecommerce site which is full of advertisements scraped from all over local websites. This process is automated and will occur every 24 hours. Since this is automated, I want the ...
0
votes
0answers
5 views

boost python won't auto-convert char* data members

I'm trying to wrap a C++ api and I'm hitting a roadblock on some char* class members. It seems that boost-python will auto convert char const * and std::string types into python objects (based on this ...
0
votes
0answers
23 views

determine prime numbers in a range in python

I am writing code for prime generator on spoj with below example On local machine the answer comes correctly. while on spoj its telling wrong answer. import math # to find if any factor till sqrt ...
0
votes
0answers
12 views

Login extended User model

I have an extended User model and can register new users to it, but can't log them in. I get this error when the POST data is sent: IntegrityError at /login UNIQUE constraint failed: ...
0
votes
1answer
8 views

Subclassing of QPushButton

I've been looking for a way of subclassing QPushButton, so I can connect 'clicked' signal when constructing new button, like: Btn = CustomButtonClass('Text', clicked='lambda: self.func(par)') So ...
1
vote
0answers
5 views

HowTo Edit two videos using alternate timestamps in a list and mute audio ?

The goal is to create a 1 minute video with the background audio(The actual audio of the video will be muted) of the given mp3 file. Also in the end of the output video we need to concatenate the logo ...
-2
votes
1answer
14 views

what does this line do flask.g.auth.logged_in?

I was going through this piece of code:- def decorated_function(*args, **kwargs): """ Decorated function, actually does the work. """ if not flask.g.auth.logged_in: flask.flash('Login ...
1
vote
0answers
14 views

How to fill an area within a polygon in Python using matplotlib?

Here is a code I tried: from scipy.spatial import ConvexHull points = np.random.rand(30, 2) # 30 random points in 2-D hull = ConvexHull(points) import matplotlib.pyplot as plt %matplotlib inline ...
0
votes
0answers
4 views

Remove all padding from Bokeh Plot

How can I remove all whitespace surrounding a Bokeh plot? I use the Bokeh plotting interface to produce the following image with progressbars for my project: From various other stack overflow ...
1
vote
2answers
58 views

Short if statement usage

In python i can do following: return x or y or my_function(x or y) if x != null or not empty will return or pass x else y. My question: There is way do this in java shorten then return x == ...
0
votes
0answers
4 views

Visualizing transformed data with Python with 2 components

This is the samplefile I am trying to analyze by first running PCA: A01_01 A01_02 A01_03 A01_04 A01_05 A01_06 A01_07 A01_08 A01_09 A01_10 A01_11 A01_12 A01_13 A01_14 A01_15 A01_16 ...