NAME ID MATH ENGLISH LENGTH
0 Ravi 1 80 80 4
1 Raju 2 40 70 4
2 Alex 3 70 40 4
3 Ron 4 70 50 3
4 King 5 70 60 4
5 Jack 6 30 30 4
Length of Integer column
We can get the length of one integer column ( Say ENGLISH ) by using len() , but we have to convert the datatype from integer to string by using astype() before using len().
NAME ID MATH ENGLISH LENGTH
0 Ravi 1 80 80 2
1 Raju 2 40 70 2
2 Alex 3 70 40 2
3 Ron 4 70 50 2
4 King 5 70 60 2
5 Jack 6 30 30 2
Let us use one float datatype and find out the length. Here also we will use astype() to convert float to string data. Here we changed MATH column by adding float data.
NAME ID MATH ENGLISH LENGTH
0 Ravi 1 80.340 80 5
1 Raju 2 40.210 70 5
2 Alex 3 70.456 40 6
3 Ron 4 70.123 50 6
4 King 5 70.000 60 4
5 Jack 6 30.900 30 4