# -*- coding: utf-8 -*-
"""
Created on Tue Mar 22 20:07:10 2022

@author: kuku
"""

import numpy as np
import pandas as pd
import seaborn as sb
import matplotlib as plt

Prob =pd.read_excel ( r"E:\IAQS\Sem 4\Python\Problem 1.xlsx")

"""Student 1:"""

#a.) I stay in Mumbai. What if there are only a few jobs available in Mumbai?
# for resolving the student's issue, we first filter out the job availability
# in Mumbai

mumbai_jobs = Prob[Prob["Location"].astype("str").str.contains("Mumbai")]

'''There are 3731 jobs in Mumbai'''

#b.) What if I wish to settle in other metro cities moving further and how many companies do
#    I have to select from?


#We are assuming the metro cities to be the following-
#Mumbai, Bengaluru, Kolkata, Delhi, Chennai, Gurgaon, Pune

metro = ["Bengaluru", "Kolkata", "Delhi", "Chennai", "Gurgaon", "Pune"]

metro_job = 0
for i in metro:
    metro_job = metro_job + Prob[Prob["Location"].astype("str").str.contains(i)].shape[0]
metro_job

list = ["Bengaluru", "Kolkata", "Delhi", "Chennai", "Gurgaon", "Pune"]
bengaluru_job = 0
kolkata_job = 0
delhi_job = 0
chennai_job = 0
gurgaon_job = 0
pune_job = 0
for i in list:
    if (i == "Bengaluru"): 
        bengaluru_job = bengaluru_job + Prob[Prob["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Kolkata"): 
        kolkata_job = kolkata_job + Prob[Prob["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Delhi"): 
        delhi_job = delhi_job + Prob[Prob["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Chennai"): 
        chennai_job = chennai_job + Prob[Prob["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Gurgaon"): 
        gurgaon_job = gurgaon_job + Prob[Prob["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Pune"): 
        pune_job = pune_job + Prob[Prob["Location"].astype("str").str.contains(i)].shape[0]

'''
bengaluru_job
5529

kolkata_job
373

delhi_job
1834

chennai_job 
1518

gurgaon_job
2770

pune_job
1781

metro_job
13805
'''        
#Student 2

#a.) Can you tell me that the majority openings require how many years of experience? Do
#    we have high intake for freshers?

sb.displot(Prob["Experience"], kind = "hist")        
sb.histplot(Prob["Experience"], kde = True)

#Due to a high number of unique values, the x axis is not distinguishable

openings = pd.value_counts(Prob.Experience).reset_index()
openings.columns = ["Experience", "Frequency"]
top5 = openings.iloc[0:5,:]


import matplotlib.pyplot as plt
plt.bar(top5.Experience, top5.Frequency, color = "yellow")

#The bar chart shows the years of experience that the majority openings require#

"""
  Experience  Frequency
0   5-10 yrs       1274
1    2-5 yrs       1188
2    3-8 yrs        922
3    2-7 yrs        832
4    4-9 yrs        678
"""
#Manually modifying the dataframe in variable explorer
#to sort ascending values of Experience

fresher_job = openings.iloc[0:6, :]

"""
   Experience  Frequency
38    0-0 yrs        151
26    0-1 yrs        296
21    0-2 yrs        386
28    0-3 yrs        269
39    0-4 yrs        130
"""

total_fresher_job = sum(fresher_job.Frequency)

"""There are 1653 total fresher jobs"""

























