Daily Dose of Data Science

Share this post

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

www.blog.dailydoseofds.com

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

Avi Chawla
Dec 8, 2022
1
Share
Share this post

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

www.blog.dailydoseofds.com

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
Share this post

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

www.blog.dailydoseofds.com
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