Question

When python list better than numpy array

When python list better than numpy array
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python Lists
*************
Python list is nothing but a datatype available in Python which can be written as a list of comma-separated values
between square brackets.

Creating a list is as simple as putting different comma-separated values between square brackets. For example
list1 = [1, 2, 3, 4, 5 ];

Numpy Array
*************
NumPy arrays are a bit like Python lists, but still very much different at the same time.
A numpy array is a grid of values, all of the same type, and is indexed by a tuple of nonnegative integers.


Python list are made for heterogeneous types while numpy.Array works on homogeneous types.
python list better than numpy array while adding and removing elements .

Python loop and access to individual items in a numpy array are slow. Use vectorized operations instead:
import numpy as np
x = np.arange(1000000).cumsum()

Add a comment
Know the answer?
Add Answer to:
When python list better than numpy array
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT