Data Preparation

OSMI has all the links of the data on their website under the research section for all the years starting from year 2014. The organization has hosted their datasets on kaggle. I took the data from the year 2017 onwards because the question asked haven’t changed from 2017 and hence it will be easier to combine the data.

All the datasets are downloaded in csv format and renamed to with respect to corresponding years in the format “osmi_<year>.csv”. Here <year> is the placeholder for the year. For example, data for year 2017 is present in file named “osmi_2017.csv”

# Import necessary packages
import pandas as pd
import re

Data cleaning - 2017

# Load 2017 data
df = pd.read_csv("./../../../datasets/osmi_2017.csv")
# Data Preview
df.head()
# <strong>Are you self-employed?</strong> How many employees does your company or organization have? Is your employer primarily a tech company/organization? Is your primary role within your company related to tech/IT? Does your employer provide mental health benefits as part of healthcare coverage? Do you know the options for mental health care available under your employer-provided health coverage? Has your employer ever formally discussed mental health (for example, as part of a wellness campaign or other official communication)? Does your employer offer resources to learn more about mental health disorders and options for seeking help? Is your anonymity protected if you choose to take advantage of mental health or substance abuse treatment resources provided by your employer? ... What is your gender? What country do you <strong>live</strong> in? What US state or territory do you <strong>live</strong> in? What is your race? Other What country do you <strong>work</strong> in? What US state or territory do you <strong>work</strong> in? Start Date (UTC) Submit Date (UTC) Network ID
0 e49fe87572831232dcfa51b376b22039 0 100-500 1.0 1.0 No Yes No I don't know I don't know ... Female United Kingdom NaN NaN NaN United Kingdom NaN 16/05/18 12:32 16/05/18 12:42 464b7a12f1
1 a1eede444ac024928d247a8372d54931 0 100-500 1.0 1.0 Yes Yes No No I don't know ... male United Kingdom NaN NaN NaN United Kingdom NaN 16/05/18 12:31 16/05/18 12:40 464b7a12f1
2 37d3fd67f62bd1e0a2dea4f9cd440d98 0 Jun-25 1.0 1.0 I don't know No I don't know No Yes ... male United States of America Missouri White NaN United States of America Missouri 09/05/18 5:34 09/05/18 5:46 1eb7e0cb94
3 519b759442c1cab0e9b5a8a1acb1b216 0 More than 1000 1.0 1.0 Yes Yes I don't know I don't know Yes ... Male United States of America Washington White NaN United States of America Washington 04/05/18 23:19 04/05/18 23:23 63852edbc4
4 ef0af4927b575b1a3e607c11ca37870e 1 NaN NaN NaN NaN NaN NaN NaN NaN ... female United States of America Illinois More than one of the above NaN United States of America Illinois 03/05/18 0:40 03/05/18 0:53 43237889f1

5 rows × 87 columns

# Data info
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 756 entries, 0 to 755
Data columns (total 87 columns):
 #   Column                                                                                                                                                                                                                                   Non-Null Count  Dtype  
---  ------                                                                                                                                                                                                                                   --------------  -----  
 0   #                                                                                                                                                                                                                                        756 non-null    object 
 1   <strong>Are you self-employed?</strong>                                                                                                                                                                                                  756 non-null    int64  
 2   How many employees does your company or organization have?                                                                                                                                                                               643 non-null    object 
 3   Is your employer primarily a tech company/organization?                                                                                                                                                                                  643 non-null    float64
 4   Is your primary role within your company related to tech/IT?                                                                                                                                                                             643 non-null    float64
 5   Does your employer provide mental health benefits as part of healthcare coverage?                                                                                                                                                        643 non-null    object 
 6   Do you know the options for mental health care available under your employer-provided health coverage?                                                                                                                                   576 non-null    object 
 7   Has your employer ever formally discussed mental health (for example, as part of a wellness campaign or other official communication)?                                                                                                   643 non-null    object 
 8   Does your employer offer resources to learn more about mental health disorders and options for seeking help?                                                                                                                             643 non-null    object 
 9   Is your anonymity protected if you choose to take advantage of mental health or substance abuse treatment resources provided by your employer?                                                                                           643 non-null    object 
 10  If a mental health issue prompted you to request a medical leave from work, how easy or difficult would it be to ask for that leave?                                                                                                     643 non-null    object 
 11  Would you feel more comfortable talking to your coworkers about your physical health or your mental health?                                                                                                                              643 non-null    object 
 12  Would you feel comfortable discussing a mental health issue with your direct supervisor(s)?                                                                                                                                              643 non-null    object 
 13  Have you ever discussed your mental health with your employer?                                                                                                                                                                           643 non-null    float64
 14  Describe the conversation you had with your employer about your mental health, including their reactions and what actions were taken to address your mental health issue/questions.                                                      172 non-null    object 
 15  Would you feel comfortable discussing a mental health issue with your coworkers?                                                                                                                                                         643 non-null    object 
 16  Have you ever discussed your mental health with coworkers?                                                                                                                                                                               643 non-null    float64
 17  Describe the conversation with coworkers you had about your mental health including their reactions.                                                                                                                                     226 non-null    object 
 18  Have you ever had a coworker discuss their or another coworker's mental health with you?                                                                                                                                                 638 non-null    float64
 19  Describe the conversation your coworker had with you about their mental health (please do not use names).                                                                                                                                230 non-null    object 
 20  Overall, how much importance does your employer place on physical health?                                                                                                                                                                643 non-null    float64
 21  Overall, how much importance does your employer place on mental health?                                                                                                                                                                  643 non-null    float64
 22  Do you have medical coverage (private insurance or state-provided) that includes treatment of mental health disorders?                                                                                                                   113 non-null    float64
 23  Do you know local or online resources to seek help for a mental health issue?                                                                                                                                                            113 non-null    object 
 24  <strong>If you have been diagnosed or treated for a mental health disorder, do you ever reveal this to clients or business contacts?</strong>                                                                                            113 non-null    object 
 25  If you have revealed a mental health disorder to a client or business contact, how has this affected you or the relationship?                                                                                                            51 non-null     object 
 26  <strong>If you have been diagnosed or treated for a mental health disorder, do you ever reveal this to coworkers or employees?</strong>                                                                                                  113 non-null    object 
 27  If you have revealed a mental health disorder to a coworker or employee, how has this impacted you or the relationship?                                                                                                                  113 non-null    object 
 28  Do you believe your productivity is ever affected by a mental health issue?                                                                                                                                                              113 non-null    object 
 29  If yes, what percentage of your work time (time performing primary or secondary job functions) is affected by a mental health issue?                                                                                                     85 non-null     object 
 30  <strong>Do you have previous employers?</strong>                                                                                                                                                                                         756 non-null    int64  
 31  Was your employer primarily a tech company/organization?                                                                                                                                                                                 667 non-null    float64
 32  <strong>Have your previous employers provided mental health benefits?</strong>                                                                                                                                                           667 non-null    object 
 33  <strong>Were you aware of the options for mental health care provided by your previous employers?</strong>                                                                                                                               667 non-null    object 
 34  Did your previous employers ever formally discuss mental health (as part of a wellness campaign or other official communication)?                                                                                                        667 non-null    object 
 35  Did your previous employers provide resources to learn more about mental health disorders and how to seek help?                                                                                                                          667 non-null    object 
 36  Was your anonymity protected if you chose to take advantage of mental health or substance abuse treatment resources with previous employers?                                                                                             667 non-null    object 
 37  Would you have felt more comfortable talking to your previous employer about your physical health or your mental health?                                                                                                                 667 non-null    object 
 38  Would you have been willing to discuss your mental health with your direct supervisor(s)?                                                                                                                                                667 non-null    object 
 39  Did you ever discuss your mental health with your previous employer?                                                                                                                                                                     667 non-null    float64
 40  Describe the conversation you had with your previous employer about your mental health, including their reactions and actions taken to address your mental health issue/questions.                                                       105 non-null    object 
 41  <strong>Would you have been willing to discuss your mental health with your coworkers at previous employers?</strong>                                                                                                                    667 non-null    object 
 42  Did you ever discuss your mental health with a previous coworker(s)?                                                                                                                                                                     666 non-null    float64
 43  Describe the conversation you had with your previous coworkers about your mental health including their reactions.                                                                                                                       130 non-null    object 
 44  Did you ever have a previous coworker discuss their or another coworker's mental health with you?                                                                                                                                        661 non-null    float64
 45  Describe the conversation your coworker had with you about their mental health (please do not use names)..1                                                                                                                              126 non-null    object 
 46  Overall, how much importance did your previous employer place on physical health?                                                                                                                                                        667 non-null    float64
 47  Overall, how much importance did your previous employer place on mental health?                                                                                                                                                          667 non-null    float64
 48  Do you currently have a mental health disorder?                                                                                                                                                                                          756 non-null    object 
 49  Have you ever been diagnosed with a mental health disorder?                                                                                                                                                                              324 non-null    object 
 50  What disorder(s) have you been diagnosed with?                                                                                                                                                                                           0 non-null      float64
 51  If possibly, what disorder(s) do you believe you have?                                                                                                                                                                                   142 non-null    object 
 52  If so, what disorder(s) were you diagnosed with?                                                                                                                                                                                         313 non-null    object 
 53  Have you had a mental health disorder in the past?                                                                                                                                                                                       746 non-null    object 
 54  Have you ever sought treatment for a mental health disorder from a mental health professional?                                                                                                                                           756 non-null    int64  
 55  Do you have a family history of mental illness?                                                                                                                                                                                          756 non-null    object 
 56  If you have a mental health disorder, how often do you feel that it interferes with your work <strong>when being treated effectively?</strong>                                                                                           756 non-null    object 
 57  If you have a mental health disorder, how often do you feel that it interferes with your work <strong>when <em>NOT</em> being treated effectively (i.e., when you are experiencing symptoms)?</strong>                                   756 non-null    object 
 58  Have your observations of how another individual who discussed a mental health issue made you less likely to reveal a mental health issue yourself in your current workplace?                                                            596 non-null    object 
 59  How willing would you be to share with friends and family that you have a mental illness?                                                                                                                                                756 non-null    int64  
 60  Would you be willing to bring up a physical health issue with a potential employer in an interview?                                                                                                                                      756 non-null    object 
 61  Why or why not?                                                                                                                                                                                                                          570 non-null    object 
 62  Would you bring up your mental health with a potential employer in an interview?                                                                                                                                                         756 non-null    object 
 63  Why or why not?.1                                                                                                                                                                                                                        580 non-null    object 
 64  Are you openly identified at work as a person with a mental health issue?                                                                                                                                                                754 non-null    float64
 65  Has being identified as a person with a mental health issue affected your career?                                                                                                                                                        84 non-null     float64
 66  How has it affected your career?                                                                                                                                                                                                         26 non-null     float64
 67  If they knew you suffered from a mental health disorder, how do you think that team members/co-workers would react?                                                                                                                      754 non-null    float64
 68  <strong>Have you observed or experienced an unsupportive or badly handled response to a mental health issue in your current or previous workplace?</strong>                                                                              754 non-null    object 
 69  Describe the circumstances of the badly handled or unsupportive response.                                                                                                                                                                157 non-null    object 
 70  <strong>Have you observed or experienced supportive or well handled response to a mental health issue in your current or previous workplace?</strong>                                                                                    754 non-null    object 
 71  Describe the circumstances of the supportive or well handled response.                                                                                                                                                                   0 non-null      float64
 72  Overall, how well do you think the tech industry supports employees with mental health issues?                                                                                                                                           754 non-null    float64
 73  Briefly describe what you think the industry as a whole and/or employers could do to improve mental health support for employees.                                                                                                        500 non-null    object 
 74  If there is anything else you would like to tell us that has not been covered by the survey questions, please use this space to do so.                                                                                                   183 non-null    object 
 75  Would you be willing to talk to one of us more extensively about your experiences with mental health issues in the tech industry? (Note that all interview responses would be used <em>anonymously</em> and only with your permission.)  754 non-null    float64
 76  What is your age?                                                                                                                                                                                                                        754 non-null    float64
 77  What is your gender?                                                                                                                                                                                                                     743 non-null    object 
 78  What country do you <strong>live</strong> in?                                                                                                                                                                                            754 non-null    object 
 79  What US state or territory do you <strong>live</strong> in?                                                                                                                                                                              497 non-null    object 
 80  What is your race?                                                                                                                                                                                                                       482 non-null    object 
 81  Other                                                                                                                                                                                                                                    15 non-null     object 
 82  What country do you <strong>work</strong> in?                                                                                                                                                                                            754 non-null    object 
 83  What US state or territory do you <strong>work</strong> in?                                                                                                                                                                              503 non-null    object 
 84  Start Date (UTC)                                                                                                                                                                                                                         756 non-null    object 
 85  Submit Date (UTC)                                                                                                                                                                                                                        756 non-null    object 
 86  Network ID                                                                                                                                                                                                                               756 non-null    object 
dtypes: float64(23), int64(4), object(60)
memory usage: 514.0+ KB
# Lower the column names
df.columns = df.columns.str.lower()
columns  = list(df.columns)

# Remove html tags from the column names
columns = [re.sub('<.*?>', '', column) for column in columns]

# Remove special character 
columns = [re.sub('\xa0', ' ', column) for column in columns]
# Reassign the columns to the respective dataframes
df.columns = columns
# Drop unuseful columns
df.drop(['#', 'start date (utc)', 'network id', 'other', 'submit date (utc)'], axis=1, inplace=True)
# Add year identifying column
df['year'] = '2017'
# Write the cleaned file back
df.to_csv("./../../../datasets/cleaned_osmi_2017.csv", index=False)

Data cleaning - 2018

# Load 2018 data
df = pd.read_csv("./../../../datasets/osmi_2018.csv")
# Data Preview
df.head()
# <strong>Are you self-employed?</strong> How many employees does your company or organization have? Is your employer primarily a tech company/organization? Is your primary role within your company related to tech/IT? Does your employer provide mental health benefits as part of healthcare coverage? Do you know the options for mental health care available under your employer-provided health coverage? Has your employer ever formally discussed mental health (for example, as part of a wellness campaign or other official communication)? Does your employer offer resources to learn more about mental health disorders and options for seeking help? Is your anonymity protected if you choose to take advantage of mental health or substance abuse treatment resources provided by your employer? ... What is your gender? What country do you <strong>live</strong> in? What US state or territory do you <strong>live</strong> in? What is your race? Other What country do you <strong>work</strong> in? What US state or territory do you <strong>work</strong> in? Start Date (UTC) Submit Date (UTC) Network ID
0 e44a0a34f2465940beda2a1537e9b99e 0 More than 1000 1.0 0.0 Yes Yes Yes Yes Yes ... Female Canada NaN NaN NaN Canada NaN 29/12/18 23:46 30/12/18 0:00 4bbb884ccc
1 0d698e3beca20fb75f19b9d528e36d73 0 More than 1000 1.0 1.0 Yes Yes No I don't know I don't know ... male United States of America Massachusetts White NaN United States of America Massachusetts 27/12/18 21:40 27/12/18 21:45 275e7543bd
2 61a40c9071eb36fa9caa254d31500c41 0 Jun-25 0.0 1.0 Yes Yes No No I don't know ... Male United States of America Florida White NaN United States of America Florida 21/12/18 17:37 21/12/18 18:08 43994c3dba
3 f8624340bead7deb08abb766704ddf6b 0 Jun-25 1.0 1.0 No No No No I don't know ... male Norway NaN NaN NaN Norway NaN 21/12/18 16:37 21/12/18 16:44 907b3a3faa
4 31d3ae93b68d79e504a0a643601b6b1e 0 26-100 1.0 1.0 Yes Yes Yes Yes Yes ... Ostensibly Male United States of America Tennessee White NaN United States of America Tennessee 20/12/18 19:39 20/12/18 20:58 26df20fea3

5 rows × 87 columns

# Data info
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 417 entries, 0 to 416
Data columns (total 87 columns):
 #   Column                                                                                                                                                                                                                                    Non-Null Count  Dtype  
---  ------                                                                                                                                                                                                                                    --------------  -----  
 0   #                                                                                                                                                                                                                                         417 non-null    object 
 1   <strong>Are you self-employed?</strong>                                                                                                                                                                                                   417 non-null    int64  
 2   How many employees does your company or organization have?                                                                                                                                                                                361 non-null    object 
 3   Is your employer primarily a tech company/organization?                                                                                                                                                                                   361 non-null    float64
 4   Is your primary role within your company related to tech/IT?                                                                                                                                                                              361 non-null    float64
 5   Does your employer provide mental health benefits as part of healthcare coverage?                                                                                                                                                         361 non-null    object 
 6   Do you know the options for mental health care available under your employer-provided health coverage?                                                                                                                                    324 non-null    object 
 7   Has your employer ever formally discussed mental health (for example, as part of a wellness campaign or other official communication)?                                                                                                    361 non-null    object 
 8   Does your employer offer resources to learn more about mental health disorders and options for seeking help?                                                                                                                              361 non-null    object 
 9   Is your anonymity protected if you choose to take advantage of mental health or substance abuse treatment resources provided by your employer?                                                                                            361 non-null    object 
 10  If a mental health issue prompted you to request a medical leave from work, how easy or difficult would it be to ask for that leave?                                                                                                      361 non-null    object 
 11  Would you feel more comfortable talking to your coworkers about your physical health or your mental health?                                                                                                                               361 non-null    object 
 12  Would you feel comfortable discussing a mental health issue with your direct supervisor(s)?                                                                                                                                               361 non-null    object 
 13  Have you ever discussed your mental health with your employer?                                                                                                                                                                            361 non-null    float64
 14  Describe the conversation you had with your employer about your mental health, including their reactions and what actions were taken to address your mental health issue/questions.                                                       96 non-null     object 
 15  Would you feel comfortable discussing a mental health issue with your coworkers?                                                                                                                                                          361 non-null    object 
 16  Have you ever discussed your mental health with coworkers?                                                                                                                                                                                360 non-null    float64
 17  Describe the conversation with coworkers you had about your mental health including their reactions.                                                                                                                                      106 non-null    object 
 18  Have you ever had a coworker discuss their or another coworker's mental health with you?                                                                                                                                                  360 non-null    float64
 19  Describe the conversation your coworker had with you about their mental health (please do not use names).                                                                                                                                 124 non-null    object 
 20  Overall, how much importance does your employer place on physical health?                                                                                                                                                                 361 non-null    float64
 21  Overall, how much importance does your employer place on mental health?                                                                                                                                                                   361 non-null    float64
 22  Do you have medical coverage (private insurance or state-provided) that includes treatment of mental health disorders?                                                                                                                    56 non-null     float64
 23  Do you know local or online resources to seek help for a mental health issue?                                                                                                                                                             56 non-null     object 
 24  <strong>If you have been diagnosed or treated for a mental health disorder, do you ever reveal this to clients or business contacts?</strong>                                                                                             56 non-null     object 
 25  If you have revealed a mental health disorder to a client or business contact, how has this affected you or the relationship?                                                                                                             21 non-null     object 
 26  <strong>If you have been diagnosed or treated for a mental health disorder, do you ever reveal this to coworkers or employees?</strong>                                                                                                   56 non-null     object 
 27  If you have revealed a mental health disorder to a coworker or employee, how has this impacted you or the relationship?                                                                                                                   56 non-null     object 
 28  Do you believe your productivity is ever affected by a mental health issue?                                                                                                                                                               56 non-null     object 
 29  If yes, what percentage of your work time (time performing primary or secondary job functions) is affected by a mental health issue?                                                                                                      41 non-null     object 
 30  <strong>Do you have previous employers?</strong>                                                                                                                                                                                          417 non-null    int64  
 31  Was your employer primarily a tech company/organization?                                                                                                                                                                                  363 non-null    float64
 32  <strong>Have your previous employers provided mental health benefits?</strong>                                                                                                                                                            363 non-null    object 
 33  <strong>Were you aware of the options for mental health care provided by your previous employers?</strong>                                                                                                                                363 non-null    object 
 34  Did your previous employers ever formally discuss mental health (as part of a wellness campaign or other official communication)?                                                                                                         363 non-null    object 
 35  Did your previous employers provide resources to learn more about mental health disorders and how to seek help?                                                                                                                           363 non-null    object 
 36  Was your anonymity protected if you chose to take advantage of mental health or substance abuse treatment resources with previous employers?                                                                                              363 non-null    object 
 37  Would you have felt more comfortable talking to your previous employer about your physical health or your mental health?                                                                                                                  363 non-null    object 
 38  Would you have been willing to discuss your mental health with your direct supervisor(s)?                                                                                                                                                 363 non-null    object 
 39  Did you ever discuss your mental health with your previous employer?                                                                                                                                                                      363 non-null    float64
 40  Describe the conversation you had with your previous employer about your mental health, including their reactions and actions taken to address your mental health issue/questions.                                                        60 non-null     object 
 41  <strong>Would you have been willing to discuss your mental health with your coworkers at previous employers?</strong>                                                                                                                     363 non-null    object 
 42  Did you ever discuss your mental health with a previous coworker(s)?                                                                                                                                                                      362 non-null    float64
 43  Describe the conversation you had with your previous coworkers about your mental health including their reactions.                                                                                                                        92 non-null     object 
 44  Did you ever have a previous coworker discuss their or another coworker's mental health with you?                                                                                                                                         363 non-null    float64
 45  Describe the conversation your coworker had with you about their mental health (please do not use names)..1                                                                                                                               79 non-null     object 
 46  Overall, how much importance did your previous employer place on physical health?                                                                                                                                                         363 non-null    float64
 47  Overall, how much importance did your previous employer place on mental health?                                                                                                                                                           363 non-null    float64
 48  Do you currently have a mental health disorder?                                                                                                                                                                                           417 non-null    object 
 49  Have you ever been diagnosed with a mental health disorder?                                                                                                                                                                               191 non-null    object 
 50  What disorder(s) have you been diagnosed with?                                                                                                                                                                                            0 non-null      float64
 51  If possibly, what disorder(s) do you believe you have?                                                                                                                                                                                    81 non-null     object 
 52  If so, what disorder(s) were you diagnosed with?                                                                                                                                                                                          188 non-null    object 
 53  Have you had a mental health disorder in the past?                                                                                                                                                                                        415 non-null    object 
 54  Have you ever sought treatment for a mental health disorder from a mental health professional?                                                                                                                                            417 non-null    int64  
 55  Do you have a family history of mental illness?                                                                                                                                                                                           417 non-null    object 
 56  If you have a mental health disorder, how often do you feel that it interferes with your work <strong>when being treated effectively?</strong>                                                                                            417 non-null    object 
 57  If you have a mental health disorder, how often do you feel that it interferes with your work <strong>when</strong> <em><strong>NOT</strong></em><strong> being treated effectively (i.e., when you are experiencing symptoms)?</strong>  417 non-null    object 
 58  Have your observations of how another individual who discussed a mental health issue made you less likely to reveal a mental health issue yourself in your current workplace?                                                             320 non-null    object 
 59  How willing would you be to share with friends and family that you have a mental illness?                                                                                                                                                 417 non-null    int64  
 60  Would you be willing to bring up a physical health issue with a potential employer in an interview?                                                                                                                                       417 non-null    object 
 61  Why or why not?                                                                                                                                                                                                                           326 non-null    object 
 62  Would you bring up your mental health with a potential employer in an interview?                                                                                                                                                          417 non-null    object 
 63  Why or why not?.1                                                                                                                                                                                                                         333 non-null    object 
 64  Are you openly identified at work as a person with a mental health issue?                                                                                                                                                                 417 non-null    int64  
 65  Has being identified as a person with a mental health issue affected your career?                                                                                                                                                         51 non-null     float64
 66  How has it affected your career?                                                                                                                                                                                                          16 non-null     float64
 67  If they knew you suffered from a mental health disorder, how do you think that team members/co-workers would react?                                                                                                                       417 non-null    int64  
 68  <strong>Have you observed or experienced an unsupportive or badly handled response to a mental health issue in your current or previous workplace?</strong>                                                                               417 non-null    object 
 69  Describe the circumstances of the badly handled or unsupportive response.                                                                                                                                                                 91 non-null     object 
 70  <strong>Have you observed or experienced supportive or well handled response to a mental health issue in your current or previous workplace?</strong>                                                                                     417 non-null    object 
 71  Describe the circumstances of the supportive or well handled response.                                                                                                                                                                    0 non-null      float64
 72  Overall, how well do you think the tech industry supports employees with mental health issues?                                                                                                                                            417 non-null    int64  
 73  Briefly describe what you think the industry as a whole and/or employers could do to improve mental health support for employees.                                                                                                         289 non-null    object 
 74  If there is anything else you would like to tell us that has not been covered by the survey questions, please use this space to do so.                                                                                                    98 non-null     object 
 75  Would you be willing to talk to one of us more extensively about your experiences with mental health issues in the tech industry? (Note that all interview responses would be used <em>anonymously</em> and only with your permission.)   417 non-null    int64  
 76  What is your age?                                                                                                                                                                                                                         417 non-null    int64  
 77  What is your gender?                                                                                                                                                                                                                      414 non-null    object 
 78  What country do you <strong>live</strong> in?                                                                                                                                                                                             417 non-null    object 
 79  What US state or territory do you <strong>live</strong> in?                                                                                                                                                                               311 non-null    object 
 80  What is your race?                                                                                                                                                                                                                        302 non-null    object 
 81  Other                                                                                                                                                                                                                                     9 non-null      object 
 82  What country do you <strong>work</strong> in?                                                                                                                                                                                             417 non-null    object 
 83  What US state or territory do you <strong>work</strong> in?                                                                                                                                                                               314 non-null    object 
 84  Start Date (UTC)                                                                                                                                                                                                                          417 non-null    object 
 85  Submit Date (UTC)                                                                                                                                                                                                                         417 non-null    object 
 86  Network ID                                                                                                                                                                                                                                417 non-null    object 
dtypes: float64(18), int64(9), object(60)
memory usage: 283.6+ KB
# Lower the column names
df.columns = df.columns.str.lower()
columns  = list(df.columns)

# Remove html tags from the column names
columns = [re.sub('<.*?>', '', column) for column in columns]
# Reassign the columns to the respective dataframes
df.columns = columns
# Drop unuseful columns
df.drop(['#', 'start date (utc)', 'network id', 'other', 'submit date (utc)'], axis=1, inplace=True)
# Add year identifying column
df['year'] = '2018'
# Write the cleaned file back
df.to_csv("./../../../datasets/cleaned_osmi_2018.csv", index=False)

Data cleaning - 2019

# Load 2019 data
df = pd.read_csv("./../../../datasets/osmi_2019.csv")
# Data preview
df.head()
*Are you self-employed?* How many employees does your company or organization have? Is your employer primarily a tech company/organization? Is your primary role within your company related to tech/IT? Does your employer provide mental health benefits as part of healthcare coverage? Do you know the options for mental health care available under your employer-provided health coverage? Has your employer ever formally discussed mental health (for example, as part of a wellness campaign or other official communication)? Does your employer offer resources to learn more about mental health disorders and options for seeking help? Is your anonymity protected if you choose to take advantage of mental health or substance abuse treatment resources provided by your employer? If a mental health issue prompted you to request a medical leave from work, how easy or difficult would it be to ask for that leave? ... Briefly describe what you think the industry as a whole and/or employers could do to improve mental health support for employees. If there is anything else you would like to tell us that has not been covered by the survey questions, please use this space to do so. Would you be willing to talk to one of us more extensively about your experiences with mental health issues in the tech industry? (Note that all interview responses would be used _anonymously_ and only with your permission.) What is your age? What is your gender? What country do you *live* in? What US state or territory do you *live* in? What is your race? What country do you *work* in? What US state or territory do you *work* in?
0 False 26-100 True True I don't know No Yes Yes I don't know Very easy ... NaN NaN False 25 Male United States of America Nebraska White United States of America Nebraska
1 False 26-100 True True Yes No No Yes Yes I don't know ... NaN NaN False 51 male United States of America Nebraska White United States of America Nebraska
2 False 26-100 True True I don't know No No I don't know I don't know Somewhat difficult ... I think opening up more conversation around th... Thank you True 27 Male United States of America Illinois White United States of America Illinois
3 False 100-500 True True I don't know No Yes Yes Yes Very easy ... NaN NaN False 37 male United States of America Nebraska White United States of America Nebraska
4 False 26-100 True True I don't know No I don't know I don't know I don't know I don't know ... NaN NaN False 46 m United States of America Nebraska White United States of America Nebraska

5 rows × 82 columns

# Data info
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 352 entries, 0 to 351
Data columns (total 82 columns):
 #   Column                                                                                                                                                                                                                            Non-Null Count  Dtype  
---  ------                                                                                                                                                                                                                            --------------  -----  
 0   *Are you self-employed?*                                                                                                                                                                                                          352 non-null    bool   
 1   How many employees does your company or organization have?                                                                                                                                                                        304 non-null    object 
 2   Is your employer primarily a tech company/organization?                                                                                                                                                                           304 non-null    object 
 3   Is your primary role within your company related to tech/IT?                                                                                                                                                                      304 non-null    object 
 4   Does your employer provide mental health benefits as part of healthcare coverage?                                                                                                                                                 304 non-null    object 
 5   Do you know the options for mental health care available under your employer-provided health coverage?                                                                                                                            278 non-null    object 
 6   Has your employer ever formally discussed mental health (for example, as part of a wellness campaign or other official communication)?                                                                                            304 non-null    object 
 7   Does your employer offer resources to learn more about mental health disorders and options for seeking help?                                                                                                                      304 non-null    object 
 8   Is your anonymity protected if you choose to take advantage of mental health or substance abuse treatment resources provided by your employer?                                                                                    304 non-null    object 
 9   If a mental health issue prompted you to request a medical leave from work, how easy or difficult would it be to ask for that leave?                                                                                              304 non-null    object 
 10  Would you feel more comfortable talking to your coworkers about your physical health or your mental health?                                                                                                                       304 non-null    object 
 11  Would you feel comfortable discussing a mental health issue with your direct supervisor(s)?                                                                                                                                       304 non-null    object 
 12  Have you ever discussed your mental health with your employer?                                                                                                                                                                    304 non-null    object 
 13  Describe the conversation you had with your employer about your mental health, including their reactions and what actions were taken to address your mental health issue/questions.                                               84 non-null     object 
 14  Would you feel comfortable discussing a mental health issue with your coworkers?                                                                                                                                                  304 non-null    object 
 15  Have you ever discussed your mental health with coworkers?                                                                                                                                                                        301 non-null    object 
 16  Describe the conversation with coworkers you had about your mental health including their reactions.                                                                                                                              119 non-null    object 
 17  Have you ever had a coworker discuss their or another coworker's mental health with you?                                                                                                                                          304 non-null    object 
 18  Describe the conversation your coworker had with you about their mental health (please do not use names).                                                                                                                         110 non-null    object 
 19  Overall, how much importance does your employer place on physical health?                                                                                                                                                         304 non-null    float64
 20  Overall, how much importance does your employer place on mental health?                                                                                                                                                           304 non-null    float64
 21  Do you have medical coverage (private insurance or state-provided) that includes treatment of mental health disorders?                                                                                                            48 non-null     object 
 22  Do you know local or online resources to seek help for a mental health issue?                                                                                                                                                     48 non-null     object 
 23  If you have been diagnosed or treated for a mental health disorder, do you ever reveal this to clients or business contacts?                                                                                                      48 non-null     object 
 24  If you have revealed a mental health disorder to a client or business contact, how has this affected you or the relationship?                                                                                                     20 non-null     object 
 25  If you have been diagnosed or treated for a mental health disorder, do you ever reveal this to coworkers or employees?                                                                                                            48 non-null     object 
 26  If you have revealed a mental health disorder to a coworker or employee, how has this impacted you or the relationship?                                                                                                           48 non-null     object 
 27  Do you believe your productivity is ever affected by a mental health issue?                                                                                                                                                       48 non-null     object 
 28  If yes, what percentage of your work time (time performing primary or secondary job functions) is affected by a mental health issue?                                                                                              37 non-null     object 
 29  *Do you have previous employers?*                                                                                                                                                                                                 352 non-null    bool   
 30  Was your employer primarily a tech company/organization?                                                                                                                                                                          296 non-null    object 
 31  Have your previous employers provided mental health benefits?                                                                                                                                                                     296 non-null    object 
 32  Were you aware of the options for mental health care provided by your previous employers?                                                                                                                                         296 non-null    object 
 33  Did your previous employers ever formally discuss mental health (as part of a wellness campaign or other official communication)?                                                                                                 296 non-null    object 
 34  Did your previous employers provide resources to learn more about mental health disorders and how to seek help?                                                                                                                   296 non-null    object 
 35  Was your anonymity protected if you chose to take advantage of mental health or substance abuse treatment resources with previous employers?                                                                                      296 non-null    object 
 36  Would you have felt more comfortable talking to your previous employer about your physical health or your mental health?                                                                                                          296 non-null    object 
 37  Would you have been willing to discuss your mental health with your direct supervisor(s)?                                                                                                                                         296 non-null    object 
 38  Did you ever discuss your mental health with your previous employer?                                                                                                                                                              296 non-null    object 
 39  Describe the conversation you had with your previous employer about your mental health, including their reactions and actions taken to address your mental health issue/questions.                                                63 non-null     object 
 40  Would you have been willing to discuss your mental health with your coworkers at previous employers?                                                                                                                              296 non-null    object 
 41  Did you ever discuss your mental health with a previous coworker(s)?                                                                                                                                                              294 non-null    object 
 42  Describe the conversation you had with your previous coworkers about your mental health including their reactions.                                                                                                                85 non-null     object 
 43  Did you ever have a previous coworker discuss their or another coworker's mental health with you?                                                                                                                                 295 non-null    object 
 44  Describe the conversation your coworker had with you about their mental health (please do not use names)..1                                                                                                                       66 non-null     object 
 45  Overall, how much importance did your previous employer place on physical health?                                                                                                                                                 296 non-null    float64
 46  Overall, how much importance did your previous employer place on mental health?                                                                                                                                                   296 non-null    float64
 47  Do you *currently* have a mental health disorder?                                                                                                                                                                                 352 non-null    object 
 48  Have you ever been *diagnosed* with a mental health disorder?                                                                                                                                                                     147 non-null    object 
 49  *What disorder(s) have you been diagnosed with?*                                                                                                                                                                                  0 non-null      float64
 50  *If possibly, what disorder(s) do you believe you have?*                                                                                                                                                                          72 non-null     object 
 51  *If so, what disorder(s) were you diagnosed with?*                                                                                                                                                                                144 non-null    object 
 52  Have you had a mental health disorder in the past?                                                                                                                                                                                349 non-null    object 
 53  Have you ever sought treatment for a mental health disorder from a mental health professional?                                                                                                                                    352 non-null    bool   
 54  Do you have a family history of mental illness?                                                                                                                                                                                   352 non-null    object 
 55  If you have a mental health disorder, how often do you feel that it interferes with your work *when being treated effectively?*                                                                                                   352 non-null    object 
 56  If you have a mental health disorder, how often do you feel that it interferes with your work *when* _*NOT*_* being treated effectively (i.e., when you are experiencing symptoms)?*                                              352 non-null    object 
 57  Have your observations of how another individual who discussed a mental health issue made you less likely to reveal a mental health issue yourself in your current workplace?                                                     282 non-null    object 
 58  How willing would you be to share with friends and family that you have a mental illness?                                                                                                                                         352 non-null    int64  
 59  Would you be willing to bring up a physical health issue with a potential employer in an interview?                                                                                                                               352 non-null    object 
 60  Why or why not?                                                                                                                                                                                                                   273 non-null    object 
 61  Would you bring up your *mental* health with a potential employer in an interview?                                                                                                                                                352 non-null    object 
 62  Why or why not?.1                                                                                                                                                                                                                 285 non-null    object 
 63  Are you openly identified at work as a person with a mental health issue?                                                                                                                                                         352 non-null    bool   
 64  Has being identified as a person with a mental health issue affected your career?                                                                                                                                                 45 non-null     object 
 65  How has it affected your career?                                                                                                                                                                                                  18 non-null     float64
 66  If they knew you suffered from a mental health disorder, how do you think that your team members/co-workers would react?                                                                                                          352 non-null    int64  
 67  Have you observed or experienced an *unsupportive or badly handled response* to a mental health issue in your current or previous workplace?                                                                                      352 non-null    object 
 68  Describe the circumstances of the badly handled or unsupportive response.                                                                                                                                                         89 non-null     object 
 69  Have you observed or experienced a *supportive or well handled response* to a mental health issue in your current or previous workplace?                                                                                          352 non-null    object 
 70  Describe the circumstances of the supportive or well handled response.                                                                                                                                                            0 non-null      float64
 71  Overall, how well do you think the tech industry supports employees with mental health issues?                                                                                                                                    352 non-null    int64  
 72  Briefly describe what you think the industry as a whole and/or employers could do to improve mental health support for employees.                                                                                                 254 non-null    object 
 73  If there is anything else you would like to tell us that has not been covered by the survey questions, please use this space to do so.                                                                                            100 non-null    object 
 74  Would you be willing to talk to one of us more extensively about your experiences with mental health issues in the tech industry? (Note that all interview responses would be used _anonymously_ and only with your permission.)  352 non-null    bool   
 75  What is your age?                                                                                                                                                                                                                 352 non-null    int64  
 76  What is your gender?                                                                                                                                                                                                              347 non-null    object 
 77  What country do you *live* in?                                                                                                                                                                                                    352 non-null    object 
 78  What US state or territory do you *live* in?                                                                                                                                                                                      204 non-null    object 
 79  What is your race?                                                                                                                                                                                                                204 non-null    object 
 80  What country do you *work* in?                                                                                                                                                                                                    352 non-null    object 
 81  What US state or territory do you *work* in?                                                                                                                                                                                      204 non-null    object 
dtypes: bool(5), float64(7), int64(4), object(66)
memory usage: 213.6+ KB
# Lower the column names
df.columns = df.columns.str.lower()
# Remove special characters from the columns of year 2019
columns  = list(df.columns)

columns = [column.replace('*', '') for column in columns]
columns = [column.replace('_', '') for column in columns]
# Assign the column names back to the dataframe
df.columns = columns
# Rename mismatched column names
df.rename(columns = {'if they knew you suffered from a mental health disorder, how do you think that your team members/co-workers would react?':
                        'if they knew you suffered from a mental health disorder, how do you think that team members/co-workers would react?'}, inplace=True)

df.rename(columns = {'have you observed or experienced a supportive or well handled response to a mental health issue in your current or previous workplace?':
                        'have you observed or experienced supportive or well handled response to a mental health issue in your current or previous workplace?'}, inplace=True)
df['year'] = '2019'
# Write the cleaned file back
df.to_csv("./../../../datasets/cleaned_osmi_2019.csv", index=False)