<jupyter_start><jupyter_text>"[Kaggle 설문놀이] Kaggle Machine Learning & Data Science Survey"> "2021 Kaggle ML-DL Survey Dataset"- toc: true- branch: master- badges: true- comments: true- author: Rauk- categories: [SSUDA, EDA]<jupyter_code>from google.colab import drive
drive.mount('/content/drive')
from google.colab import files
files.upload()

!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!chmod 600 /root/.kaggle/kaggle.json
!kaggle competitions download -c kaggle-survey-2021
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
import seaborn as sns
!ls
!unzip kaggle_survey_2021_responses.csv.zip
response = pd.read_csv("kaggle_survey_2021_responses.csv")
response.head()
response.describe()
plt.rcParams['figure.dpi'] = 300
fig = plt.figure(figsize=(5, 8), facecolor='#FEFBF3')
gs = fig.add_gridspec(2, 1)
gs.update(wspace=1.5, hspace=1.1)

##########COUNTRY##########
temp = pd.DataFrame(response.groupby('Q3', dropna=False).size()).reset_index()
temp.columns = ['country', 'amount']
temp['pct'] = temp['amount']*100/temp.amount.sum()
temp = temp.sort_values('amount', ascending=False).reset_index()
temp = temp.query("amount>1")
temp.loc[1, 'country'] = 'USA'
temp.loc[8, 'country'] = 'UK'
temp.loc[27, 'country'] = 'Iran'
for i in range(31,66):
    temp.at[i,'country'] = 'Other'

temp = temp.groupby('country').sum()
temp = temp.query("country!='Other'")
temp = temp.query("pct>1")
temp = temp.sort_values('amount', ascending=False).reset_index()
temp = temp[0:20]

background_color = "#FEFBF3"
color_map = ["#90AACB" for _ in range(20)]
color_map[0] = "#F2A154" #F2A154 79B4B7
sns.set_palette(sns.color_palette(color_map))

ax0 = fig.add_subplot(gs[0, 0])
ax0.set_facecolor(background_color)
ax0.set(xlim=(0, 40))
ax0.set(ylim=(0, 20))
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
ax0_sns = sns.barplot(ax=ax0, y=temp['country'], x=temp['pct'], 
                      zorder=2, linewidth=0, orient='h', saturation=0.9, alpha=0.7)
ax0_sns.grid(which='major', axis='x', zorder=0, color='#EEEEEE', linewidth=0.2)

#format axis
ax0_sns.set_xlabel("Percentage",fontsize=3, weight='semibold')
ax0_sns.set_ylabel("Country",fontsize=3, weight='semibold')
ax0_sns.tick_params(labelsize=3, width=0.3, length=1)

#title
x0, x1 = ax0.get_xlim()
y0, y1 = ax0.get_ylim()
ax0.text(x0, y1-1.5, 'Top 20 Countries', fontsize=4, ha='left', va='top', weight='bold')
ax0.text(x0, y1-0.8, 'Q3: In which country do you currently reside?', fontsize=3, ha='left', va='top')

# data label
i=0
for p in ax0.patches:
    value = f'{p.get_width():.1f}%'
    if i<7:
        x1 = -1
    else:
        x1 = .8
    x = p.get_x() + p.get_width() + x1
    i+=1
    y = p.get_y() + p.get_height() / 2 
    ax0.text(x, y, value, ha='center', va='center', fontsize=2, weight='semibold') 

#x_format = ticker.PercentFormatter()
#ax0.xaxis.set_major_formatter(x_format)

plt.show()<jupyter_output><empty_output><jupyter_text>한중일 인간들을 살펴보자<jupyter_code>kor = response[response.Q3 == "South Korea"]
jpn = response[response.Q3 == "Japan"]
chn = response[response.Q3 == "China"]
comb = pd.concat([kor,jpn,chn], axis = 0)
print("한국인 응답자 수:",len(kor),"명")
print("중국인 응답자 수:",len(jpn),"명")
print("일본인 응답자 수:",len(chn),"명")<jupyter_output>한국인 응답자 수: 359 명
중국인 응답자 수: 921 명
일본인 응답자 수: 814 명<jupyter_text>성별은 남성이 제일 많음- Man- Woman- Nonbinary- Prefer not to say(선택하고 싶지 않음)- Prefer to self-describe(?)<jupyter_code>plt.figure(figsize = (8,7))
sns.countplot(kor.Q2)
plt.xticks(rotation = 45)<jupyter_output>/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning<jupyter_text>학력<jupyter_code>##########EDUCATION##########
temp = kor.groupby('Q4', dropna=False).size().reset_index()
temp.columns = ['education', 'amount']
temp = temp.query("amount>1")
temp.loc[4, 'education'] = 'High school'
temp.loc[6, 'education'] = 'Some college'
temp['pct'] = temp['amount']*100/temp.amount.sum()
temp = temp.sort_values('amount', ascending=False)

plt.rcParams['figure.dpi'] = 300
fig = plt.figure(figsize=(3, 5), facecolor='#FEFBF3')
gs = fig.add_gridspec(2, 1)
gs.update(wspace=1.5, hspace=1.1)

background_color = "#FEFBF3"
color_map = ["#90AACB" for _ in range(7)]
color_map[0] = "#F2A154"
sns.set_palette(sns.color_palette(color_map))

ax0 = fig.add_subplot(gs[1, 0])
ax0.set_facecolor(background_color)
ax0.set(xlim=(0, 45))
ax0.set(ylim=(0, 7))
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
ax0_sns = sns.barplot(ax=ax0, y=temp['education'], x=temp['pct'], 
                      zorder=2, linewidth=0, orient='h', saturation=0.9, alpha=0.7)
ax0_sns.grid(which='major', axis='x', zorder=0, color='#EEEEEE', linewidth=0.2)

#format axis
ax0_sns.set_xlabel("Percentage",fontsize=3, weight='semibold')
ax0_sns.set_ylabel("Education",fontsize=3, weight='semibold')
ax0_sns.tick_params(labelsize=3, width=0.3, length=1)

#title
x0, x1 = ax0_sns.get_xlim()
y0, y1 = ax0_sns.get_ylim()
ax0_sns.text(x0, y1-1.2, 'Higher Education', fontsize=4, ha='left', va='top', weight='bold')
ax0_sns.text(x0, y1-0.6, 'What is the highest level of formal education that you have attained or plan to attain within the next 2 years?', fontsize=3, ha='left', va='top')

# data labe
i=0
for p in ax0.patches:
    value = f'{p.get_width():.1f}%'
    if i<4:
        x1 = -1.5
    else:
        x1 = 1.2
    x = p.get_x() + p.get_width() + x1
    i+=1
    y = p.get_y() + p.get_height() / 2 
    ax0.text(x, y, value, ha='center', va='center', fontsize=3, weight='semibold') 

#x_format = ticker.PercentFormatter()
#ax0.xaxis.set_major_formatter(x_format)

plt.show()
plt.rcParams['figure.dpi'] = 300
fig = plt.figure(figsize=(4, 6), facecolor='#FEFBF3')
gs = fig.add_gridspec(2, 1)
gs.update(wspace=1.5, hspace=1.1)

##########AGE##########
temp = kor.groupby('Q1', dropna=False).size().reset_index()
temp.columns = ['answer', 'amount']
temp['pct'] = temp['amount']*100/temp.amount.sum()
#temp = temp.sort_values('pct', ascending=False)

background_color = "#FEFBF3"
color_map = ["#90AACB" for _ in range(75)]
color_map[0] = "#F2A154"
sns.set_palette(sns.color_palette(color_map))

ax0 = fig.add_subplot(gs[1, 0])
ax0.set_facecolor(background_color)
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
ax0 = sns.barplot(ax=ax0, y=temp['pct'], x=temp['answer'], zorder=2, linewidth=0, saturation=1, alpha=0.7)
fillwidth = np.array([-0.5,2.5])
ax0.fill_between(fillwidth, np.max(temp['pct']+2), color='#FFE699', alpha=0.5, zorder=2, linewidth=0)
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

ax0.grid(which='major', axis='y', zorder=0, color='#EEEEEE', lw=0.3)

#title
x0, x1 = ax0.get_xlim()
y0, y1 = ax0.get_ylim() 

ax0.text(x0, y1+3, 'Age', fontsize=4, ha='left', va='top', weight='bold')
ax0.text(x0, y1+1.8, 'What is your age (# years)?', fontsize=3, ha='left', va='top')

# data label
i=0
for p in ax0.patches:
    value = f'{p.get_height():.1f}%'
    if i<8:
        y1 = -.6
    else:
        y1 = .5
    i+=1
    x = p.get_x() + p.get_width() / 2 
    y = p.get_y() + p.get_height() + y1
    ax0.text(x, y, value, ha='center', va='center', fontsize=2.5, weight='semibold') 

#format axis
ax0.set_xlabel("Age",fontsize=3, weight='semibold')
ax0.set_ylabel("Percentage",fontsize=3, weight='semibold')
ax0.tick_params(labelsize=3, width=0.3, length=1)
#plt.xticks(rotation=90)

plt.show()
plt.rcParams['figure.dpi'] = 300
fig = plt.figure(figsize=(4, 6), facecolor='#FEFBF3')
gs = fig.add_gridspec(2, 1)
gs.update(wspace=1.5, hspace=1.1)

##########AGEGENDER##########
temp = pd.DataFrame(comb.groupby(["Q1", "Q2"], dropna=False).size())
temp = temp.query("Q2=='Man' | Q2=='Woman'")
temp = temp.reset_index()
temp.columns = ['age', 'gender', 'amount']
temp['pct'] = temp['amount']*100/temp.amount.sum()

background_color = "#FEFBF3"
color_map = ["#90AACB" for _ in range(75)]
color_map[0] = "#F2A154"
sns.set_palette(sns.color_palette(color_map))

ax0 = fig.add_subplot(gs[1, 0])
ax0.set_facecolor(background_color)
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
ax0 = sns.barplot(ax=ax0, y=temp['pct'], x=temp['age'], hue=temp['gender'], zorder=2, linewidth=0, saturation=0.9, alpha=0.7, animated=True)
fillwidth1 = np.array([-0.5,2.5])
ax0.fill_between(fillwidth1, 16, color='#7C9473', alpha=0.3, zorder=2, linewidth=0)
fillwidth2 = np.array([2.5,6.5])
ax0.fill_between(fillwidth2, 12, color='#CFDAC8', alpha=0.3, zorder=2, linewidth=0)
fillwidth3 = np.array([6.5,10.5])
ax0.fill_between(fillwidth3, 4, color='#E8EAE6', alpha=0.3, zorder=2, linewidth=0)

yline = 1
plt.axvline(-0.5, linewidth=0.3, ymax=yline, linestyle='dashed', color='#90AACB', alpha=0.5)
plt.axvline(2.5, linewidth=0.3, ymax=yline, linestyle='dashed', color='#90AACB', alpha=0.5)
plt.axvline(6.5, linewidth=0.3, ymax=yline*.75, linestyle='dashed', color='#90AACB', alpha=0.5)
plt.axvline(10.5, linewidth=0.3, ymax=yline*.25, linestyle='dashed', color='#90AACB', alpha=0.5)

for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

ax0.grid(which='major', axis='y', zorder=0, color='#EEEEEE', lw=0.3)

#title
x0, x1 = ax0.get_xlim()
y0, y1 = ax0.get_ylim() 

ax0.text(x0, y1+2, 'Age by Gender', fontsize=4, ha='left', va='top', weight='bold')
ax0.text(x0, y1+1, 'What is your age (# years)?', fontsize=3, ha='left', va='top')

# data label
i=0
for p in ax0.patches:
    value = f'{p.get_height():.1f}%'
    if i<8:
        y1 = -.6
    else:
        y1 = .5
    i+=1
    x = p.get_x() + p.get_width() / 2 
    y = p.get_y() + p.get_height() + y1
    ax0.text(x, y, value, ha='center', va='center', fontsize=2, weight='semibold') 

#legend
ax0.legend(loc="upper right", prop={'size': 2}, frameon=False, ncol=5, title_fontsize=3, title='Gender')

#format axis
ax0.set_xlabel("Age",fontsize=3, weight='semibold')
ax0.set_ylabel("Percentage",fontsize=3, weight='semibold')
ax0.tick_params(labelsize=3, width=0.3, length=1)

plt.show()<jupyter_output>posx and posy should be finite values
posx and posy should be finite values<jupyter_text>- Python- R- SQL- C- C++- Java- Javascript- Julia- Swift- Bash- MATLAB- None- Other<jupyter_code>##########PROGRAMMINGLANGUAGE##########
col = 7
result=pd.DataFrame()
for col in range(col, col+13):
    choice = kor.iloc[0:1, col:col+1].to_string()
    lang = choice[choice.find('ce -')+5:len(choice)]
    grouped = kor.iloc[:, -1].groupby(kor.iloc[:, col])
    data = {"language": lang, "amount": grouped.size()[0]}
    result = result.append(data, ignore_index=True)

total = result['amount'].sum()
result = result.query("language!='None' & language!='Other'")
result['pct'] = result['amount']*100/total
temp = result
temp = temp.sort_values('pct', ascending=False)

plt.rcParams['figure.dpi'] = 300
fig = plt.figure(figsize=(3, 8), facecolor='#FEFBF3')
gs = fig.add_gridspec(2, 1)
gs.update(wspace=1.5, hspace=1.1)

background_color = "#FEFBF3"
color_map = ["#90AACB" for _ in range(75)]
color_map[0] = "#F2A154"
sns.set_palette(sns.color_palette(color_map))

ax0 = fig.add_subplot(gs[1, 0])
ax0.set_facecolor(background_color)
ax0.set(xlim=(0, 40))
ax0.set(ylim=(0, 11))
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
ax0 = sns.barplot(ax=ax0, y=temp['language'], x=temp['pct'], 
                      zorder=2, linewidth=0, orient='h', saturation=0.9, alpha=0.7)

ax0.grid(which='major', axis='x', zorder=0, color='#CDD0CB', linewidth=0.3, alpha=0.5)
ax0.grid(which='major', axis='y', zorder=0, color='#E8EAE6', linewidth=10.5, alpha=0.7)

#format axis
ax0.set_xlabel("Percentage",fontsize=3, weight='semibold')
ax0.set_ylabel("Programming Language",fontsize=3, weight='semibold')
ax0.tick_params(labelsize=3, width=0.3, length=1)

#title
x0, x1 = ax0.get_xlim()
y0, y1 = ax0.get_ylim()
ax0.text(x0, y1-1.5, 'Programming Language', fontsize=4, ha='left', va='top', weight='bold')
ax0.text(x0, y1-1, 'What programming languages do you use on a regular basis?', fontsize=3, ha='left', va='top')

# data label
i=0
for p in ax0.patches:
    value = f'{p.get_width():.1f}%'
    if i<7:
        x1 = -1.2
    else:
        x1 = 1.2
    
    i+=1
    x = p.get_x() + p.get_width() + x1
    y = p.get_y() + p.get_height() / 2 
    ax0.text(x, y, value, ha='center', va='center', fontsize=2.5, weight='semibold') 


plt.show()
##########JOBTITLE##########
temp = pd.DataFrame(.groupby('Q5', dropna=False).size()).reset_index()
temp.columns = ['jobtitle', 'amount']
temp = temp.query("amount>1")
temp = temp.query("jobtitle!='Other'")
temp['pct'] = temp['amount']*100/temp.amount.sum()
temp = temp.sort_values('amount', ascending=False).reset_index()
temp = temp.drop('index', axis=1)

plt.rcParams['figure.dpi'] = 400
fig = plt.figure(figsize=(6, 6), facecolor='#FEFBF3')
gs = fig.add_gridspec(2, 2)
gs.update(wspace=0.2, hspace=1.5)
background_color = "#FEFBF3"
color_map = ["#90AACB" for _ in range(14)]
color_map[0] = "#F2A154"
sns.set_palette(sns.color_palette(color_map))

ax0 = fig.add_subplot(gs[0, 0])
ax0.set(xlim=(-1, 14))
ax0.set(ylim=(-2, 35))
ax0.set_facecolor(background_color)
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
ax0.scatter(x=temp['jobtitle'], y=temp['pct'], s=40, color=color_map, zorder=3, alpha=0.7, lw=0.3)
ax0.grid(which='major', axis='x', zorder=0, color='#E8EAE6', linewidth=7.2, alpha=0.7)
ax0.grid(which='major', axis='y', zorder=0, color='#CDD0CB', linewidth=0.2, alpha=0.5)

#data label
y = temp['pct']
z = temp['jobtitle']
n = temp['pct']
for i, txt in enumerate(n):
    txt = f'{y[i]:.1f}%'
    ax0.annotate(txt, (z[i], y[i]), ha='center', va='center', fontsize=1.8, weight='semibold', color="#FBFBFB")


#format axis
ax0.set_xlabel("Job Title",fontsize=2, weight='semibold')
ax0.set_ylabel("Percentage",fontsize=2, weight='semibold')
ax0.tick_params(labelsize=2, width=0.3, length=1)
plt.setp( ax0.xaxis.get_majorticklabels(), rotation=45, ha="right" )

#title
x0, x1 = ax0.get_xlim()
y0, y1 = ax0.get_ylim()
ax0.text(x0, y1+3.5, 'Job Title', fontsize=4, ha='left', va='top', weight='bold')
ax0.text(x0, y1+1.5, 'Select the title most similar to your current role (or most recent title if retired)', fontsize=2, ha='left', va='top')

plt.show()
####WRITTINGCODEEXPERIENCE##########
# responses_data[responses_data.columns[34]][0]
temp = pd.DataFrame(kor.groupby(["Q6", "Q2"], dropna=False).size())
temp = temp.query("Q2=='Man' | Q2=='Woman'")
temp = temp.reset_index()
temp.columns = ['experience', 'gender', 'amount']
temp['pct'] = temp['amount']*100/temp.amount.sum()
custom_dict = {'I have never written code': 0, '< 1 years': 1, '1-3 years': 2, '3-5 years': 3, '5-10 years': 4, '10-20 years': 5, '20+ years': 6, 'Never': 7}
#temp = temp.sort_values(by=['experience'], key=lambda x: x.map(custom_dict))
temp = temp.sort_values(by=['experience'], ascending=False, key=lambda x: x.map(custom_dict)).reset_index()
#temp1 = temp.query("gender=='Man'")

plt.rcParams['figure.dpi'] = 300
fig = plt.figure(figsize=(8, 2), facecolor='#FEFBF3')
gs = fig.add_gridspec(1, 2)
gs.update(wspace=0.3, hspace=1)

background_color = "#FEFBF3"
color_map1 = ["#90AACB" for _ in range(7)]
color_map1[4] = "#E26A2C"
sns.set_palette(sns.color_palette(color_map1))

ax0 = fig.add_subplot(gs[0, 0])
ax0.set_facecolor(background_color)
ax0.set(xlim=(-2, 30))
ax0.set(ylim=(-1, 7))
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
temp1 = temp.query("gender=='Man'")
ax0.scatter(x=temp1['pct'], y=temp1['experience'], s=63, color=color_map1, zorder=3, linewidth=0, alpha=0.9)

ax0.grid(which='major', axis='x', zorder=0, color='#CDD0CB', linewidth=0.3, alpha=0.5)
ax0.grid(which='major', axis='y', zorder=0, color='#E8EAE6', linewidth=8, alpha=0.7)

color_map2 = ["#ADC2A9" for _ in range(7)]
color_map2[4] = "#FDA65D"
temp2 = temp.query("gender=='Woman'")
ax0.scatter(x=temp2['pct'], y=temp2['experience'], s=60, color=color_map2, zorder=3, linewidth=0.3, alpha=0.7)

#data label
y = temp['experience']
z = temp['pct']
n = temp['pct']
for i, txt in enumerate(n):
    label = f'{txt:.1f}%'
    ax0.annotate(label, (z[i], y[i]), ha='center', va='center', fontsize=2, weight='semibold')    

#red_patch = mpatches.Patch(color='#90AACB', label='Man')
#blue_patch = mpatches.Patch(color='#ADC2A9', label='Woman')
#ax0.legend(handles=[red_patch, blue_patch], loc='upper right', frameon=False, fontsize=3, ncol=2)

#format axis
ax0.set_ylabel("Writting Code Experience",fontsize=3, weight='semibold')
ax0.tick_params(labelsize=3, width=0.3, length=1)

#title
x0, x1 = ax0.get_xlim()
y0, y1 = ax0.get_ylim()
ax0.text(x0, y1+1.2, 'Writting Code Experience', fontsize=4, ha='left', va='top', weight='bold')
ax0.text(x0, y1+0.8, "For how many years have you been writing code and/or programming?", fontsize=3, ha='left', va='top')
ax0.text(x0+15, y0-1.5, "Percentage", fontsize=3, ha='center', va='center', weight='bold')


plt.show()
# Hosted Notebooks
# Which of the following hosted notebook products do you use on a regular basis?
col = 34
result=pd.DataFrame()
for col in range(col, col+17):
    choice = kor.iloc[0:1, col:col+1].to_string()
    question = choice[choice.find('ce -')+5:len(choice)]
    grouped = kor.iloc[:, -1].groupby(kor.iloc[:, col])
    data = {"question": question, "amount": grouped.size()[0]}
    result = result.append(data, ignore_index=True)
    
result = result.query("question!='None' & question!='Other'")
result['pct'] = result['amount']*100/result.amount.sum()
result = result.sort_values('pct', ascending=False).reset_index()
result = result.drop('index', axis=1)
temp=result

plt.rcParams['figure.dpi'] = 300
fig = plt.figure(figsize=(3, 9), facecolor='#FEFBF3')
gs = fig.add_gridspec(2, 1)
gs.update(wspace=1.5, hspace=1.1)

background_color = "#FEFBF3"
color_map = ["#90AACB" for _ in range(75)]
color_map[0] = "#F2A154"
sns.set_palette(sns.color_palette(color_map))

ax0 = fig.add_subplot(gs[1, 0])
ax0.set_facecolor(background_color)
ax0.set(xlim=(0, 40))
ax0.set(ylim=(0, 11))
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
ax0 = sns.barplot(ax=ax0, y=temp['question'], x=temp['pct'], 
                      zorder=2, linewidth=0, orient='h', saturation=0.9, alpha=0.7)

ax0.grid(which='major', axis='x', zorder=0, color='#CDD0CB', linewidth=0.3, alpha=0.5)
ax0.grid(which='major', axis='y', zorder=0, color='#E8EAE6', linewidth=9, alpha=0.7)

#format axis
ax0.set_xlabel("Percentage",fontsize=3, weight='semibold')
ax0.set_ylabel("Notebooks",fontsize=3, weight='semibold')
ax0.tick_params(labelsize=3, width=0.3, length=1)

#title
x0, x1 = ax0.get_xlim()
y0, y1 = ax0.get_ylim()
ax0.text(x0, y1-1.5, 'Data Science Notebooks', fontsize=4, ha='left', va='top', weight='bold')
ax0.text(x0, y1-1, 'Which of the following hosted notebook products do you use on a regular basis?', fontsize=3, ha='left', va='top')

# data label
i=0
for p in ax0.patches:
    value = f'{p.get_width():.1f}%'
    if i<7:
        x1 = -1.2
    else:
        x1 = 1.2
    
    i+=1
    x = p.get_x() + p.get_width() + x1
    y = p.get_y() + p.get_height() / 2 
    ax0.text(x, y, value, ha='center', va='center', fontsize=2.5, weight='semibold') 

plt.show()
# Where do you publicly share your data analysis or machine learning applications?
col = 233
result=pd.DataFrame()
for col in range(col, col+10):
    choice = comb.iloc[0:1, col:col+1].to_string()
    answer = choice[choice.find('ce -')+5:len(choice)]
    grouped = comb.iloc[:, -1].groupby(comb.iloc[:, col])
    data = {"answer": answer, "amount": grouped.size()[0]}
    result = result.append(data, ignore_index=True)

total = result['amount'].sum()
result = result.query("answer!='No / None' and answer!='None' and answer!='Other' and answer!='I do not share my work publicly'")
result['pct'] = result['amount']*100/total
temp = result
temp = temp.sort_values('pct', ascending=False)

plt.rcParams['figure.dpi'] = 300
fig = plt.figure(figsize=(3, 8), facecolor='#FEFBF3')
gs = fig.add_gridspec(2, 1)
gs.update(wspace=1.5, hspace=1.1)

background_color = "#FEFBF3"
color_map = ["#90AACB" for _ in range(75)]
color_map[0] = "#F2A154"
sns.set_palette(sns.color_palette(color_map))

ax0 = fig.add_subplot(gs[1, 0])
ax0.set_facecolor(background_color)
ax0.set(xlim=(0, 40))
ax0.set(ylim=(0, 11))
for s in ["right", "top"]:
    ax0.spines[s].set_visible(False)

#graph
ax0 = sns.barplot(ax=ax0, y=temp['answer'], x=temp['pct'], 
                      zorder=2, linewidth=0, orient='h', saturation=0.9, alpha=0.7)

ax0.grid(which='major', axis='x', zorder=0, color='#CDD0CB', linewidth=0.3, alpha=0.5)
ax0.grid(which='major', axis='y', zorder=0, color='#E8EAE6', linewidth=14, alpha=0.7)

#format axis
ax0.set_xlabel("Percentage",fontsize=3, weight='semibold')
ax0.set_ylabel("Platforms",fontsize=3, weight='semibold')
ax0.tick_params(labelsize=3, width=0.3, length=1)

#title
x0, x1 = ax0.get_xlim()
y0, y1 = ax0.get_ylim()
ax0.text(x0, y1-1, 'Share EDA', fontsize=4, ha='left', va='top', weight='bold')
ax0.text(x0, y1-0.6, 'Where do you publicly share your data analysis or machine learning applications?', fontsize=3, ha='left', va='top')

# data label
i=0
for p in ax0.patches:
    value = f'{p.get_width():.1f}%'
    if i<5:
        x1 = -1.2
    else:
        x1 = 1.2
    
    i+=1
    x = p.get_x() + p.get_width() + x1
    y = p.get_y() + p.get_height() / 2 
    ax0.text(x, y, value, ha='center', va='center', fontsize=2.5, weight='semibold') 

x_format = ticker.PercentFormatter()
ax0.xaxis.set_major_formatter(x_format)

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20626151012891344, 'fraction_numerical': 0.05165745856353591, 'mean_word_length': 5.373532863849765, 'pattern_counts': {'":': 6, '<': 26, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '649044', 'license': 'Apache-2.0', 'n_tokens_mistral': 9566, 'n_tokens_neox': 9252, 'n_words': 1766, 'path': '_notebooks/2021-12-19-Kaggle_Machine_Learning_&_Data_Science_Survey.ipynb', 'repo_name': 'RaukRauk/ML-DL', 'size': '21720'}