From 688b8c77ace0359d29b458bf7f03cfa17a80e834 Mon Sep 17 00:00:00 2001 From: alinaskukina Date: Sun, 19 Dec 2021 13:54:59 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=5F?= =?UTF-8?q?=D0=BD=D0=B0=5F=D0=BF=D0=B0=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/count_skills.py | 10 ++++++++++ .idea/men_women_zp.py | 5 +++++ .idea/para.py | 14 ++++++++++++++ .idea/para_2sposob.py | 2 ++ 4 files changed, 31 insertions(+) create mode 100644 .idea/count_skills.py create mode 100644 .idea/men_women_zp.py create mode 100644 .idea/para.py create mode 100644 .idea/para_2sposob.py diff --git a/.idea/count_skills.py b/.idea/count_skills.py new file mode 100644 index 0000000..7c3f471 --- /dev/null +++ b/.idea/count_skills.py @@ -0,0 +1,10 @@ +cursor.execute('SELECT COUNT(*) FROM works where skills not null') +print(cursor.fetchall()[0][0]) + +# Получить заполненные скиллы. +cursor.execute('SELECT skills FROM works where skills not null') +print(cursor.fetchall()) + +# Вывести зарплату только у тех, у кого в скилах есть Python +cursor.execute('SELECT salary FROM works where skills LIKE "%Python%"') +print(cursor.fetchall()) \ No newline at end of file diff --git a/.idea/men_women_zp.py b/.idea/men_women_zp.py new file mode 100644 index 0000000..5b0cb47 --- /dev/null +++ b/.idea/men_women_zp.py @@ -0,0 +1,5 @@ +plt.plot(np.linspace(0.1, 1, 10), m_salary) +plt.plot(np.linspace(0.1, 1, 10), w_salary) +plt.xlabel("Перцентили") +plt.ylabel("Зарплата") +plt.show() \ No newline at end of file diff --git a/.idea/para.py b/.idea/para.py new file mode 100644 index 0000000..1c354de --- /dev/null +++ b/.idea/para.py @@ -0,0 +1,14 @@ +cursor.execute('create index salary_index on works (salary)') +con.commit() + +# количество всех записей +ursor.execute('SELECT COUNT(*) FROM works') +print(cursor.fetchall()[0][0]) + +# men +cursor.execute('SELECT COUNT(*) FROM works where gender = "Мужской"') +print(cursor.fetchall()[0][0]) + +# women +cursor.execute('SELECT COUNT(*) FROM works where gender = "Женский"') +print(cursor.fetchall()[0][0]) \ No newline at end of file diff --git a/.idea/para_2sposob.py b/.idea/para_2sposob.py new file mode 100644 index 0000000..71fcea5 --- /dev/null +++ b/.idea/para_2sposob.py @@ -0,0 +1,2 @@ +cursor.execute('SELECT gender, COUNT(*) FROM works group by gender') +print(cursor.fetchall()) \ No newline at end of file From 1abf8af170450adcbe27c4bf14f48a9b181aa095 Mon Sep 17 00:00:00 2001 From: alinaskukina Date: Sun, 19 Dec 2021 18:54:12 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=B4=D0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dz.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++ .idea/works.sqlite | 7 ++++++ 2 files changed, 66 insertions(+) create mode 100644 .idea/dz.py create mode 100644 .idea/works.sqlite diff --git a/.idea/dz.py b/.idea/dz.py new file mode 100644 index 0000000..093f88a --- /dev/null +++ b/.idea/dz.py @@ -0,0 +1,59 @@ +import numpy as np +import pandas as pd +import sqlite3 +import matplotlib.pyplot as plt + +fail = sqlite3.connect('works.sqlite') +cursor = fail.cursor() +cursor.execute('удалить таблицу, если она существует') +cursor.execute('create table works (' + 'ID INTEGER PRIMARY KEY AUTOINCREMENT,' + 'salary INTEGER,' + 'educationType TEXT,' + 'jobTitle TEXT,' + 'qualification TEXT,' + 'gender TEXT,' + 'dateModify TEXT,' + 'skills TEXT,' + 'otherInfo TEXT)') +fail.commit() + +read_fail = pd.read_csv("works.csv") +read_fail.to_sql("works", fail, if_exists='append', index=False) +fail.commit() + + +# ДЗ +cursor.execute('удалить таблицу, если существуют гендерные категории') +cursor.execute('create table genders(id integer primary key autoincrement, gender_val)') +fail.commit() + +cursor.execute('insert into genders(gender_val) select distinct gender from works where gender is not null') +fail.commit() + +cursor.execute('alter table works add column gender_id integer references genders(id)') +fail.commit() + +cursor.execute('update works set gender_id = (select id from genders where gender_val = works.gender)') +fail.commit() + +cursor.execute('table works drop column gender') +fail.commit() + + + +cursor.execute('удалить таблицу, если существует образование') +cursor.execute('create table education(id integer primary key autoincrement, education_val text)') +fail.commit() + +cursor.execute('insert into education(education_val) select distinct educationType from works where educationType is not null') +fail.commit() + +cursor.execute('alter table works add column educationType_id integer references education(id)') +fail.commit() + +cursor.execute('update works set educationType_id = (select id from genders where education_val = works.educationType)') +fail.commit() + +cursor.execute('table works drop column educationType') +fail.commit() \ No newline at end of file diff --git a/.idea/works.sqlite b/.idea/works.sqlite new file mode 100644 index 0000000..331a6bb --- /dev/null +++ b/.idea/works.sqlite @@ -0,0 +1,7 @@ +SELECT * FROM 'education' LIMIT 0,30 + +SELECT * FROM 'genders' LIMIT 0,30 + +SELECT * FROM 'sqlite_sequence' LIMIT 0,30 + +SELECT * FROM 'works' LIMIT 0,30 From 2600f29049a8e1613114db99f99f102677806ec8 Mon Sep 17 00:00:00 2001 From: alinaskukina Date: Sun, 19 Dec 2021 18:56:48 +0500 Subject: [PATCH 3/3] =?UTF-8?q?=D0=BE=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dz.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.idea/dz.py b/.idea/dz.py index 093f88a..06844ac 100644 --- a/.idea/dz.py +++ b/.idea/dz.py @@ -2,6 +2,11 @@ import pandas as pd import sqlite3 import matplotlib.pyplot as plt +import re + + +def get_clean_field(field): + return re.sub(r'\<[^>]*\>', '', str(field)) fail = sqlite3.connect('works.sqlite') cursor = fail.cursor() @@ -19,6 +24,8 @@ fail.commit() read_fail = pd.read_csv("works.csv") +read_fail['skills'] = read_fail['skills'].apply(get_clean_field) +read_fail['otherInfo'] = read_fail['otherInfo'].apply(get_clean_field) read_fail.to_sql("works", fail, if_exists='append', index=False) fail.commit()