HomeWork: Ameo with Pandas Visualisations
ameo15

Homework - ameo15 dataset

In [ ]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
In [ ]:
d = pd.read_excel('/content/Ameo15.xlsx', index_col='ID')
In [ ]:
d.head()
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
203097 420000 2012-06-01 present senior quality engineer Bangalore f 1990-02-19 84.3 board ofsecondary education,ap 2007 ... -1 -1 -1 -1 -1 0.9737 0.8128 0.5269 1.35490 -0.4455
579905 500000 2013-09-01 present assistant manager Indore m 1989-10-04 85.4 cbse 2007 ... -1 -1 -1 -1 -1 -0.7335 0.3789 1.2396 -0.10760 0.8637
810601 325000 2014-06-01 present systems engineer Chennai f 1992-08-03 85.0 cbse 2010 ... -1 -1 -1 -1 -1 0.2718 1.7109 0.1637 -0.86820 0.6721
267447 1100000 2011-07-01 present senior software engineer Gurgaon m 1989-12-05 85.6 cbse 2007 ... -1 -1 -1 -1 -1 0.0464 0.3448 -0.3440 -0.40780 -0.9194
343523 200000 2014-03-01 2015-03-01 00:00:00 get Manesar m 1991-02-27 78.0 cbse 2008 ... -1 -1 -1 -1 -1 -0.8810 -0.2793 -1.0697 0.09163 -0.1295

5 rows × 37 columns

In [ ]:
d['Designation'].unique()
Out[ ]:
array(['senior quality engineer', 'assistant manager', 'systems engineer',
       'senior software engineer', 'get', 'system engineer',
       'java software engineer', 'mechanical engineer',
       'electrical engineer', 'project engineer', 'senior php developer',
       'senior systems engineer', 'quality assurance engineer',
       'qa analyst', 'network engineer', 'product development engineer',
       'associate software developer', 'data entry operator',
       'software engineer', 'developer', 'electrical project engineer',
       'programmer analyst', 'systems analyst', 'ase',
       'telecommunication engineer', 'application developer',
       'ios developer', 'executive assistant', 'online marketing manager',
       'documentation specialist', 'associate software engineer',
       'management trainee', 'site manager', 'software developer',
       '.net developer', 'production engineer', 'jr. software engineer',
       'trainee software developer', 'ui developer',
       'assistant system engineer', 'android developer',
       'customer service', 'test engineer', 'java developer', 'engineer',
       'recruitment coordinator', 'technical support engineer',
       'data analyst', 'assistant software engineer', 'faculty',
       'entry level management trainee',
       'customer service representative', 'software test engineer',
       'firmware engineer', 'php developer', 'research associate',
       'research analyst', 'quality engineer', 'programmer',
       'technical support executive', 'business analyst', 'web developer',
       'application engineer', 'project coordinator', 'engineer trainee',
       'sap consultant', 'quality analyst', 'marketing coordinator',
       'system administrator', 'senior engineer',
       'business development managerde', 'network administrator',
       'technical support specialist', 'business development executive',
       'junior software engineer', 'asp.net developer',
       'graduate engineer trainee', 'field engineer',
       'assistant professor', 'trainee software engineer',
       'senior software developer',
       'quality assurance automation engineer', 'design engineer',
       'telecom engineer', 'quality control engineer',
       'hardware engineer', 'hr recruiter', 'sales associate',
       'junior engineer', 'associate engineer', 'maintenance engineer',
       'sales engineer', 'human resources associate',
       'mobile application developer',
       'electronic field service engineer', 'process associate',
       'field service engineer', 'it support specialist',
       'software development engineer', 'business process analyst',
       'operation engineer', 'electrical designer', 'marketing assistant',
       'sales executive', 'admin assistant', 'senior java developer',
       'account executive', 'oracle dba', 'rf engineer',
       'embedded software engineer', 'programmer analyst trainee',
       'technical engineer', 'operations executive', 'trainee engineer',
       'recruiter', 'lecturer', '.net web developer',
       'marketing executive', 'operations assistant', 'associate manager',
       'electrical design engineer', 'systems administrator',
       'client services associate', 'it analyst', 'senior developer',
       'cad designer', 'business technology analyst', 'asst. manager',
       'service engineer', 'executive recruiter', 'planning engineer',
       'associate technical operations', 'web designer',
       'software architect', 'software quality assurance tester',
       'seo trainee', 'process engineer',
       'software quality assurance analyst', 'designer',
       'business systems consultant', 'business development manager',
       'junior research fellow', 'technical recruiter',
       'operations analyst', 'quality assurance test engineer',
       'linux systems administrator', 'software trainee',
       'entry level sales and marketing', 'electrical field engineer',
       'windows systems administrator', 'junior software developer',
       'python developer', 'web application developer',
       'assistant systems engineer', 'javascript developer',
       'operation executive', 'performance engineer', 'technical writer',
       'operations engineer and jetty handling', 'lead engineer',
       'portfolio analyst', 'associate system engineer',
       'mechanical design engineer', 'product engineer',
       'network security engineer', 'operations manager',
       'technical lead', 'operations', 'quality assurance tester',
       'automation engineer', 'data scientist', 'quality associate',
       'manual tester', 'sr. engineer', 'embedded engineer',
       'service and sales engineer', 'telecom support engineer',
       'engineer- customer support', 'cloud engineer', 'branch manager',
       'business analyst consultant', 'technology lead',
       'software trainee engineer', 'dcs engineer', 'junior manager',
       'ux designer', 'clerical', 'hr generalist',
       'database administrator', 'senior design engineer', 'seo',
       'assistant engineer', 'marketing analyst', 'it executive',
       'salesforce developer', 'software tester', 'sql dba',
       'junior engineer product support', 'manager',
       'senior business analyst', 'c# developer',
       'implementation engineer', 'executive hr', 'executive engineer',
       'sharepoint developer', 'system analyst',
       'sales management trainee', 'senior project engineer',
       'it recruiter', 'software engineer analyst',
       'desktop support technician', 'continuous improvement engineer',
       'process advisor', 'etl developer', 'sales and service engineer',
       'project manager', 'training specialist', 'product manager',
       'staffing recruiter', 'assistant programmer', 'quality controller',
       'mis executive', 'game developer', 'digital marketing specialist',
       'principal software engineer', 'software devloper',
       'senior mechanical engineer', 'technical operations analyst',
       'service coordinator', 'testing engineer', 'technical assistant',
       'sap abap consultant', 'seo engineer', 'project assistant',
       'talent acquisition specialist', 'sales account manager',
       'software engineer trainee', 'customer service manager',
       'help desk analyst', 'general manager', 'engineering manager',
       'senior network engineer',
       'field based employee relations manager', 'phone banking officer',
       'support engineer', 'associate test engineer',
       'technology analyst', 'network support engineer',
       'it business analyst', 'junior system analyst',
       'senior .net developer', 'secretary', 'research engineer',
       'quality assurance auditor', 'process executive',
       'lecturer & electrical maintenance', 'office coordinator',
       'hr manager', 'html developer', 'sales support',
       'front end web developer', 'administrative support',
       'territory sales manager', 'project administrator',
       'environmental engineer', 'web designer and seo',
       'information security analyst',
       'field business development associate', 'operational executive',
       'administrative coordinator', 'senior risk consultant',
       'desktop support engineer', 'cad drafter', 'noc engineer',
       'industrial engineer', 'it engineer', 'human resources intern',
       'senior quality assurance engineer', 'clerical assistant',
       'software enginner', 'quality assurance',
       'delivery software engineer', 'graphic designer',
       'sales development manager', 'visiting faculty',
       'business intelligence analyst', 'team lead',
       'operational excellence manager', 'sales & service engineer',
       'web intern', 'full stack developer', 'database developer',
       'sr. database engineer', 'graduate apprentice trainee',
       'software engineer associate', 'technical analyst',
       'executive engg', 'it technician', 'business system analyst',
       'process control engineer', 'technical consultant',
       'business office manager', 'quality control inspector',
       'product design engineer', 'manufacturing engineer',
       'seo executive', 'sap analyst', 'software engineere',
       'financial service consultant', 'co faculty', 'software analyst',
       'desktop support analyst', 'graduate engineer',
       'engineering technician', 'it assistant', 'marketing manager',
       'human resource assistant', 'hr assistant', 'product developer',
       'customer support engineer',
       'quality control inspection technician', 'gis/cad engineer',
       'senior web developer', 'sql developer', 'research staff member',
       'sap abap associate consultant', 'associate qa',
       'corporate recruiter', 'project management officer',
       'business systems analyst', 'software programmer',
       'help desk technician', 'sales manager', 'catalog associate',
       'assistant store manager', 'software engg', 'it developer',
       'apprentice', 'business consultant', 'controls engineer',
       'ruby on rails developer', 'risk consultant', 'account manager',
       'professor', 'assistant administrator', 'civil engineer',
       'educator', 'service manager', 'teradata dba',
       'full-time loss prevention associate', 'junior recruiter',
       'associate developer', 'assistant electrical engineer',
       'shift engineer', 'dotnet developer', 'rf/dt engineer',
       'human resources analyst', 'software test engineerte',
       'junior .net developer', 'java trainee', 'maintenance supervisor',
       'r&d engineer', 'front end developer', 'engineer-hws',
       'operations engineer', 'senior research fellow',
       'web designer and joomla administrator',
       'enterprise solutions developer',
       'information technology specialist', 'site engineer',
       'graduate trainee engineer', 'quality assurance analyst',
       'cnc programmer', 'financial analyst', 'system engineer trainee',
       'sap mm consultant', 'assistant system engineer trainee',
       'qa trainee', 'teradata developer', 'hr executive',
       'senior programmer', 'software test engineer (etl)',
       'associate software engg', 'supply chain analyst', 'sales trainer',
       'software executive', 'team leader',
       'assistant system engineer - trainee', 'seo analyst',
       'risk investigator', 'executive administrative assistant',
       'program manager', 'r & d', 'sap functional consultant',
       'website developer/tester', 'software designer',
       'sales coordinator', 'qa engineer', 'aircraft technician',
       'customer care executive', 'senior test engineer',
       'program analyst trainee', 'electrical controls engineer',
       'trainee decision scientist', 'editor', 'bss engineer', 'dba',
       'software eng', 'computer faculty', 'recruitment associate',
       'logistics executive', 'quality consultant',
       'senior sales executive', 'db2 dba', 'test technician',
       'it operations associate', 'software engineering associate',
       'research scientist', 'jr. software developer'], dtype=object)
In [ ]:
d['Designation'].str.upper()
Out[ ]:
ID
203097         SENIOR QUALITY ENGINEER
579905               ASSISTANT MANAGER
810601                SYSTEMS ENGINEER
267447        SENIOR SOFTWARE ENGINEER
343523                             GET
                      ...             
407755                         MANAGER
575154               SOFTWARE ENGINEER
216598                TECHNICAL WRITER
919755     ASSOCIATE SOFTWARE ENGINEER
1037308             SOFTWARE DEVELOPER
Name: Designation, Length: 5498, dtype: object
In [ ]:
d.head(2)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
203097 420000 2012-06-01 present senior quality engineer Bangalore f 1990-02-19 84.3 board ofsecondary education,ap 2007 ... -1 -1 -1 -1 -1 0.9737 0.8128 0.5269 1.3549 -0.4455
579905 500000 2013-09-01 present assistant manager Indore m 1989-10-04 85.4 cbse 2007 ... -1 -1 -1 -1 -1 -0.7335 0.3789 1.2396 -0.1076 0.8637

2 rows × 37 columns

In [ ]:
d['10percentage'].mean()
Out[ ]:
78.05070025463795
In [ ]:
d['Salary'].mean()
Out[ ]:
305605.49290651147
In [ ]:
d.describe()
Out[ ]:
Salary 10percentage 12graduation 12percentage CollegeID CollegeTier collegeGPA CollegeCityID CollegeCityTier GraduationYear ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
count 5.498000e+03 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 ... 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000 5498.000000
mean 3.056055e+05 78.050700 2008.096944 74.597506 5169.293198 1.925973 71.521359 5169.293198 0.294289 2012.246453 ... 89.173518 22.979629 17.623136 32.580757 3.042197 -0.037976 0.156622 0.015219 -0.147904 -0.128363
std 2.030102e+05 9.774724 1.636035 10.902039 4787.707246 0.261839 8.328995 4787.707246 0.455764 27.174495 ... 174.314470 98.511684 90.694107 105.358134 38.560043 1.026689 0.919777 0.943009 1.008903 0.982055
min 3.500000e+04 43.000000 1995.000000 40.000000 2.000000 1.000000 6.450000 2.000000 0.000000 0.000000 ... -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -4.126700 -5.781600 -4.600900 -2.643000 -7.375700
25% 1.800000e+05 72.000000 2007.000000 66.400000 513.000000 2.000000 66.700000 513.000000 0.000000 2012.000000 ... -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -0.726400 -0.287100 -0.604800 -0.868200 -0.669200
50% 3.000000e+05 79.600000 2008.000000 74.530000 3879.000000 2.000000 71.830000 3879.000000 0.000000 2013.000000 ... -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 0.046400 0.212400 0.091400 -0.172700 -0.050600
75% 3.700000e+05 85.615000 2009.000000 82.800000 8816.250000 2.000000 76.400000 8816.250000 1.000000 2014.000000 ... -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 0.702700 0.812800 0.672000 0.526200 0.502400
max 4.000000e+06 97.760000 2013.000000 98.700000 18409.000000 2.000000 99.930000 18409.000000 1.000000 2017.000000 ... 746.000000 653.000000 676.000000 553.000000 548.000000 1.995300 1.904800 2.535400 3.352500 1.822400

8 rows × 26 columns

In [ ]:
d['Designation'] = d['Designation'].astype(str)
  • Pandas 1.0 introduces a new datatype specific to string data which is StringDtype.
  • As of now, we can still use object or StringDtype to store strings but in the future, we may be required to only use StringDtype.
  • One important thing to note here is that object datatype is still the default datatype for strings
  • Covert a column to string string datatype
    • df['points'] = df['points'].astype(str)
  • Convert multiple columns to string type
    • df[['points', 'assists']] = df[['points', 'assists']].astype(str)
In [ ]:
df10 = d.sample(10)
In [ ]:
df10
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
902841 430000 2014-05-01 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 83.00 state board 2010 ... -1 -1 -1 -1 -1 -0.7335 -0.4536 0.1637 1.0333 -0.2859
89357 225000 2011-02-01 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 69.00 sslc 2006 ... -1 -1 -1 -1 -1 1.4374 -1.2153 -0.6343 -0.2902 -2.0253
984851 320000 2015-03-01 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 78.17 state board 2010 ... -1 -1 676 -1 -1 1.1336 0.3789 0.1637 -0.7415 -0.6692
1129408 250000 2013-06-01 present system engineer Chennai m 1990-04-19 69.00 state board 2009 ... -1 -1 -1 -1 -1 0.1282 0.5454 -0.6048 0.0192 -1.0524
1088496 120000 2014-08-01 present junior software engineer Trivandrum m 1990-11-16 75.00 cbse 2009 ... -1 -1 -1 -1 -1 -0.4463 0.0459 -0.7585 -1.2486 -0.4776
687711 300000 2014-06-01 present software engineer noida m 1990-10-31 83.20 cbse 2009 ... 438 -1 -1 -1 -1 -1.4517 0.2124 0.1637 -0.7415 -0.8608
994256 340000 2014-04-01 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 74.00 state board 2009 ... -1 -1 -1 -1 -1 0.5591 0.0459 0.6248 0.5262 1.6302
109166 380000 2012-02-01 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 79.83 gshseb 2006 ... -1 -1 -1 -1 -1 0.2009 0.0328 -0.0537 -1.4653 0.1864
1193139 325000 2014-08-01 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 71.84 state board 2010 ... -1 -1 -1 -1 -1 0.1282 0.2124 -0.9122 1.0333 -0.0943
1226693 350000 2015-02-01 present front end developer Gurgaon f 1993-08-12 92.00 cbse 2011 ... -1 -1 -1 -1 -1 -1.1644 0.7119 -0.6048 -0.3612 0.6721

10 rows × 37 columns

In [ ]:
def sal_low_red(x):
    color = 'red' if x < 200000 else 'blue'
    return "color:" + color

work with single column in a dataframe

In [ ]:
df10.style.bar(subset = ['Salary'])
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100

work with one column as single column

In [ ]:
df10[['Salary']].style.bar()
Out[ ]:
  Salary
ID  
902841 430000
89357 225000
984851 320000
1129408 250000
1088496 120000
687711 300000
994256 340000
109166 380000
1193139 325000
1226693 350000
In [ ]:
df10.style.bar(subset = ['Salary'], color = 'blue')
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100
In [ ]:
df10[['Salary']].style.bar(color='blue')
Out[ ]:
  Salary
ID  
902841 430000
89357 225000
984851 320000
1129408 250000
1088496 120000
687711 300000
994256 340000
109166 380000
1193139 325000
1226693 350000
In [ ]:
def gender_color(x):
    color = "red" if x == "M" else ""
    return "color:" + color

applying function on Gender col

In [ ]:
df10.style.applymap(gender_color)
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100
In [ ]:
df10[['10percentage']].style.highlight_max(color='red').highlight_min(color='green')
Out[ ]:
  10percentage
ID  
902841 83.000000
89357 69.000000
984851 78.170000
1129408 69.000000
1088496 75.000000
687711 83.200000
994256 74.000000
109166 79.830000
1193139 71.840000
1226693 92.000000

For every cell in the DataFrame, if the value is less than 6 then we will highlight the cell with red color, otherwise with blue color.

link: https://www.geeksforgeeks.org/highlight-pandas-dataframes-specific-columns-using-applymap/?ref=rp

Write a function to find the max value and make it bold

  • apply() is used to apply a function along an axis or column of the DataFrame or on values of Series.
  • applymap() is used to apply a function to each element in a DataFrame.
  • map() is used to substitute each value in a Series with another value
In [ ]:
# importing pandas as pd
import pandas as pd

# creating the dataframe
df = pd.DataFrame({"A" : [14, 4, 5, 4, 1],
				"B" : [5, 2, 54, 3, 2],
				"C" : [20, 20, 7, 3, 8],
				"D" : [14, 3, 6, 2, 6]})

print("Original DataFrame :")
display(df)
Original DataFrame :
A B C D
0 14 5 20 14
1 4 2 20 3
2 5 54 7 6
3 4 3 3 2
4 1 2 8 6
In [ ]:
# function definition
def highlight_cols(s):
    color = 'red' if s < 6 else 'blue'
    return 'background-color: % s' % color
  
# highlighting the cells
display(df.style.applymap(highlight_cols))
  A B C D
0 14 5 20 14
1 4 2 20 3
2 5 54 7 6
3 4 3 3 2
4 1 2 8 6
In [ ]:
# function definition
def highlight_cols(s):
    color = "red" if s < 10 else "blue"
    # return 'background-color: % s' % 'green' if s < 10 else "blue"
    return "color:" + color
    # return 'background-color:' + color
  
# highlighting the cells
display(df.style.applymap(highlight_cols, 
                          subset = pd.IndexSlice[:, ['B', 'C']]))
  A B C D
0 14 5 20 14
1 4 2 20 3
2 5 54 7 6
3 4 3 3 2
4 1 2 8 6
In [ ]:
df10.head(2)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
902841 430000 2014-05-01 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 83.0 state board 2010 ... -1 -1 -1 -1 -1 -0.7335 -0.4536 0.1637 1.0333 -0.2859
89357 225000 2011-02-01 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 69.0 sslc 2006 ... -1 -1 -1 -1 -1 1.4374 -1.2153 -0.6343 -0.2902 -2.0253

2 rows × 37 columns

apply color code for multiple colums with IndexSlice Option

In [ ]:
# function definition
def highlight_cols(s):
    color = "red" if s <= 70 else "green"
    # return 'background-color: % s' % 'green'
    # return "color:" + color
    return 'background-color: ' + color
  
# highlighting the cells
display(df10.style.applymap(highlight_cols, 
                          subset = pd.IndexSlice[:, ['10percentage', '12percentage']]))
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100

apply color code for one column

In [ ]:
def highlight_cols(s):
    color = "red" if s <= 70 else "green"
    return 'background-color: ' + color
In [ ]:
display(df10.style.applymap(highlight_cols, subset = pd.IndexSlice[:, ['12percentage']]))
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100
In [ ]:
df10.style.applymap(highlight_cols, subset = pd.IndexSlice[:, ['10percentage']]).bar(color='blue')
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100

apply style with bar only for two cols with SUBSET option

In [ ]:
df10.style.bar(subset=['10percentage','12percentage', 'English', 'Logical', 'Quant'], color="blue")
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100
In [ ]:
## highlight min and max values
In [ ]:
df10.style.highlight_max(subset=['10percentage', '12percentage'], color='red')
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100
In [ ]:
df10.style.highlight_max(subset=['10percentage', '12percentage'], color='red').highlight_min(subset = ['10percentage', "12percentage"], color='blue')
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100
In [ ]:
df10.style.background_gradient(cmap = 'red')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/IPython/core/formatters.py in __call__(self, obj)
    332                 pass
    333             else:
--> 334                 return printer(obj)
    335             # Finally look for special method names
    336             method = get_real_method(obj, self.print_method)

/usr/local/lib/python3.7/dist-packages/google/colab/_reprs.py in new_formatter(dataframe)
     86 
     87   def new_formatter(dataframe):
---> 88     return dataframe.set_table_attributes('class="dataframe"')._repr_html_()  # pylint: disable=protected-access
     89 
     90   _original_df_formatters[key] = formatters[key].for_type_by_name(

/usr/local/lib/python3.7/dist-packages/pandas/io/formats/style.py in _repr_html_(self)
    214         Hooks into Jupyter notebook rich display system.
    215         """
--> 216         return self.render()
    217 
    218     def render(

/usr/local/lib/python3.7/dist-packages/pandas/io/formats/style.py in render(self, sparse_index, sparse_columns, **kwargs)
    270         if sparse_columns is None:
    271             sparse_columns = get_option("styler.sparse.columns")
--> 272         return self._render_html(sparse_index, sparse_columns, **kwargs)
    273 
    274     def set_tooltips(

/usr/local/lib/python3.7/dist-packages/pandas/io/formats/style_render.py in _render_html(self, sparse_index, sparse_columns, **kwargs)
    119         Generates a dict with necessary kwargs passed to jinja2 template.
    120         """
--> 121         self._compute()
    122         # TODO: namespace all the pandas keys
    123         d = self._translate(sparse_index, sparse_columns)

/usr/local/lib/python3.7/dist-packages/pandas/io/formats/style_render.py in _compute(self)
    158         r = self
    159         for func, args, kwargs in self._todo:
--> 160             r = func(self)(*args, **kwargs)
    161         return r
    162 

/usr/local/lib/python3.7/dist-packages/pandas/io/formats/style.py in _apply(self, func, axis, subset, **kwargs)
   1053         data = self.data.loc[subset]
   1054         if axis is not None:
-> 1055             result = data.apply(func, axis=axis, result_type="expand", **kwargs)
   1056             result.columns = data.columns
   1057         else:

/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py in apply(self, func, axis, raw, result_type, args, **kwargs)
   8738             kwargs=kwargs,
   8739         )
-> 8740         return op.apply()
   8741 
   8742     def applymap(

/usr/local/lib/python3.7/dist-packages/pandas/core/apply.py in apply(self)
    686             return self.apply_raw()
    687 
--> 688         return self.apply_standard()
    689 
    690     def agg(self):

/usr/local/lib/python3.7/dist-packages/pandas/core/apply.py in apply_standard(self)
    810 
    811     def apply_standard(self):
--> 812         results, res_index = self.apply_series_generator()
    813 
    814         # wrap results

/usr/local/lib/python3.7/dist-packages/pandas/core/apply.py in apply_series_generator(self)
    826             for i, v in enumerate(series_gen):
    827                 # ignore SettingWithCopy here in case the user mutates
--> 828                 results[i] = self.f(v)
    829                 if isinstance(results[i], ABCSeries):
    830                     # If we have a view on v, we need to make a copy because

/usr/local/lib/python3.7/dist-packages/pandas/core/apply.py in f(x)
    129 
    130             def f(x):
--> 131                 return func(x, *args, **kwargs)
    132 
    133         else:

/usr/local/lib/python3.7/dist-packages/pandas/io/formats/style.py in _background_gradient(data, cmap, low, high, text_color_threshold, vmin, vmax, gmap, text_only)
   2816         # extend lower / upper bounds, compresses color range
   2817         norm = colors.Normalize(smin - (rng * low), smax + (rng * high))
-> 2818         rgbas = plt.cm.get_cmap(cmap)(norm(gmap))
   2819 
   2820         def relative_luminance(rgba) -> float:

/usr/local/lib/python3.7/dist-packages/matplotlib/cm.py in get_cmap(name, lut)
    132     if isinstance(name, colors.Colormap):
    133         return name
--> 134     cbook._check_in_list(sorted(cmap_d), name=name)
    135     if lut is None:
    136         return cmap_d[name]

/usr/local/lib/python3.7/dist-packages/matplotlib/cbook/__init__.py in _check_in_list(_values, **kwargs)
   2143             raise ValueError(
   2144                 "{!r} is not a valid value for {}; supported values are {}"
-> 2145                 .format(v, k, ', '.join(map(repr, values))))
   2146 
   2147 

ValueError: 'red' is not a valid value for name; supported values are 'Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', 'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'crest', 'crest_r', 'cubehelix', 'cubehelix_r', 'flag', 'flag_r', 'flare', 'flare_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'icefire', 'icefire_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma...
Out[ ]:
<pandas.io.formats.style.Styler at 0x7f53ca4c9850>
In [ ]:
df10.style.background_gradient(cmap = 'Blues')
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100
In [ ]:
df10.style.background_gradient(cmap = 'Pastel1')
Out[ ]:
  Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation 12percentage 12board CollegeID CollegeTier Degree Specialization collegeGPA CollegeCityID CollegeCityTier CollegeState GraduationYear English Logical Quant Domain ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID                                                                          
902841 430000 2014-05-01 00:00:00 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 00:00:00 83.000000 state board 2010 82.000000 state board 9775 2 B.Tech/B.E. computer science & engineering 71.000000 9775 1 Telangana 2014 425 465 470 -1.000000 -1 -1 -1 -1 -1 -1 -1 -0.733500 -0.453600 0.163700 1.033300 -0.285900
89357 225000 2011-02-01 00:00:00 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 00:00:00 69.000000 sslc 2006 50.000000 puc 1648 2 B.Tech/B.E. information technology 60.000000 1648 1 Karnataka 2010 404 375 395 0.488348 405 -1 -1 -1 -1 -1 -1 1.437400 -1.215300 -0.634300 -0.290200 -2.025300
984851 320000 2015-03-01 00:00:00 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 00:00:00 78.170000 state board 2010 77.850000 state board 4948 2 B.Tech/B.E. electrical engineering 76.850000 4948 1 Rajasthan 2014 675 495 545 0.997698 -1 -1 -1 -1 676 -1 -1 1.133600 0.378900 0.163700 -0.741500 -0.669200
1129408 250000 2013-06-01 00:00:00 present system engineer Chennai m 1990-04-19 00:00:00 69.000000 state board 2009 61.300000 state board 5039 2 B.Tech/B.E. electronics and communication engineering 69.000000 5039 0 Andhra Pradesh 2013 430 425 295 0.338786 175 292 -1 -1 -1 -1 -1 0.128200 0.545400 -0.604800 0.019200 -1.052400
1088496 120000 2014-08-01 00:00:00 present junior software engineer Trivandrum m 1990-11-16 00:00:00 75.000000 cbse 2009 80.000000 state board 10361 2 B.Tech/B.E. electronics and communication engineering 60.850000 10361 0 Kerala 2013 570 580 750 -1.000000 495 -1 -1 -1 -1 -1 -1 -0.446300 0.045900 -0.758500 -1.248600 -0.477600
687711 300000 2014-06-01 00:00:00 present software engineer noida m 1990-10-31 00:00:00 83.200000 cbse 2009 67.000000 state board 7814 2 B.Tech/B.E. computer science & engineering 70.700000 7814 0 Orissa 2013 565 615 445 0.744758 295 -1 438 -1 -1 -1 -1 -1.451700 0.212400 0.163700 -0.741500 -0.860800
994256 340000 2014-04-01 00:00:00 2015-04-01 00:00:00 web application developer Bangalore m 1991-12-13 00:00:00 74.000000 state board 2009 78.000000 state board 10389 2 B.Tech/B.E. electronics & telecommunications 73.720000 10389 0 Madhya Pradesh 2013 405 470 585 0.783304 505 388 -1 -1 -1 -1 -1 0.559100 0.045900 0.624800 0.526200 1.630200
109166 380000 2012-02-01 00:00:00 2014-08-01 00:00:00 software engineer Pune f 1989-09-03 00:00:00 79.830000 gshseb 2006 68.330000 gshseb 988 2 B.Tech/B.E. electronics and communication engineering 68.740000 988 0 Gujarat 2010 435 605 685 0.824666 -1 400 -1 -1 -1 -1 -1 0.200900 0.032800 -0.053700 -1.465300 0.186400
1193139 325000 2014-08-01 00:00:00 2015-04-01 00:00:00 software engineer Bangalore m 1992-06-25 00:00:00 71.840000 state board 2010 66.830000 state board 3770 2 B.Tech/B.E. computer science & engineering 70.350000 3770 0 Karnataka 2016 640 615 585 0.974396 615 -1 -1 -1 -1 -1 -1 0.128200 0.212400 -0.912200 1.033300 -0.094300
1226693 350000 2015-02-01 00:00:00 present front end developer Gurgaon f 1993-08-12 00:00:00 92.000000 cbse 2011 85.600000 cbse 115 2 B.Tech/B.E. computer science & engineering 91.000000 115 0 Punjab 2015 535 480 605 -1.000000 -1 -1 -1 -1 -1 -1 -1 -1.164400 0.711900 -0.604800 -0.361200 0.672100
In [ ]:
d.groupby('Designation')['Designation'].count()
Out[ ]:
Designation
.net developer                   48
.net web developer                5
account executive                 4
account manager                   1
admin assistant                   2
                                 ..
web designer and seo              1
web developer                    77
web intern                        1
website developer/tester          2
windows systems administrator     1
Name: Designation, Length: 419, dtype: int64
In [ ]:
c = df10.groupby('JobCity')['JobCity'].count()
In [ ]:
plt.pie(c, labels = c.index)
Out[ ]:
([<matplotlib.patches.Wedge at 0x7f53ca96f350>,
  <matplotlib.patches.Wedge at 0x7f53ca96fa10>,
  <matplotlib.patches.Wedge at 0x7f53ca9b5290>,
  <matplotlib.patches.Wedge at 0x7f53ca9b5390>,
  <matplotlib.patches.Wedge at 0x7f53ca9bb4d0>,
  <matplotlib.patches.Wedge at 0x7f53ca9bbd90>,
  <matplotlib.patches.Wedge at 0x7f53ca96d3d0>,
  <matplotlib.patches.Wedge at 0x7f53ca96d050>],
 [Text(1.0461621663333946, 0.3399186987098808, 'Ahmedabad'),
  Text(-5.149471629032507e-08, 1.0999999999999988, 'Bangalore'),
  Text(-1.0461621981588756, 0.3399186007611085, 'Chennai'),
  Text(-1.0461621345079049, -0.3399187966586502, 'Gurgaon'),
  Text(-0.646563681703485, -0.8899187634284573, 'Hyderabad'),
  Text(1.2873679044788556e-07, -1.0999999999999925, 'Pune'),
  Text(0.646563890003987, -0.8899186120892812, 'Trivandrum'),
  Text(1.0461622140716127, -0.3399185517867209, 'noida')])

use semi-colon ";" to supress the running text before graph

In [ ]:
plt.pie(c, labels = c.index);
In [ ]:
plt.pie(c, labels = c.index, autopct = "%.2f%%");
In [ ]:
plt.pie(c, labels = c.index, autopct = "%.2f%%", rotatelabels = True);
In [ ]:
plt.pie(d.groupby('Designation')['Designation'].count());
In [ ]:
plt.pie(d.groupby('Designation')['Designation'].count(), autopct = "%2.f%%", pctdistance = 1.2);
In [ ]:
plt.pie(df10.groupby('Designation')['Designation'].count(), autopct="%.2f%%", pctdistance = 0.6, shadow=False, labeldistance = 2.1);
In [ ]:
d.head(1)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
203097 420000 2012-06-01 present senior quality engineer Bangalore f 1990-02-19 84.3 board ofsecondary education,ap 2007 ... -1 -1 -1 -1 -1 0.9737 0.8128 0.5269 1.3549 -0.4455

1 rows × 37 columns

In [ ]:
plt.pie(df10.groupby('Designation')['Designation'].count(), autopct="%.2f%%", pctdistance = 1.2, shadow=False, labeldistance = 2.1, wedgeprops = dict(width=0.3));
In [ ]:
plt.pie(df10.groupby('JobCity')['JobCity'].count(), 
        wedgeprops = dict(width = 0.2), 
        autopct = "%.2f%%", 
        shadow=True, 
        pctdistance = 1.2);

Pie chart Parameters

  • (x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=None, radius=None, counterclock=True, wedgeprops=None, textprops=None, center=(0, 0), frame=False, rotatelabels=False, *, data=None) -> Any
  • to convert a pie chart to a donut chart, use wedgeprops property with suitable value
  • a full circle has a value of 1, and the value may range between 0.1 to 1 ie: wedgeprops = dict(width = 0.2)
In [ ]:
c = df10.groupby('JobCity')['JobCity'].count()
plt.pie(c, autopct = "%.2f%%", 
        pctdistance = 1.2, 
        labels = c.index, 
        labeldistance = 1.4, 
        wedgeprops = dict(width = .25));
In [ ]:
df10.head(3)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
902841 430000 2014-05-01 2014-08-01 00:00:00 software engineer Hyderabad m 1992-05-19 83.00 state board 2010 ... -1 -1 -1 -1 -1 -0.7335 -0.4536 0.1637 1.0333 -0.2859
89357 225000 2011-02-01 2011-07-01 00:00:00 technical support engineer Bangalore m 1989-01-05 69.00 sslc 2006 ... -1 -1 -1 -1 -1 1.4374 -1.2153 -0.6343 -0.2902 -2.0253
984851 320000 2015-03-01 2015-05-01 00:00:00 system engineer Ahmedabad m 1993-08-20 78.17 state board 2010 ... -1 -1 676 -1 -1 1.1336 0.3789 0.1637 -0.7415 -0.6692

3 rows × 37 columns

data split

In [ ]:
d.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 5498 entries, 203097 to 1037308
Data columns (total 37 columns):
 #   Column                 Non-Null Count  Dtype         
---  ------                 --------------  -----         
 0   Salary                 5498 non-null   int64         
 1   DOJ                    5498 non-null   datetime64[ns]
 2   DOL                    5498 non-null   object        
 3   Designation            5498 non-null   object        
 4   JobCity                5498 non-null   object        
 5   Gender                 5498 non-null   object        
 6   DOB                    5498 non-null   datetime64[ns]
 7   10percentage           5498 non-null   float64       
 8   10board                5498 non-null   object        
 9   12graduation           5498 non-null   int64         
 10  12percentage           5498 non-null   float64       
 11  12board                5498 non-null   object        
 12  CollegeID              5498 non-null   int64         
 13  CollegeTier            5498 non-null   int64         
 14  Degree                 5498 non-null   object        
 15  Specialization         5498 non-null   object        
 16  collegeGPA             5498 non-null   float64       
 17  CollegeCityID          5498 non-null   int64         
 18  CollegeCityTier        5498 non-null   int64         
 19  CollegeState           5498 non-null   object        
 20  GraduationYear         5498 non-null   int64         
 21  English                5498 non-null   int64         
 22  Logical                5498 non-null   int64         
 23  Quant                  5498 non-null   int64         
 24  Domain                 5498 non-null   float64       
 25  ComputerProgramming    5498 non-null   int64         
 26  ElectronicsAndSemicon  5498 non-null   int64         
 27  ComputerScience        5498 non-null   int64         
 28  MechanicalEngg         5498 non-null   int64         
 29  ElectricalEngg         5498 non-null   int64         
 30  TelecomEngg            5498 non-null   int64         
 31  CivilEngg              5498 non-null   int64         
 32  conscientiousness      5498 non-null   float64       
 33  agreeableness          5498 non-null   float64       
 34  extraversion           5498 non-null   float64       
 35  nueroticism            5498 non-null   float64       
 36  openess_to_experience  5498 non-null   float64       
dtypes: datetime64[ns](2), float64(9), int64(17), object(9)
memory usage: 1.6+ MB
In [ ]:
df_init = d[['Salary', 'DOJ', 'DOL', 'Designation', 'JobCity', 'Gender', 'DOB',
             'CollegeID', 'conscientiousness', 'agreeableness', 'extraversion', 'nueroticism', 'openess_to_experience']]
In [ ]:
dfs_init = df_init.sample(1000)
In [ ]:
dfs_init.head(2)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB CollegeID conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
796983 415000 2014-06-01 present assistant manager PATNA m 1993-01-20 11848 -1.3080 0.3789 -1.6807 -1.24860 -0.4776
342646 180000 2014-03-01 2014-08-01 00:00:00 software developer -1 m 1990-09-06 2563 -0.4173 0.5008 0.1640 -0.87777 -0.2875
In [ ]:
df_engg = d[['CollegeID', 'ComputerProgramming', 'ElectronicsAndSemicon', 'ComputerScience', 'MechanicalEngg', 'ElectricalEngg', 'TelecomEngg', 'CivilEngg',  'CollegeState']]
In [ ]:
dfs_engg = df_engg.sample(1000)
In [ ]:
dfs_engg.head(3)
Out[ ]:
CollegeID ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg CollegeState
ID
693149 272 515 433 -1 -1 -1 -1 -1 Punjab
279776 51 525 -1 -1 -1 -1 -1 -1 Uttar Pradesh
335701 3174 -1 400 -1 -1 -1 313 -1 Andhra Pradesh
In [ ]:
df_engg.head(2)
Out[ ]:
CollegeID ComputerProgramming ElectronicsAndSemicon ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg CollegeState
ID
203097 1141 445 -1 -1 -1 -1 -1 -1 Andhra Pradesh
579905 5807 -1 466 -1 -1 -1 -1 -1 Madhya Pradesh
In [ ]:
df_score = d[['Gender', '10board', '10percentage', '12board', '12graduation', 'Degree',
              'CollegeID', 'CollegeTier', 'CollegeState', 'Specialization', 'English', 'Logical', 'Quant'	]]
In [ ]:
df_score.head(2)
Out[ ]:
Gender 10board 10percentage 12board 12graduation Degree CollegeID CollegeTier CollegeState Specialization English Logical Quant
ID
203097 f board ofsecondary education,ap 84.3 board of intermediate education,ap 2007 B.Tech/B.E. 1141 2 Andhra Pradesh computer engineering 515 585 525
579905 m cbse 85.4 cbse 2007 B.Tech/B.E. 5807 2 Madhya Pradesh electronics and communication engineering 695 610 780
In [ ]:
df_user = d[['Salary', 'DOJ', 'DOL', 'Designation', 'JobCity', 'Gender', 'DOB']]
In [ ]:
dfs_user = df_user.sample(100)
In [ ]:
dfs_user.head()
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB
ID
53722 460000 2010-07-01 present senior software engineer Pune m 1988-04-01
87369 400000 2013-02-01 present senior software engineer Kolkata m 1988-07-26
51320 545000 2011-03-01 2015-05-01 00:00:00 technical lead Bangalore m 1988-04-17
752121 300000 2014-09-01 present software developer Bangalore m 1988-09-03
909904 345000 2014-12-01 2015-05-01 00:00:00 network engineer Bangalore m 1993-06-30
  • dfs_user
  • dfs_engg
  • dfs_init
In [ ]:
dfs_user.head(2)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB
ID
53722 460000 2010-07-01 present senior software engineer Pune m 1988-04-01
87369 400000 2013-02-01 present senior software engineer Kolkata m 1988-07-26
In [ ]:
dfs_user.groupby(dfs_user['JobCity']).count()
Out[ ]:
Salary DOJ DOL Designation Gender DOB
JobCity
-1 12 12 12 12 12 12
AM 1 1 1 1 1 1
Bangalore 20 20 20 20 20 20
Bhubaneswar 1 1 1 1 1 1
Chennai 5 5 5 5 5 5
Greater noida 1 1 1 1 1 1
Gurgaon 6 6 6 6 6 6
Hyderabad 7 7 7 7 7 7
Jaipur 2 2 2 2 2 2
Kochi/Cochin 1 1 1 1 1 1
Kolkata 2 2 2 2 2 2
Lucknow 1 1 1 1 1 1
Mangalore 1 1 1 1 1 1
Mumbai 2 2 2 2 2 2
Mysore 3 3 3 3 3 3
Nagpur 2 2 2 2 2 2
Neemrana 1 1 1 1 1 1
New Delhi 4 4 4 4 4 4
Noida 11 11 11 11 11 11
Pune 7 7 7 7 7 7
Sonipat 1 1 1 1 1 1
Thiruvananthapuram 1 1 1 1 1 1
bangalore 1 1 1 1 1 1
chennai 2 2 2 2 2 2
delhi 1 1 1 1 1 1
noida 2 2 2 2 2 2
pune 1 1 1 1 1 1
pune 1 1 1 1 1 1
In [ ]:
dfs_user.groupby('JobCity')['JobCity'].count()
Out[ ]:
JobCity
-1                    12
AM                     1
Bangalore             20
Bhubaneswar            1
Chennai                5
Greater noida          1
Gurgaon                6
Hyderabad              7
Jaipur                 2
Kochi/Cochin           1
Kolkata                2
Lucknow                1
Mangalore              1
Mumbai                 2
Mysore                 3
Nagpur                 2
Neemrana               1
New Delhi              4
Noida                 11
Pune                   7
Sonipat                1
Thiruvananthapuram     1
bangalore              1
chennai                2
delhi                  1
noida                  2
pune                   1
pune                   1
Name: JobCity, dtype: int64
In [ ]:
dfs_user['JobCity'] = dfs_user['JobCity'].replace("-1", "Not Available", inplace=True)
In [ ]:
dfs_user.groupby('JobCity')['JobCity'].count()
Out[ ]:
Series([], Name: JobCity, dtype: int64)
In [ ]:
c
Out[ ]:
JobCity
Ahmedabad     1
Bangalore     3
Chennai       1
Gurgaon       1
Hyderabad     1
Pune          1
Trivandrum    1
noida         1
Name: JobCity, dtype: int64

to replace an existing value with another value in JobCity col

In [ ]:
dfs_user.replace(to_replace = -1, value="Not Available")
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB
ID
53722 460000 2010-07-01 present senior software engineer None m 1988-04-01
87369 400000 2013-02-01 present senior software engineer None m 1988-07-26
51320 545000 2011-03-01 2015-05-01 00:00:00 technical lead None m 1988-04-17
752121 300000 2014-09-01 present software developer None m 1988-09-03
909904 345000 2014-12-01 2015-05-01 00:00:00 network engineer None m 1993-06-30
... ... ... ... ... ... ... ...
281940 660000 2011-08-01 present assistant manager None m 1989-07-31
1119013 200000 2014-05-01 present senior quality engineer None f 1990-09-29
295545 180000 2011-08-01 2013-03-01 00:00:00 software engineer None m 1987-11-17
1072371 240000 2015-02-01 present software developer None m 1991-06-03
359890 510000 2013-09-01 present test engineer None f 1991-07-29

100 rows × 7 columns

In [ ]:
sns.barplot(x='Designation', y='Salary', data = dfs_user)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f53c92f3490>
In [ ]:
d.head(1)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
203097 420000 2012-06-01 present senior quality engineer Bangalore f 1990-02-19 84.3 board ofsecondary education,ap 2007 ... -1 -1 -1 -1 -1 0.9737 0.8128 0.5269 1.3549 -0.4455

1 rows × 37 columns

In [ ]:
sns.histplot(d['10percentage'])
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f53c9108dd0>
In [ ]:
plt.bar(d.Designation, d.Salary)
Out[ ]:
<BarContainer object of 5498 artists>
In [ ]:
ds100 = d.sample(100)
In [ ]:
ds = d.sample(100)
In [ ]:
ds.head()
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
330760 240000 2013-09-01 2014-12-01 00:00:00 sales management trainee Pune m 1991-06-24 90.5 andhra pradesh board of secondary education 2008 ... -1 -1 -1 -1 -1 1.1283 0.3448 0.6720 -0.2902 -0.0506
982387 325000 2010-09-01 2012-08-01 00:00:00 software engineer Mumbai m 1993-02-06 63.5 cbse 2010 ... 376 -1 -1 -1 -1 -1.4517 -0.2871 0.3174 0.2727 0.2889
529705 330000 2014-01-01 present software engineer Chennai m 1990-06-10 83.3 indian certificate for secondary education 2008 ... -1 -1 -1 -1 -1 0.0464 0.6178 -0.0537 -0.2902 -0.2875
627124 500000 2013-08-01 present software developer Banglore m 1992-10-23 87.0 cbse 2009 ... -1 -1 -1 -1 -1 0.2718 0.3789 -0.7585 -0.6147 0.0973
358189 345000 2013-07-01 present software engineer Pune m 1989-11-20 74.8 cbse 2007 ... -1 -1 -1 -1 -1 -1.0135 -0.2793 -0.1988 0.7493 -0.2875

5 rows × 37 columns

In [ ]:
plt.bar(ds.Designation, ds.Salary)
Out[ ]:
<BarContainer object of 100 artists>
In [ ]:
fig = plt.gcf();
fig.set_size_inches(15, 10);
plt.barh(ds.Designation, ds.Salary)
Out[ ]:
<BarContainer object of 100 artists>
In [ ]:
ds.sort_values('Salary')
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
1042501 85000 2014-08-01 2015-04-01 00:00:00 quality consultant Kolkata f 1991-11-23 72.5 state board 2009 ... -1 -1 -1 -1 -1 1.2772 1.5444 0.9322 -1.1218 0.8637
308499 85000 2012-06-01 2013-04-01 00:00:00 account executive Technopark, Trivandrum f 1988-08-02 77.0 cbse 2007 ... -1 -1 -1 366 -1 0.9737 -0.9033 0.0914 -1.8179 -1.2354
288761 95000 2011-07-01 2012-02-01 00:00:00 design engineer Ernakulam m 1988-09-15 92.0 kerala state board 2007 ... -1 366 -1 -1 -1 0.8192 -0.2793 -0.1988 -0.6428 0.0284
505831 100000 2012-05-01 2012-09-01 00:00:00 software developer -1 f 1990-03-15 75.4 central board of secondary education 2008 ... -1 -1 -1 -1 -1 -0.1855 0.9688 -0.1988 1.2374 0.1864
215660 105000 2014-08-01 2015-04-01 00:00:00 java software engineer Kolkata m 1989-05-27 69.2 jharkhand academic council 2007 ... -1 -1 -1 233 -1 0.2009 -0.4353 -0.0537 1.1199 0.3444
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
35716 600000 2012-01-01 present software test engineer Bangalore m 1988-09-18 90.0 cbse 2006 ... -1 -1 -1 -1 -1 -0.1082 1.1248 0.0914 -0.8778 -0.2875
1091134 655000 2012-06-01 present technical consultant Mumbai m 1991-02-10 70.0 cbse 2009 ... 500 -1 -1 -1 -1 -2.1698 -1.4526 0.6248 1.5404 0.0973
796197 800000 2014-07-01 2015-04-01 00:00:00 software engineer Bangalore f 1993-01-11 93.0 cbse 2010 ... 500 -1 -1 -1 -1 0.2718 0.5454 -1.2196 -1.5021 -1.2440
42943 1000000 2010-09-01 present assistant manager Vadodara m 1988-05-03 86.0 gseb 2006 ... -1 446 -1 -1 -1 0.9737 -1.5273 0.6720 -0.0552 -1.2354
803778 2000000 2013-07-01 2014-10-01 00:00:00 technical lead Pune m 1992-04-24 69.5 state board 2008 ... -1 -1 -1 -1 -1 0.5591 1.0449 1.2396 0.3995 1.0554

100 rows × 37 columns

In [ ]:
fig = plt.gcf()
fig.set_size_inches(8 ,8)
plt.bar(ds.Designation, ds.Salary)
Out[ ]:
<BarContainer object of 100 artists>
In [ ]:
fig = plt.gcf()
fig.set_size_inches(10, 8)
dsa = ds.sort_values(by='Salary', ascending=True, kind = "mergesort")
plt.barh(dsa.Designation, dsa.Salary)
Out[ ]:
<BarContainer object of 100 artists>
In [ ]:
dsa = ds.sort_values(by=["Salary", "Designation"])[["Salary", "Designation"]]
In [ ]:
fig = plt.gcf()
fig.set_size_inches(8, 8)
plt.barh(dsa.Designation, ds.Salary)
Out[ ]:
<BarContainer object of 100 artists>

Find the min salary and corresponding Designation

In [ ]:
dsa[['Salary', 'Designation']].min()
Out[ ]:
Salary                  85000
Designation    .net developer
dtype: object
In [ ]:
d[['Salary', 'Designation']].min()
Out[ ]:
Salary                  35000
Designation    .net developer
dtype: object
In [ ]:
dsa.min()
Out[ ]:
Salary                  85000
Designation    .net developer
dtype: object

returns min in all the columns in the dataframe

In [ ]:
ds.min()
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:1: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError.  Select only valid columns before calling the reduction.
  """Entry point for launching an IPython kernel.
Out[ ]:
Salary                                 85000
DOJ                      2010-04-01 00:00:00
Designation                   .net developer
Gender                                     f
DOB                      1985-02-06 00:00:00
10percentage                            45.0
12graduation                            2002
12percentage                            50.0
CollegeID                                 44
CollegeTier                                1
Degree                           B.Tech/B.E.
Specialization             civil engineering
collegeGPA                              7.56
CollegeCityID                             44
CollegeCityTier                            0
CollegeState                  Andhra Pradesh
GraduationYear                          2010
English                                  205
Logical                                  235
Quant                                    150
Domain                                  -1.0
ComputerProgramming                       -1
ElectronicsAndSemicon                     -1
ComputerScience                           -1
MechanicalEngg                            -1
ElectricalEngg                            -1
TelecomEngg                               -1
CivilEngg                                 -1
conscientiousness                    -3.0448
agreeableness                        -3.9501
extraversion                         -2.7565
nueroticism                          -2.5163
openess_to_experience                -5.6512
dtype: object

gets min values from each row

In [ ]:
ds.min(axis = 1)
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:1: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError.  Select only valid columns before calling the reduction.
  """Entry point for launching an IPython kernel.
Out[ ]:
ID
330760   -1.0000
982387   -1.4517
529705   -1.0000
627124   -1.0000
358189   -1.0135
           ...  
942010   -1.0000
668152   -1.0000
42943    -1.5273
335166   -1.0000
536794   -1.0000
Length: 100, dtype: float64
In [ ]:
dsa.head()
Out[ ]:
Salary Designation
ID
308499 85000 account executive
1042501 85000 quality consultant
288761 95000 design engineer
505831 100000 software developer
215660 105000 java software engineer

get the entire row for a max value on a particular column

In [ ]:
dsa.loc[dsa['Salary'].idxmax()]
Out[ ]:
Salary                2000000
Designation    technical lead
Name: 803778, dtype: object
In [ ]:
ds.loc[ds['Salary'].idxmin()]
Out[ ]:
Salary                                                       85000
DOJ                                            2012-06-01 00:00:00
DOL                                            2013-04-01 00:00:00
Designation                                      account executive
JobCity                                     Technopark, Trivandrum
Gender                                                           f
DOB                                            1988-08-02 00:00:00
10percentage                                                  77.0
10board                                                       cbse
12graduation                                                  2007
12percentage                                                  70.0
12board                                                       cbse
CollegeID                                                     5442
CollegeTier                                                      2
Degree                                                 B.Tech/B.E.
Specialization           electronics and communication engineering
collegeGPA                                                   69.34
CollegeCityID                                                 5442
CollegeCityTier                                                  0
CollegeState                                                Kerala
GraduationYear                                                2011
English                                                        505
Logical                                                        445
Quant                                                          445
Domain                                                    0.694479
ComputerProgramming                                            365
ElectronicsAndSemicon                                          366
ComputerScience                                                 -1
MechanicalEngg                                                  -1
ElectricalEngg                                                  -1
TelecomEngg                                                    366
CivilEngg                                                       -1
conscientiousness                                           0.9737
agreeableness                                              -0.9033
extraversion                                                0.0914
nueroticism                                                -1.8179
openess_to_experience                                      -1.2354
Name: 308499, dtype: object
In [ ]:
dfs_user.head(2)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB
ID
53722 460000 2010-07-01 present senior software engineer None m 1988-04-01
87369 400000 2013-02-01 present senior software engineer None m 1988-07-26
In [ ]:
dfs_user.loc[dfs_user['Salary'].idxmin()]
Out[ ]:
Salary                          60000
DOJ               2013-03-01 00:00:00
DOL               2014-04-01 00:00:00
Designation    software test engineer
JobCity                          None
Gender                              m
DOB               1989-10-20 00:00:00
Name: 371808, dtype: object
In [ ]:
dfs_user.loc[dfs_user['Salary'].idxmax()]
Out[ ]:
Salary                     1200000
DOJ            2011-02-01 00:00:00
DOL                        present
Designation        design engineer
JobCity                       None
Gender                           m
DOB            1987-10-02 00:00:00
Name: 30706, dtype: object
In [ ]:
res = dfs_user.loc[dfs_user['Salary'].idxmax()]
In [ ]:
display(res)
Salary                     1200000
DOJ            2011-02-01 00:00:00
DOL                        present
Designation        design engineer
JobCity                       None
Gender                           m
DOB            1987-10-02 00:00:00
Name: 30706, dtype: object
In [ ]:
print(res)
Salary                     1200000
DOJ            2011-02-01 00:00:00
DOL                        present
Designation        design engineer
JobCity                       None
Gender                           m
DOB            1987-10-02 00:00:00
Name: 30706, dtype: object
In [ ]:
dfs_user['Salary'].mean()
Out[ ]:
289900.0
In [ ]:
dfs_user['Salary'].median()
Out[ ]:
245000.0
In [ ]:
dfs_user['Salary'].mean() / dfs_user["Salary"].median()
Out[ ]:
1.183265306122449
In [ ]:
plt.bar(ds100['Designation'], ds100['Salary'])
Out[ ]:
<BarContainer object of 100 artists>
In [ ]:
ds100.head(1)
Out[ ]:
Salary DOJ DOL Designation JobCity Gender DOB 10percentage 10board 12graduation ... ComputerScience MechanicalEngg ElectricalEngg TelecomEngg CivilEngg conscientiousness agreeableness extraversion nueroticism openess_to_experience
ID
249086 240000 2014-01-01 2014-03-01 00:00:00 sales associate -1 f 1989-06-01 75.0 icse 2007 ... -1 340 -1 -1 -1 -0.1082 0.6568 -0.6343 0.1798 0.5024

1 rows × 37 columns

In [ ]:
ds100['JobCity'] = np.where(ds100['JobCity'] == "-1", "Not available", ds100['JobCity'])
In [ ]:
ds100

Example

In [ ]:
df_ex = pd.DataFrame({'A': [-2, 7, -4, 0], 'B': [-6, -1, 2, -8], 'C': [1, 2, 3, 4]})
In [ ]:
df_ex
Out[ ]:
A B C
0 -2 -6 1
1 7 -1 2
2 -4 2 3
3 0 -8 4
In [ ]:
#it goes through column A, selects where it's negative & replaces with 2, or if it's not negative it puts in the values from column C
df_ex.A = np.where(df_ex.A < 0, 250, df_ex.C)
In [ ]:
df_ex
Out[ ]:
A B C
0 2 -6 1
1 2 -1 2
2 3 2 3
3 4 -8 4
In [ ]:
#it goes through column A, selects where it's negative & replaces with 2, or if it's not negative it leaves it as is
df_ex.A = np.where(df_ex.A < 0, 250, df_ex.A)
In [ ]:
df_ex
Out[ ]:
A B C
0 250 -6 1
1 7 -1 2
2 250 2 3
3 0 -8 4
In [ ]: