Using .sub() over a variable length dataframe?

I have a need to calculate the difference between one static column in a dataframe and some variable amount of columns that make up the rest of the dataframe. My data look like this: School District | 01-01-2017 | 01-02-2017 |...| 02-01-2017 | Base...
more »

2017-06-21 21:06 (2) Answers

Python: Unable to call function when in while loop

Just starting out here soz. I've been trying to make a menu with several options (def logged():) by entering a number and it would jump to that function with a purpose. However, I cannot seem to call the designated functions with the if statements pu...
more »

2017-06-21 14:06 (2) Answers

Extract all urls in a string with python3

I am trying to find a clean way to extract all urls in a text string. After an extensive search, i have found many posts suggesting using regular expressions to do the task and they give the regular expressions that suppose to do that. Each of the R...
more »

2017-06-20 07:06 (4) Answers

Python Emailed PDF Arriving with no name

I found and extended a script that will scan a directory and then email the pdfs inside it. The problem occurs when I receive the email. The PDFs are arriving as 'noname' files without an extension. I have to download them and manually add the extens...
more »

2017-06-19 16:06 (1) Answers

(numpy array) Binary to Decimal Python-3.x

I am using python-3.x, and I am trying to convert a list of a numpy array "Binary's" to decimal numbers, as I know I need to convert these Binary's first to Strings then I can convert them to Decimal ex: 1.Binary = 101011111 >>> 2.String= '101011111...
more »

2017-06-18 21:06 (1) Answers

Flask: Find first open port

How can I find the first open HTTP port on my computer, and start a Flask server running on it? I will run the app like this:, host='') ...
more »

2017-06-16 23:06 (1) Answers

Email Recipients Unable to View Attachments

I've been using this code to automate emailing with attachments. But apparently, some of my email recipients are unable to receive the attachments but are able to view the rest of the email message. I've tried sending it to a few of my personal email...
more »

2017-06-16 16:06 (0) Answers

Length of each string in a NumPy array

Is there any builtin operation in NumPy that returns the length of each string in an array? I don't think any of the NumPy string operations does that, is this correct? I can do it with a for loop, but maybe there's something more efficient? impor...
more »

2017-06-16 13:06 (2) Answers

Pyinstaller executable very large

I'd like to create an executable with pyinstaller for my colleagues. My first attempt (on anaconda python 3.6) causes so much crap to get included the executable is over 200mb in size. For a 20 line script that only needs numpy because pandas require...
more »

2017-06-16 09:06 (0) Answers

Installing Python 2.7 and 3.6 Side by Side on Mac

Python newbie here. I just bought a new Mac Book Pro (switched from Windows) and Python 2.7 is already installed on it. I want to install 3.6 side by side and choose between the two versions. I found a great tutorial located here http://joebergantine...
more »

2017-06-16 08:06 (2) Answers

Intersect two boolean arrays for True

Having the numpy arrays a = np.array([ True, False, False, True, False], dtype=bool) b = np.array([False, True, True, True, False], dtype=bool) how can I make the intersection of the two so that only the True values match? I can do something ...
more »

2017-06-16 01:06 (1) Answers

How does numpy's fancy indexing work?

I was doing a little experimentation with 2D lists and numpy arrays. From this, I've raised 3 questions I'm quite curious to know the answer for. First, I initialised a 2D python list. >>> my_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] I th...
more »

2017-06-15 20:06 (3) Answers

Python/Storing lists in class

class Phone: def __init__(self,alankodu,numara): self.alankodu = alankodu self.numara = numara def __str__(self): return str(self.alankodu) + " " + str(self.numara) class Name: def __init__(self,onad,soyad): self.onad = onad ...
more »

2017-06-15 11:06 (0) Answers

Trapezoidal wave in Python

How do I generate a trapezoidal wave in Python? I looked into the modules such as SciPy and NumPy, but in vain. Is there a module such as the scipy.signal.gaussian which returns an array of values representing the Gaussian function wave? I genera...
more »

2017-06-14 10:06 (4) Answers

Sorting array data by common date

I have a .csv file with many rows and 3 columns: Date, Rep, and Sales. I would like to use Python to generate a new array that groups the data by Date and, for the given date, sorts the Reps by Sales. As an example, my input data looks like this: ...
more »

2017-06-12 19:06 (2) Answers

Python date range based on current date

I'm looking to achieve a search of files based on user input on a date. For example, I'm attempting to write the script to ask user for a range in which to search (month to date, last full week, or specific day). last full week needs to go backward...
more »

2017-05-26 20:05 (0) Answers

Calling a method unspecified at built-time

Note: A similar question already exists, albeit being for C#. Let's suppose my code looks like the following: class SomeClass: def __init__(self): pass def do(self): print("a") class SomeOtherClass: def __init__(sel...
more »

2017-05-26 16:05 (1) Answers

Why is the id same for these two objects?

In the below code, why is the id of parent and child the same? Should they not be different? class Parent: def __init__(self): print(id(self)) class Child(Parent): def __init__(self): print(id(self)) super().__init__...
more »

2017-05-26 15:05 (1) Answers