10
Data Types
Data types determine what can and cannot be done to a variable (i.e., column). For example, when numeric data types are added together, the result will be a sum of the values; in contrast, if strings (in Pandas they are object
or string
types) are added, the strings will be concatenated together.
This chapter presents a quick overview of the various data types you may encounter in Pandas, and means to convert from one data type to another.
Learning Objectives
Recognize columns in data store the same data type
Identify what kind of data type is stored in a column
Use functions to change the type of a column
Modify categorical columns
10.1 Data Types
In this chapter, we’ll use the built-in tips
data set from the seaborn
library. ...
Get Pandas for Everyone: Python Data Analysis, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.