master
Wojciech Janota 10 months ago
parent d24a3848a2
commit c7f7890971

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CsvFileAttributes">
<option name="attributeMap">
<map>
<entry key="/Automobile_Data_Cleaned.csv">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
<entry key="/Automobile_data.csv">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
<entry key="/world_alcohol.csv">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (lab3)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (lab3)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/lab3.iml" filepath="$PROJECT_DIR$/.idea/lab3.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

@ -0,0 +1,62 @@
index,company,body-style,wheel-base,length,engine-type,num-of-cylinders,horsepower,average-mileage,price
0,alfa-romero,convertible,88.6,168.8,dohc,four,111,21,13495.0
1,alfa-romero,convertible,88.6,168.8,dohc,four,111,21,16500.0
2,alfa-romero,hatchback,94.5,171.2,ohcv,six,154,19,16500.0
3,audi,sedan,99.8,176.6,ohc,four,102,24,13950.0
4,audi,sedan,99.4,176.6,ohc,five,115,18,17450.0
5,audi,sedan,99.8,177.3,ohc,five,110,19,15250.0
6,audi,wagon,105.8,192.7,ohc,five,110,19,18920.0
9,bmw,sedan,101.2,176.8,ohc,four,101,23,16430.0
10,bmw,sedan,101.2,176.8,ohc,four,101,23,16925.0
11,bmw,sedan,101.2,176.8,ohc,six,121,21,20970.0
13,bmw,sedan,103.5,189.0,ohc,six,182,16,30760.0
14,bmw,sedan,103.5,193.8,ohc,six,182,16,41315.0
15,bmw,sedan,110.0,197.0,ohc,six,182,15,36880.0
16,chevrolet,hatchback,88.4,141.1,l,three,48,47,5151.0
17,chevrolet,hatchback,94.5,155.9,ohc,four,70,38,6295.0
18,chevrolet,sedan,94.5,158.8,ohc,four,70,38,6575.0
19,dodge,hatchback,93.7,157.3,ohc,four,68,31,6377.0
20,dodge,hatchback,93.7,157.3,ohc,four,68,31,6229.0
27,honda,wagon,96.5,157.1,ohc,four,76,30,7295.0
28,honda,sedan,96.5,175.4,ohc,four,101,24,12945.0
29,honda,sedan,96.5,169.1,ohc,four,100,25,10345.0
30,isuzu,sedan,94.3,170.7,ohc,four,78,24,6785.0
31,isuzu,sedan,94.5,155.9,ohc,four,70,38,11095.0
32,isuzu,sedan,94.5,155.9,ohc,four,70,38,11095.0
33,jaguar,sedan,113.0,199.6,dohc,six,176,15,32250.0
34,jaguar,sedan,113.0,199.6,dohc,six,176,15,35550.0
35,jaguar,sedan,102.0,191.7,ohcv,twelve,262,13,36000.0
36,mazda,hatchback,93.1,159.1,ohc,four,68,30,5195.0
37,mazda,hatchback,93.1,159.1,ohc,four,68,31,6095.0
38,mazda,hatchback,93.1,159.1,ohc,four,68,31,6795.0
39,mazda,hatchback,95.3,169.0,rotor,two,101,17,11845.0
43,mazda,sedan,104.9,175.0,ohc,four,72,31,18344.0
44,mercedes-benz,sedan,110.0,190.9,ohc,five,123,22,25552.0
45,mercedes-benz,wagon,110.0,190.9,ohc,five,123,22,28248.0
46,mercedes-benz,sedan,120.9,208.1,ohcv,eight,184,14,40960.0
47,mercedes-benz,hardtop,112.0,199.2,ohcv,eight,184,14,45400.0
49,mitsubishi,hatchback,93.7,157.3,ohc,four,68,37,5389.0
50,mitsubishi,hatchback,93.7,157.3,ohc,four,68,31,6189.0
51,mitsubishi,sedan,96.3,172.4,ohc,four,88,25,6989.0
52,mitsubishi,sedan,96.3,172.4,ohc,four,88,25,8189.0
53,nissan,sedan,94.5,165.3,ohc,four,55,45,7099.0
54,nissan,sedan,94.5,165.3,ohc,four,69,31,6649.0
55,nissan,sedan,94.5,165.3,ohc,four,69,31,6849.0
56,nissan,wagon,94.5,170.2,ohc,four,69,31,7349.0
57,nissan,sedan,100.4,184.6,ohcv,six,152,19,13499.0
61,porsche,hardtop,89.5,168.9,ohcf,six,207,17,34028.0
62,porsche,convertible,89.5,168.9,ohcf,six,207,17,37028.0
63,porsche,hatchback,98.4,175.7,dohcv,eight,288,17,11095.0
66,toyota,hatchback,95.7,158.7,ohc,four,62,35,5348.0
67,toyota,hatchback,95.7,158.7,ohc,four,62,31,6338.0
68,toyota,hatchback,95.7,158.7,ohc,four,62,31,6488.0
69,toyota,wagon,95.7,169.7,ohc,four,62,31,6918.0
70,toyota,wagon,95.7,169.7,ohc,four,62,27,7898.0
71,toyota,wagon,95.7,169.7,ohc,four,62,27,8778.0
79,toyota,wagon,104.5,187.8,dohc,six,156,19,15750.0
80,volkswagen,sedan,97.3,171.7,ohc,four,52,37,7775.0
81,volkswagen,sedan,97.3,171.7,ohc,four,85,27,7975.0
82,volkswagen,sedan,97.3,171.7,ohc,four,52,37,7995.0
86,volkswagen,sedan,97.3,171.7,ohc,four,100,26,9995.0
87,volvo,sedan,104.3,188.8,ohc,four,114,23,12940.0
88,volvo,wagon,104.3,188.8,ohc,four,114,23,13415.0
1 index company body-style wheel-base length engine-type num-of-cylinders horsepower average-mileage price
2 0 alfa-romero convertible 88.6 168.8 dohc four 111 21 13495.0
3 1 alfa-romero convertible 88.6 168.8 dohc four 111 21 16500.0
4 2 alfa-romero hatchback 94.5 171.2 ohcv six 154 19 16500.0
5 3 audi sedan 99.8 176.6 ohc four 102 24 13950.0
6 4 audi sedan 99.4 176.6 ohc five 115 18 17450.0
7 5 audi sedan 99.8 177.3 ohc five 110 19 15250.0
8 6 audi wagon 105.8 192.7 ohc five 110 19 18920.0
9 9 bmw sedan 101.2 176.8 ohc four 101 23 16430.0
10 10 bmw sedan 101.2 176.8 ohc four 101 23 16925.0
11 11 bmw sedan 101.2 176.8 ohc six 121 21 20970.0
12 13 bmw sedan 103.5 189.0 ohc six 182 16 30760.0
13 14 bmw sedan 103.5 193.8 ohc six 182 16 41315.0
14 15 bmw sedan 110.0 197.0 ohc six 182 15 36880.0
15 16 chevrolet hatchback 88.4 141.1 l three 48 47 5151.0
16 17 chevrolet hatchback 94.5 155.9 ohc four 70 38 6295.0
17 18 chevrolet sedan 94.5 158.8 ohc four 70 38 6575.0
18 19 dodge hatchback 93.7 157.3 ohc four 68 31 6377.0
19 20 dodge hatchback 93.7 157.3 ohc four 68 31 6229.0
20 27 honda wagon 96.5 157.1 ohc four 76 30 7295.0
21 28 honda sedan 96.5 175.4 ohc four 101 24 12945.0
22 29 honda sedan 96.5 169.1 ohc four 100 25 10345.0
23 30 isuzu sedan 94.3 170.7 ohc four 78 24 6785.0
24 31 isuzu sedan 94.5 155.9 ohc four 70 38 11095.0
25 32 isuzu sedan 94.5 155.9 ohc four 70 38 11095.0
26 33 jaguar sedan 113.0 199.6 dohc six 176 15 32250.0
27 34 jaguar sedan 113.0 199.6 dohc six 176 15 35550.0
28 35 jaguar sedan 102.0 191.7 ohcv twelve 262 13 36000.0
29 36 mazda hatchback 93.1 159.1 ohc four 68 30 5195.0
30 37 mazda hatchback 93.1 159.1 ohc four 68 31 6095.0
31 38 mazda hatchback 93.1 159.1 ohc four 68 31 6795.0
32 39 mazda hatchback 95.3 169.0 rotor two 101 17 11845.0
33 43 mazda sedan 104.9 175.0 ohc four 72 31 18344.0
34 44 mercedes-benz sedan 110.0 190.9 ohc five 123 22 25552.0
35 45 mercedes-benz wagon 110.0 190.9 ohc five 123 22 28248.0
36 46 mercedes-benz sedan 120.9 208.1 ohcv eight 184 14 40960.0
37 47 mercedes-benz hardtop 112.0 199.2 ohcv eight 184 14 45400.0
38 49 mitsubishi hatchback 93.7 157.3 ohc four 68 37 5389.0
39 50 mitsubishi hatchback 93.7 157.3 ohc four 68 31 6189.0
40 51 mitsubishi sedan 96.3 172.4 ohc four 88 25 6989.0
41 52 mitsubishi sedan 96.3 172.4 ohc four 88 25 8189.0
42 53 nissan sedan 94.5 165.3 ohc four 55 45 7099.0
43 54 nissan sedan 94.5 165.3 ohc four 69 31 6649.0
44 55 nissan sedan 94.5 165.3 ohc four 69 31 6849.0
45 56 nissan wagon 94.5 170.2 ohc four 69 31 7349.0
46 57 nissan sedan 100.4 184.6 ohcv six 152 19 13499.0
47 61 porsche hardtop 89.5 168.9 ohcf six 207 17 34028.0
48 62 porsche convertible 89.5 168.9 ohcf six 207 17 37028.0
49 63 porsche hatchback 98.4 175.7 dohcv eight 288 17 11095.0
50 66 toyota hatchback 95.7 158.7 ohc four 62 35 5348.0
51 67 toyota hatchback 95.7 158.7 ohc four 62 31 6338.0
52 68 toyota hatchback 95.7 158.7 ohc four 62 31 6488.0
53 69 toyota wagon 95.7 169.7 ohc four 62 31 6918.0
54 70 toyota wagon 95.7 169.7 ohc four 62 27 7898.0
55 71 toyota wagon 95.7 169.7 ohc four 62 27 8778.0
56 79 toyota wagon 104.5 187.8 dohc six 156 19 15750.0
57 80 volkswagen sedan 97.3 171.7 ohc four 52 37 7775.0
58 81 volkswagen sedan 97.3 171.7 ohc four 85 27 7975.0
59 82 volkswagen sedan 97.3 171.7 ohc four 52 37 7995.0
60 86 volkswagen sedan 97.3 171.7 ohc four 100 26 9995.0
61 87 volvo sedan 104.3 188.8 ohc four 114 23 12940.0
62 88 volvo wagon 104.3 188.8 ohc four 114 23 13415.0

@ -0,0 +1,62 @@
index,company,body-style,wheel-base,length,engine-type,num-of-cylinders,horsepower,average-mileage,price
0,alfa-romero,convertible,88.6,168.8,dohc,four,111,21,13495
1,alfa-romero,convertible,88.6,168.8,dohc,four,111,21,16500
2,alfa-romero,hatchback,94.5,171.2,ohcv,six,154,19,16500
3,audi,sedan,99.8,176.6,ohc,four,102,24,13950
4,audi,sedan,99.4,176.6,ohc,five,115,18,17450
5,audi,sedan,99.8,177.3,ohc,five,110,19,15250
6,audi,wagon,105.8,192.7,ohc,five,110,19,18920
9,bmw,sedan,101.2,176.8,ohc,four,101,23,16430
10,bmw,sedan,101.2,176.8,ohc,four,101,23,16925
11,bmw,sedan,101.2,176.8,ohc,six,121,21,20970
13,bmw,sedan,103.5,189,ohc,six,182,16,30760
14,bmw,sedan,103.5,193.8,ohc,six,182,16,41315
15,bmw,sedan,110,197,ohc,six,182,15,36880
16,chevrolet,hatchback,88.4,141.1,l,three,48,47,5151
17,chevrolet,hatchback,94.5,155.9,ohc,four,70,38,6295
18,chevrolet,sedan,94.5,158.8,ohc,four,70,38,6575
19,dodge,hatchback,93.7,157.3,ohc,four,68,31,6377
20,dodge,hatchback,93.7,157.3,ohc,four,68,31,6229
27,honda,wagon,96.5,157.1,ohc,four,76,30,7295
28,honda,sedan,96.5,175.4,ohc,four,101,24,12945
29,honda,sedan,96.5,169.1,ohc,four,100,25,10345
30,isuzu,sedan,94.3,170.7,ohc,four,78,24,6785
31,isuzu,sedan,94.5,155.9,ohc,four,70,38,
32,isuzu,sedan,94.5,155.9,ohc,four,70,38,
33,jaguar,sedan,113,199.6,dohc,six,176,15,32250
34,jaguar,sedan,113,199.6,dohc,six,176,15,35550
35,jaguar,sedan,102,191.7,ohcv,twelve,262,13,36000
36,mazda,hatchback,93.1,159.1,ohc,four,68,30,5195
37,mazda,hatchback,93.1,159.1,ohc,four,68,31,6095
38,mazda,hatchback,93.1,159.1,ohc,four,68,31,6795
39,mazda,hatchback,95.3,169,rotor,two,101,17,11845
43,mazda,sedan,104.9,175,ohc,four,72,31,18344
44,mercedes-benz,sedan,110,190.9,ohc,five,123,22,25552
45,mercedes-benz,wagon,110,190.9,ohc,five,123,22,28248
46,mercedes-benz,sedan,120.9,208.1,ohcv,eight,184,14,40960
47,mercedes-benz,hardtop,112,199.2,ohcv,eight,184,14,45400
49,mitsubishi,hatchback,93.7,157.3,ohc,four,68,37,5389
50,mitsubishi,hatchback,93.7,157.3,ohc,four,68,31,6189
51,mitsubishi,sedan,96.3,172.4,ohc,four,88,25,6989
52,mitsubishi,sedan,96.3,172.4,ohc,four,88,25,8189
53,nissan,sedan,94.5,165.3,ohc,four,55,45,7099
54,nissan,sedan,94.5,165.3,ohc,four,69,31,6649
55,nissan,sedan,94.5,165.3,ohc,four,69,31,6849
56,nissan,wagon,94.5,170.2,ohc,four,69,31,7349
57,nissan,sedan,100.4,184.6,ohcv,six,152,19,13499
61,porsche,hardtop,89.5,168.9,ohcf,six,207,17,34028
62,porsche,convertible,89.5,168.9,ohcf,six,207,17,37028
63,porsche,hatchback,98.4,175.7,dohcv,eight,288,17,
66,toyota,hatchback,95.7,158.7,ohc,four,62,35,5348
67,toyota,hatchback,95.7,158.7,ohc,four,62,31,6338
68,toyota,hatchback,95.7,158.7,ohc,four,62,31,6488
69,toyota,wagon,95.7,169.7,ohc,four,62,31,6918
70,toyota,wagon,95.7,169.7,ohc,four,62,27,7898
71,toyota,wagon,95.7,169.7,ohc,four,62,27,8778
79,toyota,wagon,104.5,187.8,dohc,six,156,19,15750
80,volkswagen,sedan,97.3,171.7,ohc,four,52,37,7775
81,volkswagen,sedan,97.3,171.7,ohc,four,85,27,7975
82,volkswagen,sedan,97.3,171.7,ohc,four,52,37,7995
86,volkswagen,sedan,97.3,171.7,ohc,four,100,26,9995
87,volvo,sedan,104.3,188.8,ohc,four,114,23,12940
88,volvo,wagon,104.3,188.8,ohc,four,114,23,13415
1 index company body-style wheel-base length engine-type num-of-cylinders horsepower average-mileage price
2 0 alfa-romero convertible 88.6 168.8 dohc four 111 21 13495
3 1 alfa-romero convertible 88.6 168.8 dohc four 111 21 16500
4 2 alfa-romero hatchback 94.5 171.2 ohcv six 154 19 16500
5 3 audi sedan 99.8 176.6 ohc four 102 24 13950
6 4 audi sedan 99.4 176.6 ohc five 115 18 17450
7 5 audi sedan 99.8 177.3 ohc five 110 19 15250
8 6 audi wagon 105.8 192.7 ohc five 110 19 18920
9 9 bmw sedan 101.2 176.8 ohc four 101 23 16430
10 10 bmw sedan 101.2 176.8 ohc four 101 23 16925
11 11 bmw sedan 101.2 176.8 ohc six 121 21 20970
12 13 bmw sedan 103.5 189 ohc six 182 16 30760
13 14 bmw sedan 103.5 193.8 ohc six 182 16 41315
14 15 bmw sedan 110 197 ohc six 182 15 36880
15 16 chevrolet hatchback 88.4 141.1 l three 48 47 5151
16 17 chevrolet hatchback 94.5 155.9 ohc four 70 38 6295
17 18 chevrolet sedan 94.5 158.8 ohc four 70 38 6575
18 19 dodge hatchback 93.7 157.3 ohc four 68 31 6377
19 20 dodge hatchback 93.7 157.3 ohc four 68 31 6229
20 27 honda wagon 96.5 157.1 ohc four 76 30 7295
21 28 honda sedan 96.5 175.4 ohc four 101 24 12945
22 29 honda sedan 96.5 169.1 ohc four 100 25 10345
23 30 isuzu sedan 94.3 170.7 ohc four 78 24 6785
24 31 isuzu sedan 94.5 155.9 ohc four 70 38
25 32 isuzu sedan 94.5 155.9 ohc four 70 38
26 33 jaguar sedan 113 199.6 dohc six 176 15 32250
27 34 jaguar sedan 113 199.6 dohc six 176 15 35550
28 35 jaguar sedan 102 191.7 ohcv twelve 262 13 36000
29 36 mazda hatchback 93.1 159.1 ohc four 68 30 5195
30 37 mazda hatchback 93.1 159.1 ohc four 68 31 6095
31 38 mazda hatchback 93.1 159.1 ohc four 68 31 6795
32 39 mazda hatchback 95.3 169 rotor two 101 17 11845
33 43 mazda sedan 104.9 175 ohc four 72 31 18344
34 44 mercedes-benz sedan 110 190.9 ohc five 123 22 25552
35 45 mercedes-benz wagon 110 190.9 ohc five 123 22 28248
36 46 mercedes-benz sedan 120.9 208.1 ohcv eight 184 14 40960
37 47 mercedes-benz hardtop 112 199.2 ohcv eight 184 14 45400
38 49 mitsubishi hatchback 93.7 157.3 ohc four 68 37 5389
39 50 mitsubishi hatchback 93.7 157.3 ohc four 68 31 6189
40 51 mitsubishi sedan 96.3 172.4 ohc four 88 25 6989
41 52 mitsubishi sedan 96.3 172.4 ohc four 88 25 8189
42 53 nissan sedan 94.5 165.3 ohc four 55 45 7099
43 54 nissan sedan 94.5 165.3 ohc four 69 31 6649
44 55 nissan sedan 94.5 165.3 ohc four 69 31 6849
45 56 nissan wagon 94.5 170.2 ohc four 69 31 7349
46 57 nissan sedan 100.4 184.6 ohcv six 152 19 13499
47 61 porsche hardtop 89.5 168.9 ohcf six 207 17 34028
48 62 porsche convertible 89.5 168.9 ohcf six 207 17 37028
49 63 porsche hatchback 98.4 175.7 dohcv eight 288 17
50 66 toyota hatchback 95.7 158.7 ohc four 62 35 5348
51 67 toyota hatchback 95.7 158.7 ohc four 62 31 6338
52 68 toyota hatchback 95.7 158.7 ohc four 62 31 6488
53 69 toyota wagon 95.7 169.7 ohc four 62 31 6918
54 70 toyota wagon 95.7 169.7 ohc four 62 27 7898
55 71 toyota wagon 95.7 169.7 ohc four 62 27 8778
56 79 toyota wagon 104.5 187.8 dohc six 156 19 15750
57 80 volkswagen sedan 97.3 171.7 ohc four 52 37 7775
58 81 volkswagen sedan 97.3 171.7 ohc four 85 27 7975
59 82 volkswagen sedan 97.3 171.7 ohc four 52 37 7995
60 86 volkswagen sedan 97.3 171.7 ohc four 100 26 9995
61 87 volvo sedan 104.3 188.8 ohc four 114 23 12940
62 88 volvo wagon 104.3 188.8 ohc four 114 23 13415

@ -0,0 +1,104 @@
import pandas as pd
import numpy as np
import random
input_data = pd.read_csv('Automobile_data.csv', sep=',')
print("---First task---")
print("First 5 rows:")
print(input_data.head(5))
print("Last 5 rows:")
print(input_data.tail(5))
print("---Second task---")
input_data.replace("?", np.NaN, inplace=True)
input_data.replace("N.a", np.NaN, inplace=True)
numeric_cols = input_data.select_dtypes(include=['number']).columns
input_data[numeric_cols] = input_data[numeric_cols].fillna(input_data[numeric_cols].median())
non_numeric_cols = input_data.select_dtypes(exclude=['number']).columns
input_data[non_numeric_cols] = input_data[non_numeric_cols].fillna(input_data[non_numeric_cols].mode())
input_data.to_csv("Automobile_Data_Cleaned.csv", sep=",", index=False)
print("---Third task---")
most_expensive_company = input_data.loc[input_data['price'].idxmax(), 'company']
print(f"Most expensive company: {most_expensive_company}")
most_expensive_cars = input_data[input_data['price'] == input_data['price'].max()]
print("\nThe most expensive cars are:")
print(most_expensive_cars[['company', 'price']])
print("---Fourth task---")
toyota_cars = input_data[input_data["company"] == "toyota"]
print(toyota_cars)
print("---Fifth task---")
count_group_by_company = input_data.groupby(["company"])["index"].count()
print(count_group_by_company)
print("---Sixth task---")
group_by_company = input_data.groupby("company")["price"].idxmax()
group_by_company_df = input_data.loc[group_by_company]
print(group_by_company_df)
print("---Seventh task---")
group_by_company = input_data.groupby("company")["average-mileage"].mean()
group_by_company_df = group_by_company.reset_index()
print(group_by_company_df)
print("---Eigth task---")
sorted_by_price = input_data.sort_values(by="price", ascending=True)
print(sorted_by_price)
print("---Ninth task---")
GermanCars = {'Company': ['Ford', 'Mercedes', 'BMV', 'Audi'], 'Price': [23845, 171995, 135925, 71400]}
japaneseCars = {'Company': ['Toyota', 'Honda', 'Nissan', 'Mitsubishi '], 'Price': [29995, 23600, 61500, 58900]}
german_cars_df = pd.DataFrame(GermanCars)
japanese_cars_df = pd.DataFrame(japaneseCars)
print(german_cars_df)
print(japanese_cars_df)
print("---Tenth task---")
Car_Price = {'Company': ['Toyota', 'Honda', 'BMV', 'Audi'], 'Price': [23845, 17995, 135925, 71400]}
car_Horsepower = {'Company': ['Toyota', 'Honda', 'BMV', 'Audi'], 'horsepower': [141, 80, 182, 160]}
car_price_df = pd.DataFrame(Car_Price)
car_horsepower_df = pd.DataFrame(car_Horsepower)
merged_df = pd.merge(car_price_df, car_horsepower_df, how="inner", on="Company")
print(merged_df)
print("---===Second dataset===---")
second_dataset = pd.read_csv("world_alcohol.csv", sep=",")
print("---Eleventh task---")
print(second_dataset.sample(n=random.randint(1, 10)))
print("---Twelfth task---")
group_by_region = second_dataset.groupby(["WHO region", "Year"])
for region, year in group_by_region.groups:
if year == 1989:
print(group_by_region.get_group((region, year)))
print("--Thirteenth task---")
america_1985_data = second_dataset[(second_dataset["WHO region"] == "Americas") & (second_dataset["Year"] == 1985)]
print(america_1985_data)
print("---Fourteenth task---")
data_14 = second_dataset[(second_dataset["Display Value"] >= 5) & (second_dataset["Beverage Types"] == "Beer")]
print(data_14)
print("---Fifteenth task---")
data_wine = second_dataset[(second_dataset["Display Value"] >= 2) & (second_dataset["Beverage Types"] == "Wine")]
print(data_wine)

@ -0,0 +1,101 @@
Year,WHO region,Country,Beverage Types,Display Value
1986,Western Pacific,Viet Nam,Wine,0
1986,Americas,Uruguay,Other,0.5
1985,Africa,Cte d'Ivoire,Wine,1.62
1986,Americas,Colombia,Beer,4.27
1987,Americas,Saint Kitts and Nevis,Beer,1.98
1987,Americas,Guatemala,Other,0
1987,Africa,Mauritius,Wine,0.13
1985,Africa,Angola,Spirits,0.39
1986,Americas,Antigua and Barbuda,Spirits,1.55
1984,Africa,Nigeria,Other,6.1
1987,Africa,Botswana,Wine,0.2
1989,Americas,Guatemala,Beer,0.62
1985,Western Pacific,Lao People's Democratic Republic,Beer,0
1984,Eastern Mediterranean,Afghanistan,Other,0
1985,Western Pacific,Viet Nam,Spirits,0.05
1987,Africa,Guinea-Bissau,Wine,0.07
1984,Americas,Costa Rica,Wine,0.06
1989,Africa,Seychelles,Beer,2.23
1984,Europe,Norway,Spirits,1.62
1984,Africa,Kenya,Beer,1.08
1986,South-East Asia,Myanmar,Wine,0
1989,Americas,Costa Rica,Spirits,4.51
1984,Europe,Romania,Spirits,2.67
1984,Europe,Turkey,Beer,0.44
1985,Africa,Comoros,Other,
1984,Eastern Mediterranean,Tunisia,Other,0
1985,Europe,United Kingdom of Great Britain and Northern Ireland,Wine,1.36
1984,Eastern Mediterranean,Bahrain,Beer,2.22
1987,Western Pacific,Viet Nam,Beer,0.11
1986,Europe,Italy,Other,
1986,Africa,Sierra Leone,Other,4.48
1986,Western Pacific,Micronesia (Federated States of),Wine,0
1989,Africa,Mauritius,Beer,1.6
1985,Africa,Mauritania,Other,0
1986,Europe,Russian Federation,Wine,0.8
1985,Americas,Saint Kitts and Nevis,Spirits,2.24
1987,Eastern Mediterranean,Egypt,Beer,0.07
1986,Europe,Sweden,Beer,3.04
1987,Eastern Mediterranean,Qatar,Other,0
1987,Africa,Burkina Faso,Spirits,0.01
1987,Europe,Austria,Spirits,1.9
1986,Europe,Czech Republic,Beer,6.82
1984,Europe,Ukraine,Spirits,3.06
1984,Western Pacific,China,Wine,0.03
1985,Europe,Lithuania,Other,
1989,Africa,Zimbabwe,Beer,0.19
1987,Americas,Trinidad and Tobago,Spirits,2.26
1986,Americas,Mexico,Other,0.04
1987,Americas,Nicaragua,Beer,0.7
1986,Europe,Malta,Wine,1.49
1985,Europe,Switzerland,Other,0.3
1987,Europe,Finland,Beer,3.88
1986,Eastern Mediterranean,Saudi Arabia,Wine,0
1984,Eastern Mediterranean,Kuwait,Beer,0
1984,Americas,El Salvador,Spirits,1.81
1989,Americas,Suriname,Wine,0.04
1987,Western Pacific,Viet Nam,Wine,0
1989,Europe,Croatia,Wine,5.1
1984,Eastern Mediterranean,Somalia,Spirits,0
1989,Eastern Mediterranean,Syrian Arab Republic,Other,0
1987,Eastern Mediterranean,Iran (Islamic Republic of),Other,0
1984,Western Pacific,Papua New Guinea,Spirits,0.08
1987,Americas,Suriname,Other,0
1985,Eastern Mediterranean,Libya,Other,0
1989,Americas,Bolivia (Plurinational State of),Beer,1.26
1989,Eastern Mediterranean,Somalia,Beer,0
1987,Eastern Mediterranean,Iraq,Wine,0.01
1989,Africa,Namibia,Beer,0
1989,Africa,Uganda,Beer,0.12
1986,Africa,Togo,Spirits,0.42
1986,Africa,Madagascar,Spirits,1.02
1985,Africa,Mali,Other,0.57
1987,Africa,Mauritania,Other,0
1986,Eastern Mediterranean,Pakistan,Other,0.01
1986,Americas,Bolivia (Plurinational State of),Spirits,2.06
1989,Eastern Mediterranean,Afghanistan,Other,0
1985,Africa,Comoros,Beer,0.02
1985,Africa,Cameroon,Spirits,0.01
1989,Americas,Jamaica,Other,0
1989,Europe,Finland,Other,2.09
1985,Africa,Malawi,Other,0.84
1985,Europe,Netherlands,Wine,2.54
1987,Europe,Ireland,Spirits,2.25
1986,Europe,Ukraine,Other,
1986,South-East Asia,Sri Lanka,Other,0
1985,Africa,Democratic Republic of the Congo,Wine,0.01
1986,Americas,Bahamas,Wine,1.83
1989,Eastern Mediterranean,Iraq,Wine,0.01
1987,Eastern Mediterranean,Lebanon,Beer,0.42
1986,Eastern Mediterranean,Lebanon,Wine,0.7
1989,Africa,Malawi,Wine,0.01
1989,Europe,Bulgaria,Beer,4.43
1986,Africa,Eritrea,Spirits,0
1987,Africa,Madagascar,Other,
1985,Europe,Ukraine,Spirits,3.06
1984,Africa,Niger,Other,0
1985,Europe,Luxembourg,Wine,7.38
1984,South-East Asia,Indonesia,Wine,0
1984,Africa,Equatorial Guinea,Wine,0
1985,South-East Asia,Democratic People's Republic of Korea,Wine,0
1 Year WHO region Country Beverage Types Display Value
2 1986 Western Pacific Viet Nam Wine 0
3 1986 Americas Uruguay Other 0.5
4 1985 Africa Cte d'Ivoire Wine 1.62
5 1986 Americas Colombia Beer 4.27
6 1987 Americas Saint Kitts and Nevis Beer 1.98
7 1987 Americas Guatemala Other 0
8 1987 Africa Mauritius Wine 0.13
9 1985 Africa Angola Spirits 0.39
10 1986 Americas Antigua and Barbuda Spirits 1.55
11 1984 Africa Nigeria Other 6.1
12 1987 Africa Botswana Wine 0.2
13 1989 Americas Guatemala Beer 0.62
14 1985 Western Pacific Lao People's Democratic Republic Beer 0
15 1984 Eastern Mediterranean Afghanistan Other 0
16 1985 Western Pacific Viet Nam Spirits 0.05
17 1987 Africa Guinea-Bissau Wine 0.07
18 1984 Americas Costa Rica Wine 0.06
19 1989 Africa Seychelles Beer 2.23
20 1984 Europe Norway Spirits 1.62
21 1984 Africa Kenya Beer 1.08
22 1986 South-East Asia Myanmar Wine 0
23 1989 Americas Costa Rica Spirits 4.51
24 1984 Europe Romania Spirits 2.67
25 1984 Europe Turkey Beer 0.44
26 1985 Africa Comoros Other
27 1984 Eastern Mediterranean Tunisia Other 0
28 1985 Europe United Kingdom of Great Britain and Northern Ireland Wine 1.36
29 1984 Eastern Mediterranean Bahrain Beer 2.22
30 1987 Western Pacific Viet Nam Beer 0.11
31 1986 Europe Italy Other
32 1986 Africa Sierra Leone Other 4.48
33 1986 Western Pacific Micronesia (Federated States of) Wine 0
34 1989 Africa Mauritius Beer 1.6
35 1985 Africa Mauritania Other 0
36 1986 Europe Russian Federation Wine 0.8
37 1985 Americas Saint Kitts and Nevis Spirits 2.24
38 1987 Eastern Mediterranean Egypt Beer 0.07
39 1986 Europe Sweden Beer 3.04
40 1987 Eastern Mediterranean Qatar Other 0
41 1987 Africa Burkina Faso Spirits 0.01
42 1987 Europe Austria Spirits 1.9
43 1986 Europe Czech Republic Beer 6.82
44 1984 Europe Ukraine Spirits 3.06
45 1984 Western Pacific China Wine 0.03
46 1985 Europe Lithuania Other
47 1989 Africa Zimbabwe Beer 0.19
48 1987 Americas Trinidad and Tobago Spirits 2.26
49 1986 Americas Mexico Other 0.04
50 1987 Americas Nicaragua Beer 0.7
51 1986 Europe Malta Wine 1.49
52 1985 Europe Switzerland Other 0.3
53 1987 Europe Finland Beer 3.88
54 1986 Eastern Mediterranean Saudi Arabia Wine 0
55 1984 Eastern Mediterranean Kuwait Beer 0
56 1984 Americas El Salvador Spirits 1.81
57 1989 Americas Suriname Wine 0.04
58 1987 Western Pacific Viet Nam Wine 0
59 1989 Europe Croatia Wine 5.1
60 1984 Eastern Mediterranean Somalia Spirits 0
61 1989 Eastern Mediterranean Syrian Arab Republic Other 0
62 1987 Eastern Mediterranean Iran (Islamic Republic of) Other 0
63 1984 Western Pacific Papua New Guinea Spirits 0.08
64 1987 Americas Suriname Other 0
65 1985 Eastern Mediterranean Libya Other 0
66 1989 Americas Bolivia (Plurinational State of) Beer 1.26
67 1989 Eastern Mediterranean Somalia Beer 0
68 1987 Eastern Mediterranean Iraq Wine 0.01
69 1989 Africa Namibia Beer 0
70 1989 Africa Uganda Beer 0.12
71 1986 Africa Togo Spirits 0.42
72 1986 Africa Madagascar Spirits 1.02
73 1985 Africa Mali Other 0.57
74 1987 Africa Mauritania Other 0
75 1986 Eastern Mediterranean Pakistan Other 0.01
76 1986 Americas Bolivia (Plurinational State of) Spirits 2.06
77 1989 Eastern Mediterranean Afghanistan Other 0
78 1985 Africa Comoros Beer 0.02
79 1985 Africa Cameroon Spirits 0.01
80 1989 Americas Jamaica Other 0
81 1989 Europe Finland Other 2.09
82 1985 Africa Malawi Other 0.84
83 1985 Europe Netherlands Wine 2.54
84 1987 Europe Ireland Spirits 2.25
85 1986 Europe Ukraine Other
86 1986 South-East Asia Sri Lanka Other 0
87 1985 Africa Democratic Republic of the Congo Wine 0.01
88 1986 Americas Bahamas Wine 1.83
89 1989 Eastern Mediterranean Iraq Wine 0.01
90 1987 Eastern Mediterranean Lebanon Beer 0.42
91 1986 Eastern Mediterranean Lebanon Wine 0.7
92 1989 Africa Malawi Wine 0.01
93 1989 Europe Bulgaria Beer 4.43
94 1986 Africa Eritrea Spirits 0
95 1987 Africa Madagascar Other
96 1985 Europe Ukraine Spirits 3.06
97 1984 Africa Niger Other 0
98 1985 Europe Luxembourg Wine 7.38
99 1984 South-East Asia Indonesia Wine 0
100 1984 Africa Equatorial Guinea Wine 0
101 1985 South-East Asia Democratic People's Republic of Korea Wine 0
Loading…
Cancel
Save