Tag: arrays

62 votes
5 answers
564 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
65 votes
8 answers
415 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
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
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
747 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
47 votes
11 answers
453 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
57 votes
21 answers
1.9K views
How to print the full NumPy array, without truncation?

When I print a numpy array, I get a truncated representation, but I want the full array. Is there any way to

avatar
Cortez
0 1 0 9
asked 07 September, 2021
58 votes
14 answers
2.8K views
Yii model to array?

How can I convert the result of Trips::model()->findAll() to an array?

avatar
Adolfo
0 1 0 9
asked 07 September, 2021
64 votes
14 answers
336 views
How do I concatenate or merge arrays in Swift?

If there are two arrays created in swift like this: var a:[CGFloat] = [1, 2, 3] var b:[CGFloat] = [4, 5, 6]

avatar
Benton
0 1 0 9
asked 07 September, 2021
54 votes
23 answers
2.1K views
How to find index of list item in Swift?

I am trying to find an item index by searching a list. Does anybody know how to do that? I see there is list

avatar
Kisha
0 1 0 9
asked 07 September, 2021
62 votes
17 answers
972 views
How to check if an element is in an array

In Swift, how can I check if an element exists in an array? Xcode does not have any suggestions for contain, i

avatar
Vi
0 1 0 9
asked 07 September, 2021
53 votes
18 answers
2.6K views
Swift how to sort array of custom objects by property value

lets say we have a custom class named imageFile and this class contains two properties. class imageFile {

avatar
Wilber
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
1.9K views
Split a String into an array in Swift?

Say I have a string here: var fullName: String = "First Last" I want to split the string base on white spac

avatar
Sena
0 1 0 9
asked 07 September, 2021
56 votes
16 answers
1.2K views
How to iterate a loop with index and element in Swift

Is there a function that I can use to iterate over an array and have both index and element, like Python'

avatar
Keith
0 1 0 9
asked 07 September, 2021
54 votes
8 answers
412 views
PHP - Merging two arrays into one array (also Remove Duplicates)

Hi I'm Trying to merge two arrays and also want to remove duplicate values from final Array. Here is my

avatar
Keila
0 1 0 9
asked 07 September, 2021
61 votes
6 answers
2.1K views
How are multi-dimensional arrays formatted in memory?

In C, I know I can dynamically allocate a two-dimensional array on the heap using the following code: int** s

avatar
Georgie
0 1 0 9
asked 07 September, 2021
63 votes
4 answers
2.3K views
Why do we use arrays instead of other data structures?

As I was programming, I haven't seen an instance where an array is better for storing information than an

avatar
Roger
0 1 0 9
asked 07 September, 2021
50 votes
30 answers
2.9K views
Array versus linked-list

Why would someone want to use a linked-list over an array? Coding a linked-list is, no doubt, a bit more work

avatar
Chaya
0 1 0 9
asked 07 September, 2021