I wanted to run a rolling 1000 window OLS regression estimation of the dataset for my evaluation found at the following URL:
I tried using the following Python script with pandas version... more
This might sound like a duplicate to many other questions that have already been answered, but I really think that it is not. I'm doing a bunch of operations on pandas dataframes. For example finding max, min and average inside columns and return the... more
Below is an example, where I've used a comparator function that explicitly requires both the items being present (x+y < y+x) to provide a comparison. The question is how do I write the below without using cmp_to_key function, since key takes only ... more
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
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
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
So I'm recreating a Matlab project they made last year, part of which involves creating mask that pull out the RGB bands.
They did this by an array of logical zeroes.
GMask_Whole = false(ROWS,COLS);
which I reconstructed as a numpy array.
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
I'm trying to do the following, given an numpy array 'A', I need to get the maximum element (in absolute value) of each column and also need the row of this element (duplicate values do not matter).
import numpy as np
A = np.array(
[[1, 1, 1],... more
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
I have a vector with a name stim. The length of the vector is
len(stim)=600000. The vector stim has 600000 indices over time. The vector is given below.
array([-111.94824219, -81.80664062, 10.21972656, ..., 9.78515625... more
I am new to python and having trouble with a function. It should delete rows of a (N,10) matrix (imported fron a file) where -1 appears. This is the code
import pandas as pd
import numpy as np
def load(name, f):
file = pd.read_csv(name,header=N... more
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
I have written a small Facebook OAUTH function that I want to use as a module whenever I need to generate a token to post to my FB feed or page. The problem is unless I'm in the directory that fb_auth is in I can't call the module.
Here's my code:
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?
I am trying to access to another variable that inside a function and also that is from another class, so I coded it in that way
self.hello = 'Hello World'
class Helloworl... more
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
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
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
Let's say I have a pandas DataFrame called purity_list as follows:
48 49 50
2 0.1 0.9 0.3
A 0.2 -0.5 -0.6
4 0.3 0.8 0.9
I would like to compare this to another numpy array and get the maximum +v... more
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
I would like to identify column names in a dataframe that partially match a string, and replace them with the original names plus some new elements added to them. The new elements are integers defined by a list. Here is a similar question... more
First of all I want to apologize for the bad title, but it was the best I could do. I tried to take a lot of screenshots to hopefully make this a little bit easier to understand.
So I am working on a chat-bot for discord, and right now on a feature ... more
I'm currently running Red Hat 7.3 and installed Python 3.5 from the SCL (www.softwarecollections.org/en/scls/rhscl/rh-python35/). When I attempt to pip install C intensive packages such as numpy and pandas, the install process on Python 3.5 is taking... more
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
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:
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
I am a bit confused with the definition of class inside a function.
Usually while defining class inside a function, we define it as follows:
What if there is no object at all and the function goes like this:
Note: A similar question already exists, albeit being for C#.
Let's suppose my code looks like the following:
def __init__(sel... more
In the below code, why is the id of parent and child the same? Should they not be different?