Member-only story
11 Essential Python Functions Every Data Scientist Should Know
3 min readOct 4, 2024
1. len()
Returns the number of elements in an object such as lists, tuples, strings, etc.
data = [10, 20, 30, 40]
print(len(data))
4
2. sum()
Returns the sum of elements in an iterable (like lists, arrays).
numbers = [1, 2, 3, 4]
print(sum(numbers))
10
3. type()
Returns the type of a given object, useful for inspecting data types.
x = 3.14
print(type(x))
<class 'float'>
4. map()
Applies a function to all items in an iterable.
numbers = [1, 2, 3, 4]
squared = list(map(lambda x: x**2, numbers))
print(squared)
[1, 4, 9, 16]