Skip to content

Commit 4b5cf29

Browse files
authored
Update get.py
1 parent 4eef895 commit 4b5cf29

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

braininventory/get.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,47 @@ def __get_award_numbers(df):
262262

263263

264264
def __get_affiliations(df):
265+
"""
266+
Return a dictionary containing the count of occurrences of each unique value
267+
in the "affiliation" column of the input DataFrame.
268+
269+
Parameters:
270+
-----------
271+
df : pandas DataFrame
272+
The input DataFrame containing a column named "affiliation" from which
273+
the unique values will be counted.
274+
275+
Returns:
276+
--------
277+
dict
278+
A dictionary where the keys represent unique values in the "affiliation"
279+
column, and the values represent the count of occurrences of each unique value.
280+
281+
Example:
282+
--------
283+
>>> import pandas as pd
284+
>>> data = {
285+
... "name": ["John", "Jane", "Michael", "Emily", "William"],
286+
... "affiliation": ["Company A", "Company B", "Company A", "Company C", "Company B"]
287+
... }
288+
>>> df = pd.DataFrame(data)
289+
>>> result = __get_affiliation(df)
290+
>>> print(result)
291+
{
292+
"Company A": 2,
293+
"Company B": 2,
294+
"Company C": 1
295+
}
296+
297+
Note:
298+
-----
299+
The input DataFrame `df` should have a column named "affiliation" containing
300+
categorical data, where the function will count the occurrences of each unique value.
301+
"""
265302
return df["affiliation"].value_counts().to_dict()
266303

267304

305+
268306
def __get_contributors(df):
269307
return df["contributorname"].value_counts().to_dict()
270308

0 commit comments

Comments
 (0)