Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samoylov Pavel AT-18 #32

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions HW-8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#8
import pandas as pd

def non_matches(firs_param, second_param, data):
count = 0
for (f1, f2) in zip(data[firs_param], data[second_param]):
if not is_contains(f1, f2) and not is_contains(f2, f1):
count += 1
return count

def is_contains(first_field, second_field):
for word in first_field.lower().replace('-', ' ').split():
if word in second_field.lower():
return True
return False

def get_top(size, data, search_field, return_field, word_to_search):
return data[data[search_field].str.lower().str.contains(word_to_search[:-2])][return_field]\
.str\
.lower()\
.value_counts()\
.head(size)

works = pd.read_csv("works.csv").dropna()
not_matches_count = non_matches("jobTitle", "qualification", works)
managers = get_top(5, works, "jobTitle", "qualification", "менеджер")
engineers = get_top(5, works, "qualification", "jobTitle", "инженер")
output_string = f"Всего записей {works.shape[0]} из них не совпадают {not_matches_count}\n\n" \
f"Топ - 5 образовний менеджеров\n" \
f"{managers}\n\n" \
f"Топ - 5 должностей инженеров\n" \
f"{engineers}"

with open('homework8.txt', 'w', encoding='utf-8') as file:
file.write(output_string)
51 changes: 51 additions & 0 deletions class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import numpy as np
import pandas as pd
import matplotlib.pyplot as mp

works = pd.read_csv("works.csv")

# 1
#print("Общее количество записей:", works.shape[0])

# 2
#print("Количество мужчин:", works[works["gender"] == "Мужской"].shape[0])
#print("Количество женщин:", (works["gender"] == "Женский").sum())

# 3
#print("Количество не NaN значений:", works["skills"].count())

# 4
#print("Все заполненные скиллы\n", works['skills'].dropna())

# 5
#skills_bool = works['skills'].str.lower().str.contains('python | питон') & works['skills'].notnull()
#print("Зарплата тех, у кого в скиллах есть Python (Питон)\n", works[skills_bool]['salary'])

# 6
#salary_p = np.linspace(0.1, 1, 10)
#w = works[works.gender == "Женский"]['salary'].quantile(salary_p)
#m = works[works.gender == "Мужской"]['salary'].quantile(salary_p)

#mp.plot(m, salary_p, color='blue')
#mp.plot(w, salary_p, color='r')
#mp.xlabel('salary')
#mp.ylabel('quantile')
#mp.show()

#7

men_salary = works.query("gender == 'Мужской'").groupby("educationType").agg("mean").reset_index()
women_salary = works.query("gender == 'Женский'").groupby("educationType").agg("mean").reset_index()

educationTypes = men_salary["educationType"].values
men_salaries = men_salary["salary"].values
women_salary = women_salary["salary"].values

index = np.arange(len(educationTypes))

bw = 0.4
mp.bar(index-bw/2, men_salaries, bw, color="b", label="Средняя зарплата мужчин")
mp.bar(index+bw/2, women_salary, bw, color="r", label="Средняя зарплата женщин")
mp.xticks(index, educationTypes, rotation=45)
mp.legend()
mp.show()
17 changes: 17 additions & 0 deletions homework8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Всего записей 1068 из них не совпадают 793

Топ - 5 образовний менеджеров
бакалавр 11
менеджер 10
специалист 6
экономист 6
экономист-менеджер 4
Name: qualification, dtype: int64

Топ - 5 должностей инженеров
заместитель директора 3
главный инженер 3
ведущий инженер-конструктор 2
инженер лесопользования 2
директор 2
Name: jobTitle, dtype: int64
27 changes: 27 additions & 0 deletions отчет_class.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 1 Общее количество записей в датасете:

<img width="1280" alt="image" src="https://user-images.githubusercontent.com/73825639/147072438-b88f72d0-2665-42dd-8086-3e68739217fa.png">

# 2 Количество мужчин и женщин в датасете:

<img width="1280" alt="image" src="https://user-images.githubusercontent.com/73825639/147072723-a5db265b-0247-42d5-81bf-d33d61944d7f.png">

# 3 Сколько значений в столбце skills не NAN:

<img width="1280" alt="image" src="https://user-images.githubusercontent.com/73825639/147073394-b0a41022-0fa0-42ab-b822-c70ca114812e.png">

# 4 Все заполненные скиллы:

<img width="1280" alt="image" src="https://user-images.githubusercontent.com/73825639/147073615-b637960a-a490-4735-890c-e649521814db.png">

# 5 Вывести зарплату только у тех, у которых в скиллах есть Python (Питон):

<img width="1280" alt="image" src="https://user-images.githubusercontent.com/73825639/147073878-8fcc17bb-c8bd-49e6-a234-df705e6a40ac.png">

# 6 Построить перцентили по заработной плате у мужчин и женщин:

<img width="1280" alt="image" src="https://user-images.githubusercontent.com/73825639/147074200-160f796f-24af-4386-b287-647410af7818.png">

# 7 Построить графики распределения по заработной плате мужчин и женщин в зависимости от высшего образования:

<img width="1280" alt="image" src="https://user-images.githubusercontent.com/73825639/147263358-206b6d2b-3c21-41e8-bea6-ac8264b64048.png">