| Conditions | 2 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from collections import defaultdict |
||
| 5 | def count_by(records: Sequence[Dict], field_name: str) -> defaultdict: |
||
| 6 | """ |
||
| 7 | Frequency each value occurs in a record sequence for a given field name. |
||
| 8 | """ |
||
| 9 | |||
| 10 | counter = defaultdict(int) |
||
| 11 | |||
| 12 | for record in records: |
||
| 13 | name = record[field_name] |
||
| 14 | counter[name] += 1 |
||
| 15 | |||
| 16 | return counter |
||
| 17 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.