Skip to content
Justice Tech School

where and clip

where keeps values that match and replaces others. clip limits values to a range.

Example
s = pd.Series([5, 150, -3, 40])
print(s.clip(0, 100).tolist())
print(s.where(s > 0, 0).tolist())

Result

[5, 100, 0, 40]
[5, 150, 0, 40]

Exercise

Limit a range.

s.(0, 100)

Quiz Test

What does where do with failures?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.