How do you convert between the different python data types? What data quality issues arise when converting data types?
You can change the data type as follows:
a = 10
b = str(a) # b = " 10"
But when converting, the following problems may arise:
a = 10.3
b = int (a) # b = 10
Thus, we lose in accuracy
Or when trying to convert:
a = 'fg'
b = float (a) # Value Error: could not convert string to float: 'fg'
Some data types cannot be converted to others
Comments
Leave a comment