Search code examples
pandasdata-cleaning

What the difference between int32 and int64


I changed the type of AGHIGH, AGELOW from float to integer but I found the output is int32 not int64 by using that code

df[['AGEHIGH', 'AGELOW']] = df[['AGEHIGH', 'AGELOW']].astype(int) 
1   SCHNAME     13902 non-null  object
2   LOCALITY    13902 non-null  object
3   TOWN        13902 non-null  object
4   SCHSTATUS   13902 non-null  object
5   MINORGROUP  13902 non-null  object
6   AGELOW      13902 non-null  int32 
7   AGEHIGH     13902 non-null  int32 
8   GENDER      13902 non-null  object

Solution

  • This was answered very well over here.

    The key difference is in terms of storage capacity. An integer is held in bits (1s and 0s). Very simply a 64-bit integer can store a much larger/smaller number by virtue of having more bits.

    Type Capacity

    Int16 -- (-32,768 to +32,767)

    Int32 -- (-2,147,483,648 to +2,147,483,647)

    Int64 -- (-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807)