Modifier le type de colonne Dataframe
>>> df.astype({'col1': 'int32'}).dtypes
col1 int32
col2 int64
dtype: object
Obedient Oryx
>>> df.astype({'col1': 'int32'}).dtypes
col1 int32
col2 int64
dtype: object
int(anyData) #any into integer
str(anyData) #any into string
ord(chr) #character into number
hex(int) #integer into hexadecimal string
oct(int) #integer into octal string
float(anyData) #any into float
tuple() #convert to tuple
set() #returns the type after converting to set
list() #convert any data type to a list
dict() #convert a tuple of order (key,value) into a dictionary
complex(real,imag) #converts real numbers to complex(real,imag) number
df['myvar'] = df['myvar'].astype(str)
data_types_dict = {'id': str}
df = df.astype(data_types_dict)
# checking the data types
# using df.dtypes method
df.dtypes