Skip to content

Commit 54b0a68

Browse files
committed
ex 05.5 to 06.3
1 parent b9b564b commit 54b0a68

File tree

12 files changed

+192
-7
lines changed

12 files changed

+192
-7
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import io, os, sys, pytest, re
2+
3+
@pytest.mark.it('You must import pandas')
4+
def test_import_pandas():
5+
path = os.path.dirname(os.path.abspath('app.py'))+'/app.py'
6+
with open(path, 'r') as content_file:
7+
content = content_file.read()
8+
regex = re.compile(r"import\s*pandas\s*as\s*pd")
9+
assert bool(regex.search(content)) == True
10+
11+
@pytest.mark.it("Use the print function")
12+
def test_output():
13+
f = open('app.py')
14+
content = f.read()
15+
assert "print" in content
16+
17+
@pytest.mark.it('The output should be the expected')
18+
def test_expected_output(capsys):
19+
import app
20+
captured = capsys.readouterr()
21+
assert captured.out == """ Name Type 1
22+
0 Bulbasaur Grass
23+
1 Ivysaur Grass
24+
2 Venusaur Grass
25+
3 VenusaurMega Venusaur Grass
26+
4 Charmander Fire
27+
5 Charmeleon Fire
28+
6 Charizard Fire
29+
7 CharizardMega Charizard X Fire
30+
8 CharizardMega Charizard Y Fire
31+
9 Squirtle Water
32+
"""

.learn/exercises/05.6-loc/test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import io, os, sys, pytest, re, pandas
2+
data_frame = pandas.read_csv('.learn/assets/pokemon_data.csv')
3+
4+
@pytest.mark.it('You must import pandas')
5+
def test_import_pandas():
6+
path = os.path.dirname(os.path.abspath('app.py'))+'/app.py'
7+
with open(path, 'r') as content_file:
8+
content = content_file.read()
9+
regex = re.compile(r"import\s*pandas\s*as\s*pd")
10+
assert bool(regex.search(content)) == True
11+
12+
@pytest.mark.it("Use the print function")
13+
def test_output():
14+
f = open('app.py')
15+
content = f.read()
16+
assert "print" in content
17+
18+
@pytest.mark.it('The output should be the expected')
19+
def test_expected_output(capsys):
20+
import app
21+
captured = capsys.readouterr()
22+
assert captured.out == str(data_frame.loc[data_frame['Attack'] > 80])+"\n"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import io, os, sys, pytest, re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
def test_import_pandas():
6+
path = os.path.dirname(os.path.abspath('app.py'))+'/app.py'
7+
with open(path, 'r') as content_file:
8+
content = content_file.read()
9+
regex = re.compile(r"import\s*pandas\s*as\s*pd")
10+
assert bool(regex.search(content)) == True
11+
12+
@pytest.mark.it("Use the print function")
13+
def test_output():
14+
f = open('app.py')
15+
content = f.read()
16+
assert "print" in content
17+
18+
@pytest.mark.it('The output should be the expected')
19+
def test_expected_output(capsys):
20+
import app
21+
captured = capsys.readouterr()
22+
assert captured.out == "65\n"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import io, os, sys, pytest, re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
def test_import_pandas():
6+
path = os.path.dirname(os.path.abspath('app.py'))+'/app.py'
7+
with open(path, 'r') as content_file:
8+
content = content_file.read()
9+
regex = re.compile(r"import\s*pandas\s*as\s*pd")
10+
assert bool(regex.search(content)) == True
11+
12+
@pytest.mark.it("Use the print function")
13+
def test_output():
14+
f = open('app.py')
15+
content = f.read()
16+
assert "print" in content
17+
18+
@pytest.mark.it('The output should be the expected')
19+
def test_expected_output(capsys):
20+
import app
21+
captured = capsys.readouterr()
22+
assert captured.out == """ Unnamed: 0 Id Name Year Gender State Count
23+
0 11349 11350 Emma 2004 F AK 62
24+
1 11350 11351 Madison 2004 F AK 48
25+
2 11351 11352 Hannah 2004 F AK 46
26+
3 11352 11353 Grace 2004 F AK 44
27+
4 11353 11354 Emily 2004 F AK 41
28+
"""
29+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pandas as pd
2+
3+
data_frame = pd.read_csv('.learn/assets/us_baby_names_right.csv')
4+
# data_frame = pd.iloc[: , 1:]
5+
del data_frame[data_frame.columns[0]]
6+
print(data_frame.head())
7+
8+
# https://thispointer.com/pandas-delete-first-column-of-dataframe-in-python/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import io, os, sys, pytest, re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
def test_import_pandas():
6+
path = os.path.dirname(os.path.abspath('app.py'))+'/app.py'
7+
with open(path, 'r') as content_file:
8+
content = content_file.read()
9+
regex = re.compile(r"import\s*pandas\s*as\s*pd")
10+
assert bool(regex.search(content)) == True
11+
12+
@pytest.mark.it("Use the print function")
13+
def test_output():
14+
f = open('app.py')
15+
content = f.read()
16+
assert "print" in content
17+
18+
@pytest.mark.it('The output should be the expected')
19+
def test_expected_output(capsys):
20+
import app
21+
captured = capsys.readouterr()
22+
assert captured.out == """ Id Name Year Gender State Count
23+
0 11350 Emma 2004 F AK 62
24+
1 11351 Madison 2004 F AK 48
25+
2 11352 Hannah 2004 F AK 46
26+
3 11353 Grace 2004 F AK 44
27+
4 11354 Emily 2004 F AK 41
28+
"""
29+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import io, os, sys, pytest, re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
def test_import_pandas():
6+
path = os.path.dirname(os.path.abspath('app.py'))+'/app.py'
7+
with open(path, 'r') as content_file:
8+
content = content_file.read()
9+
regex = re.compile(r"import\s*pandas\s*as\s*pd")
10+
assert bool(regex.search(content)) == True
11+
12+
@pytest.mark.it("Use the print function")
13+
def test_output():
14+
f = open('app.py')
15+
content = f.read()
16+
assert "print" in content
17+
18+
@pytest.mark.it('The output should be the expected')
19+
def test_expected_output(capsys):
20+
import app
21+
captured = capsys.readouterr()
22+
assert captured.out == """F 558846
23+
M 457549
24+
Name: Gender, dtype: int64
25+
"""
26+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import io, os, sys, pytest, re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
def test_import_pandas():
6+
path = os.path.dirname(os.path.abspath('app.py'))+'/app.py'
7+
with open(path, 'r') as content_file:
8+
content = content_file.read()
9+
regex = re.compile(r"import\s*pandas\s*as\s*pd")
10+
assert bool(regex.search(content)) == True
11+
12+
@pytest.mark.it("Use the print function")
13+
def test_output():
14+
f = open('app.py')
15+
content = f.read()
16+
assert "print" in content
17+
18+
@pytest.mark.it('The output should be the expected')
19+
def test_expected_output(capsys):
20+
import app
21+
captured = capsys.readouterr()
22+
assert captured.out == "17632\n"
23+

.learn/resets/05.2-iloc/solution.hiden.py

Whitespace-only changes.

.learn/vscode_queue.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)