{
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "python",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8"
},
"kernelspec": {
"name": "python",
"display_name": "Python (Pyodide)",
"language": "python"
}
},
"nbformat_minor": 4,
"nbformat": 4,
"cells": [
{
"cell_type": "code",
"source": "import pandas as pd",
"metadata": {
"trusted": true
},
"execution_count": 1,
"outputs": []
},
{
"cell_type": "code",
"source": "df=[1,2,3,4]\nprint(pd.DataFrame(df))",
"metadata": {
"trusted": true
},
"execution_count": 2,
"outputs": [
{
"name": "stdout",
"text": " 0\n0 1\n1 2\n2 3\n3 4\n",
"output_type": "stream"
}
]
},
{
"cell_type": "code",
"source": "print(pd.Series(df))",
"metadata": {
"trusted": true
},
"execution_count": 3,
"outputs": [
{
"name": "stdout",
"text": "0 1\n1 2\n2 3\n3 4\ndtype: int64\n",
"output_type": "stream"
}
]
},
{
"cell_type": "code",
"source": "Employ=pd.read_csv(\"employees.csv\")",
"metadata": {
"trusted": true
},
"execution_count": 115,
"outputs": []
},
{
"cell_type": "code",
"source": "Employ_dub=Employ.head(20)",
"metadata": {
"trusted": true
},
"execution_count": 116,
"outputs": []
},
{
"cell_type": "code",
"source": "Employ_dub",
"metadata": {
"trusted": true
},
"execution_count": 117,
"outputs": [
{
"execution_count": 117,
"output_type": "execute_result",
"data": {
"text/plain": " First Name Gender Start Date Last Login Time Salary Bonus % \\\n0 Douglas Male 8/6/1993 12:42 PM 97308 6.945 \n1 Thomas Male 3/31/1996 6:53 AM 61933 4.170 \n2 Maria Female 4/23/1993 11:17 AM 130590 11.858 \n3 Jerry Male 3/4/2005 1:00 PM 138705 9.340 \n4 Larry Male 1/24/1998 4:47 PM 101004 1.389 \n5 Dennis Male 4/18/1987 1:35 AM 115163 10.125 \n6 Ruby Female 8/17/1987 4:20 PM 65476 10.012 \n7 NaN Female 7/20/2015 10:43 AM 45906 11.598 \n8 Angela Female 11/22/2005 6:29 AM 95570 18.523 \n9 Frances Female 8/8/2002 6:51 AM 139852 7.524 \n10 Louise Female 8/12/1980 9:01 AM 63241 15.132 \n11 Julie Female 10/26/1997 3:19 PM 102508 12.637 \n12 Brandon Male 12/1/1980 1:08 AM 112807 17.492 \n13 Gary Male 1/27/2008 11:40 PM 109831 5.831 \n14 Kimberly Female 1/14/1999 7:13 AM 41426 14.543 \n15 Lillian Female 6/5/2016 6:09 AM 59414 1.256 \n16 Jeremy Male 9/21/2010 5:56 AM 90370 7.369 \n17 Shawn Male 12/7/1986 7:45 PM 111737 6.414 \n18 Diana Female 10/23/1981 10:27 AM 132940 19.082 \n19 Donna Female 7/22/2010 3:48 AM 81014 1.894 \n\n Senior Management Team \n0 True Marketing \n1 True NaN \n2 False Finance \n3 True Finance \n4 True Client Services \n5 False Legal \n6 True Product \n7 NaN Finance \n8 True Engineering \n9 True Business Development \n10 True NaN \n11 True Legal \n12 True Human Resources \n13 False Sales \n14 True Finance \n15 False Product \n16 False Human Resources \n17 False Product \n18 False Client Services \n19 False Product ",
"text/html": "
\n\n
\n \n \n | \n First Name | \n Gender | \n Start Date | \n Last Login Time | \n Salary | \n Bonus % | \n Senior Management | \n Team | \n
\n \n \n \n 0 | \n Douglas | \n Male | \n 8/6/1993 | \n 12:42 PM | \n 97308 | \n 6.945 | \n True | \n Marketing | \n
\n \n 1 | \n Thomas | \n Male | \n 3/31/1996 | \n 6:53 AM | \n 61933 | \n 4.170 | \n True | \n NaN | \n
\n \n 2 | \n Maria | \n Female | \n 4/23/1993 | \n 11:17 AM | \n 130590 | \n 11.858 | \n False | \n Finance | \n
\n \n 3 | \n Jerry | \n Male | \n 3/4/2005 | \n 1:00 PM | \n 138705 | \n 9.340 | \n True | \n Finance | \n
\n \n 4 | \n Larry | \n Male | \n 1/24/1998 | \n 4:47 PM | \n 101004 | \n 1.389 | \n True | \n Client Services | \n
\n \n 5 | \n Dennis | \n Male | \n 4/18/1987 | \n 1:35 AM | \n 115163 | \n 10.125 | \n False | \n Legal | \n
\n \n 6 | \n Ruby | \n Female | \n 8/17/1987 | \n 4:20 PM | \n 65476 | \n 10.012 | \n True | \n Product | \n
\n \n 7 | \n NaN | \n Female | \n 7/20/2015 | \n 10:43 AM | \n 45906 | \n 11.598 | \n NaN | \n Finance | \n
\n \n 8 | \n Angela | \n Female | \n 11/22/2005 | \n 6:29 AM | \n 95570 | \n 18.523 | \n True | \n Engineering | \n
\n \n 9 | \n Frances | \n Female | \n 8/8/2002 | \n 6:51 AM | \n 139852 | \n 7.524 | \n True | \n Business Development | \n
\n \n 10 | \n Louise | \n Female | \n 8/12/1980 | \n 9:01 AM | \n 63241 | \n 15.132 | \n True | \n NaN | \n
\n \n 11 | \n Julie | \n Female | \n 10/26/1997 | \n 3:19 PM | \n 102508 | \n 12.637 | \n True | \n Legal | \n
\n \n 12 | \n Brandon | \n Male | \n 12/1/1980 | \n 1:08 AM | \n 112807 | \n 17.492 | \n True | \n Human Resources | \n
\n \n 13 | \n Gary | \n Male | \n 1/27/2008 | \n 11:40 PM | \n 109831 | \n 5.831 | \n False | \n Sales | \n
\n \n 14 | \n Kimberly | \n Female | \n 1/14/1999 | \n 7:13 AM | \n 41426 | \n 14.543 | \n True | \n Finance | \n
\n \n 15 | \n Lillian | \n Female | \n 6/5/2016 | \n 6:09 AM | \n 59414 | \n 1.256 | \n False | \n Product | \n
\n \n 16 | \n Jeremy | \n Male | \n 9/21/2010 | \n 5:56 AM | \n 90370 | \n 7.369 | \n False | \n Human Resources | \n
\n \n 17 | \n Shawn | \n Male | \n 12/7/1986 | \n 7:45 PM | \n 111737 | \n 6.414 | \n False | \n Product | \n
\n \n 18 | \n Diana | \n Female | \n 10/23/1981 | \n 10:27 AM | \n 132940 | \n 19.082 | \n False | \n Client Services | \n
\n \n 19 | \n Donna | \n Female | \n 7/22/2010 | \n 3:48 AM | \n 81014 | \n 1.894 | \n False | \n Product | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "",
"metadata": {
"trusted": true
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": "#total info about the employee\nEmploy_dub.info()",
"metadata": {
"trusted": true
},
"execution_count": 26,
"outputs": [
{
"name": "stdout",
"text": "\nRangeIndex: 20 entries, 0 to 19\nData columns (total 8 columns):\n # Column Non-Null Count Dtype \n--- ------ -------------- ----- \n 0 First Name 19 non-null object \n 1 Gender 20 non-null object \n 2 Start Date 20 non-null object \n 3 Last Login Time 20 non-null object \n 4 Salary 20 non-null int64 \n 5 Bonus % 20 non-null float64\n 6 Senior Management 19 non-null object \n 7 Team 18 non-null object \ndtypes: float64(1), int64(1), object(6)\nmemory usage: 868.0+ bytes\n",
"output_type": "stream"
}
]
},
{
"cell_type": "code",
"source": "Employ_dub.isnull()",
"metadata": {
"trusted": true
},
"execution_count": 27,
"outputs": [
{
"execution_count": 27,
"output_type": "execute_result",
"data": {
"text/plain": " First Name Gender Start Date Last Login Time Salary Bonus % \\\n0 False False False False False False \n1 False False False False False False \n2 False False False False False False \n3 False False False False False False \n4 False False False False False False \n5 False False False False False False \n6 False False False False False False \n7 True False False False False False \n8 False False False False False False \n9 False False False False False False \n10 False False False False False False \n11 False False False False False False \n12 False False False False False False \n13 False False False False False False \n14 False False False False False False \n15 False False False False False False \n16 False False False False False False \n17 False False False False False False \n18 False False False False False False \n19 False False False False False False \n\n Senior Management Team \n0 False False \n1 False True \n2 False False \n3 False False \n4 False False \n5 False False \n6 False False \n7 True False \n8 False False \n9 False False \n10 False True \n11 False False \n12 False False \n13 False False \n14 False False \n15 False False \n16 False False \n17 False False \n18 False False \n19 False False ",
"text/html": "\n\n
\n \n \n | \n First Name | \n Gender | \n Start Date | \n Last Login Time | \n Salary | \n Bonus % | \n Senior Management | \n Team | \n
\n \n \n \n 0 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 1 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n True | \n
\n \n 2 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 3 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 4 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 5 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 6 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 7 | \n True | \n False | \n False | \n False | \n False | \n False | \n True | \n False | \n
\n \n 8 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 9 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 10 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n True | \n
\n \n 11 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 12 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 13 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 14 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 15 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 16 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 17 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 18 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n 19 | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n False | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#checking for the null values in the dataset of employee\nEmploy_dub.isnull().sum()",
"metadata": {
"trusted": true
},
"execution_count": 28,
"outputs": [
{
"execution_count": 28,
"output_type": "execute_result",
"data": {
"text/plain": "First Name 1\nGender 0\nStart Date 0\nLast Login Time 0\nSalary 0\nBonus % 0\nSenior Management 1\nTeam 2\ndtype: int64"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#changing the name of the dataset\ned=Employ_dub",
"metadata": {
"trusted": true
},
"execution_count": 29,
"outputs": []
},
{
"cell_type": "code",
"source": "#dimension of the dataset\ned.shape",
"metadata": {
"trusted": true
},
"execution_count": 30,
"outputs": [
{
"execution_count": 30,
"output_type": "execute_result",
"data": {
"text/plain": "(20, 8)"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ed.columns",
"metadata": {
"trusted": true
},
"execution_count": 31,
"outputs": [
{
"execution_count": 31,
"output_type": "execute_result",
"data": {
"text/plain": "Index(['First Name', 'Gender', 'Start Date', 'Last Login Time', 'Salary',\n 'Bonus %', 'Senior Management', 'Team'],\n dtype='object')"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#working on the dictionary for a while:",
"metadata": {
"trusted": true
},
"execution_count": 32,
"outputs": []
},
{
"cell_type": "code",
"source": "#creating test objects:\nimport numpy as np\nff=pd.DataFrame(np.random.rand(20,5))",
"metadata": {
"trusted": true
},
"execution_count": 39,
"outputs": []
},
{
"cell_type": "code",
"source": "ff",
"metadata": {
"trusted": true
},
"execution_count": 40,
"outputs": [
{
"execution_count": 40,
"output_type": "execute_result",
"data": {
"text/plain": " 0 1 2 3 4\n0 0.020780 0.365190 0.673825 0.800112 0.188644\n1 0.660845 0.265913 0.445028 0.889438 0.601047\n2 0.646987 0.926823 0.722838 0.475271 0.827945\n3 0.871724 0.290353 0.099578 0.109949 0.229182\n4 0.704794 0.884062 0.751327 0.595746 0.612269\n5 0.371269 0.560512 0.510264 0.247923 0.618853\n6 0.150398 0.116999 0.934865 0.315723 0.221538\n7 0.556336 0.875514 0.471526 0.539511 0.271221\n8 0.428221 0.546766 0.921274 0.500520 0.400341\n9 0.150170 0.802378 0.608124 0.342871 0.076631\n10 0.099049 0.280748 0.865939 0.214541 0.083318\n11 0.042867 0.701639 0.051457 0.691385 0.051529\n12 0.530845 0.248395 0.433733 0.049458 0.314959\n13 0.142230 0.746634 0.536247 0.096499 0.123294\n14 0.139630 0.056464 0.595644 0.764071 0.193826\n15 0.709624 0.590262 0.816268 0.187931 0.366224\n16 0.982939 0.260358 0.918897 0.531278 0.304655\n17 0.381823 0.003594 0.052597 0.921529 0.022103\n18 0.227944 0.706832 0.137266 0.129158 0.882734\n19 0.226257 0.818213 0.326071 0.230419 0.668891",
"text/html": "\n\n
\n \n \n | \n 0 | \n 1 | \n 2 | \n 3 | \n 4 | \n
\n \n \n \n 0 | \n 0.020780 | \n 0.365190 | \n 0.673825 | \n 0.800112 | \n 0.188644 | \n
\n \n 1 | \n 0.660845 | \n 0.265913 | \n 0.445028 | \n 0.889438 | \n 0.601047 | \n
\n \n 2 | \n 0.646987 | \n 0.926823 | \n 0.722838 | \n 0.475271 | \n 0.827945 | \n
\n \n 3 | \n 0.871724 | \n 0.290353 | \n 0.099578 | \n 0.109949 | \n 0.229182 | \n
\n \n 4 | \n 0.704794 | \n 0.884062 | \n 0.751327 | \n 0.595746 | \n 0.612269 | \n
\n \n 5 | \n 0.371269 | \n 0.560512 | \n 0.510264 | \n 0.247923 | \n 0.618853 | \n
\n \n 6 | \n 0.150398 | \n 0.116999 | \n 0.934865 | \n 0.315723 | \n 0.221538 | \n
\n \n 7 | \n 0.556336 | \n 0.875514 | \n 0.471526 | \n 0.539511 | \n 0.271221 | \n
\n \n 8 | \n 0.428221 | \n 0.546766 | \n 0.921274 | \n 0.500520 | \n 0.400341 | \n
\n \n 9 | \n 0.150170 | \n 0.802378 | \n 0.608124 | \n 0.342871 | \n 0.076631 | \n
\n \n 10 | \n 0.099049 | \n 0.280748 | \n 0.865939 | \n 0.214541 | \n 0.083318 | \n
\n \n 11 | \n 0.042867 | \n 0.701639 | \n 0.051457 | \n 0.691385 | \n 0.051529 | \n
\n \n 12 | \n 0.530845 | \n 0.248395 | \n 0.433733 | \n 0.049458 | \n 0.314959 | \n
\n \n 13 | \n 0.142230 | \n 0.746634 | \n 0.536247 | \n 0.096499 | \n 0.123294 | \n
\n \n 14 | \n 0.139630 | \n 0.056464 | \n 0.595644 | \n 0.764071 | \n 0.193826 | \n
\n \n 15 | \n 0.709624 | \n 0.590262 | \n 0.816268 | \n 0.187931 | \n 0.366224 | \n
\n \n 16 | \n 0.982939 | \n 0.260358 | \n 0.918897 | \n 0.531278 | \n 0.304655 | \n
\n \n 17 | \n 0.381823 | \n 0.003594 | \n 0.052597 | \n 0.921529 | \n 0.022103 | \n
\n \n 18 | \n 0.227944 | \n 0.706832 | \n 0.137266 | \n 0.129158 | \n 0.882734 | \n
\n \n 19 | \n 0.226257 | \n 0.818213 | \n 0.326071 | \n 0.230419 | \n 0.668891 | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ff.info()",
"metadata": {
"trusted": true
},
"execution_count": 41,
"outputs": [
{
"name": "stdout",
"text": "\nRangeIndex: 20 entries, 0 to 19\nData columns (total 5 columns):\n # Column Non-Null Count Dtype \n--- ------ -------------- ----- \n 0 0 20 non-null float64\n 1 1 20 non-null float64\n 2 2 20 non-null float64\n 3 3 20 non-null float64\n 4 4 20 non-null float64\ndtypes: float64(5)\nmemory usage: 868.0 bytes\n",
"output_type": "stream"
}
]
},
{
"cell_type": "code",
"source": "#data functon:\ndate=pd.DataFrame(\n{\n\"date\":['10/9/2020','11/09/2020','12/09/2020'],\n\"students\":[10,20,30]})\n",
"metadata": {
"trusted": true
},
"execution_count": 43,
"outputs": [
{
"execution_count": 43,
"output_type": "execute_result",
"data": {
"text/plain": " date students\n0 10/9/2020 10\n1 11/09/2020 20\n2 12/09/2020 30",
"text/html": "\n\n
\n \n \n | \n date | \n students | \n
\n \n \n \n 0 | \n 10/9/2020 | \n 10 | \n
\n \n 1 | \n 11/09/2020 | \n 20 | \n
\n \n 2 | \n 12/09/2020 | \n 30 | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ed.value_counts()",
"metadata": {
"trusted": true
},
"execution_count": 52,
"outputs": [
{
"execution_count": 52,
"output_type": "execute_result",
"data": {
"text/plain": "First Name Gender Start Date Last Login Time Salary Bonus % Senior Management Team \nAngela Female 11/22/2005 6:29 AM 95570 18.523 True Engineering 1\nJerry Male 3/4/2005 1:00 PM 138705 9.340 True Finance 1\nRuby Female 8/17/1987 4:20 PM 65476 10.012 True Product 1\nMaria Female 4/23/1993 11:17 AM 130590 11.858 False Finance 1\nLillian Female 6/5/2016 6:09 AM 59414 1.256 False Product 1\nLarry Male 1/24/1998 4:47 PM 101004 1.389 True Client Services 1\nKimberly Female 1/14/1999 7:13 AM 41426 14.543 True Finance 1\nJulie Female 10/26/1997 3:19 PM 102508 12.637 True Legal 1\nJeremy Male 9/21/2010 5:56 AM 90370 7.369 False Human Resources 1\nBrandon Male 12/1/1980 1:08 AM 112807 17.492 True Human Resources 1\nGary Male 1/27/2008 11:40 PM 109831 5.831 False Sales 1\nFrances Female 8/8/2002 6:51 AM 139852 7.524 True Business Development 1\nDouglas Male 8/6/1993 12:42 PM 97308 6.945 True Marketing 1\nDonna Female 7/22/2010 3:48 AM 81014 1.894 False Product 1\nDiana Female 10/23/1981 10:27 AM 132940 19.082 False Client Services 1\nDennis Male 4/18/1987 1:35 AM 115163 10.125 False Legal 1\nShawn Male 12/7/1986 7:45 PM 111737 6.414 False Product 1\ndtype: int64"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ed[['Gender','Salary']]",
"metadata": {
"trusted": true
},
"execution_count": 62,
"outputs": [
{
"execution_count": 62,
"output_type": "execute_result",
"data": {
"text/plain": " Gender Salary\n0 Male 97308\n1 Male 61933\n2 Female 130590\n3 Male 138705\n4 Male 101004\n5 Male 115163\n6 Female 65476\n7 Female 45906\n8 Female 95570\n9 Female 139852\n10 Female 63241\n11 Female 102508\n12 Male 112807\n13 Male 109831\n14 Female 41426\n15 Female 59414\n16 Male 90370\n17 Male 111737\n18 Female 132940\n19 Female 81014",
"text/html": "\n\n
\n \n \n | \n Gender | \n Salary | \n
\n \n \n \n 0 | \n Male | \n 97308 | \n
\n \n 1 | \n Male | \n 61933 | \n
\n \n 2 | \n Female | \n 130590 | \n
\n \n 3 | \n Male | \n 138705 | \n
\n \n 4 | \n Male | \n 101004 | \n
\n \n 5 | \n Male | \n 115163 | \n
\n \n 6 | \n Female | \n 65476 | \n
\n \n 7 | \n Female | \n 45906 | \n
\n \n 8 | \n Female | \n 95570 | \n
\n \n 9 | \n Female | \n 139852 | \n
\n \n 10 | \n Female | \n 63241 | \n
\n \n 11 | \n Female | \n 102508 | \n
\n \n 12 | \n Male | \n 112807 | \n
\n \n 13 | \n Male | \n 109831 | \n
\n \n 14 | \n Female | \n 41426 | \n
\n \n 15 | \n Female | \n 59414 | \n
\n \n 16 | \n Male | \n 90370 | \n
\n \n 17 | \n Male | \n 111737 | \n
\n \n 18 | \n Female | \n 132940 | \n
\n \n 19 | \n Female | \n 81014 | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#selection by position:rows data:\ned.iloc[8:12]",
"metadata": {
"trusted": true
},
"execution_count": 69,
"outputs": [
{
"execution_count": 69,
"output_type": "execute_result",
"data": {
"text/plain": " First Name Gender Start Date Last Login Time Salary Bonus % \\\n8 Angela Female 11/22/2005 6:29 AM 95570 18.523 \n9 Frances Female 8/8/2002 6:51 AM 139852 7.524 \n10 Louise Female 8/12/1980 9:01 AM 63241 15.132 \n11 Julie Female 10/26/1997 3:19 PM 102508 12.637 \n\n Senior Management Team \n8 True Engineering \n9 True Business Development \n10 True NaN \n11 True Legal ",
"text/html": "\n\n
\n \n \n | \n First Name | \n Gender | \n Start Date | \n Last Login Time | \n Salary | \n Bonus % | \n Senior Management | \n Team | \n
\n \n \n \n 8 | \n Angela | \n Female | \n 11/22/2005 | \n 6:29 AM | \n 95570 | \n 18.523 | \n True | \n Engineering | \n
\n \n 9 | \n Frances | \n Female | \n 8/8/2002 | \n 6:51 AM | \n 139852 | \n 7.524 | \n True | \n Business Development | \n
\n \n 10 | \n Louise | \n Female | \n 8/12/1980 | \n 9:01 AM | \n 63241 | \n 15.132 | \n True | \n NaN | \n
\n \n 11 | \n Julie | \n Female | \n 10/26/1997 | \n 3:19 PM | \n 102508 | \n 12.637 | \n True | \n Legal | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ed.loc[8]",
"metadata": {
"trusted": true
},
"execution_count": 64,
"outputs": [
{
"execution_count": 64,
"output_type": "execute_result",
"data": {
"text/plain": "First Name Angela\nGender Female\nStart Date 11/22/2005\nLast Login Time 6:29 AM\nSalary 95570\nBonus % 18.523\nSenior Management True\nTeam Engineering\nName: 8, dtype: object"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#data cleaning:\ned.isnull().sum()",
"metadata": {
"trusted": true
},
"execution_count": 73,
"outputs": [
{
"execution_count": 73,
"output_type": "execute_result",
"data": {
"text/plain": "First Name 1\nGender 0\nStart Date 0\nLast Login Time 0\nSalary 0\nBonus % 0\nSenior Management 1\nTeam 2\ndtype: int64"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#total null values:\ned.isnull().sum().sum()",
"metadata": {
"trusted": true
},
"execution_count": 74,
"outputs": [
{
"execution_count": 74,
"output_type": "execute_result",
"data": {
"text/plain": "4"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ed.notnull().sum().sum()",
"metadata": {
"trusted": true
},
"execution_count": 77,
"outputs": [
{
"execution_count": 77,
"output_type": "execute_result",
"data": {
"text/plain": "156"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#fpr practice on drop we will take the copy of the original data:\ned2=ed",
"metadata": {
"trusted": true
},
"execution_count": 78,
"outputs": []
},
{
"cell_type": "code",
"source": "ed2",
"metadata": {
"trusted": true
},
"execution_count": 79,
"outputs": [
{
"execution_count": 79,
"output_type": "execute_result",
"data": {
"text/plain": " First Name Gender Start Date Last Login Time Salary Bonus % \\\n0 Douglas Male 8/6/1993 12:42 PM 97308 6.945 \n1 Thomas Male 3/31/1996 6:53 AM 61933 4.170 \n2 Maria Female 4/23/1993 11:17 AM 130590 11.858 \n3 Jerry Male 3/4/2005 1:00 PM 138705 9.340 \n4 Larry Male 1/24/1998 4:47 PM 101004 1.389 \n5 Dennis Male 4/18/1987 1:35 AM 115163 10.125 \n6 Ruby Female 8/17/1987 4:20 PM 65476 10.012 \n7 NaN Female 7/20/2015 10:43 AM 45906 11.598 \n8 Angela Female 11/22/2005 6:29 AM 95570 18.523 \n9 Frances Female 8/8/2002 6:51 AM 139852 7.524 \n10 Louise Female 8/12/1980 9:01 AM 63241 15.132 \n11 Julie Female 10/26/1997 3:19 PM 102508 12.637 \n12 Brandon Male 12/1/1980 1:08 AM 112807 17.492 \n13 Gary Male 1/27/2008 11:40 PM 109831 5.831 \n14 Kimberly Female 1/14/1999 7:13 AM 41426 14.543 \n15 Lillian Female 6/5/2016 6:09 AM 59414 1.256 \n16 Jeremy Male 9/21/2010 5:56 AM 90370 7.369 \n17 Shawn Male 12/7/1986 7:45 PM 111737 6.414 \n18 Diana Female 10/23/1981 10:27 AM 132940 19.082 \n19 Donna Female 7/22/2010 3:48 AM 81014 1.894 \n\n Senior Management Team \n0 True Marketing \n1 True NaN \n2 False Finance \n3 True Finance \n4 True Client Services \n5 False Legal \n6 True Product \n7 NaN Finance \n8 True Engineering \n9 True Business Development \n10 True NaN \n11 True Legal \n12 True Human Resources \n13 False Sales \n14 True Finance \n15 False Product \n16 False Human Resources \n17 False Product \n18 False Client Services \n19 False Product ",
"text/html": "\n\n
\n \n \n | \n First Name | \n Gender | \n Start Date | \n Last Login Time | \n Salary | \n Bonus % | \n Senior Management | \n Team | \n
\n \n \n \n 0 | \n Douglas | \n Male | \n 8/6/1993 | \n 12:42 PM | \n 97308 | \n 6.945 | \n True | \n Marketing | \n
\n \n 1 | \n Thomas | \n Male | \n 3/31/1996 | \n 6:53 AM | \n 61933 | \n 4.170 | \n True | \n NaN | \n
\n \n 2 | \n Maria | \n Female | \n 4/23/1993 | \n 11:17 AM | \n 130590 | \n 11.858 | \n False | \n Finance | \n
\n \n 3 | \n Jerry | \n Male | \n 3/4/2005 | \n 1:00 PM | \n 138705 | \n 9.340 | \n True | \n Finance | \n
\n \n 4 | \n Larry | \n Male | \n 1/24/1998 | \n 4:47 PM | \n 101004 | \n 1.389 | \n True | \n Client Services | \n
\n \n 5 | \n Dennis | \n Male | \n 4/18/1987 | \n 1:35 AM | \n 115163 | \n 10.125 | \n False | \n Legal | \n
\n \n 6 | \n Ruby | \n Female | \n 8/17/1987 | \n 4:20 PM | \n 65476 | \n 10.012 | \n True | \n Product | \n
\n \n 7 | \n NaN | \n Female | \n 7/20/2015 | \n 10:43 AM | \n 45906 | \n 11.598 | \n NaN | \n Finance | \n
\n \n 8 | \n Angela | \n Female | \n 11/22/2005 | \n 6:29 AM | \n 95570 | \n 18.523 | \n True | \n Engineering | \n
\n \n 9 | \n Frances | \n Female | \n 8/8/2002 | \n 6:51 AM | \n 139852 | \n 7.524 | \n True | \n Business Development | \n
\n \n 10 | \n Louise | \n Female | \n 8/12/1980 | \n 9:01 AM | \n 63241 | \n 15.132 | \n True | \n NaN | \n
\n \n 11 | \n Julie | \n Female | \n 10/26/1997 | \n 3:19 PM | \n 102508 | \n 12.637 | \n True | \n Legal | \n
\n \n 12 | \n Brandon | \n Male | \n 12/1/1980 | \n 1:08 AM | \n 112807 | \n 17.492 | \n True | \n Human Resources | \n
\n \n 13 | \n Gary | \n Male | \n 1/27/2008 | \n 11:40 PM | \n 109831 | \n 5.831 | \n False | \n Sales | \n
\n \n 14 | \n Kimberly | \n Female | \n 1/14/1999 | \n 7:13 AM | \n 41426 | \n 14.543 | \n True | \n Finance | \n
\n \n 15 | \n Lillian | \n Female | \n 6/5/2016 | \n 6:09 AM | \n 59414 | \n 1.256 | \n False | \n Product | \n
\n \n 16 | \n Jeremy | \n Male | \n 9/21/2010 | \n 5:56 AM | \n 90370 | \n 7.369 | \n False | \n Human Resources | \n
\n \n 17 | \n Shawn | \n Male | \n 12/7/1986 | \n 7:45 PM | \n 111737 | \n 6.414 | \n False | \n Product | \n
\n \n 18 | \n Diana | \n Female | \n 10/23/1981 | \n 10:27 AM | \n 132940 | \n 19.082 | \n False | \n Client Services | \n
\n \n 19 | \n Donna | \n Female | \n 7/22/2010 | \n 3:48 AM | \n 81014 | \n 1.894 | \n False | \n Product | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#removing the totyal columns if they are with the null values:\ned3=ed2.dropna(axis=1)\nprint(\"prasent null values:\",ed3.isnull().sum().sum())",
"metadata": {
"trusted": true
},
"execution_count": 90,
"outputs": [
{
"name": "stdout",
"text": "prasent null values: 0\n",
"output_type": "stream"
}
]
},
{
"cell_type": "code",
"source": "ed2.fillna(10,inplace=True)",
"metadata": {
"trusted": true
},
"execution_count": 96,
"outputs": [
{
"name": "stderr",
"text": ":1: SettingWithCopyWarning: \nA value is trying to be set on a copy of a slice from a DataFrame\n\nSee the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n ed2.fillna(10,inplace=True)\n",
"output_type": "stream"
}
]
},
{
"cell_type": "code",
"source": "ed2.isnull().sum()",
"metadata": {
"trusted": true
},
"execution_count": 97,
"outputs": [
{
"execution_count": 97,
"output_type": "execute_result",
"data": {
"text/plain": "First Name 0\nGender 0\nStart Date 0\nLast Login Time 0\nSalary 0\nBonus % 0\nSenior Management 0\nTeam 0\ndtype: int64"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ed2",
"metadata": {
"trusted": true
},
"execution_count": 98,
"outputs": [
{
"execution_count": 98,
"output_type": "execute_result",
"data": {
"text/plain": " First Name Gender Start Date Last Login Time Salary Bonus % \\\n0 Douglas Male 8/6/1993 12:42 PM 97308 6.945 \n1 Thomas Male 3/31/1996 6:53 AM 61933 4.170 \n2 Maria Female 4/23/1993 11:17 AM 130590 11.858 \n3 Jerry Male 3/4/2005 1:00 PM 138705 9.340 \n4 Larry Male 1/24/1998 4:47 PM 101004 1.389 \n5 Dennis Male 4/18/1987 1:35 AM 115163 10.125 \n6 Ruby Female 8/17/1987 4:20 PM 65476 10.012 \n7 10 Female 7/20/2015 10:43 AM 45906 11.598 \n8 Angela Female 11/22/2005 6:29 AM 95570 18.523 \n9 Frances Female 8/8/2002 6:51 AM 139852 7.524 \n10 Louise Female 8/12/1980 9:01 AM 63241 15.132 \n11 Julie Female 10/26/1997 3:19 PM 102508 12.637 \n12 Brandon Male 12/1/1980 1:08 AM 112807 17.492 \n13 Gary Male 1/27/2008 11:40 PM 109831 5.831 \n14 Kimberly Female 1/14/1999 7:13 AM 41426 14.543 \n15 Lillian Female 6/5/2016 6:09 AM 59414 1.256 \n16 Jeremy Male 9/21/2010 5:56 AM 90370 7.369 \n17 Shawn Male 12/7/1986 7:45 PM 111737 6.414 \n18 Diana Female 10/23/1981 10:27 AM 132940 19.082 \n19 Donna Female 7/22/2010 3:48 AM 81014 1.894 \n\n Senior Management Team \n0 True Marketing \n1 True 10 \n2 False Finance \n3 True Finance \n4 True Client Services \n5 False Legal \n6 True Product \n7 10 Finance \n8 True Engineering \n9 True Business Development \n10 True 10 \n11 True Legal \n12 True Human Resources \n13 False Sales \n14 True Finance \n15 False Product \n16 False Human Resources \n17 False Product \n18 False Client Services \n19 False Product ",
"text/html": "\n\n
\n \n \n | \n First Name | \n Gender | \n Start Date | \n Last Login Time | \n Salary | \n Bonus % | \n Senior Management | \n Team | \n
\n \n \n \n 0 | \n Douglas | \n Male | \n 8/6/1993 | \n 12:42 PM | \n 97308 | \n 6.945 | \n True | \n Marketing | \n
\n \n 1 | \n Thomas | \n Male | \n 3/31/1996 | \n 6:53 AM | \n 61933 | \n 4.170 | \n True | \n 10 | \n
\n \n 2 | \n Maria | \n Female | \n 4/23/1993 | \n 11:17 AM | \n 130590 | \n 11.858 | \n False | \n Finance | \n
\n \n 3 | \n Jerry | \n Male | \n 3/4/2005 | \n 1:00 PM | \n 138705 | \n 9.340 | \n True | \n Finance | \n
\n \n 4 | \n Larry | \n Male | \n 1/24/1998 | \n 4:47 PM | \n 101004 | \n 1.389 | \n True | \n Client Services | \n
\n \n 5 | \n Dennis | \n Male | \n 4/18/1987 | \n 1:35 AM | \n 115163 | \n 10.125 | \n False | \n Legal | \n
\n \n 6 | \n Ruby | \n Female | \n 8/17/1987 | \n 4:20 PM | \n 65476 | \n 10.012 | \n True | \n Product | \n
\n \n 7 | \n 10 | \n Female | \n 7/20/2015 | \n 10:43 AM | \n 45906 | \n 11.598 | \n 10 | \n Finance | \n
\n \n 8 | \n Angela | \n Female | \n 11/22/2005 | \n 6:29 AM | \n 95570 | \n 18.523 | \n True | \n Engineering | \n
\n \n 9 | \n Frances | \n Female | \n 8/8/2002 | \n 6:51 AM | \n 139852 | \n 7.524 | \n True | \n Business Development | \n
\n \n 10 | \n Louise | \n Female | \n 8/12/1980 | \n 9:01 AM | \n 63241 | \n 15.132 | \n True | \n 10 | \n
\n \n 11 | \n Julie | \n Female | \n 10/26/1997 | \n 3:19 PM | \n 102508 | \n 12.637 | \n True | \n Legal | \n
\n \n 12 | \n Brandon | \n Male | \n 12/1/1980 | \n 1:08 AM | \n 112807 | \n 17.492 | \n True | \n Human Resources | \n
\n \n 13 | \n Gary | \n Male | \n 1/27/2008 | \n 11:40 PM | \n 109831 | \n 5.831 | \n False | \n Sales | \n
\n \n 14 | \n Kimberly | \n Female | \n 1/14/1999 | \n 7:13 AM | \n 41426 | \n 14.543 | \n True | \n Finance | \n
\n \n 15 | \n Lillian | \n Female | \n 6/5/2016 | \n 6:09 AM | \n 59414 | \n 1.256 | \n False | \n Product | \n
\n \n 16 | \n Jeremy | \n Male | \n 9/21/2010 | \n 5:56 AM | \n 90370 | \n 7.369 | \n False | \n Human Resources | \n
\n \n 17 | \n Shawn | \n Male | \n 12/7/1986 | \n 7:45 PM | \n 111737 | \n 6.414 | \n False | \n Product | \n
\n \n 18 | \n Diana | \n Female | \n 10/23/1981 | \n 10:27 AM | \n 132940 | \n 19.082 | \n False | \n Client Services | \n
\n \n 19 | \n Donna | \n Female | \n 7/22/2010 | \n 3:48 AM | \n 81014 | \n 1.894 | \n False | \n Product | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ed5=Employ.head(20)\ned5",
"metadata": {
"trusted": true
},
"execution_count": 118,
"outputs": [
{
"execution_count": 118,
"output_type": "execute_result",
"data": {
"text/plain": " First Name Gender Start Date Last Login Time Salary Bonus % \\\n0 Douglas Male 8/6/1993 12:42 PM 97308 6.945 \n1 Thomas Male 3/31/1996 6:53 AM 61933 4.170 \n2 Maria Female 4/23/1993 11:17 AM 130590 11.858 \n3 Jerry Male 3/4/2005 1:00 PM 138705 9.340 \n4 Larry Male 1/24/1998 4:47 PM 101004 1.389 \n5 Dennis Male 4/18/1987 1:35 AM 115163 10.125 \n6 Ruby Female 8/17/1987 4:20 PM 65476 10.012 \n7 NaN Female 7/20/2015 10:43 AM 45906 11.598 \n8 Angela Female 11/22/2005 6:29 AM 95570 18.523 \n9 Frances Female 8/8/2002 6:51 AM 139852 7.524 \n10 Louise Female 8/12/1980 9:01 AM 63241 15.132 \n11 Julie Female 10/26/1997 3:19 PM 102508 12.637 \n12 Brandon Male 12/1/1980 1:08 AM 112807 17.492 \n13 Gary Male 1/27/2008 11:40 PM 109831 5.831 \n14 Kimberly Female 1/14/1999 7:13 AM 41426 14.543 \n15 Lillian Female 6/5/2016 6:09 AM 59414 1.256 \n16 Jeremy Male 9/21/2010 5:56 AM 90370 7.369 \n17 Shawn Male 12/7/1986 7:45 PM 111737 6.414 \n18 Diana Female 10/23/1981 10:27 AM 132940 19.082 \n19 Donna Female 7/22/2010 3:48 AM 81014 1.894 \n\n Senior Management Team \n0 True Marketing \n1 True NaN \n2 False Finance \n3 True Finance \n4 True Client Services \n5 False Legal \n6 True Product \n7 NaN Finance \n8 True Engineering \n9 True Business Development \n10 True NaN \n11 True Legal \n12 True Human Resources \n13 False Sales \n14 True Finance \n15 False Product \n16 False Human Resources \n17 False Product \n18 False Client Services \n19 False Product ",
"text/html": "\n\n
\n \n \n | \n First Name | \n Gender | \n Start Date | \n Last Login Time | \n Salary | \n Bonus % | \n Senior Management | \n Team | \n
\n \n \n \n 0 | \n Douglas | \n Male | \n 8/6/1993 | \n 12:42 PM | \n 97308 | \n 6.945 | \n True | \n Marketing | \n
\n \n 1 | \n Thomas | \n Male | \n 3/31/1996 | \n 6:53 AM | \n 61933 | \n 4.170 | \n True | \n NaN | \n
\n \n 2 | \n Maria | \n Female | \n 4/23/1993 | \n 11:17 AM | \n 130590 | \n 11.858 | \n False | \n Finance | \n
\n \n 3 | \n Jerry | \n Male | \n 3/4/2005 | \n 1:00 PM | \n 138705 | \n 9.340 | \n True | \n Finance | \n
\n \n 4 | \n Larry | \n Male | \n 1/24/1998 | \n 4:47 PM | \n 101004 | \n 1.389 | \n True | \n Client Services | \n
\n \n 5 | \n Dennis | \n Male | \n 4/18/1987 | \n 1:35 AM | \n 115163 | \n 10.125 | \n False | \n Legal | \n
\n \n 6 | \n Ruby | \n Female | \n 8/17/1987 | \n 4:20 PM | \n 65476 | \n 10.012 | \n True | \n Product | \n
\n \n 7 | \n NaN | \n Female | \n 7/20/2015 | \n 10:43 AM | \n 45906 | \n 11.598 | \n NaN | \n Finance | \n
\n \n 8 | \n Angela | \n Female | \n 11/22/2005 | \n 6:29 AM | \n 95570 | \n 18.523 | \n True | \n Engineering | \n
\n \n 9 | \n Frances | \n Female | \n 8/8/2002 | \n 6:51 AM | \n 139852 | \n 7.524 | \n True | \n Business Development | \n
\n \n 10 | \n Louise | \n Female | \n 8/12/1980 | \n 9:01 AM | \n 63241 | \n 15.132 | \n True | \n NaN | \n
\n \n 11 | \n Julie | \n Female | \n 10/26/1997 | \n 3:19 PM | \n 102508 | \n 12.637 | \n True | \n Legal | \n
\n \n 12 | \n Brandon | \n Male | \n 12/1/1980 | \n 1:08 AM | \n 112807 | \n 17.492 | \n True | \n Human Resources | \n
\n \n 13 | \n Gary | \n Male | \n 1/27/2008 | \n 11:40 PM | \n 109831 | \n 5.831 | \n False | \n Sales | \n
\n \n 14 | \n Kimberly | \n Female | \n 1/14/1999 | \n 7:13 AM | \n 41426 | \n 14.543 | \n True | \n Finance | \n
\n \n 15 | \n Lillian | \n Female | \n 6/5/2016 | \n 6:09 AM | \n 59414 | \n 1.256 | \n False | \n Product | \n
\n \n 16 | \n Jeremy | \n Male | \n 9/21/2010 | \n 5:56 AM | \n 90370 | \n 7.369 | \n False | \n Human Resources | \n
\n \n 17 | \n Shawn | \n Male | \n 12/7/1986 | \n 7:45 PM | \n 111737 | \n 6.414 | \n False | \n Product | \n
\n \n 18 | \n Diana | \n Female | \n 10/23/1981 | \n 10:27 AM | \n 132940 | \n 19.082 | \n False | \n Client Services | \n
\n \n 19 | \n Donna | \n Female | \n 7/22/2010 | \n 3:48 AM | \n 81014 | \n 1.894 | \n False | \n Product | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "ed2.isnull().sum()",
"metadata": {
"trusted": true
},
"execution_count": 111,
"outputs": [
{
"execution_count": 111,
"output_type": "execute_result",
"data": {
"text/plain": "First Name 0\nGender 0\nStart Date 0\nLast Login Time 0\nSalary 0\nBonus % 0\nSenior Management 0\nTeam 0\ndtype: int64"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "date",
"metadata": {
"trusted": true
},
"execution_count": 120,
"outputs": [
{
"execution_count": 120,
"output_type": "execute_result",
"data": {
"text/plain": " date students\n0 10/9/2020 10\n1 11/09/2020 20\n2 12/09/2020 30",
"text/html": "\n\n
\n \n \n | \n date | \n students | \n
\n \n \n \n 0 | \n 10/9/2020 | \n 10 | \n
\n \n 1 | \n 11/09/2020 | \n 20 | \n
\n \n 2 | \n 12/09/2020 | \n 30 | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "date.dtypes",
"metadata": {
"trusted": true
},
"execution_count": 124,
"outputs": [
{
"execution_count": 124,
"output_type": "execute_result",
"data": {
"text/plain": "date object\nstudents int64\ndtype: object"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "#rename for the date with the check:\ndate.rename(columns={'date':'check'})",
"metadata": {
"trusted": true
},
"execution_count": 131,
"outputs": [
{
"execution_count": 131,
"output_type": "execute_result",
"data": {
"text/plain": " check students\n0 10/9/2020 10\n1 11/09/2020 20\n2 12/09/2020 30",
"text/html": "\n\n
\n \n \n | \n check | \n students | \n
\n \n \n \n 0 | \n 10/9/2020 | \n 10 | \n
\n \n 1 | \n 11/09/2020 | \n 20 | \n
\n \n 2 | \n 12/09/2020 | \n 30 | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "date.sort_values('students',ascending=False)",
"metadata": {
"trusted": true
},
"execution_count": 134,
"outputs": [
{
"execution_count": 134,
"output_type": "execute_result",
"data": {
"text/plain": " date students\n2 12/09/2020 30\n1 11/09/2020 20\n0 10/9/2020 10",
"text/html": "\n\n
\n \n \n | \n date | \n students | \n
\n \n \n \n 2 | \n 12/09/2020 | \n 30 | \n
\n \n 1 | \n 11/09/2020 | \n 20 | \n
\n \n 0 | \n 10/9/2020 | \n 10 | \n
\n \n
\n
"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": "",
"metadata": {
"trusted": true
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": "",
"metadata": {
"trusted": true
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": "",
"metadata": {},
"execution_count": null,
"outputs": []
}
]
}