Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2432b8

Browse files
Merge pull request4GeeksAcademy#2 from kiddopro/05_1_to_06_3
05 1 to 06 3
2 parents4fe6306 +fcd5bd6 commitd2432b8

File tree

17 files changed

+312
-111
lines changed

17 files changed

+312
-111
lines changed

‎.learn/exercises/04.1-Date_range/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Series Date Range
1+
#`04.1`Series Date Range
22

33
Use the pd.date_range function to create a series from`05-01-2021` to`05-12-2021`
44

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
importpytest,io,os,sys,re
2+
3+
@pytest.mark.it('You must import pandas')
4+
deftest_import_pandas():
5+
path='app.py'
6+
withopen(path,'r')ascontent_file:
7+
content=content_file.read()
8+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
9+
assertbool(regex.search(content))==True
10+
11+
@pytest.mark.it("Use the print function")
12+
deftest_output():
13+
f=open('app.py')
14+
content=f.read()
15+
assert"print"incontent
16+
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
assertcaptured.out==""" brand make color
23+
0 Toyota Corolla Blue
24+
1 Ford K Yellow
25+
2 Porche Cayenne White
26+
3 Tesla Model S Red
27+
"""
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
importpandasaspd
2+
3+
data=pd.read_csv('.learn/assets/pokemon_data.csv')
4+
5+
print(data.iloc[133,6])

‎.learn/exercises/05.2-iloc/test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
importpytest,io,os,sys,re
2+
3+
@pytest.mark.it('You must import pandas')
4+
deftest_import_pandas():
5+
path='app.py'
6+
withopen(path,'r')ascontent_file:
7+
content=content_file.read()
8+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
9+
assertbool(regex.search(content))==True
10+
11+
@pytest.mark.it("Use the print function")
12+
deftest_output():
13+
f=open('app.py')
14+
content=f.read()
15+
assert"print"incontent
16+
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
assertcaptured.out=="35\n"

‎.learn/exercises/05.3-head/test.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
importpytest,io,os,sys,re,pandas
2+
data_frame=pandas.read_csv('.learn/assets/pokemon_data.csv').head(3)
3+
4+
@pytest.mark.it('You must import pandas')
5+
deftest_import_pandas():
6+
path=os.path.dirname(os.path.abspath('app.py'))+'/app.py'
7+
withopen(path,'r')ascontent_file:
8+
content=content_file.read()
9+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
10+
assertbool(regex.search(content))==True
11+
12+
@pytest.mark.it("Use the print function")
13+
deftest_output():
14+
f=open('app.py')
15+
content=f.read()
16+
assert"print"incontent
17+
18+
19+
@pytest.mark.it('The output should be the expected')
20+
deftest_expected_output(capsys):
21+
importapp
22+
captured=capsys.readouterr()
23+
assertcaptured.out==str(data_frame)+'\n'
24+
25+
# @pytest.mark.it('The variable data_frame should exist')
26+
# def test_variable_existence():
27+
# from app import data_frame
28+
29+
"""
30+
# Name Type 1 Type 2 HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
31+
0 1 Bulbasaur Grass Poison 45 49 49 65 65 45 1 False
32+
1 2 Ivysaur Grass Poison 60 62 63 80 80 60 1 False
33+
2 3 Venusaur Grass Poison 80 82 83 100 100 80 1 False
34+
"""

‎.learn/exercises/05.4-tail/test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
importio,os,re,sys,pytest,pandas
2+
3+
@pytest.mark.it('You must import pandas')
4+
deftest_import_pandas():
5+
path='app.py'
6+
withopen(path,'r')ascontent_file:
7+
content=content_file.read()
8+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
9+
assertbool(regex.search(content))==True
10+
11+
@pytest.mark.it("Use the print function")
12+
deftest_output():
13+
f=open('app.py')
14+
content=f.read()
15+
assert"print"incontent
16+
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
data_frame=pandas.read_csv('.learn/assets/pokemon_data.csv').tail(3)
23+
assertcaptured.out==str(data_frame)+'\n'
24+
25+
# @pytest.mark.it('The variable data_frame should exist')
26+
# def test_variable_existence():
27+
# from app import data_frame
28+
29+
""" # Name Type 1 Type 2 HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
30+
797 720 HoopaHoopa Confined Psychic Ghost 80 110 60 150 130 70 6 True
31+
798 720 HoopaHoopa Unbound Psychic Dark 80 160 60 170 130 80 6 True
32+
799 721 Volcanion Fire Water 80 110 120 130 90 70 6 True
33+
"""
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
importio,os,sys,pytest,re
2+
3+
@pytest.mark.it('You must import pandas')
4+
deftest_import_pandas():
5+
path='app.py'
6+
withopen(path,'r')ascontent_file:
7+
content=content_file.read()
8+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
9+
assertbool(regex.search(content))==True
10+
11+
@pytest.mark.it("Use the print function")
12+
deftest_output():
13+
f=open('app.py')
14+
content=f.read()
15+
assert"print"incontent
16+
17+
@pytest.mark.it('The output should be the expected')
18+
deftest_expected_output(capsys):
19+
importapp
20+
captured=capsys.readouterr()
21+
assertcaptured.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+
importio,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+
deftest_import_pandas():
6+
path='app.py'
7+
withopen(path,'r')ascontent_file:
8+
content=content_file.read()
9+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
10+
assertbool(regex.search(content))==True
11+
12+
@pytest.mark.it("Use the print function")
13+
deftest_output():
14+
f=open('app.py')
15+
content=f.read()
16+
assert"print"incontent
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
assertcaptured.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+
importio,os,sys,pytest,re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
deftest_import_pandas():
6+
path='app.py'
7+
withopen(path,'r')ascontent_file:
8+
content=content_file.read()
9+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
10+
assertbool(regex.search(content))==True
11+
12+
@pytest.mark.it("Use the print function")
13+
deftest_output():
14+
f=open('app.py')
15+
content=f.read()
16+
assert"print"incontent
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
assertcaptured.out=="65\n"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
importio,os,sys,pytest,re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
deftest_import_pandas():
6+
path='app.py'
7+
withopen(path,'r')ascontent_file:
8+
content=content_file.read()
9+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
10+
assertbool(regex.search(content))==True
11+
12+
@pytest.mark.it("Use the print function")
13+
deftest_output():
14+
f=open('app.py')
15+
content=f.read()
16+
assert"print"incontent
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
assertcaptured.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+
importpandasaspd
2+
3+
data_frame=pd.read_csv('.learn/assets/us_baby_names_right.csv')
4+
# data_frame = pd.iloc[: , 1:]
5+
deldata_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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
importio,os,sys,pytest,re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
deftest_import_pandas():
6+
path='app.py'
7+
withopen(path,'r')ascontent_file:
8+
content=content_file.read()
9+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
10+
assertbool(regex.search(content))==True
11+
12+
@pytest.mark.it("Use the print function")
13+
deftest_output():
14+
f=open('app.py')
15+
content=f.read()
16+
assert"print"incontent
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
assertcaptured.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+
"""
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
importio,os,sys,pytest,re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
deftest_import_pandas():
6+
path='app.py'
7+
withopen(path,'r')ascontent_file:
8+
content=content_file.read()
9+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
10+
assertbool(regex.search(content))==True
11+
12+
@pytest.mark.it("Use the print function")
13+
deftest_output():
14+
f=open('app.py')
15+
content=f.read()
16+
assert"print"incontent
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
assertcaptured.out=="""F 558846
23+
M 457549
24+
Name: Gender, dtype: int64
25+
"""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
importio,os,sys,pytest,re
2+
3+
4+
@pytest.mark.it('You must import pandas')
5+
deftest_import_pandas():
6+
path='app.py'
7+
withopen(path,'r')ascontent_file:
8+
content=content_file.read()
9+
regex=re.compile(r"import\s*pandas\s*as\s*pd")
10+
assertbool(regex.search(content))==True
11+
12+
@pytest.mark.it("Use the print function")
13+
deftest_output():
14+
f=open('app.py')
15+
content=f.read()
16+
assert"print"incontent
17+
18+
@pytest.mark.it('The output should be the expected')
19+
deftest_expected_output(capsys):
20+
importapp
21+
captured=capsys.readouterr()
22+
assertcaptured.out=="17632\n"
23+

‎Pipfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp