"""
# 2020 Kaggle ML & DS Survey
"""
"""
In this survey dataset answered by Kagglers all over the world, I am very curious to see the characteristics of kagglers from developing countries, especially in Indonesia (since I am an Indonesian myself). I would like to know if they are so different than kagglers from the U.S, Europe, India, etc.

I will compare kagglers from Indonesia to the rest of Southeast Asia and also the rest of the world. Let's see if we can find something interesting!
"""
import numpy as np
import pandas as pd

%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import matplotlib.pyplot as plt
import seaborn as sns

import warnings
warnings.filterwarnings("ignore")
data = pd.read_csv('../input/kaggle-survey-2020/kaggle_survey_2020_responses.csv')
data.head()
##Filter out the first row with questions
data = data.iloc[1:]
"""
**Distribution of countries where Kagglers who completed the survey are from:**
"""
sns.set(rc={'figure.figsize':(12,8)})
sns.set_style("whitegrid", {'axes.grid' : False})

##Country
sns.countplot(y = 'Q3', data =data, order = pd.value_counts(data['Q3']).iloc[:20].index, palette='tab10')
plt.title("Where are the Kagglers from?", fontweight="bold", fontsize=18)
plt.xlabel("")
plt.ylabel("")
plt.yticks(fontsize = 14)
plt.show()
"""
Most of the Kagglers are from <b>India</b>. The number of Kagglers from Indonesia in the dataset is more than I first expected. I will be able to use this sample for exploration. 
"""
##Gender
sns.countplot(y = 'Q2', data =data, order = pd.value_counts(data['Q2']).index, palette='tab10')
plt.title("Gender Distribution of the Kagglers", fontweight="bold", fontsize=18)
plt.xlabel("")
plt.ylabel("")
plt.yticks(fontsize = 14)
plt.show()
##Job Title
sns.countplot(y = 'Q5', data =data, order = pd.value_counts(data['Q5']).index, palette='tab10')
plt.title("What are the Kagglers working as?", fontweight="bold", fontsize=18)
plt.xlabel("")
plt.ylabel("")
plt.yticks(fontsize = 14)
plt.show()
"""
Most of the Kagglers are <b>students</b>. I will filter out the students later because I want to get to know the difference in characteristics for Kagglers that are employed.

Next, let's divide the datasets to see the comparison of Indonesian kagglers with the rest of Southeast Asia & the world:

- <b>Indonesia</b>: Indonesia only
- <b>Southeast Asia</b>: Singapore, Vietnam, Malaysia, Thailand, Phillipines
- <b>Rest of the World</b>: Other countries outside of the ones mentioned above
"""
##Filter out students 
data = data[data['Q5'] != 'Student']

##Indonesia
indo = data[data['Q3'] == 'Indonesia']

##Asia
southeast_asia_list = ['Singapore', 'Viet Nam', 'Malaysia', 'Thailand', 'Philippines']

se_asia = data[data['Q3'].isin(southeast_asia_list)]

##Rest of the world
not_included = ['Indonesia', 'Singapore', 'Viet Nam', 'Malaysia', 'Thailand', 'Philippines']

world = data[~data['Q3'].isin(not_included)]
"""
- **Age & Education level**
"""
fig, axs = plt.subplots(nrows = 3, ncols = 2, figsize=(20,10))
sns.countplot(y = 'Q1', data = indo, order = pd.value_counts(indo['Q1']).index, ax = axs[0][0], palette = 'Set1').set_title('Indonesia (Age)', fontweight="bold", size=18)
sns.countplot(y = 'Q1', data = se_asia, order = pd.value_counts(se_asia['Q1']).index, ax = axs[1][0], palette = 'Dark2').set_title('Southeast Asia (Age)', fontweight="bold", size=18)
sns.countplot(y = 'Q1', data = world, order = pd.value_counts(world['Q1']).index, ax = axs[2][0],palette = 'tab10').set_title('Rest of the World (Age)', fontweight="bold", size=18)
sns.countplot(y = 'Q4', data = indo, order = pd.value_counts(indo['Q4']).index, ax = axs[0][1], palette = 'Set1').set_title('Indonesia (Education)', fontweight="bold", size=18)
sns.countplot(y = 'Q4', data = se_asia, order = pd.value_counts(se_asia['Q4']).index, ax = axs[1][1], palette = 'Dark2').set_title('Southeast Asia (Education)', fontweight="bold", size=18)
sns.countplot(y = 'Q4', data = world, order = pd.value_counts(world['Q4']).index, ax = axs[2][1],palette = 'tab10').set_title('Rest of the World (Education)', fontweight="bold", size=18)

for ax in axs.flat:
    ax.set_ylabel('') 
    ax.set_xlabel('')
    ax.tick_params(labelsize=16)
    
plt.tight_layout()
"""
Even though most of the Kagglers from Indonesia seem younger than the rest of the world & Southeast Asia, the age difference is not that significant.

The difference can be seen in the education level where most of Kagglers from Indonesia only have a bachelor's degree, but Master's degree is the most popular education level for the other parts of the world.

There are also only few Indonesia kagglers that have Doctoral degree if compared to the rest of the world & Southeast Asia.
"""
"""
- **Job Title, Salary Range & Company Size**
"""
fig, axs = plt.subplots(nrows = 3, ncols = 3, figsize=(20,10))
sns.countplot(y = 'Q5', data = indo, order = pd.value_counts(indo['Q5']).index, ax = axs[0][0], palette = 'Set1').set_title('Indonesia (Job Title)', fontweight="bold", size=18)
sns.countplot(y = 'Q5', data = se_asia, order = pd.value_counts(se_asia['Q5']).index, ax = axs[0][1], palette = 'Dark2').set_title('Southeast Asia (Job Title)', fontweight="bold", size=18)
sns.countplot(y = 'Q5', data = world, order = pd.value_counts(world['Q5']).index, ax = axs[0][2],palette = 'tab10').set_title('Rest of the World (Job Title)', fontweight="bold", size=18)
sns.countplot(y = 'Q20', data = indo, order = pd.value_counts(indo['Q20']).index, ax = axs[1][0], palette = 'Set1').set_title('Indonesia (Company Size)', fontweight="bold", size=18)
sns.countplot(y = 'Q20', data = se_asia, order = pd.value_counts(se_asia['Q20']).index, ax = axs[1][1], palette = 'Dark2').set_title('Southeast Asia (Company Size)', fontweight="bold", size=18)
sns.countplot(y = 'Q20', data = world, order = pd.value_counts(world['Q20']).index, ax = axs[1][2],palette = 'tab10').set_title('Rest of the World (Company Size)', fontweight="bold", size=18)
sns.countplot(y = 'Q24', data = indo, order = pd.value_counts(indo['Q24']).iloc[:5].index, ax = axs[2][0], palette = 'Set1').set_title('Indonesia (Salary Range)', fontweight="bold", size=18)
sns.countplot(y = 'Q24', data = se_asia, order = pd.value_counts(se_asia['Q24']).iloc[:5].index, ax = axs[2][1], palette = 'Dark2').set_title('Southeast Asia (Salary Range)', fontweight="bold", size=18)
sns.countplot(y = 'Q24', data = world, order = pd.value_counts(world['Q24']).iloc[:5].index, ax = axs[2][2],palette = 'tab10').set_title('Rest of the World (Salary Range)', fontweight="bold", size=18)

for ax in axs.flat:
    ax.set_ylabel('') 
    ax.set_xlabel('')
    ax.tick_params(labelsize=16)
    
plt.tight_layout()
"""
There are more software engineering kagglers in the rest of Southeast Asia & the world compared to Indonesia. Also, the size of companies & salaries are also much lower in Indonesia.
"""
"""
- **Years of Coding & ML Experience**
"""
fig, axs = plt.subplots(nrows = 2, ncols = 3, figsize=(20,10))
sns.countplot(y = 'Q6', data = indo, order = pd.value_counts(indo['Q6']).index, ax = axs[0][0], palette = 'Set1').set_title('Indonesia (Years of Coding Experience)', fontweight="bold", size=18)
sns.countplot(y = 'Q6', data = se_asia, order = pd.value_counts(se_asia['Q6']).index, ax = axs[0][1], palette = 'Dark2').set_title('Southeast Asia (Years of Coding Experience)', fontweight="bold", size=18)
sns.countplot(y = 'Q6', data = world, order = pd.value_counts(world['Q6']).index, ax = axs[0][2],palette = 'tab10').set_title('Rest of the World (Years of Coding Experience)', fontweight="bold", size=18)
sns.countplot(y = 'Q15', data = indo, order = pd.value_counts(indo['Q15']).index, ax = axs[1][0], palette = 'Set1').set_title('Indonesia (Years of ML Experience)', fontweight="bold", size=18)
sns.countplot(y = 'Q15', data = se_asia, order = pd.value_counts(se_asia['Q15']).index, ax = axs[1][1], palette = 'Dark2').set_title('Southeast Asia (Years of ML Experience)', fontweight="bold", size=18)
sns.countplot(y = 'Q15', data = world, order = pd.value_counts(world['Q15']).index, ax = axs[1][2],palette = 'tab10').set_title('Rest of the World (Years of ML Experience)', fontweight="bold", size=18)

for ax in axs.flat:
    ax.set_ylabel('') 
    ax.set_xlabel('')
    ax.tick_params(labelsize=16)
    
plt.tight_layout()
"""
In terms of coding experience, most kagglers from Indonesia do not have as much experience compared to the rest of Southeast Asia & the world. Most kagglers everywhere are not that experienced in Machine Learning.
"""
"""
- **Most Popular ML Algorithms & Frameworks**
"""
##World
#Q16
world_q16 = world[['Q16_Part_1', 'Q16_Part_2', 'Q16_Part_3',
                   'Q16_Part_4', 'Q16_Part_5', 'Q16_Part_6',
                   'Q16_Part_7', 'Q16_Part_8', 'Q16_Part_9',
                   'Q16_Part_10', 'Q16_Part_11', 'Q16_Part_12', 
                   'Q16_Part_13', 'Q16_Part_14', 'Q16_Part_15',
                   'Q16_OTHER']]

world_q16 = pd.DataFrame({'Response':world_q16.apply(lambda x:x.dropna().unique()[0]), 'Count':world_q16.count()})

world_q16.sort_values(by='Count', ascending=False, inplace=True)

#Q17
world_q17 = world[['Q17_Part_1', 'Q17_Part_2', 'Q17_Part_3',
                  'Q17_Part_4', 'Q17_Part_5', 'Q17_Part_6',
                  'Q17_Part_7', 'Q17_Part_8', 'Q17_Part_9',
                  'Q17_Part_10', 'Q17_Part_11','Q17_OTHER']]

world_q17 = pd.DataFrame({'Response':world_q17.apply(lambda x:x.dropna().unique()[0]), 'Count':world_q17.count()})

world_q17.sort_values(by='Count', ascending=False, inplace=True)

##Southeast Asia
#Q16
se_asia_q16 = se_asia[['Q16_Part_1', 'Q16_Part_2', 'Q16_Part_3',
                   'Q16_Part_4', 'Q16_Part_5', 'Q16_Part_6',
                   'Q16_Part_7', 'Q16_Part_8', 'Q16_Part_9',
                   'Q16_Part_10', 'Q16_Part_11', 'Q16_Part_12', 
                   'Q16_Part_13', 'Q16_Part_14', 'Q16_Part_15',
                   'Q16_OTHER']]

se_asia_q16 = pd.DataFrame({'Response':se_asia_q16.apply(lambda x:x.dropna().unique()[0]), 'Count':se_asia_q16.count()})

se_asia_q16.sort_values(by='Count', ascending=False, inplace=True)

#Q17
se_asia_q17 = se_asia[['Q17_Part_1', 'Q17_Part_2', 'Q17_Part_3',
                  'Q17_Part_4', 'Q17_Part_5', 'Q17_Part_6',
                  'Q17_Part_7', 'Q17_Part_8', 'Q17_Part_9',
                  'Q17_Part_10', 'Q17_Part_11','Q17_OTHER']]

se_asia_q17 = pd.DataFrame({'Response':se_asia_q17.apply(lambda x:x.dropna().unique()[0]), 'Count':se_asia_q17.count()})

se_asia_q17.sort_values(by='Count', ascending=False, inplace=True)

##Indonesia
#Q16
indo_q16 = indo[['Q16_Part_1', 'Q16_Part_2', 'Q16_Part_3',
                   'Q16_Part_4', 'Q16_Part_5', 'Q16_Part_6',
                   'Q16_Part_7', 'Q16_Part_8', 'Q16_Part_9',
                   'Q16_Part_10', 'Q16_Part_11', 'Q16_Part_12', 
                   'Q16_Part_13', 'Q16_Part_14', 'Q16_Part_15',
                   'Q16_OTHER']]

indo_q16 = pd.DataFrame({'Response':indo_q16.apply(lambda x:x.dropna().unique()[0]), 'Count':indo_q16.count()})

indo_q16.sort_values(by='Count', ascending=False, inplace=True)

#Q17
indo_q17 = indo[['Q17_Part_1', 'Q17_Part_2', 'Q17_Part_3',
                  'Q17_Part_4', 'Q17_Part_5', 'Q17_Part_6',
                  'Q17_Part_7', 'Q17_Part_8', 'Q17_Part_9',
                  'Q17_Part_10', 'Q17_Part_11','Q17_OTHER']]

indo_q17 = pd.DataFrame({'Response':indo_q17.apply(lambda x:x.dropna().unique()[0]), 'Count':indo_q17.count()})

indo_q17.sort_values(by='Count', ascending=False, inplace=True)

##Q16 & Q17 Plot
fig, axs = plt.subplots(nrows = 3, ncols = 2, figsize=(20,10))
sns.barplot(y = 'Response', x='Count', data = indo_q16, order = indo_q16['Response'].iloc[:8], ax = axs[0][0], palette = 'Set1').set_title('Indonesia (Most used ML Frameworks)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = se_asia_q16, order = se_asia_q16['Response'].iloc[:8], ax = axs[1][0], palette = 'Dark2').set_title('Southeast Asia (Most used ML Frameworks)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = world_q16, order = world_q16['Response'].iloc[:8], ax = axs[2][0],palette = 'tab10').set_title('Rest of the World (Most used ML Frameworks)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = indo_q17, order = indo_q17['Response'].iloc[:8], ax = axs[0][1], palette = 'Set1').set_title('Indonesia (Most used ML Algorithms)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = se_asia_q17, order = se_asia_q17['Response'].iloc[:8], ax = axs[1][1], palette = 'Dark2').set_title('Southeast Asia (Most used ML Algorithms)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = world_q17, order = world_q17['Response'].iloc[:8], ax = axs[2][1],palette = 'tab10').set_title('Rest of the World (Most used ML Algorithms)', fontweight="bold", size=18)

for ax in axs.flat:
    ax.set_ylabel('') 
    ax.set_xlabel('')
    ax.tick_params(labelsize=16)
    
plt.tight_layout()
"""
There is not much difference here. The most popular ML frameworks for every region is scikit-learn & Tensorflow. Linear models & Random Forest are the most popular ML algorithms for all regions.
"""
"""
- **Most Popular Data Science Learning Platform & Media Sources**
"""
##World
#Q37
world_q37 = world[['Q37_Part_1', 'Q37_Part_2', 'Q37_Part_3',
                   'Q37_Part_4', 'Q37_Part_5', 'Q37_Part_6',
                   'Q37_Part_7', 'Q37_Part_8', 'Q37_Part_9',
                   'Q37_Part_10', 'Q37_Part_11','Q37_OTHER']]

world_q37 = pd.DataFrame({'Response':world_q37.apply(lambda x:x.dropna().unique()[0]), 'Count':world_q37.count()})

world_q37.sort_values(by='Count', ascending=False, inplace=True)

#Q39
world_q39 = world[['Q39_Part_1', 'Q39_Part_2', 'Q39_Part_3',
                  'Q39_Part_4', 'Q39_Part_5', 'Q39_Part_6',
                  'Q39_Part_7', 'Q39_Part_8', 'Q39_Part_9',
                  'Q39_Part_10', 'Q39_Part_11','Q39_OTHER']]

world_q39 = pd.DataFrame({'Response':world_q39.apply(lambda x:x.dropna().unique()[0]), 'Count':world_q39.count()})

world_q39.sort_values(by='Count', ascending=False, inplace=True)

##Southeast Asia
#Q37
se_asia_q37 = se_asia[['Q37_Part_1', 'Q37_Part_2', 'Q37_Part_3',
                   'Q37_Part_4', 'Q37_Part_5', 'Q37_Part_6',
                   'Q37_Part_7', 'Q37_Part_8', 'Q37_Part_9',
                   'Q37_Part_10', 'Q37_Part_11','Q37_OTHER']]

se_asia_q37 = pd.DataFrame({'Response':se_asia_q37.apply(lambda x:x.dropna().unique()[0]), 'Count':se_asia_q37.count()})

se_asia_q37.sort_values(by='Count', ascending=False, inplace=True)

#Q39
se_asia_q39 = se_asia[['Q39_Part_1', 'Q39_Part_2', 'Q39_Part_3',
                  'Q39_Part_4', 'Q39_Part_5', 'Q39_Part_6',
                  'Q39_Part_7', 'Q39_Part_8', 'Q39_Part_9',
                  'Q39_Part_10', 'Q39_Part_11','Q39_OTHER']]

se_asia_q39 = pd.DataFrame({'Response':se_asia_q39.apply(lambda x:x.dropna().unique()[0]), 'Count':se_asia_q39.count()})

se_asia_q39.sort_values(by='Count', ascending=False, inplace=True)

##Indonesia
#Q37
indo_q37 = indo[['Q37_Part_1', 'Q37_Part_2', 'Q37_Part_3',
                   'Q37_Part_4', 'Q37_Part_5', 'Q37_Part_6',
                   'Q37_Part_7', 'Q37_Part_8', 'Q37_Part_9',
                   'Q37_Part_10', 'Q37_Part_11','Q37_OTHER']]

indo_q37 = pd.DataFrame({'Response':indo_q37.apply(lambda x:x.dropna().unique()[0]), 'Count':indo_q37.count()})

indo_q37.sort_values(by='Count', ascending=False, inplace=True)

#Q39
indo_q39 = indo[['Q39_Part_1', 'Q39_Part_2', 'Q39_Part_3',
                  'Q39_Part_4', 'Q39_Part_5', 'Q39_Part_6',
                  'Q39_Part_7', 'Q39_Part_8', 'Q39_Part_9',
                  'Q39_Part_10', 'Q39_Part_11','Q39_OTHER']]

indo_q39 = pd.DataFrame({'Response':indo_q39.apply(lambda x:x.dropna().unique()[0]), 'Count':indo_q39.count()})

indo_q39.sort_values(by='Count', ascending=False, inplace=True)

##Q37 & Q39 Plot
fig, axs = plt.subplots(nrows = 3, ncols = 2, figsize=(20,10))
sns.barplot(y = 'Response', x='Count', data = indo_q37, order = indo_q37['Response'].iloc[:8], ax = axs[0][0], palette = 'Set1').set_title('Indonesia (Most Popular DS Courses)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = se_asia_q37, order = se_asia_q37['Response'].iloc[:8], ax = axs[1][0], palette = 'Dark2').set_title('Southeast Asia (Most Popular DS Courses)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = world_q37, order = world_q37['Response'].iloc[:8], ax = axs[2][0],palette = 'tab10').set_title('Rest of the World (Most Popular DS Courses)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = indo_q39, order = indo_q39['Response'].iloc[:8], ax = axs[0][1], palette = 'Set1').set_title('Indonesia (Most Popular Media Sources)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = se_asia_q39, order = se_asia_q39['Response'].iloc[:8], ax = axs[1][1], palette = 'Dark2').set_title('Southeast Asia (Most Popular Media Sources)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = world_q39, order = world_q39['Response'].iloc[:8], ax = axs[2][1],palette = 'tab10').set_title('Rest of the World (Most Popular Media Sources)', fontweight="bold", size=18)

for ax in axs.flat:
    ax.set_ylabel('') 
    ax.set_xlabel('')
    ax.tick_params(labelsize=16)
    
plt.tight_layout()
"""
In Indonesia, most Kagglers are learning from Kaggle courses. For the rest of Southeast Asia & the world, Coursera is the most popular learning platform. Kaggle, Youtube & Blogs are the most popular media source in every part.
"""
"""
#### Now we only look at the Data Scientists in the dataset
"""
##Data Scientists only
data_ds = data[data['Q5'] == 'Data Scientist']

##Indonesia
indo_ds = data_ds[data_ds['Q3'] == 'Indonesia']

##Asia
southeast_asia_list = ['Singapore', 'Viet Nam', 'Malaysia', 'Thailand', 'Philippines']

se_asia_ds = data_ds[data_ds['Q3'].isin(southeast_asia_list)]

##Rest of the world
not_included = ['Indonesia', 'Singapore', 'Viet Nam', 'Malaysia', 'Thailand', 'Philippines']

world_ds = data_ds[~data_ds['Q3'].isin(not_included)]
"""
- **Data Scientist's Tools & IDE**
"""
##World
#Q7
world_q7 = world_ds[['Q7_Part_1', 'Q7_Part_2', 'Q7_Part_3',
                   'Q7_Part_4', 'Q7_Part_5', 'Q7_Part_6',
                   'Q7_Part_7', 'Q7_Part_8', 'Q7_Part_9',
                   'Q7_Part_10', 'Q7_Part_11', 'Q7_Part_12', 'Q7_OTHER']]

world_q7 = pd.DataFrame({'Response':world_q7.apply(lambda x:x.dropna().unique()[0]), 'Count':world_q7.count()})

world_q7.sort_values(by='Count', ascending=False, inplace=True)

#Q9
world_q9 = world_ds[['Q9_Part_1', 'Q9_Part_2', 'Q9_Part_3',
                  'Q9_Part_4', 'Q9_Part_5', 'Q9_Part_6',
                  'Q9_Part_7', 'Q9_Part_8', 'Q9_Part_9',
                  'Q9_Part_10', 'Q9_Part_11','Q9_OTHER']]

world_q9 = pd.DataFrame({'Response':world_q9.apply(lambda x:x.dropna().unique()[0]), 'Count':world_q9.count()})

world_q9.sort_values(by='Count', ascending=False, inplace=True)

##Southeast Asia
#Q7
se_asia_q7 = se_asia_ds[['Q7_Part_1', 'Q7_Part_2', 'Q7_Part_3',
                   'Q7_Part_4', 'Q7_Part_5', 'Q7_Part_6',
                   'Q7_Part_7', 'Q7_Part_9','Q7_Part_10', 
                   'Q7_Part_11', 'Q7_OTHER']]

se_asia_q7 = pd.DataFrame({'Response':se_asia_q7.apply(lambda x:x.dropna().unique()[0]), 'Count':se_asia_q7.count()})

se_asia_q7.sort_values(by='Count', ascending=False, inplace=True)

#Q9
se_asia_q9 = se_asia_ds[['Q9_Part_1', 'Q9_Part_2', 'Q9_Part_3',
                  'Q9_Part_4', 'Q9_Part_5', 'Q9_Part_6',
                  'Q9_Part_7', 'Q9_Part_8', 'Q9_Part_9',
                  'Q9_Part_10', 'Q9_OTHER']]

se_asia_q9 = pd.DataFrame({'Response':se_asia_q9.apply(lambda x:x.dropna().unique()[0]), 'Count':se_asia_q9.count()})

se_asia_q9.sort_values(by='Count', ascending=False, inplace=True)

##Indonesia
#Q7
indo_q7 = indo_ds[['Q7_Part_1', 'Q7_Part_2', 'Q7_Part_3',
                   'Q7_Part_4', 'Q7_Part_5', 'Q7_Part_6',
                   'Q7_Part_7','Q7_Part_10', 'Q7_Part_11', 'Q7_OTHER']]

indo_q7 = pd.DataFrame({'Response':indo_q7.apply(lambda x:x.dropna().unique()[0]), 'Count':indo_q7.count()})

indo_q7.sort_values(by='Count', ascending=False, inplace=True)

#Q9
indo_q9 = indo_ds[['Q9_Part_1', 'Q9_Part_2', 'Q9_Part_3',
                  'Q9_Part_4', 'Q9_Part_5', 'Q9_Part_6',
                  'Q9_Part_7', 'Q9_Part_8', 'Q9_Part_9',
                  'Q9_Part_10', 'Q9_OTHER']]

indo_q9 = pd.DataFrame({'Response':indo_q9.apply(lambda x:x.dropna().unique()[0]), 'Count':indo_q9.count()})

indo_q9.sort_values(by='Count', ascending=False, inplace=True)

##Q37 & Q39 Plot
fig, axs = plt.subplots(nrows = 3, ncols = 2, figsize=(20,10))
sns.barplot(y = 'Response', x='Count', data = indo_q7, order = indo_q7['Response'].iloc[:8], ax = axs[0][0], palette = 'Set1').set_title('Indonesia (Most Used Programming Tools)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = se_asia_q7, order = se_asia_q7['Response'].iloc[:8], ax = axs[1][0], palette = 'Dark2').set_title('Southeast Asia (Most Used Programming Tools)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = world_q7, order = world_q7['Response'].iloc[:8], ax = axs[2][0],palette = 'tab10').set_title('Rest of the World (Most Used Programming Tools)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = indo_q9, order = indo_q9['Response'].iloc[:8], ax = axs[0][1], palette = 'Set1').set_title('Indonesia (Most Popular IDE)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = se_asia_q9, order = se_asia_q9['Response'].iloc[:8], ax = axs[1][1], palette = 'Dark2').set_title('Southeast Asia (Most Popular IDE)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = world_q9, order = world_q9['Response'].iloc[:8], ax = axs[2][1],palette = 'tab10').set_title('Rest of the World (Most Popular IDE)', fontweight="bold", size=18)

for ax in axs.flat:
    ax.set_ylabel('') 
    ax.set_xlabel('')
    ax.tick_params(labelsize=16)
    
plt.tight_layout()
"""
An intereseting thing to know here is that R is not as popular in Indonesia as compared to the rest of Southeast Asia & the world. Python in Jupyter Notebooks is still the most used programming tool & IDE everywhere.
"""
"""
- **Data Scientist's Cloud & ML/AI Cloud Services**
"""
##World
#Q26
world_q26 = world_ds[['Q26_A_Part_1', 'Q26_A_Part_2', 'Q26_A_Part_3',
                   'Q26_A_Part_4', 'Q26_A_Part_5', 'Q26_A_Part_6',
                   'Q26_A_Part_7', 'Q26_A_Part_8', 'Q26_A_Part_9',
                   'Q26_A_Part_10', 'Q26_A_Part_11', 'Q26_A_OTHER']]

world_q26 = pd.DataFrame({'Response':world_q26.apply(lambda x:x.dropna().unique()[0]), 'Count':world_q26.count()})

world_q26.sort_values(by='Count', ascending=False, inplace=True)

#Q28
world_q28 = world_ds[['Q28_A_Part_1', 'Q28_A_Part_2', 'Q28_A_Part_3',
                  'Q28_A_Part_4', 'Q28_A_Part_5', 'Q28_A_Part_6',
                  'Q28_A_Part_7', 'Q28_A_Part_8', 'Q28_A_Part_9',
                  'Q28_A_Part_10', 'Q28_A_OTHER']]

world_q28 = pd.DataFrame({'Response':world_q28.apply(lambda x:x.dropna().unique()[0]), 'Count':world_q28.count()})

world_q28.sort_values(by='Count', ascending=False, inplace=True)

##Southeast Asia
#Q26
se_asia_q26 = se_asia_ds[['Q26_A_Part_1', 'Q26_A_Part_2', 'Q26_A_Part_3',
                   'Q26_A_Part_4', 'Q26_A_Part_7', 'Q26_A_Part_8', 
                   'Q26_A_Part_10', 'Q26_A_Part_11', 'Q26_A_OTHER']]

se_asia_q26 = pd.DataFrame({'Response':se_asia_q26.apply(lambda x:x.dropna().unique()[0]), 'Count':se_asia_q26.count()})

se_asia_q26.sort_values(by='Count', ascending=False, inplace=True)

#Q28
se_asia_q28 = se_asia_ds[['Q28_A_Part_1', 'Q28_A_Part_3', 'Q28_A_Part_5', 
                       'Q28_A_Part_6','Q28_A_Part_7', 'Q28_A_Part_8', 
                       'Q28_A_Part_9', 'Q28_A_Part_10', ]]

se_asia_q28 = pd.DataFrame({'Response':se_asia_q28.apply(lambda x:x.dropna().unique()[0]), 'Count':se_asia_q28.count()})

se_asia_q28.sort_values(by='Count', ascending=False, inplace=True)

##Indonesia
#Q26
indo_q26 = indo_ds[['Q26_A_Part_1', 'Q26_A_Part_2', 'Q26_A_Part_3',
                   'Q26_A_Part_4', 'Q26_A_Part_5', 'Q26_A_Part_6',
                   'Q26_A_Part_8', 'Q26_A_Part_9','Q26_A_OTHER']]

indo_q26 = pd.DataFrame({'Response':indo_q26.apply(lambda x:x.dropna().unique()[0]), 'Count':indo_q26.count()})

indo_q26.sort_values(by='Count', ascending=False, inplace=True)

#Q28
indo_q28 = indo_ds[['Q28_A_Part_2', 'Q28_A_Part_4', 'Q28_A_Part_5', 
                 'Q28_A_Part_6','Q28_A_Part_7', 'Q28_A_Part_8', 
                 'Q28_A_Part_9','Q28_A_Part_10', 'Q28_A_OTHER']]

indo_q28 = pd.DataFrame({'Response':indo_q28.apply(lambda x:x.dropna().unique()[0]), 'Count':indo_q28.count()})

indo_q28.sort_values(by='Count', ascending=False, inplace=True)

##Q37 & Q39 Plot
fig, axs = plt.subplots(nrows = 3, ncols = 2, figsize=(20,10))
sns.barplot(y = 'Response', x='Count', data = indo_q26, order = indo_q26['Response'].iloc[:8], ax = axs[0][0], palette = 'Set1').set_title('Indonesia (Most Popular Cloud Services)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = se_asia_q26, order = se_asia_q26['Response'].iloc[:8], ax = axs[1][0], palette = 'Dark2').set_title('Southeast Asia (Most Popular Cloud Services)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = world_q26, order = world_q26['Response'].iloc[:8], ax = axs[2][0],palette = 'tab10').set_title('Rest of the World (Most Popular Cloud Services)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = indo_q28, order = indo_q28['Response'].iloc[:8], ax = axs[0][1], palette = 'Set1').set_title('Indonesia (Most Popular Cloud ML/AI Services)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = se_asia_q28, order = se_asia_q28['Response'].iloc[:8], ax = axs[1][1], palette = 'Dark2').set_title('Southeast Asia (Most Popular Cloud ML/AI Services)', fontweight="bold", size=18)
sns.barplot(y = 'Response', x='Count', data = world_q28, order = world_q28['Response'].iloc[:8], ax = axs[2][1],palette = 'tab10').set_title('Rest of the World (Most Popular Cloud ML/AI Services)', fontweight="bold", size=18)

for ax in axs.flat:
    ax.set_ylabel('') 
    ax.set_xlabel('')
    ax.tick_params(labelsize=16)
    
plt.tight_layout()
"""
Unsurprisingly, AWS & GCP dominates the cloud market everywhere. What is interesting here is that AWS Sagemaker is not seen as the top ML cloud service in Indonesia, unlike the rest of Southeast Asia & the world. GCP AI Platform is most popular in Indonesia.
"""
"""
Thanks for reading until the end. If you find this kernel interesting or helpful, please help by upvoting this kernel! :D
"""