Question

Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from...

Python Programming language. Complete the problems below using Jupyter Notebook.

Problem Needs to be solved from number #1

link provided for the Data: -----> https://docs.google.com/spreadsheets/d/1TqhyxFKQlOHAyXpQBL-4C96kgZFBoMwUgE8-b33CqPQ/edit?usp=sharing

PROBLEMS

# 0.0 Import the libraries (pandas, matplotlib, and seaborn) Include the code line: %matplotlib inline #Include the code line: plt.style.use(“ggplot”) #Load the data using pandas #Inspect the data using head(), dtypes

ANSWERD:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('ggplot')
%matplotlib inline
df = pd.read_csv()
print(df.head())
print(df.dtypes)

# 1

Create two subset dataframes: one for those with an MBA and those without an MBA

Use matplotlib (not seaborn) to display two box plots side by side (in one figure/axes) comparing the salaries for those with an MBA and those without one.

Include the labels: x-axis, y-axis, chart title.

# 2

Use seaborn's catplot function to display a box plot comparing the salaries between those

with an MBA and those without. Hint: Do not use two subsets created in the previous problem and use the col parameter instead.

# 3

Use matplotlib (not seaborn) to display a scatter plot between age and salary.

Include the labels: x-axis, y-axis, chart title.

# 4

#Use seaborn's jointplot function between age and salaries.

# 5

#Use matplotlib to create two histograms on salary--one for those employees with an MBA and one for those employees without an MBA. Reference the same subset variables from problem 1.

The figure should contain one row and two columns for the two subplots.

Include the labels: x-axis, y-axis, chart titles for both histograms, and a figure title.

# 6

Use seaborn's stripplot function to compare the salaires between those with and

without an MBA on salary. A legend should be apparent using hue.

# 7

Use matplotlib to create a pie chart on the MBA data column.

Include the labels for each slice by providing the percentage and include a chart title.

# 8

Use seaborn's barplot function on the MBA and Salary data columns.

Include a chart title.

# 9

Use matplotlib’s plt.bar function to create a bar chart that displays the frequency of those with an MBA and those without one. Hint: Use the value_counts() method on the MBA data column.

Include the labels: x-axis, y-axis, chart title.

# 10

#Create one figure displaying four subplots/axes. Specifically, the subplot should contain two rows and two columns. The first row will contain any two the matplotlib charts. While the second row will contain any two seaborn charts. You may reuse the code/charts from previous problems above.

Include the labels on each chart: x-axis, y-axis, chart titles. Format as needed and adjust the figure size

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('ggplot')
%matplotlib inline
df = pd.read_csv('/content/HomeworkLib_Data.csv')
print(df.head())
print(df.dtypes)

#1. 
df_with_MBA = df.loc[df['MBA']=='Yes']
df_without_MBA = df.loc[df['MBA']=='No']

fig = plt.figure(figsize =(10, 7)) 
data = [df_with_MBA['Salary'], df_without_MBA['Salary']]
plt.figure(figsize=(10, 6))
box = plt.boxplot(data,
                  positions=[1,2],
                  labels=['MBA','Non-MBA'])
plt.xlabel('MBA or Non-MBA')
plt.ylabel('Salaries')
plt.title("SALARY coparison MBA vs Non-MBA")
plt.show()

SALARY coparison MBA vs Non-MBA o 80000 70000 60000 Salaries 50000 40000 30000 MBA Non-MBA MBA or Non-MBA

g = sns.catplot(x='MBA', y="Salary", hue="MBA",data=df, kind="box")

80000 70000 60000 Salary 50000 40000 30000 No Yes MBA

#3. 
plt.scatter(df['Age'],df['Salary'],c='blue') 
plt.xlabel('Age')
plt.ylabel('Salaries')
plt.title("Scatter plot between age & salary")
plt.show() 

Scatter plot between age & salary 80000 - 70000 60000 Salaries 50000 40000 30000 25 30 35 45 50 55 60 40 Age

#4.
sns.jointplot(data=df, x="Age", y="Salary",color='blue')

80000 70000 60000 Salary 50000 40000 30000 25 30 35 50 55 60 40 45 Age

#5. 
fig = plt.figure(figsize=(20,7))
plt.subplot(1, 2, 1)
plt.hist(df_with_MBA['Salary'], bins=30)
plt.xlabel('Salaries')
plt.ylabel('Count')
plt.title('MBA salary histogram')
plt.subplot(1, 2, 2)
plt.hist(df_without_MBA['Salary'], bins=50)
plt.xlabel('Salaries')
plt.ylabel('Count')
plt.title('Non-MBA salary histogram')
fig.suptitle("MBA and Non-MBA Salary Histogram")
plt.show()

MBA and Non-MBA Salary Histogram MBA salary histogram Non-MBA salary histogram 10 3.0 25 0.8 20 0.6 15 0.4 10 0.2 05 00 40000

#6.
sns.stripplot(x="MBA", y="Salary",hue='MBA', data=df)

80000 - MBA No Yes 70000 60000 - Salary 50000 - 40000 - 30000 - No Yes MBA

#7.
fig = plt.figure(figsize=(10,7))
label=['MBA','Non-MBA']
data = [len(df.loc[df['MBA']=='Yes']),len(df.loc[df['MBA']=='No'])]
explode = (0.1, 0)
plt.pie(data, labels = label,explode=explode,autopct='%1.2f%%')
plt.title('Pie chart MBA vs Non-MBA')
plt.show()

Pie chart MBA vs Non-MBA MBA 17.14% 82.86% Non-MBA

#8.
sns.barplot(x="MBA", y="Salary", data=df)

60000 50000 - 40000 - Salary 30000 20000 - 10000 0 No Yes MBA

#9.
plt.bar(['No','Yes'],df['MBA'].value_counts())
plt.xlabel('MBA or Non-MBA')
plt.ylabel('Counts')
plt.title("Bar plot MBA-Non-MBA counts")
plt.show() 

Bar plot MBA-Non-MBA counts 30 25 - 20 Counts 15 10 5 - 0 No Yes MBA or Non-MBA

fig = plt.figure(figsize=(20,10))
plt.subplot(2, 2, 1)
plt.scatter(df['Age'],df['Salary'],c='blue')
plt.xlabel('Age')
plt.ylabel('Salaries')
plt.title("Matplotlib Scatter plot(Age & Salary")
plt.subplot(2, 2, 2)
plt.bar(['No','Yes'],df['MBA'].value_counts())
plt.xlabel('MBA or Non-MBA')
plt.ylabel('Counts')
plt.title("Matpltlib Bar plot MBA-Non-MBA counts")
plt.subplot(2, 2, 3)
sns.stripplot(x="MBA", y="Salary",hue='MBA', data=df)
plt.xlabel('MBA or Non-MBA')
plt.ylabel('Salry')
plt.title("Seaborn strip plot MBA vs non-MBA salary")
plt.subplot(2, 2, 4)
sns.barplot(x="MBA", y="Salary", data=df)
plt.xlabel('MBA or Non-MBA')
plt.ylabel('Salry')
plt.title("Seaborn Bar plot MBA vs non-MBA salary")
fig.suptitle("Matplotlib & Seaborn plots")
plt.show() 

Matplotlib & Seaborn plots Matplotlib Scatter plot(Age & Salary Matpltlib Bar plot MBA-Non-MBA counts 30 80000 25 70000 20 60

Add a comment
Know the answer?
Add Answer to:
Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use the link in the Jupyter Notebook activity to access your Python script. Once you have...

    Use the link in the Jupyter Notebook activity to access your Python script. Once you have made your calculations, complete this discussion. The script will output answers to the questions given below. You must attach your Python script output as an HTML file and respond to the questions below. In this discussion, you will apply the statistical concepts and techniques covered in this week's reading about hypothesis testing for the difference between two population proportions. In the previous week’s discussion,...

  • Please solve the following problem with programming using proper data structures. (Programming Language: Python) A similar...

    Please solve the following problem with programming using proper data structures. (Programming Language: Python) A similar application to the parentheses matching problem comes from hypertext markup language (HTML). In HTML, tags exist in both opening and closing forms and must be balanced to properly describe a web document. This very simple HTML document: Example> Hello, world is intended only to show the matching and nesting structure for tags in the language. Write a program that can check an HTML document...

  • Before you start For this homework, we will need to import some libraries. You need to...

    Before you start For this homework, we will need to import some libraries. You need to execute the following cell only once; you don't need to copy this in every cell you run. In [ ]: import pandas import numpy from urllib.request import urlretrieve from matplotlib import pyplot %matplotlib inline ​ #This library is needed for testing from IPython.display import set_matplotlib_close set_matplotlib_close(False) Introduction In this homework, you will work with data from the World Bank. The subject of study is...

  • In Python!! 1. Correcting string errors It's easy to make errors when you're trying to type...

    In Python!! 1. Correcting string errors It's easy to make errors when you're trying to type strings quickly. Don't forget to use quotes! Without quotes, you'll get a name error. owner = DataCamp Use the same type of quotation mark. If you start with a single quote, and end with a double quote, you'll get a syntax error. fur_color = "blonde' Someone at the police station made an error when filling out the final lines of Bayes' Missing Puppy Report....

  • Please help me with this MATLAB programming problem! Im coding iin MATLAB2018 if that makes any d...

    Please help me with this MATLAB programming problem! Im coding iin MATLAB2018 if that makes any difference! The first picture is the question i need to answer. The picture below is used as reference to answer the question. The last picture (below) is the into to the problem, and is used as reference. 1. Use Matlab to create the following single plot with three subplots. All titles, gridlines, and axis labels should be as shown. Arc System Response 15 E...

  • COMPLETE THE FOLLOWING USING THE ATTACHED DOCUMENTS In this exercise, you will perform a financial statement...

    COMPLETE THE FOLLOWING USING THE ATTACHED DOCUMENTS In this exercise, you will perform a financial statement analysis for Water Feature Designers Inc. You will perform horizontal/vertical analyses and create charts to highlight key information from these analyses. You will also calculate financial ratios and insert cell comments. Use this information to complete the ratio analysis. Ratio Current Ratio Debt-to-Equity Ratio Profit Margin 2016 7.62 0.17 .186 2015 3.45 0.28 292 2014 8.21 0.18 255 1. Open EA9-A2-FSA from your Chapter...

  • PYTHON import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import...

    PYTHON import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split Our goal is to create a linear regression model to estimate values of ln_price using ln_carat as the only feature. We will now prepare the feature and label arrays. "carat"   "cut" "color"   "clarity"   "depth"   "table"   "price"   "x"   "y"   "z" "1" 0.23   "Ideal" "E" "SI2" 61.5 55 326   3.95   3.98   2.43 "2" 0.21   "Premium" "E" "SI1"...

  • In this project, you will work with sales data from Top’t Corn, a popcorn company with...

    In this project, you will work with sales data from Top’t Corn, a popcorn company with an online store, multiple food trucks, and two retail stores. You will begin by inserting a new worksheet and entering sales data for the four food truck locations, formatting the data, and calculating totals. You will create a pie chart to represent the total units sold by location and a column chart to represent sales by popcorn type. You will format the charts, and...

  • Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real...

    Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real-valued functions, the general formula for a Taylor series is given as ia) (a) (z- a) (z- a)2 + £(a (r- a) + + -a + f(x)(a) (1) A special case of the Taylor series (known as the Maclaurin series) exists when a- 0. The Maclaurin series expansions for four commonly used functions in science and engineering are: sin(x) (-1)"...

  • Need some help I am not understanding this programming class at all. We are using Microsoft...

    Need some help I am not understanding this programming class at all. We are using Microsoft visual studio with python in console mode to complete these labs. Double-click to hide white space CIS115 Week 4 Lab Overview Title of Lab: Multiplication Table in Python Summary This week's lab is to create a simple multiplication table using nested loops and if statements. Prompt the user for the size of the multiplication table (from 2x2 to 10x10). Use a validation loop to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT