Questions tagged [numpy]

NumPy is one of the fundamental packages used for scientific computing in the Python ecosystem. Specifically, NumPy is used for numerical computing and uses n-dimensional arrays.

What is NumPy?

NumPy is one of the fundamental packages used for scientific computing in the Python ecosystem. Specifically, NumPy is used for numerical computing and uses n-dimensional arrays. Topics include applications in quantum computing, statistical computing, image processing, bioinformatics, geosciences, chemistry, etc. It is also frequently used in machine learning and data visualization. It is open-sourced and distributed under the BDS License.


New to NumPy?

There are various resources including books, tutorials/workshops, etc. for those looking to learn how to use NumPy.

A popular introductory tutorial is:

SciPy 2019 Conference Tutorial:

An list of additional tutorials are listed on the NumPy website:


Tag Usage

When posting questions about numpy, please take the following into consideration:

  • Topics/use cases that involve the use of other packages as well should include all other relevant tags as well to make questions easier to find.

  • Explicit programming related questions are more suitable for Stack Overflow and should not be posted on Stack Exchange Data Science.

  • Questions should include sufficient details and clarity to be able to provide support for the problem at hand. This includes linking/showing underlying data being used, providing code, highlighting relevant outputs/desired outcomes, etc.


External Resources

numpy: Documentation page

numpy: GitHub page


Important links

Books

354 questions
22
votes
2 answers

How to include labels in sns heatmap

I got this matrix 120 100 80 40 20 10 5 0 120 64.21 58.20 51.20 56.37 47.00 45.61 46.86 2.16 100 62.84 57.80 50.60 51.32 39.43 39.30 42.80 0.89 80 62.62 56.20 51.20 51.61 …
Srihari
  • 797
  • 4
  • 12
  • 27
16
votes
3 answers

How to remove outliers using box-plot?

I have data of a metric grouped date wise. I have plotted the data, now, how do I remove the values outside the range of the boxplot (outliers)? All the ['AVG'] data is in a single column, I need it for time series modelling.
Uday T
  • 362
  • 1
  • 5
  • 11
14
votes
1 answer

How to deal with TypeError: ufunc 'isnan' not supported for the input types

I have dealt with all the Nan values in the features dataframe, then why I am still getting this error? sns.heatmap(features, annot=True, annot_kws={"size": 7}) sns.plt.show() TypeError Traceback (most recent…
Jodh Singh
  • 284
  • 1
  • 3
  • 10
11
votes
4 answers

How to replace NaN values for image data?

My data set has a total of 200 columns, where each column corresponds to the same pixel in all of my images. In total, I have 48,500 rows. The labels for the data range from 0-9. The data looks something like this: raw_0 raw_1 raw_2 raw_3 …
9
votes
2 answers

Are there any graph embedding algorithms like this already?

I wrote an algorithm for generating node embeddings based on the graph's topology. Most of the explanation is done in the readme file and the examples. The question is: Am I reinventing the wheel? Does this approach have any practical advantages…
monomonedula
  • 201
  • 1
  • 2
9
votes
1 answer

how to check all values in particular column has same data type or not?

I have column 'ABC' which has 5000 rows. Currently, dtype of column is object. Mostly it has string values but some values dtype is not string, I want to find all those rows and modify those rows. Column is as following: 1 abc 2 def 3 ghi 4 23 5…
Kiran
  • 205
  • 1
  • 2
  • 5
9
votes
2 answers

How to determine input shape in keras?

I am having difficulty finding where my error is while building deep learning models, but I typically have issues when setting the input layer input shape. This is my model: model = Sequential([ Dense(32, activation='relu', input_shape=(1461,…
Josh Zwiebel
  • 193
  • 1
  • 1
  • 6
9
votes
2 answers

Python - Converting 3D numpy array to 2D

I have a 3D matrix like this: array([[[ 0, 1], [ 2, 3]], [[ 4, 5], [ 6, 7]], [[ 8, 9], [10, 11]], [[12, 13], [14, 15]]]) and would like to stack them in a grid format, ending up with: array([[ 0, …
Tarlan Ahad
  • 271
  • 2
  • 5
  • 15
8
votes
2 answers

Fill missing values AND normalise

I have two columns of training data for a neural net which are missing values. (There are many other columns which aren't missing values.) For example Height | Weight 180 | 70 175 | N/A N/A | N/A I want to fill missing values and…
joel
  • 180
  • 1
  • 5
7
votes
4 answers

ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int) in Python

I have written the following code for a neural network to perform regression on a dataset, but I am getting a ValueError. I have looked up to different answers and they suggested to use df = df.values to get a numpy array. I tried it but it still…
Ishan Dutta
  • 293
  • 3
  • 5
  • 14
7
votes
4 answers

Convert Numpy array with 'n' and 'y' into integer array of 0 and 1

I have a NumPy array of strings: 'n', 'y', wanna convert it into integer array of 0, 1, how to convert it? imp = SimpleImputer(missing_values=np.nan, strategy='most_frequent') X = imp.fit_transform(X) X array([['n', 'y', 'n', ..., 'y', 'n', 'y'], …
JL1829
  • 81
  • 1
  • 5
5
votes
2 answers

Normalize matrix in Python numpy

I've an array like this: array([[ 0, 1], [ 2, 3], [ 4, 5], [ 6, 7], [ 8, 9], [10, 11], [12, 13], [14, 15]]) I want to make normalize this array between -1 and 1. I'm currently using…
Tarlan Ahad
  • 271
  • 2
  • 5
  • 15
5
votes
2 answers

Plotting in Multiple Linear Regression in Python 3

So I'm working on linear regression. So far I've managed to plot in linear regression, but currently I'm on Multiple Linear Regression and I couldn't manage to plot it, I can get some results if I enter the values manually, but I couldn't manage to…
hael
  • 51
  • 1
  • 1
  • 3
5
votes
1 answer

Are view() in Pytorch and reshape() in Numpy similar?

Are view() in torch and reshape() in Numpy similar? view() is applied on torch tensors to change their shape and reshape() is a numpy function to change shape of ndarrays.
Kailash Ahirwar
  • 151
  • 1
  • 1
  • 5
5
votes
3 answers

Scatter plot for binary class dataset with two features in python

I have my dataset that has multiple features and based on that the dependent variable is defined to be 0 or 1. I want to get a scatter plot such that all my positive examples are marked with 'o' and negative ones with 'x'. I am using python and here…
Nitish
  • 91
  • 1
  • 1
  • 7
1
2 3
23 24