Tag: r

53 votes
14 answers
1.8K views
How to pretty-print a numpy.array without scientific notation and with given precision?

I'm curious, whether there is any way to print formatted numpy.arrays, e.g., in a way similar to this: x

avatar
Joseph
0 1 0 9
asked 07 September, 2021
62 votes
5 answers
565 views
What are the differences between numpy arrays and matrices? Which one should I use?

What are the advantages and disadvantages of each? From what I've seen, either one can work as a replace

avatar
Sachiko
0 1 0 9
asked 07 September, 2021
53 votes
10 answers
2.5K views
Pandas conditional creation of a series/dataframe column

I have a dataframe along the lines of the below: Type Set 1 A Z 2 B Z

avatar
Janella
0 1 0 9
asked 07 September, 2021
64 votes
18 answers
813 views
Find nearest value in numpy array

Is there a numpy-thonic way, e.g. function, to find the nearest value in an array? Example: np.find_nearest

avatar
Dario
0 1 0 9
asked 07 September, 2021
69 votes
7 answers
442 views
What is the purpose of meshgrid in Python / NumPy?

Can someone explain to me what is the purpose of meshgrid function in Numpy? I know it creates some kind of gr

avatar
Yolando
0 1 0 9
asked 07 September, 2021
66 votes
3 answers
415 views
Simple Digit Recognition OCR in OpenCV-Python

I am trying to implement a "Digit Recognition OCR" in OpenCV-Python (cv2). It is just for learning purposes. I

avatar
Serina
0 1 0 9
asked 07 September, 2021
65 votes
8 answers
416 views
Numpy array dimensions

I'm currently trying to learn Numpy and Python. Given the following array: import numpy as np a = np.arr

avatar
Fabian
0 1 0 9
asked 07 September, 2021
48 votes
15 answers
435 views
Sorting arrays in NumPy by column

How can I sort an array in NumPy by the nth column? For example, a = array([[9, 2, 3], [4, 5, 6],

avatar
Nidia
0 1 0 9
asked 07 September, 2021
60 votes
10 answers
1.8K views
Pandas read_csv low_memory and dtype options

When calling df = pd.read_csv('somefile.csv') I get: /Users/josh/anaconda/envs/py27/lib/pytho

avatar
Fabian
0 1 0 9
asked 07 September, 2021
55 votes
17 answers
1.5K views
How to find all occurrences of an element in a list

index() will give the first occurrence of an item in a list. Is there a neat trick which returns all indices i

avatar
Shanita
0 1 0 9
asked 07 September, 2021
53 votes
13 answers
929 views
How do I read CSV data into a record array in NumPy?

I wonder if there is a direct way to import the contents of a CSV file into a record array, much in the way th

avatar
Arline
0 1 0 9
asked 07 September, 2021
60 votes
11 answers
1.4K views
Most efficient way to map function over numpy array

What is the most efficient way to map a function over a numpy array? The way I've been doing it in my cur

avatar
Lawanda
0 1 0 9
asked 07 September, 2021
47 votes
30 answers
798 views
How to count the occurrence of certain item in an ndarray?

In Python, I have an ndarray y that is printed as array([0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1]) I'm trying

avatar
Lynette
0 1 0 9
asked 07 September, 2021
65 votes
5 answers
2.6K views
What are the advantages of NumPy over regular Python lists?

What are the advantages of NumPy over regular Python lists? I have approximately 100 financial markets series

avatar
Emilia
0 1 0 9
asked 07 September, 2021
54 votes
17 answers
1.3K views
Is there a NumPy function to return the first index of something in an array?

I know there is a method for a Python list to return the first index of something: >>> l = [1, 2, 3]

avatar
Alba
0 1 0 9
asked 07 September, 2021
68 votes
11 answers
1.3K views
What does -1 mean in numpy reshape?

A numpy matrix can be reshaped into a vector using reshape function with parameter -1. But I don't know w

avatar
Sena
0 1 0 9
asked 07 September, 2021
47 votes
8 answers
1.7K views
How to access the ith column of a NumPy multidimensional array?

Suppose I have: test = numpy.array([[1, 2], [3, 4], [5, 6]]) test[i] gets me ith line of the array (eg [1,

avatar
Nidia
0 1 0 9
asked 07 September, 2021
62 votes
15 answers
748 views
Convert pandas dataframe to NumPy array

I am interested in knowing how to convert a pandas dataframe into a NumPy array. dataframe: import numpy as

avatar
Patsy
0 1 0 9
asked 07 September, 2021
51 votes
20 answers
2.3K views
How do I get indices of N maximum values in a NumPy array?

NumPy proposes a way to get the index of the maximum value of an array via np.argmax. I would like a similar

avatar
Lynette
0 1 0 9
asked 07 September, 2021
47 votes
11 answers
454 views
Dump a NumPy array into a csv file

Is there a way to dump a NumPy array into a CSV file? I have a 2D NumPy array and need to dump it in human-rea

avatar
Joseph
0 1 0 9
asked 07 September, 2021