{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-11T21:50:37.448739Z","iopub.execute_input":"2022-08-11T21:50:37.449115Z","iopub.status.idle":"2022-08-11T21:50:37.458919Z","shell.execute_reply.started":"2022-08-11T21:50:37.449084Z","shell.execute_reply":"2022-08-11T21:50:37.457688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ndf=pd.read_csv(\"../input/kaggle-survey-2021/kaggle_survey_2021_responses.csv\")\nprint(df.head())\n","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:50:43.170116Z","iopub.execute_input":"2022-08-11T21:50:43.170526Z","iopub.status.idle":"2022-08-11T21:50:44.795330Z","shell.execute_reply.started":"2022-08-11T21:50:43.170492Z","shell.execute_reply":"2022-08-11T21:50:44.794205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:50:51.915598Z","iopub.execute_input":"2022-08-11T21:50:51.916715Z","iopub.status.idle":"2022-08-11T21:50:51.925521Z","shell.execute_reply.started":"2022-08-11T21:50:51.916671Z","shell.execute_reply":"2022-08-11T21:50:51.924329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# data cleaning","metadata":{}},{"cell_type":"code","source":"#extract questions\nquestions=df.iloc[0,:]\nquestions\n","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:50:58.163789Z","iopub.execute_input":"2022-08-11T21:50:58.164697Z","iopub.status.idle":"2022-08-11T21:50:58.173410Z","shell.execute_reply.started":"2022-08-11T21:50:58.164659Z","shell.execute_reply":"2022-08-11T21:50:58.172066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#drop questions from data\ndf.drop(index=0 , axis=1)\n\n","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:02.280594Z","iopub.execute_input":"2022-08-11T21:51:02.281422Z","iopub.status.idle":"2022-08-11T21:51:02.467728Z","shell.execute_reply.started":"2022-08-11T21:51:02.281379Z","shell.execute_reply":"2022-08-11T21:51:02.466570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:09.286842Z","iopub.execute_input":"2022-08-11T21:51:09.287528Z","iopub.status.idle":"2022-08-11T21:51:09.323839Z","shell.execute_reply.started":"2022-08-11T21:51:09.287487Z","shell.execute_reply":"2022-08-11T21:51:09.322977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns\ndf[\"Q6\"].str.isnumeric().all()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:13.112463Z","iopub.execute_input":"2022-08-11T21:51:13.113116Z","iopub.status.idle":"2022-08-11T21:51:13.128927Z","shell.execute_reply.started":"2022-08-11T21:51:13.113069Z","shell.execute_reply":"2022-08-11T21:51:13.127559Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#convert to numeric data\n\nfor col in df.columns:\n    if df[col].str.isnumeric().all():\n        df[col]=pd.to_numeric(df[col])\n        \nprint(df.info())","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:16.096433Z","iopub.execute_input":"2022-08-11T21:51:16.096859Z","iopub.status.idle":"2022-08-11T21:51:19.218773Z","shell.execute_reply.started":"2022-08-11T21:51:16.096823Z","shell.execute_reply":"2022-08-11T21:51:19.217686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#allcountries in data\ndf['Q3'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:22.790542Z","iopub.execute_input":"2022-08-11T21:51:22.791154Z","iopub.status.idle":"2022-08-11T21:51:22.799498Z","shell.execute_reply.started":"2022-08-11T21:51:22.791105Z","shell.execute_reply":"2022-08-11T21:51:22.798619Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"countries_str=\" Algeria, Bahrain, Comoros, Djibouti, Egypt, Iraq, Jordan, Kuwait, Lebanon, Libya, Mauritania, Morocco, Oman, Palestine, Qatar, Saudi Arabia, Somalia, Sudan, Syria, Tunisia, United Arab Emirates, Yemen\"\narab_countries=countries_str.split( \", \")\narab_countries","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:26.976434Z","iopub.execute_input":"2022-08-11T21:51:26.977455Z","iopub.status.idle":"2022-08-11T21:51:26.983804Z","shell.execute_reply.started":"2022-08-11T21:51:26.977410Z","shell.execute_reply":"2022-08-11T21:51:26.982890Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[df['Q3'].isin(arab_countries)]","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_arabs=df[df['Q3'].isin(arab_countries)]\ndf_arabs.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:35.511071Z","iopub.execute_input":"2022-08-11T21:51:35.511549Z","iopub.status.idle":"2022-08-11T21:51:35.545544Z","shell.execute_reply.started":"2022-08-11T21:51:35.511512Z","shell.execute_reply":"2022-08-11T21:51:35.544335Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_arabs['Q3'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:40.758844Z","iopub.execute_input":"2022-08-11T21:51:40.759273Z","iopub.status.idle":"2022-08-11T21:51:40.768492Z","shell.execute_reply.started":"2022-08-11T21:51:40.759234Z","shell.execute_reply":"2022-08-11T21:51:40.767573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# #Bar plot for age destribution ","metadata":{}},{"cell_type":"code","source":"age_groups=df_arabs['Q1'].value_counts().sort_values().sort_index()\nage_groups","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:45.245517Z","iopub.execute_input":"2022-08-11T21:51:45.246412Z","iopub.status.idle":"2022-08-11T21:51:45.260139Z","shell.execute_reply.started":"2022-08-11T21:51:45.246371Z","shell.execute_reply":"2022-08-11T21:51:45.259253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x=age_groups.index\ny=age_groups.values","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:48.771542Z","iopub.execute_input":"2022-08-11T21:51:48.772822Z","iopub.status.idle":"2022-08-11T21:51:48.777275Z","shell.execute_reply.started":"2022-08-11T21:51:48.772780Z","shell.execute_reply":"2022-08-11T21:51:48.776226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.style.use('ggplot')\n\n\nplt.figure(figsize=(10,7))\n\nplt.plot(x,y)\nplt.title('Age Distribution')\nplt.xlabel('Age Group')\nplt.ylabel('frequancy')\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:51:57.044079Z","iopub.execute_input":"2022-08-11T21:51:57.044934Z","iopub.status.idle":"2022-08-11T21:51:57.293857Z","shell.execute_reply.started":"2022-08-11T21:51:57.044890Z","shell.execute_reply":"2022-08-11T21:51:57.292487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# country distribution","metadata":{}},{"cell_type":"code","source":"#at x we have arab countries \n# at y we have frequancy","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:52:05.214982Z","iopub.execute_input":"2022-08-11T21:52:05.215746Z","iopub.status.idle":"2022-08-11T21:52:05.220281Z","shell.execute_reply.started":"2022-08-11T21:52:05.215707Z","shell.execute_reply":"2022-08-11T21:52:05.219188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"country_groups=df_arabs['Q3'].value_counts()\ncountry_groups","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:52:08.540223Z","iopub.execute_input":"2022-08-11T21:52:08.540909Z","iopub.status.idle":"2022-08-11T21:52:08.548988Z","shell.execute_reply.started":"2022-08-11T21:52:08.540874Z","shell.execute_reply":"2022-08-11T21:52:08.548111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10,7))\nplt.bar(country_groups.index ,country_groups.values)\n\nplt.title('country_destribution')\nplt.xlabel('country',color='b')\nplt.ylabel('frequancy',color='r')\n\nplt.xticks(rotation=45)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:52:11.464525Z","iopub.execute_input":"2022-08-11T21:52:11.464917Z","iopub.status.idle":"2022-08-11T21:52:11.624952Z","shell.execute_reply.started":"2022-08-11T21:52:11.464883Z","shell.execute_reply":"2022-08-11T21:52:11.623803Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# arab kaggle users by programming language destribution","metadata":{}},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2022-08-11T22:00:07.874050Z","iopub.execute_input":"2022-08-11T22:00:07.874805Z","iopub.status.idle":"2022-08-11T22:00:07.882138Z","shell.execute_reply.started":"2022-08-11T22:00:07.874762Z","shell.execute_reply":"2022-08-11T22:00:07.881345Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns[df.columns.str.contains('Q7')]\nq7_columns=df.columns[df.columns.str.contains('Q7')]\nq7_columns","metadata":{"execution":{"iopub.status.busy":"2022-08-11T22:09:42.121653Z","iopub.execute_input":"2022-08-11T22:09:42.122056Z","iopub.status.idle":"2022-08-11T22:09:42.131793Z","shell.execute_reply.started":"2022-08-11T22:09:42.122024Z","shell.execute_reply":"2022-08-11T22:09:42.130668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_arabs[q7_columns]","metadata":{"execution":{"iopub.status.busy":"2022-08-11T22:11:19.757804Z","iopub.execute_input":"2022-08-11T22:11:19.758213Z","iopub.status.idle":"2022-08-11T22:11:19.783472Z","shell.execute_reply.started":"2022-08-11T22:11:19.758173Z","shell.execute_reply":"2022-08-11T22:11:19.782234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Q7_Part_1'].value_counts()[0]","metadata":{"execution":{"iopub.status.busy":"2022-08-11T22:20:16.944747Z","iopub.execute_input":"2022-08-11T22:20:16.945128Z","iopub.status.idle":"2022-08-11T22:20:16.955961Z","shell.execute_reply.started":"2022-08-11T22:20:16.945096Z","shell.execute_reply":"2022-08-11T22:20:16.954813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#for language name\ndf['Q7_Part_1'].value_counts().index[0]","metadata":{"execution":{"iopub.status.busy":"2022-08-11T22:19:02.324267Z","iopub.execute_input":"2022-08-11T22:19:02.324666Z","iopub.status.idle":"2022-08-11T22:19:02.335174Z","shell.execute_reply.started":"2022-08-11T22:19:02.324633Z","shell.execute_reply":"2022-08-11T22:19:02.334203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dic_7=dict()\nfor col in q7_columns:\n    key=df[col].value_counts().index[0]\n    dic_7[key]=df[col].value_counts()[0]\n    \ndic_7","metadata":{"execution":{"iopub.status.busy":"2022-08-11T22:25:23.958038Z","iopub.execute_input":"2022-08-11T22:25:23.958492Z","iopub.status.idle":"2022-08-11T22:25:24.002231Z","shell.execute_reply.started":"2022-08-11T22:25:23.958456Z","shell.execute_reply":"2022-08-11T22:25:24.001390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.Series(dic_7)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T22:27:00.972085Z","iopub.execute_input":"2022-08-11T22:27:00.972874Z","iopub.status.idle":"2022-08-11T22:27:00.981059Z","shell.execute_reply.started":"2022-08-11T22:27:00.972834Z","shell.execute_reply":"2022-08-11T22:27:00.979933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q7_series=pd.Series(dic_7)\nplt.figure(figsize=(10,10))\nplt.pie(q7_series ,labels=q7_series.index, autopct=\"%1.1f%%\")\n\nplt.legend(q7_series.index)\n\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-08-11T22:36:42.191768Z","iopub.execute_input":"2022-08-11T22:36:42.192206Z","iopub.status.idle":"2022-08-11T22:36:42.555519Z","shell.execute_reply.started":"2022-08-11T22:36:42.192170Z","shell.execute_reply":"2022-08-11T22:36:42.554473Z"},"trusted":true},"execution_count":null,"outputs":[]}]}