When we store True into a dataframe, is it stored as a string?


#1

Question

When we store values such as True or False into a dataframe, are they stored as strings?

Answer

No, although the values may seem to be string types when printing out a dataframe, the values of True and False are stored as the bool type.

To see the data types that each column of your dataframe stores, you can utilize the .info() method, as covered in the previous lesson on Pandas.

One thing to keep in mind is that when inspecting the column data types using .info(), you will see types such as float64, bool, as well as object. The object data type means that the column can store any Python object. Columns that store more than one type of value, say a column that contains numbers and strings, will have a dtype of object.