Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Data Analysis with NumPy and Pandas

You're reading from  Hands-On Data Analysis with NumPy and Pandas

Product type Book
Published in Jun 2018
Publisher Packt
ISBN-13 9781789530797
Pages 168 pages
Edition 1st Edition
Languages
Author (1):
Curtis Miller Curtis Miller
Profile icon Curtis Miller
Toc

Special numeric values


In addition to dtype objects, NumPy introduces special numeric values: nan and inf. These can arise in mathematical computations. Not A Number (nan). It indicates that a value that should be numeric is, in fact, not defined mathematically. For example, 0/0 yields nan. Sometimes, nan is also used to signify missing information; for example, pandas uses this. inf indicates a quantity that is arbitrarily large, so in practice, it means larger than any number the computer can conceive of. -inf is also defined and it means arbitrarily small. This could occur if a numeric operation blows up, that is, grows rapidly without bounds.

Nothing is ever equal to nan; it makes no sense for something undefined to be equal to something else. You need to use the NumPy function isnan to identify nan. While the == sign does not work for nan, it does work for inf. That said, you're better off distinguishing finite and infinite values using the function is finite or is inf. Arithmetic involving...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime