Daily Dose of Data Science

Share this post

Don't Print NumPy Arrays! Use Lovely-NumPy Instead.

www.blog.dailydoseofds.com

Discover more from Daily Dose of Data Science

High-quality insights on Data Science and Python, along with best practices — shared daily. Get a free 550+ page data science PDF guide and 450+ practice questions notebook.
Over 50,000 subscribers
Continue reading
Sign in

Don't Print NumPy Arrays! Use Lovely-NumPy Instead.

Avi Chawla
Dec 8, 2022
1
Share this post

Don't Print NumPy Arrays! Use Lovely-NumPy Instead.

www.blog.dailydoseofds.com
Share

We often print raw numpy arrays during debugging. But this approach is not very useful. This is because printing does not convey much information about the data it holds, especially when the array is large.

Instead, use 𝐥𝐨𝐯𝐞𝐥𝐲-𝐧𝐮𝐦𝐩𝐲. Rather than viewing raw arrays, it prints a summary of the array. This includes its shape, distribution, mean, standard deviation, etc.

It also shows if the numpy array has NaNs and Inf values, whether it is filled with zeros, and many more.

P.S. If you work with tensors, then you can use 𝐥𝐨𝐯𝐞𝐥𝐲-𝐭𝐞𝐧𝐬𝐨𝐫𝐬.

Read more: Documentation.

Share this post on LinkedIn: Post Link.

Thanks for reading Daily Dose of Data Science! Subscribe for free to receive new posts and support my work.


The code snippets for the posts I have shared here are available on GitHub. Check out this repository: GitHub.

I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn.

1
Share this post

Don't Print NumPy Arrays! Use Lovely-NumPy Instead.

www.blog.dailydoseofds.com
Share
Previous
Next
Comments
Top
New
Community

No posts

Ready for more?

© 2023 Avi Chawla
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing