4.2. Changing Datatypes of Python’s inbuilt types#
4.2.1. Changing Python’s data types of values#
- Values means single elements
- The data types present in python (string/float/int/list)
- The data types present in pandas (series/dataframe/column) can't be done by this
4.2.2. Converting one data type to other#
list('sahil')
['s', 'a', 'h', 'i', 'l']
list(('cat','dog'))
['cat', 'dog']
tuple(['cat','dog'])
('cat', 'dog')
float(1)
1.0
int('001')
1
Note : Integer do not consider leading zeroes. So it automatically got removed
int(15.78)
15
Note : int on floats just removes the decimal part
str(1.2)
'1.2'
str(['sahil'])
"['sahil']"
str('001')
'001'