4 ms·
Scipy Lecture Notes – Learn numerics, science, and data with Python
- Dawny33 10y agoOne doc to learn them all :) The `Optimizing and debugging code` part is where most data scientists falter. So, this is a really nice effort for bringing it all together!
- deleted 10y ago[deleted]
- tsaprailis 10y agoLook like it's covering both Python 2 & 3. Good job.
- goatlover 10y agoIs Python 2 going to be kept alive forever and ever? Is there any other language on the planet that keeps a previous version supported years after a major release came out?
- tomrod 10y agoThis is a great first start. Some resources the author may consider drawing upon, depending on whether and how they choose to expand: [1] http://quant-econ.net/py/index.html http://quant-econ.net/py/index.html [2] http://people.duke.edu/~ccc14/sta-663/ http://people.duke.edu/~ccc14/sta-663/
- Feneric 10y agoThis looks like a great document to help one get started on the road to using Python for lots of STEM type tasks. Pandas fans: don't be put off by the lack of mention of it on the title page, as it is covered in there, too.
- cjf4 10y agoI wish I had this when I was learning the Python data analysis ecosystem. Does a nice job of clearly distinguishing the differences of the major elements.
- KKKKkkkk1 10y agoI hope you don't take this as trolling, but: What's the deal with matrix multiplication in numpy? I wanted to dot-product two vectors yesterday, and I got it right only on the third try: x.T * y # nope x.dot(y) # still no x.inner(y) # ok This is a disaster. I'm sure there are valid historical reasons for this state of affairs, but this makes numpy an environment where random idiosyncrasies get cast in concrete.
- chestervonwinch 10y agoThe first is just a misunderstanding of the `*` operator. I don't believe there is any context for which this would yield anything other than the element-wise product between `x` and `y` (provided these are `ndarray`s). The second, (the matrix product between `x` and `y`) works provided that the dimensions of `x` and `y` make sense to perform matrix multiplication, i.e., `x` is 1xN and `y` is Nx1. While I agree there are some idiosyncrasies, I think it is hyperbole to call it a disaster. I will say that one idiosyncrasy that annoyed me up when moving from octave / matlab, was that NumPy's `zeros` and `ones` functions require the dimensions as a tuple, while others, like `rand` or `randn` take multiple arguments as the dimensions.
- zodiac 10y agoDoes x.T.dot(y) work?
- Derbasti 10y agoBy default, numpy.ndarray multiply element-wise. There is a separate type called numpy.matrix which does matrix math. Alternatively, as of Python 3.5, `a @ b` will do matrix multiplication on NDArrays.
- jofer 10y agoIt's not historical. It's conceptual and deliberate (and far less confusing than the alternative, i.m.o.). What's likely happening is that you're using a 1D array and a 2D array. If they were both actually vectors, `x.dot(y)` would work fine. For example: import numpy as np x = y = np.arange(10) x.dot(y) # Yields 285 However, your problem is likely that one's a vector and one's a 2D array. Matlab doesn't actually have vectors at all, so this distinction confuses a lot of people. A row vector and a column vector are both 2D and aren't actually vectors at all. You can transpose them and swap the dimensions. When you transpose a vector in numpy, you still get a 1D vector. Transposing doesn't change the number of dimensions (To me it would be _incredibly_ confusing if it did...). So, in your case, you probably had something like: import numpy as np x = np.arange(10) y = x[np.newaxis, :] x.dot(y) # Raises a ValueError Note that the opposite (`y.dot(x)`) would have worked fine in this case, as well as `np.inner`. `np.dot` uses the last dimension of the first array (10) and the second-to-last dimension of the other array (1). They don't match. It's that simple. You might have also been trying to take the dot product of two 2D arrays with the same dimension. In that case, the same thing happens. The last dimension of one doesn't match the second-to-last dimension of the other.
- icalc 10y agoGood job