forked from shezanmirzan/DataVis-Mental-Health
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsunburst.py
54 lines (40 loc) · 1.67 KB
/
sunburst.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 16 16:58:44 2020
@author: Nidhi
"""
import numpy as np
import pandas as pd
import os
#Replace while maintaining ratio
def assign():
if np.random.randint(1,100)<=58: # Use 58 for 2016; Use 60 for 2019
return "Yes"
else:
return "No"
#Set path
cur_Dir = os.getcwd();
fileName = "mental-heath-in-tech-2016_cleaned.csv"
#Read data
data = pd.read_csv(os.path.join(cur_Dir,fileName))
#Use for 2016/2019 data
#Pre-Process : Replace "I don't know"
data.loc[(data['Do you have a family history of mental illness?']=="I don't know"), 'Do you have a family history of mental illness?'] = assign();
hist = ["Yes", "No"]
gender = ["Male", "Female","Other"]
ans = ["Yes", "No", "Some of them"]
#ans = ["Yes", "No", "Some of them"] # Use for 2016/2019
print("------Total responders: "+str(len(data))+"--------")
for i in hist:
for j in gender:
for k in ans:
#Use for2016/2019 # disorder -> issue (2016->2019)
x = len(data.loc[(data['Do you have a family history of mental illness?']==i) & (data['What is your gender?']==j) &
(data['Would you feel comfortable discussing a mental health disorder with your coworkers?']==k)])
#Use for 2014
#x = len(data.loc[(data['family_history']==i) & (data['Gender']==j) & (data['coworkers']==k)])
print("Has Family History?: "+ str(i))
print("Gender: "+str(j))
print("Comfortable to discuss?: "+str(k))
print("Count: "+str(x))
print("---------")