- Daily Dose of Data Science
- Posts
- Beware of This Unexpected Behaviour of NumPy Methods
Beware of This Unexpected Behaviour of NumPy Methods
...and here's how to counter it.
🍿 Movie Genre Prediction Competition 🍿
Data-Driven Science launched a new competition on Hugging Face: The Movie Genre Prediction Competition 🎥
The objective of this competition is to design a predictive model that accurately classifies movies into their respective genres based on their titles and synopses.

Participants will be provided with a comprehensive dataset comprising ~100,000 movies, and the primary evaluation metric will be accuracy.
The submission deadline is July 31st, 2023.
Let’s get to today’s post now!

If a NumPy array contains NaNs, NumPy's aggregate functions (np.mean, np.min, np.max, etc.) return NaN.
But this may not be desired at times.
One solution is to replace the NaN entries with a default value (0).
However, NumPy also provides nan-insensitive methods, such as np.nansum, np.nanmin, etc.
As a result, the output isn't influenced by the presence of NaNs.
👉 Over to you: What are some other unexpected behaviors of NumPy that you are aware of?
👉 Tell the world what makes this newsletter special for you by leaving a review here :)
👉 If you liked this post, don’t forget to leave a like ❤️. It helps more people discover this newsletter on Substack and tells me that you appreciate reading these daily insights. The button is located towards the bottom of this email.
👉 If you love reading this newsletter, feel free to share it with friends!
👉 Sponsor the Daily Dose of Data Science Newsletter. More info here: Sponsorship details.
Find the code for my tips here: GitHub.
Reply