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
8 changes: 8 additions & 0 deletions REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## У какого количества людей профессия и должность не совпадают?
![img.png](img.png)

## Люди с каким образованием становятся менеджерами (топ-5)?
![img_1.png](img_1.png)

## Кем работают люди, которые по диплому являются инженерами (топ-5)?
![img_2.png](img_2.png)
165 changes: 165 additions & 0 deletions homework.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"pycharm": {
"is_executing": true,
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import pandas as pd\n",
"works = pd.read_csv('works.csv')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"pycharm": {
"is_executing": true,
"name": "#%% подготовка данных\n"
}
},
"outputs": [],
"source": [
"worksnew = works[works['jobTitle'].notna()]\n",
"works = worksnew[worksnew['qualification'].notna()]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"pycharm": {
"is_executing": true,
"name": "#%% сравнивает входит ли одно слово в другое\n"
}
},
"outputs": [],
"source": [
"def compare(first_param, second_param):\n",
" for i in first_param.lower().replace('-', ' ').split():\n",
" if i in second_param.lower():\n",
" return True\n",
" return False"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"pycharm": {
"is_executing": true,
"name": "#%% У какого количества людей профессия и должность не совпадают?\n"
}
},
"outputs": [
{
"data": {
"text/plain": [
"7714"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res = 0\n",
"for (job, qualification) in zip(works[\"jobTitle\"], works[\"qualification\"]):\n",
" if not compare(job, qualification) and not compare(qualification, job):\n",
" res += 1\n",
"res"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"pycharm": {
"is_executing": true,
"name": "#%% Люди с каким образованием становятся менеджерами (топ-5)?\n"
}
},
"outputs": [
{
"data": {
"text/plain": [
"бакалавр 96\n",
"экономист 85\n",
"менеджер 79\n",
"юрист 41\n",
"инженер 37\n",
"Name: qualification, dtype: int64"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"worksjob = works[works[\"jobTitle\"].str.lower().str.contains(\"менеджер\")]\n",
"worksjob[\"qualification\"].str.lower().value_counts().head(5)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"pycharm": {
"is_executing": true,
"name": "#%% Кем работают люди, которые по диплому являются инженерами (топ-5)?\n"
}
},
"outputs": [
{
"data": {
"text/plain": [
"инженер 25\n",
"главный инженер 23\n",
"директор 21\n",
"менеджер 13\n",
"водитель 11\n",
"Name: jobTitle, dtype: int64"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"worksjob = works[works[\"qualification\"].str.lower().str.contains(\"инженер\")]\n",
"worksjob[\"jobTitle\"].str.lower().value_counts().head(5)\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Binary file added img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

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

# Количество записей в датасете

# countRecords = works.shape
# print(countRecords)
# countRecords1 = len(works.index)
# print(countRecords1)


# Количество мужчин и женщин

# genderMale = works[works['gender'] == 'Мужской'].shape[0]
# print(genderMale)
# genderFemale = (works['gender'] == 'Женский').values.sum()
# print(genderFemale)
# genders = works['gender'].value_counts()
# print(genders)


# Узнать сколько значений в столбце skills не NAN;

# s = works['skills'].notnull().values.sum()
# print(s)
# s1 = works['skills'].dropna().shape[0]
# print(s1)


# Получить все заполненные скиллы;

# s = works['skills'].dropna()
# print(s)
# s1 = works.query("skills == skills")["skills"]
# print(s1)

# a = 10000
# b = 'Женский'
# print(works.query("salary == @a and gender == @b"))


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

# df = works.skills.dropna().str.lower().str.contains('python|питон')
# print(works[works.skills.notna()][df]['salary'])


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

# percentiles = np.linspace(.1, 1, 10)
# men_salary = works.query("gender == 'Мужской'").quantile(percentiles)
# women_salary = works.query("gender == 'Женский'").quantile(percentiles)
#
# fig, ax1 = plt.subplots()
# ax1.plot(percentiles, men_salary)
# plt.xlabel("Перцентили")
# plt.ylabel("Зарплата мужчин")
#
# fig, ax2 = plt.subplots()
# ax2.plot(percentiles, women_salary)
# plt.xlabel("Перцентили")
# plt.ylabel("Зарплата женщин")
# plt.show()


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

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

educationTypes = men_salary["educationType"].values
men_salaries = men_salary["salary"].values
women_salaries = women_salary["salary"].values
index = np.arange(len(educationTypes))

bw = 0.4
plt.bar(index-bw/2, men_salaries, bw, color="b", label="Средняя зарплата мужчин")
plt.bar(index+bw/2, women_salaries, bw, color="r", label="Средняя зарплата женщин")
plt.xticks(index, educationTypes, rotation=45)
plt.legend()
plt.show()

# Надо прочитать как установить модуль юпитера
works.query("gender == 'Мужской' and educationType == 'Высшее'").hist(bins=100, alpha=0.5)
works.query("gender == 'Женский' and educationType == 'Высшее'").hist(bins=100, alpha=0.5)

works.query("gender == 'Мужской' and educationType == 'Незаконченное высшее'").hist(bins=100, alpha=0.5)
works.query("gender == 'Женский' and educationType == 'Незаконченное высшее'").hist(bins=100, alpha=0.5)

works.query("gender == 'Мужской' and educationType == 'Среднее'").hist(bins=100, alpha=0.5)
works.query("gender == 'Женский' and educationType == 'Среднее'").hist(bins=100, alpha=0.5)

works.query("gender == 'Мужской' and educationType == 'Среднее профессиональное'").hist(bins=100, alpha=0.5)
works.query("gender == 'Женский' and educationType == 'Среднее профессиональное'").hist(bins=100, alpha=0.5)