1-
1+ # -*- coding: utf-8 -*-
2+ ###############################################################################
3+ # Copyright (c), Forschungszentrum Jülich GmbH, IAS-9, Germany. #
4+ # All rights reserved. #
5+ # This file is part of the survey_dashboard package. #
6+ # #
7+ # The code is hosted on GitHub at #
8+ # https://github.com/Materials-Data-Science-and-Informatics/survey_dashboard #
9+ # For further information on the license, see the LICENSE file #
10+ ###############################################################################
11+ """
12+ This module contains some function to process survey data in certain way and
13+ prepare the data for visualization
14+ """
15+ import math
216import pandas as pd
317from typing import List , Tuple
418
@@ -88,8 +102,8 @@ def prepare_data_research_field(df: pd.DataFrame, key:str, key2:str='researchAre
88102 all_areas = df [key ].value_counts ()
89103 all_areas = all_areas .sort_index ()
90104 research_areas = list (df [key2 ].value_counts ().keys ())
91- data = {'All ' : all_areas .values , key :list (all_areas .keys ()), 'x_value' : list (all_areas .keys ())}
92- y_keys = ['All ' ] + research_areas
105+ data = {'Cum. Sum ' : all_areas .values , key :list (all_areas .keys ()), 'x_value' : list (all_areas .keys ())}
106+ y_keys = ['Cum. Sum ' ] + research_areas
93107 for area in research_areas :
94108 area_counts = df [df [key2 ] == area ][key ].value_counts ()
95109 area_counts = area_counts .sort_index ()
@@ -116,4 +130,8 @@ def prepare_data_research_field(df: pd.DataFrame, key:str):
116130 data[area] = {'counts': area_counts.values, 'values': list(area_counts.keys())}
117131
118132 return data
119- '''
133+ '''
134+
135+ def percentage_to_area (data , scale_m = 1.0 ):
136+ radius_data = [2 * math .sqrt (val * scale_m / math .pi ) for val in data ]
137+ return radius_data
0 commit comments