I have a dataframe with 2 columns: type and value, where some type usually has the same value in every row. In some rows, however, the value missing and we just have NaN. I want to fill in the appropriate value for each row (based on the row’s type). I’ve made a sample dataframe and ..
I am trying to calculate the intersection points of a line and a rectangular prism. The volume of the rectangular prism is represented by 6 planes. s1 = np.array([[-0.25,0,0], [1,0,0]]); s2 = np.array([[0.25,0,0], [1,0,0]]); s3 = np.array([[0,-0.15,0],[0,1,0]]); s4 = np.array([[0,0.15,0],[0,1,0]]); s5 = np.array([[0,0,0],[0,0,1]]); s6 = np.array([[0,0,0.3],[0,0,1]]) surfaces = np.array([s1,s2,s3,s4,s5,s6]) The line is represented by a ..
How do I reshape a numpy array ? The array that I want to reshape is called C4 and currently has a shape of: C4 shape: (606976,) I want to rehsape it to (1,) or I want to reshape an array of shape (1,) to shape (606976,). How do I go about doing this ? ..
my pandas dataframe is not correctly placing items when i append new row to it. i use a function to make it easier to append. also when i append without function it works fine. image code: from emailsender import email_send import pandas as pd import numpy as np try: file = pd.read_csv("customers.csv") except: pass customers ..
I want to run recursive regressions with np.linalg.lstsq and I know it takes each column of X and Y when it performs the regression. However, I want it to ignore the missing values when it runs. If I try to remove the missing values from my array with: for [i,j] in np.argwhere((np.nan(X)) | (np.nan(Y)): np.delete(X, ..
I get this error when I try to import linearmodels: "numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject" I run Anaconda, python 3.8.8 on Windows 10. It is a fresh installation of Anaconda Python on a new machine. I tried to solve this problem by using an ..
I’m trying to search and see if a numpy array is within another for debugging something. #Pattern arr1 = np.array([1.62434536, -0.61175641, -0.52817175]) #type : np.ndarray #dtype : ‘float64’ #shape : (3,) Then I have a list of tuples, where the first element in each tuple is a n by m ndarray Lets say this object ..
I have a DataFrame that contains gas concentrations and the corresponding valve number. This data was taken continuously where we switched the valves back and forth (valves=1 or 2) for a certain amount of time to get 10 cycles for each valve value (20 cycles total). A snippet of the data looks like this (I ..
I am fitting x and y values with a 1D polynomial, using the poly1d numpy function: import numpy as np z = np.polyfit(x, y, 8, rcond=None, full=False, w=None, cov=False) p = np.poly1d(z) What is the best way to export the poly1d object p to a file, so that I can access it later using another ..
Let a = np.arange(1, 4). To get the 2 dimensional multiplication table for a, I do: >>> a * a[:, None] >>> array([[1, 2, 3], [2, 4, 6], [3, 6, 9]]) For 3 dimensions, I can do the following: >>> a * a[:, None] * a[:, None, None] >>> array([[[ 1, 2, 3], [ 2, ..