Skip to content

Commit 184e6ad

Browse files
committed
Added pie chart, multiple choices works now except for correlation plot
1 parent 898990a commit 184e6ad

13 files changed

Lines changed: 3506 additions & 8714 deletions

Citation.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ authors:
2626
email: j.broeder@fz-juelich.de
2727
affiliation: Forschungszentrum Jülich GmbH (FZJ)
2828
- family-names: Gerlich
29-
given-names: Silke
29+
given-names: Silke Christine
3030
orcid: 'https://orcid.org/0000-0003-3043-5657'
3131
email: s.gerlich@fz-juelich.de
3232
affiliation: Forschungszentrum Jülich GmbH (FZJ)

dashboard/analysis.py

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
def calculate_crosstab(df: pd.DataFrame, data_key1: str, data_key2: str, id_vars: str=None, astype: str="int") -> pd.DataFrame:
2020
"""Calulate the cross table for two keys in a given pandas data frame"""
21+
2122
if id_vars is None:
2223
id_vars = data_key1
2324

@@ -41,12 +42,15 @@ def calculate_crosstab(df: pd.DataFrame, data_key1: str, data_key2: str, id_vars
4142
def filter_dataframe(df: pd.DataFrame, include: list=None, exclude: List[Tuple[str, list]]=None,
4243
exclude_nan=True, exclude_anonymized=True, as_type="category") -> pd.DataFrame:
4344
"""
44-
Filter pandas dataframe
45+
Filter a pandas dataframe
4546
4647
example:
4748
```
4849
to_exclude = ['Other', 'Undergraduate / Masters student', 'Director (of the institute)']
4950
df = filter_dataframe(surveydata, include=["careerLevel", "docStructured", "researchArea"], exclude=[("careerLevel", to_exclude)])
51+
52+
returns a dataFrame with columns ["careerLevel", "docStructured", "researchArea"],
53+
where rows which contain to_exclude values in the "careerLevel" column are removed
5054
```
5155
"""
5256

@@ -93,24 +97,26 @@ def get_all_values(df: pd.DataFrame, keylist: List[str], display_dict=None) -> d
9397
if a.empty:
9498
combined[xtick] = 0
9599
else:
100+
# greedy, there is probably a pandas way to do this...
101+
# there is a problem if df is empty, i.e temp.value_counts() True 0
96102
for i, ke in enumerate(a.keys()):
97103
# because other can contain all... others..
98-
ke = ke.lower() # sometimes there are mixed upper and lower case keys...
99-
ke = ke.replace(' \n', '') # some are with and without breaks
104+
#ke = ke.lower() # sometimes there are mixed upper and lower case keys...
105+
#ke = ke.replace(' \n', '') # some are with and without breaks
100106
temp_val = combined.get(ke, 0)
101107
temp_val = temp_val + a.values[i]
102108
combined[ke] = temp_val
103-
# greedy, there is probably a pandas way to do this...
104-
# there is a problem if df is empty, i.e temp.value_counts() True 0
105-
for i, ke in enumerate(a.keys()):
106-
ke = ke.lower() # sometimes there are mixed upper and lower case keys...
107-
ke = ke.replace(' \n', '') # some are with and without breaks
108-
temp_val = combined.get(ke, 0)
109-
temp_val = temp_val + a.values[i]
110-
combined[ke] = temp_val
109+
110+
#for i, ke in enumerate(a.keys()):
111+
# ke = ke.lower() # sometimes there are mixed upper and lower case keys...
112+
# ke = ke.replace(' \n', '') # some are with and without breaks
113+
# temp_val = combined.get(ke, 0)
114+
# temp_val = temp_val + a.values[i]
115+
# combined[ke] = temp_val
111116
data = {'All' : list(combined.values()), key:list(combined.keys())}
112117
return data
113118

119+
114120
def prepare_data_research_field(df: pd.DataFrame, keylist:List[str], key2:str='researchArea', sort_as=None, display_dict= None):# -> dict, list:
115121
"""Creates a dict dictionary with data in the form needed by the plotting functions
116122
@@ -161,7 +167,8 @@ def prepare_data_research_field(df: pd.DataFrame, keylist:List[str], key2:str='r
161167
area_counts = df[df[key2] == area][key].value_counts()
162168
area_counts = area_counts.sort_index()
163169
data[area] = area_counts.values
164-
else:
170+
else:
171+
# Cum. Sum. is buggy?
165172
combined = {}
166173
data = {}
167174
for key in keylist:
@@ -176,28 +183,30 @@ def prepare_data_research_field(df: pd.DataFrame, keylist:List[str], key2:str='r
176183
a = temp.value_counts()
177184
# greedy, there is probably a pandas way to do this...
178185
# there is a problem if df is empty, i.e temp.value_counts() True 0
179-
for i, ke in enumerate(a.keys()):
180-
# because other can contain all... others..
181-
ke = ke.lower() # sometimes there are mixed upper and lower case keys...
182-
ke = ke.replace(' \n', '') # some are with and without breaks
183-
temp_val = combined.get(ke, 0)
184-
temp_val = temp_val + a.values[i]
185-
combined[ke] = temp_val
186-
186+
if a.empty:
187+
combined[xtick] = 0
188+
else:
189+
for i, ke in enumerate(a.keys()):
190+
# because other can contain all... others..
191+
#ke = ke.lower() # sometimes there are mixed upper and lower case keys...
192+
#ke = ke.replace(' \n', '') # some are with and without breaks
193+
temp_val = combined.get(ke, 0)
194+
temp_val = temp_val + a.values[i]
195+
combined[ke] = temp_val
196+
197+
# now fill research area specifics
187198
for area in research_areas:
188199
area_counts = df[df[key2] == area][key]
189-
temp = data.get(area, [])
190-
191200
area_counts.replace(to_replace=True, value=xtick, inplace=True)
192201
area_counts.replace(to_replace=False, value=None, inplace=True)
193-
area_counts.value_counts()
202+
area_counts = area_counts.value_counts()
194203
area_counts = area_counts.sort_index()
195-
196-
print(area_counts)
204+
temp = data.get(area, [])
205+
#print(area_counts)
197206
if area_counts.empty:
198207
temp.append(0)
199208
else:
200-
temp.append(list(area_counts.values))
209+
temp.append(int(area_counts.values[0]))
201210
data[area] = temp
202211

203212
data['Cum. Sum'] = list(combined.values())

dashboard/data/display_specifications/hcs_clean_dictionaries.py

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
###############################################################################
1111
"""
1212
A collection of dictionaries/maps to influence the display of certain categorical data
13-
14-
@author: s.gerlich
1513
"""
1614

1715
##########################################
@@ -2194,7 +2192,7 @@
21942192

21952193

21962194
# This what will be displayed in selection widgets and titles
2197-
HCSquestions = {
2195+
HCSquestions_long = {
21982196
"EN" : {
21992197
"PERBG1/_":"Which Helmholtz center do you typically work in?",
22002198
"PERBG2/_":"Please select the Helmholtz research field you associate yourself with.",
@@ -2278,6 +2276,91 @@
22782276
"SERVC3":"Sie haben es fast geschafft! Gerne können Sie Fragen, Wünsche oder Anregungen im folgenden Freitextfeld formulieren:"
22792277
}
22802278
}
2279+
# These are used as displays on selection and for titles
2280+
HCSquestions = { # shortened
2281+
"EN" : {
2282+
"PERBG1/_":"Helmholtz center participants typically work in",
2283+
"PERBG2/_":"Helmholtz research field participants associate with.",
2284+
"PERBG3/_":"Principle research area of participants.",
2285+
"PERBG4/_":"Working years in research.",
2286+
"PERBG6/_":"Career level of participants.",
2287+
"PERBG7/_":"Do you have an ORCID ID?",
2288+
"PERBG8/_":"Familiarity with the FAIR data guidelines",
2289+
"RSDP1":"Origin of research data.",
2290+
"RSDP1b/1":"Percentage of data sets recorded at large scale facilities.",
2291+
"RSDP1c":"Large scale facilities used.",
2292+
"RSDP2":"Research data generation methods used (selected).",
2293+
"RSDP2b":"Research data generation methods used (specified).",
2294+
"RSDP3":"Data formats used in research projects.",
2295+
"RSDP7/_":"Amount of data a typical publication is based on.",
2296+
"RSDP4/_":"Average time from planning to completion for projects. (months)",
2297+
"RSDP8/_":"Experiments take ___ time than on average in my domain.",
2298+
"RSDP11/_":"Data analyses take ___ time than on average in my domain.",
2299+
"RSDP10/_":"Unpublished raw data kept in long-term storage (>10 years).",
2300+
"DTPUB6/1":"Percentage of data sets made publicly available.",
2301+
"DTPUB1b":"How data was publised.",
2302+
"DTPUB5":"Repositories data is published in.",
2303+
"DTPUB3":"Motivations to publish data.",
2304+
"DTPUB4a":"Obstacles for publishing research data.",
2305+
"DTPUB4b":"Discouragements for publishing data so far.",
2306+
"RDMPR1":"Data storage for finished projects.",
2307+
"RDMPR3":"Where are data generation and processing are documented.",
2308+
"RDMPR7":"Information (metadata) typically used to describe research data.",
2309+
"RDMPR8":"Information (metadata) typically documented in digital way.",
2310+
"RDMPR9":"Information (metadata) typically gathered in automated way.",
2311+
"RDMPR4/_":"Reseach data documented in a structued.",
2312+
"RDMPR5/_":"Usage of internationally templates, schemas or standards.",
2313+
"DTPUB7":"Metadata published along with research data.",
2314+
"RDMPR6":"International standards in use.",
2315+
"RDMPR10":"Three most important software applications used in research.",
2316+
"RDMPR12":"Motivations to documented work in a structured way.",
2317+
"RDMPR11":"Difficulties in collecting metadata as part of work.",
2318+
"SERVC1":" Support or services needed by research data management area.",
2319+
"SERVC2":"Interest in certain service formats.",
2320+
"SERVC3":"Free feedback text field:"
2321+
},
2322+
"DE" : {
2323+
"PERBG1/_":"In welchem Helmholtz-Zentrum sind Sie in erster Linie tätig?",
2324+
"PERBG2/_":"Welchem Helmholtz-Forschungsbereich ordnen Sie sich am ehesten zu?",
2325+
"PERBG3/_":"Welcher Forschungsdisziplin ordnen Sie sich am ehesten zu?",
2326+
"PERBG4/_":"Wie viele Jahre sind Sie bereits in der Forschung tätig?",
2327+
"PERBG6/_":"Was ist Ihre aktuelle Position?",
2328+
"PERBG7/_":"Haben Sie eine ORCID iD?",
2329+
"PERBG8/_":"Wie vertraut sind Sie mit den FAIR-Data Leitlinien?",
2330+
"RSDP1":"Bitte charakterisieren Sie den Ursprung Ihrer Forschungsdaten.",
2331+
"RSDP1b/1":"Welcher Anteil Ihrer Datensätze wurde an Großforschungsanlagen (z.B. LHC, PETRA III, KATRIN ELBE, BESSY II) erfasst? (Angabe in Prozent)",
2332+
"RSDP1c":"Bitte nennen Sie die genutzte Großforschungseinrichtung:",
2333+
"RSDP2":"Mit welchen Methoden erheben Sie Ihre Forschungsdaten?",
2334+
"RSDP2b":"Bitte spezifizieren Sie die Methoden, mit denen Sie Ihre Forschungsdaten erheben.",
2335+
"RSDP3":"In welchen Datenformaten liegen die Daten vor, die Sie in Ihrem aktuellen Forschungsprojekt generieren bzw. nutzen?",
2336+
"RSDP7/_":"Bitte schätzen Sie, auf welcher Datenmenge eine typische Veröffentlichung von Ihnen beruht.",
2337+
"RSDP4/_":"Wie viel Zeit vergeht durchschnittlich von der Planung bis zum Abschluss der Datenaufnahme für Ihre Forschungsprojekte? (in Monaten)",
2338+
"RSDP8/_":"Meine Experimente nehmen ___ Zeit in Anspruch als eine durchnittliche Untersuchung in meinem Forschungsbereich.",
2339+
"RSDP11/_":"Meine Datenanalysen nehmen ___ Zeit in Anspruch als eine durchschnittliche Untersuchung in meinem Forschungsbereich.",
2340+
"RSDP10/_":"Speichern Sie Rohdaten, die nicht publiziert werden, langfristig (10 Jahre und länger)?",
2341+
"DTPUB6/1":"Bitte schätzen Sie, welchen relativen Anteil Ihrer Datensätze Sie publizieren. (Angabe in Prozent)",
2342+
"DTPUB1b":"Wie haben Sie Ihre Daten publiziert?",
2343+
"DTPUB5":"In welchen Repositorien haben Sie Ihre Daten veröffentlicht?",
2344+
"DTPUB3":"Was motivierte Sie dazu, Ihre Forschungsdaten zu veröffentlichen? (Bitte wählen Sie bis zu 3 Antworten)",
2345+
"DTPUB4a":"Auf welche Hindernisse sind Sie bei der Veröffentlichung Ihrer Forschungsdaten gestoßen?",
2346+
"DTPUB4b":"Welche Bedenken oder Hindernisse haben Sie bisher davon abgehalten, Ihre Forschungsdaten zu veröffentlichen?",
2347+
"RDMPR1":"Wo werden Ihre Forschungsdaten nach Abschluss eine Projekts hauptsächlich gespeichert?",
2348+
"RDMPR3":"Wo dokumentieren Sie in Ihrem aktuellen Projekt die Arbeitsschritte, mit denen Ihre Daten erzeugt und verarbeitet werden?",
2349+
"RDMPR7":"Mit welchen Informationen (Metadaten) beschreiben Sie normalerweise Ihre Forschungsdaten?",
2350+
"RDMPR8/_":"Welche Informationen (Metadaten) davon erfassen Sie in der Regel digital?",
2351+
"RDMPR9":"Welche dieser Informationen (Metadaten) erfassen Sie in der Regel automatisiert?",
2352+
"RDMPR4/_":"Dokumentieren Sie Ihre Forschungsdaten auf strukturierte Weise? (z.B. mittels Formularen, Vorlagen oder Schemata)",
2353+
"RDMPR5/_":"Verwenden Sie hierzu international genutzte Formulare, Schemata oder Standards?",
2354+
"DTPUB7":"Welche dieser Metadaten publizieren Sie zusammen mit Ihren Forschungsdaten?",
2355+
"RDMPR6":"Welche internationalen Standards nutzen Sie?",
2356+
"RDMPR10":"Bitte nennen Sie die drei wichtigsten Softwareanwendungen, die Sie für Ihre Forschung verwenden.",
2357+
"RDMPR12":"Was motiviert Sie dazu, Ihre Arbeitsschritte auf strukturierte Weise zu dokumentieren?",
2358+
"RDMPR11":"Auf welche Hindernisse oder Schwierigkeiten sind Sie bei der Erfassung von Metadaten im Rahmen Ihrer Arbeit gestoßen?",
2359+
"SERVC1":"In welchen Bereichen des Forschungsdatenmanagements haben Sie Bedarf an unterstützenden Angeboten?",
2360+
"SERVC2":"Bitte bewerten Sie Ihr Interesse an den folgenden Service-Formaten.",
2361+
"SERVC3":"Sie haben es fast geschafft! Gerne können Sie Fragen, Wünsche oder Anregungen im folgenden Freitextfeld formulieren:"
2362+
}
2363+
}
22812364

22822365

22832366
# Dashboard specific white lists
@@ -2359,6 +2442,7 @@
23592442
"Engineering Science",
23602443
"Life Science",
23612444
"Mathematics",
2445+
"Other",
23622446
"Physics",
23632447
"Psychology"]
23642448

dashboard/data/display_specifications/hmc_colordicts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ def make_Ramp( ramp_colors ):
7979
# continuous color scale based on Hub Info color palette
8080
hubInfoRamp = make_Ramp(hubInfoPalette)
8181
#cmr.view_cmap(hubInfoRamp)
82+
83+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
hmc_custom_css_accordion ='''
2+
.bk.card {
3+
border: 1px solid rgba(0,0,0,.125);
4+
border-radius: 0.25rem;
5+
}
6+
.bk.accordion {
7+
border: 1px solid rgba(0,0,0,.125);
8+
}
9+
.bk.card-header {
10+
align-items: center;
11+
background-color: rgba(0, 0, 0, 0.03);
12+
border-radius: 0.25rem;
13+
display: inline-flex;
14+
justify-content: start;
15+
width: 100%;
16+
}
17+
.bk.accordion-header {
18+
align-items: center;
19+
background-color: rgba(0, 0, 0, 0.03);
20+
border-radius: 0;
21+
display: flex;
22+
justify-content: start;
23+
width: 100%;
24+
}
25+
.bk.card-button {
26+
background-color: transparent;
27+
margin-left: 0.5em;
28+
}
29+
.bk.card-header-row {
30+
position: relative !important;
31+
}
32+
.bk.card-title {
33+
align-items: left;
34+
font-size: 1.4em;
35+
font-weight: bold;
36+
overflow-wrap: break-word;
37+
}
38+
.bk.card-header-row > .bk {
39+
overflow-wrap: break-word;
40+
text-align: left;
41+
}
42+
'''
43+
#rgba(0, 0, 0, 0.03);
44+
#"#005AA0" : rgba(0, 90, 160, 0.53);
45+
# background-color: rgba(0, 90, 160, 0.53);

dashboard/data/download_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#url="https://access.gesis.org/sharing/2433/3778"
1616

1717
def download_data(url="https://access.gesis.org/sharing/2433/3778",
18-
destination="dashboard/data/hmc_survey_2021_data_cleaned-csv"):
18+
destination="dashboard/data/hmc_survey_2021_data_cleaned.csv"):
1919
"""
2020
This function downloads the dataset for a given DOI
2121
"""

0 commit comments

Comments
 (0)