Anaconda keeps caching modules

How can I prevent Anaconda from caching my module? Every time that I make a change in a specific file in my codebase (for which the containing folder has a __init__.py file), python does not recognize those changes and keeps executing the previous ve...
more »

2017-08-13 23:08 (1) Answers

Calculating Confusion matrices

I am currently calculating multiple confusion matrices and normalizing them. for i in range(0,215) [...] matrix_confusion[i] = np.asarray(confusion_matrix(Y_test, Y_pred)) matrix_confusion[i] = matrix_confusion[i].astype(float) / matrix_confus...
more »

2017-08-13 21:08 (1) Answers

I messed up pip; where did it go?

I had some trouble with the Python pip package manager, so I uninstalled it using sudo pip uninstall pip after which I reinstalled it again: wget https://bootstrap.pypa.io/get-pip.py sudo python get-pip.py It installed without any errors, so I ...
more »

2017-08-13 21:08 (0) Answers

Python Short Url expander

i have a problem with expanding short URLs, since not all i work with use the same redirection: the idea is to expand shortened urls: here a few examples of short url --> Final url. I need a function to get the shorten url and return the expanded ur...
more »

2017-08-13 20:08 (1) Answers

Plotting 3D image form a data in NumPy-array

I have a data file in NumPy array, I would like to view the 3D-image. I am sharing an example, where I can view 2D image of size (100, 100), this is a slice in xy-plane at z = 0. import numpy as np from matplotlib import pyplot as plt from mpl_toolk...
more »

2017-08-13 20:08 (1) Answers

Validate city combination in google geolocation

I want, using Google geolocations, to validate the input that a user may have entered (as it is possible to type something that is wrong). So, given the following parameters, I would like to know if there is a valid combination: political administra...
more »

2017-08-13 20:08 (0) Answers

numpy array with the second dimension empty

Although I have seen some answers for this question, I was wondering if there's any better way to solve this problem. For example, N = 15 A = np.repeat(1/N, N) if I do this the result will have shape (15, ) If I want the shape to be (15,1), I t...
more »

2017-08-13 19:08 (1) Answers

Namespaces inside class in Python3

I am new to Python and I wonder if there is any way to aggregate methods into 'subspaces'. I mean something similar to this syntax: smth = Something() smth.subspace.do_smth() smth.another_subspace.do_smth_else() I am writing an API wrapper and I'm...
more »

2017-08-13 19:08 (1) Answers

Open a folder in explorer if not opened yet

I know how to open a folder in explorer with python via : subprocess.Popen(r'explorer /select,"C:\path\of\folder"') But I don't know how to prevent my program from opening the folder if it is already "opened" in explorer. Is there a way to do this ...
more »

2017-08-13 18:08 (3) Answers

Pygame class keeps resetting self.variable

so i, trying to make my sprite move, however rather than move it will quikcly move then reset back to its original position, ive tried retutning values, update and eveything. the print self.y's were their to see if i had done the logic correcly and y...
more »

2017-08-13 16:08 (0) Answers

Python OOP program printing "None" for no reason?

I am learning Object Orientated Python and decided to make a program that generates a random grade for you and prints out a praise or a reassurance message depending on the grade you receive. The program works but for some reason, after the message i...
more »

2017-08-13 12:08 (0) Answers

vector representation matlab vs numpy

I have to switch between MATLAB and NumPy (Python 3.x) . What always causes problems for me, is the way vectors are used in NumPy. In MATLAB a vector is more or less nothing else than a 1xn or nx1 matrix. To provide an example: b=np.array([0,2]) ...
more »

2017-08-13 09:08 (1) Answers

Remove duplicates using pandas & Python

I want to remove duplicates based on my first column, Lets assume this to be 'id'. the value that I need to be removed is the records with the least complete data. For example I have 4 records shown in the screenshot below and I want to remove d...
more »

2017-08-12 23:08 (2) Answers

Holiday Calendar in pandas DataFrame

I created a Holiday calendar for Germany (not all days included) as followed: from pandas.tseries.holiday import Holiday,AbstractHolidayCalendar class GermanHolidays(AbstractHolidayCalendar): rules = [Holiday('New Years Day', month=1, day=1), ...
more »

2017-08-12 22:08 (2) Answers

Rounding errors with PIL

I am having trouble writing to an image with my Mandelbrot program; it is to do with rounding errors with "(maxx-minx)/width" compared to "(maxy-miny)/width" line 31, which leads to a 501 by 500 picture rather than a 500 square picture. ((width+1) *...
more »

2017-08-12 20:08 (1) Answers

Interrupting a timer with spacebar

Say I want to time how long I can hold my breath, and I want to do that with Python. I have short script: start = time() try: while True: pass except KeyboardInterrupt: print(time() - start) This has the basic functionality I want, but it...
more »

2017-08-12 19:08 (3) Answers

Pandas read csv is shifting columns

I'm trying to create a dataframe of a csv file that has 4 empty columns. When I open it on LibreOffice or Excel it correctly identifies the empty columns. However, opening with DataFrame.read_csv() end up shifting the columns' values by one. How ca...
more »

2017-08-12 18:08 (1) Answers

convert set to numpy 0-1 array?

I am currently using this method to convert a set of integers (the variable words) to a numpy array: wordMask = np.asarray( [ int(x not in words) for x in xrange(0,nwords) ] ).reshape(nwords,1) Here nwords can be as large as 10000. Instead ...
more »

2017-08-12 18:08 (2) Answers

No password set. django save user without form

Sorry for my english. Now i learning django rest, and i not clearly understand how save user. For example: i want you send json to server and server save new user {"username": "bob", "password":"123321"} in views i writed method for save user @csr...
more »

2017-08-12 17:08 (1) Answers