How do I count the number of times a value/string etc. occures in a field (using field calculator)?

In my example I want to count the number of times the letter "H" occures in a field; see attached image.

enter image description here

1 Answer 1


Use String count:

str.count(sub[, start[, end]]) Return the number of non-overlapping occurrences of substring sub in the range [start, end]. Optional arguments start and end are interpreted as in slice notation.

Example in Field Calculator with Python Parser:

tmp =


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.