Type conversion

Type conversion gives each column the type that matches its nature (number, date, category, text), because an imported file often yields columns of type object. A good type enables calculations and correct sorting and reduces memory use. astype() and dedicated functions perform it.

Example

df['id'] = df['id'].astype('string')

Related concepts

The whole glossary