#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 28 17:02:28 2022

@author: madeehashaikh
"""
'''QUESTION 1'''

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


problem = pd.read_excel(r"/Users/madeehashaikh/Desktop")
m_jobs = 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

metro = ["Bengaluru", "Kolkata", "Delhi", "Chennai", "Gurgaon", "Pune"]

metro.jobs = 0
for i in metro:
    metro.jobs = metro.jobs + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
metro.obs

list = ["Bengaluru", "Kolkata", "Delhi", "Chennai", "Gurgaon", "Pune"]
bengalurujobs = 0
kolkatajobs = 0
delhijobs = 0
chennaijobs = 0
gurgaonjobs = 0
pune_obs = 0
for i in list:
    if (i == "Bengaluru"): 
        bengalurujobs = bengalurujobs + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Kolkata"): 
        kolkatajobs = kolkatajobs + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Delhi"): 
        delhijobs = delhijobs + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Chennai"): 
        chennaijobs = chennaijobs + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Gurgaon"): 
        gurgaonjobs = gurgaon_obs + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]
    if (i == "Pune"): 
        punejobs = pune_obs + Problem[Problem["Location"].astype("str").str.contains(i)].shape[0]

'''
bengalurujobs 
= 5529

kolkatajobs 
= 373

delhijobs 
= 1834

chennaijobs 
= 1518

gurgaon_obs 
= 2770

punejobs
= 1781

metrojobs
= 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(roblem["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 = 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 = sum(fresher_jobs.Frequency)

"""There are 1653 total fresher jobs"""

'''QUESTION 2'''

problem1 = pd.read_excel(r"‪/Users/madeehashaikh/Desktop")
import statsmodels.formula.api as smf

lr1 = smf.ols(formula='Y1 ~ X1', data=problem2)
fitted_model1 = lr1.fit()
fitted_model1.summary()


lr2 = smf.ols(formula='Y2 ~ X2', data=problem2)
fitted_model2 = lr2.fit()
fitted_model2.summary()


lr3 = smf.ols(formula='Y3 ~ X3', data=problem2)
fitted_model3 = lr3.fit()
fitted_model3.summary()


lr4 = smf.ols(formula='Y4 ~ X4', data=problem2)
fitted_model4 = lr4.fit()
fitted_model4.summary()