Category "numpy"

Adding Pandas column in custom function not working when using numpy

I have the following function: def create_col4(df): df['col4'] = df['col1'] + df['col2'] If I apply this function within my jupyter notebook as in create_c

Round number down to the next 1000 in python [duplicate]

can somebody tell me how i can round down to the nearest thousand. So far I tried it with math.round(), the truncate function but i couldn't f

Will Numpy wheels for python 3.10 32 bits be available

First I asked on gitter, though I got help they were not sure, see link Numpy release v1.21.3 states: Note a few oddities about Python 3.10: There are no 32 bi

Error in Jupyter notebook even after importing the required library

I'm getting an NameError in jupyter notebook even after importing numpy as np. Any idea how to go about it will be appreciated %matplotlib inline %config Inline

Reshape of dataset (Time Series) after filtering?

i am using HampelFilter to detect outliers by SKTIME on my dataset but i faced a problem after applied the filter . My dataset contains Timeseries (signals) the

Python: Formatting a Pandas dataframe head with LaTex

I have made a Pandas dataframe from several NumPy arrays and tried to format columns heads using LaTex, but it looks awful. I'm working with Jupyter Notebook. i

Forming a 3D np array from a 2D array

Let's say I have a 2D array: L = np.array([[1,2,3], [4,5,6], [7,8,9]]) I would like to make a 3D array from this, using a parameter

Problem with python while loop going over every element in 2d array

I am having problems with while loops in python right now: while(j < len(firstx)): trainingset[j][0] = firstx[j] trainingset[j][1] = firsty[j] tr

ValueError: operands could not be broadcast together with shapes (120,) (6,)

So this is my python code import numpy as np n = 3 T = 100 ts = .2*(100/(2*n-3))

module 'numpy' has no attribute 'ndarray'

My Jupiter notebook was crushed, so I have to reinstall the notebook, but in the new Jupiter notebook, I cannot run pandas. import pandas as pd AttributeError

Assigning to a double-indexed numpy array

I know that when assigning to a double indexed-array gives bad results because you're assigning to a view rather then to an array directly, but I cannot figure

Crop a polygon shape from an image without libraries except numpy

I have a list of points let's say 5 points. I want to crop the area that this polygon is covering from the image. Here, red areas are the points and I want to c

How to I make a image from numpy array in python?

I want to map each numpy array to a color to create an image. For example: if I have the numpy array: [ [0 0 1 3] [0 2 4 5] [1 2 3 6] ] I want to make an ima

Remove and insert element to a specified indices in Numpy array

Suppose I have a numpy array from which I want to remove a specific element. # data = np.array([ 97 32 98 32 99 32 100 32 101]) # collect indices where th

Reshaping numpy array without changing the data

I'm trying to reshape an array of bitmap images that has a shape of (50,50,90000). How can I modify it so that I can get an array of (90000,50,50)? - I tried ar

Assign multiple columns different values based on conditions in Panda dataframe

I have dataframe where new columns need to be added based on existing column values conditions and I am looking for an efficient way of doing. For Ex: df = pd.D

How to calculate values in Pandas Dataframe itself?

You can see my dataframe below, x values are different value, but other values are same with left values, for example, column 15 and column 16 are same value. I

Any efficient analogue of argsort for array of indices with NumPy?

I have an array of indices like a = [2, 4, 1, 0, 3] and I want to transform it into np.argsort(a) = [3, 2, 0, 4, 1]. The problem is that argsort has O(n*log(n))

What is the best way in numpy to use a vector of positions as indexes in a an nd array?

I have a numpy array of agents positions: positions = np.array([[row_0, col_0], [row_1, col_1], [row_2, col_2]]) I

Calculate the pair-wise correlation between distinct class pairs over two feature columns and the target variable?

Most similar questions relating to calculating this involve a single correlation value for each feature column, showing how the features in a dataset correlate