-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask
More file actions
62 lines (44 loc) · 1.67 KB
/
task
File metadata and controls
62 lines (44 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sqlite3
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
con = sqlite3.connect('works.sqlite')
cursor = con.cursor()
cursor.execute('drop table if exists works')
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)')
con.commit()
df = pd.read_csv("works.csv")
df.to_sql("works", con, if_exists='append', index=False)
con.commit()
cursor.execute('create index salary_index on works (salary)')
con.commit()
cursor.execute('SELECT count(*) FROM works')
print(cursor.fetchall()[0][0])
cursor.execute("SELECT gender, count(*) FROM works GROUP BY works.gender")
print(cursor.fetchall())
cursor.execute("SELECT count(*) FROM works WHERE works.skills IS NOT NULL")
print(cursor.fetchall()[0][0])
cursor.execute("SELECT * FROM works WHERE works.skills IS NOT NULL")
print(cursor.fetchall())
cursor.execute("SELECT salary FROM works WHERE skills LIKE '%Python%'")
print(cursor.fetchall())
cursor.execute("SELECT salary FROM works WHERE gender = 'Мужской'")
m_salary = [i[0] for i in cursor.fetchall()]
cursor.execute("SELECT salary FROM works WHERE gender = 'Женский'")
w_salary = [i[0] for i in cursor.fetchall()]
m_quantile = np.quantile(m_salary, np.linspace(0.1, 1, 10))
w_quantile = np.quantile(w_salary, np.linspace(0.1, 1, 10))
plt.hist(m_quantile, 100, color='blue')
plt.show()
plt.hist(w_quantile, 100, color='red')
plt.show()
con.commit()