Skip to content

Commit 6092db4

Browse files
authored
Merge pull request #99 from brain-image-library/96-dictionary-of-creation-months-and-numbers
Dictionary of Dates
2 parents b51382a + 105a3a2 commit 6092db4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

braininventory/get.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,4 +1434,17 @@ def create_tree_map(frequency_dict, width, height):
14341434
today = date.today()
14351435
output_path = f'treemap-{today.strftime("%Y%m%d")}.png'
14361436
fig.write_image(output_path)
1437-
fig.show()
1437+
fig.show()
1438+
1439+
def __get_dates(df):
1440+
"""
1441+
Get a dictionary that has keys as creation months and values as the number of datasets
1442+
1443+
Input: dataframe
1444+
1445+
Output: dictionary
1446+
"""
1447+
df['date'] = pd.to_datetime(df['creation_date'], format='%a %b %d %H:%M:%S %Y')
1448+
df['year_month'] = df['date'].dt.strftime('%B %Y')
1449+
grouped_data = df['year_month'].value_counts().to_dict()
1450+
return grouped_data

0 commit comments

Comments
 (0)