Skip to content
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
39 changes: 39 additions & 0 deletions 1-7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

works = pd.read_csv('works.csv')
# 1
print('общее количество записей в датасете:', works.shape[0]) # 32683
# 2
print('Количество мужчин:', works[works['gender'] == 'Мужской'].shape[0]) # 13386
print('Количество женщин:', (works['gender'] == 'Женский').sum()) # 17910
# 3
print('Количество значений в столбце skills не NAN:', works['skills'].notna().values.sum()) # 8972
# 4
print('Все заполненные скиллы:\n', works['skills'].dropna())
# 5
skills_base = works.skills.str.lower().str.contains('python|питон').dropna()
print('Зарплата у тех, у кого в скиллах есть Python(Питон):\n', works[works.skills.notna()][skills_base]['salary'])
# 6
percentiles = np.linspace(.1, 1, 10)
m_salary = works[works.gender == 'Мужской']['salary'].quantile(percentiles)
w_salary = works[works.gender == 'Женский']['salary'].quantile(percentiles)
plt.plot(m_salary, color='blue')
plt.plot(w_salary, color='red')
plt.xlabel('Перцентили')
plt.ylabel('Зарплата')
plt.show()
# 7
men_salary = works.query('gender == "Мужской"').groupby('educationType').agg('mean').reset_index()
women_salary = works.query('gender == "Женский"').groupby('educationType').agg('mean').reset_index()
educationType = men_salary['educationType'].values
men_salary = men_salary['salary'].values
women_salary = women_salary['salary'].values
index = np.arange(len(educationType))
wd = 0.1
plt.bar(index - wd / 2, men_salary, wd, color='blue', label='Средняя зарплата мужчин')
plt.bar(index + wd / 2, women_salary, wd, color='red', label='Средняя зарплата женщин')
plt.xticks(index, educationType)
plt.legend()
plt.show()
33 changes: 33 additions & 0 deletions 8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pandas as pd

works = pd.read_csv('works.csv').dropna()


def count(f1, f2, works):
result = 0
for n1, n2 in zip(works[f1], works[f2]):
if not match(n1, n2) and not match(n2, n1):
result += 1
return result


def match(c1, c2):
array = c1.lower().replace('-', ' ').split()
for word in array:
if word in c2.lower():
return True
return False


result = count('jobTitle', 'qualification', works)
print('Из {} людей не совпадают профессия и должность у {}'.format(works.shape[0], result))

print('\nТоп образований для менеджеров:')
print(
works[works['jobTitle'].str.lower().str.contains('менеджер'[:-2])]['qualification'].str.lower().value_counts().head(
5))

print('\nТоп образований для инженеров:')
print(
works[works['jobTitle'].str.lower().str.contains('инженер'[:-2])]['qualification'].str.lower().value_counts().head(
5))