Live data from Hacker News

NumPy Exercises for Data Analysis in Python

machinelearningplus.com

1–10 of 34 posts

NumPy Exercises for Data Analysis in Python

#1
I compiled a list of numpy practice exercises related to data analysis. Might be helpful if you want to practice some data munging problems. Feedback welcome!

https://www.machinelearningplus.com/101-numpy-exercises-python/

NumPy Exercises for Data Analysis in Python
machinelearningplus.com

Re: NumPy Exercises for Data Analysis in Python

#4
post #3

This is very similar in spirit to https://github.com/rougier/numpy-100/blob/master/100%20Numpy... . In fact, now that I look at it a bit more, it seems like all of this post's examples are reworded versions of Nicolas Rougier's "numpy 100"...

Look a little bit more, please.

Re: NumPy Exercises for Data Analysis in Python

#5
post #4
post #3

This is very similar in spirit to https://github.com/rougier/numpy-100/blob/master/100%20Numpy... . In fact, now that I look at it a bit more, it seems like all of this post's examples are reworded versions of Nicolas Rougier's "numpy 100"...

Look a little bit more, please.

You're right. There's a fair number of original examples there as well. Still, there's a lot of overlap.

Re: NumPy Exercises for Data Analysis in Python

#6
post #5
post #4

Earlier quoted context omitted.

Look a little bit more, please.

You're right. There's a fair number of original examples there as well. Still, there's a lot of overlap.

Well, that's bound to happen when framing questions on the same topic.

Re: NumPy Exercises for Data Analysis in Python

#7
There are some nice exercises here, good work.

For question 48 it might be simpler to just write

  np.sort(a)[-5:]
instead of using argsort() and then using fancy indexing. Better yet, use

  np.partition(a, kth=-5)[-5:]
which scales linearly with the size of the array.

Also, the one-hot encoding puzzle (51) would be more efficiently solved using

  (arr[:, None] == np.unique(arr)).view(np.int8)
In general, `for` loops over NumPy arrays should be avoided where at all possible.

Re: NumPy Exercises for Data Analysis in Python

#9
post #8

Does anyone know of any similar resources for Pandas? I've found the following to be quite helpful but would love to know if anyone knows of other resources in a similar vein: https://pandas.pydata.org/pandas-docs/stable/cookbook.html

I started writing a '100-pandas-puzzles' set of exercises here: https://github.com/ajcr/100-pandas-puzzles

There's also pandas_exercises by Guilherme Samora (https://github.com/guipsamora/pandas_exercises) which is very good - it's split across multiple notebooks and is more extensive than my repo.

Post reply on HN