AI engineering glossary · NumPy pandas visualization

What is type casting?

Type casting (also called astype in NumPy, type promotion): Converting an array's values from one data type to another, for example floats to integers, using astype. Down-casting may drop decimals or lose precision, and mixing types in an operation makes NumPy pick a common type, which can silently change results.

Level: intermediateTopic: NumPy pandas visualization

Type casting: an example

np.array([1.9, 2.7]).astype(int) returns array([1, 2]), because the decimals are cut off, not rounded.

Related terms

More NumPy pandas visualization terms

Where you learn it

Type casting is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.