Lesson 5: Data types and missing values
    1 / 11

    Lesson 5 of 6 · about 20 minutes

    Data types and missing values

    Data types

    Every column has a dtype: the kind of values it holds. pandas picks one when it builds the table, and it decides what you can do with the column. dtypes shows them all:

    import pandas as pd
    
    df = pd.DataFrame({
        "name": ["Ava", "Ben", "Cleo"],
        "age": [12, 13, 12],
        "height": [1.52, 1.61, 1.49],
        "member": [True, False, True],
    })
    print(df.dtypes)

    The output:

    name       object
    age         int64
    height    float64
    member       bool
    dtype: object

    The common ones are int64 (whole numbers), float64 (decimal numbers), bool (True or False) and object, which pandas uses for text. A single column's type is df["age"].dtype.