# -*- coding: utf-8 -*-
"""
Created on Sun Mar 27 13:50:25 2022

@author: HP
"""

import numpy as np
import pandas as pd
import seaborn as sb
import matplotlib as plt

"""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

mumbaijobs_1 = Problem[Problem["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

metross = ["Bengaluru", "Kolkata", "Delhi", "Chennai", "Gurgaon", "Pune"]

metrojobss_2 = 0
for i in metross:
    metrojobss_2 = metrojobss_2 + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
metrojobss_2

list = ["Bengaluru", "Kolkata", "Delhi", "Chennai", "Gurgaon", "Pune"]
bengaluru_jobs_3 = 0
kolkata_jobs_4 = 0
delhi_jobs_5 = 0
chennai_jobs_6 = 0
gurgaon_jobs_7 = 0
pune_jobs_8 = 0
for i in list:
    if (i == "Bengaluru"): 
        bengaluru_jobs_3 = bengaluru_jobs_3 + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Kolkata"): 
        kolkata_jobs_4 = kolkata_jobs_4 + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Delhi"): 
        delhi_jobs_5 = delhi_jobs_5 + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Chennai"): 
        chennai_jobs_6 = chennai_jobs_6 + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Gurgaon"): 
        gurgaon_jobs_7 = gurgaon_jobs_7 + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Pune"): 
        pune_jobs_8 = pune_jobs_8 + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]

'''
bengaluru_jobs_3
5529

kolkata_jobs_4
373

delhi_jobs_5
1834

chennai_jobs_6
1518

gurgaon_jobs_7
2770

pune_jobs_8
1781

metrojobss_2
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(Problem["Experience"], kind = "hist")        
sb.histplot(Problem["Experience"], kde = True)

#Due to a high number of unique values, the x axis is not distinguishable

openings = pd.value_counts(Problem.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_jobs_9 = 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_jobs_10 = sum(fresher_jobs_9.Frequency)

"""There are 1653 total fresher jobs"""