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

Commite4b2f18

Browse files
committed
all ready
1 parent508b817 commite4b2f18

File tree

7 files changed

+256
-5
lines changed

7 files changed

+256
-5
lines changed

‎.learn/exercises/06.2-value-counts/test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def test_output():
1919
deftest_expected_output(capsys):
2020
importapp
2121
captured=capsys.readouterr()
22-
assertcaptured.out=="""F 558846
22+
assertcaptured.out=="""Gender
23+
F 558846
2324
M 457549
24-
Name:Gender, dtype: int64
25+
Name:count, dtype: int64
2526
"""
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/vscode_queue.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"name":"initializing","time":4367635.891},{"name":"reset","time":4367682.592},{"name":"configuration_loaded","time":4499042.118}]
1+
[{"name":"initializing","time":909990.499},{"name":"reset","time":910047.2},{"name":"configuration_loaded","time":1009713.508},{"name":"start_exercise","time":1185310.445,"data":"00-welcome"},{"name":"start_exercise","time":1101782.932,"data":"01-new-terminal"},{"name":"start_exercise","time":750330.001,"data":"01.2-pipenv"},{"name":"start_exercise","time":1298108.211,"data":"02-install"},{"name":"start_exercise","time":1293363.493,"data":"02.1-create-a-script"},{"name":"start_exercise","time":1190941.173,"data":"02.2-import"},{"name":"start_exercise","time":2568597.56,"data":"03-datasets"},{"name":"start_exercise","time":2441247.78,"data":"04-Series"},{"name":"start_exercise","time":2197602.311,"data":"04.1-date-range"},{"name":"start_exercise","time":2676128.264,"data":"04.2-series-apply"},{"name":"start_exercise","time":3362206.882,"data":"05-dataframes"},{"name":"start_exercise","time":2661569.195,"data":"05.1-dataframe-dict"},{"name":"start_exercise","time":2840438.361,"data":"05.2-dataframe-iloc"},{"name":"start_exercise","time":3114756.123,"data":"05.3-file-head"},{"name":"start_exercise","time":3441803.411,"data":"05.4-dataframe-tail"},{"name":"start_exercise","time":3821474.765,"data":"05.5-print-columns"},{"name":"start_exercise","time":4050565.957,"data":"05.6-loc-function"},{"name":"start_exercise","time":4363793.815,"data":"05.7-filter-and-count"},{"name":"start_exercise","time":3796730.645,"data":"06-clean-datasets"},{"name":"start_exercise","time":4495662.24,"data":"06.1-remove-column"},{"name":"start_exercise","time":4209836.35,"data":"06.2-value-counts"},{"name":"start_exercise","time":5877545.746,"data":"06.3-group-by"}]

‎Pipfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[[source]]
2+
url ="https://pypi.org/simple"
3+
verify_ssl =true
4+
name ="pypi"
5+
6+
[packages]
7+
pandas ="*"
8+
9+
[dev-packages]
10+
11+
[requires]
12+
python_version ="3.10"

‎Pipfile.lock

Lines changed: 117 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎app.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
importpandasaspd
2+
# data_frame = pd.read_csv('.learn/assets/pokemon_data.csv')
3+
# print(data_frame)
4+
5+
# 4.0
6+
# ages = [23,45,7,34,6,63,36,78,54,34]
7+
# data = pd.Series(ages)
8+
# print(data)
9+
10+
# 4.1
11+
# date_time_index = pd.date_range('05-01-2021', '05-12-2021')
12+
# print(date_time_index)
13+
14+
# 4.2
15+
# my_series = pd.Series([2, 4, 6, 8, 10])
16+
# print(my_series.apply(lambda x: x / 2))
17+
18+
# 5
19+
"""
20+
data = [["Toyota", "Corolla", "Blue"], ["Ford", "K", "Yellow"], ["Porche", "Cayenne", "White"]]
21+
df = pd.DataFrame(data, columns=['Brand', 'Model', 'Color'])
22+
print(df)
23+
"""
24+
25+
# 5.1
26+
"""
27+
data = [
28+
{
29+
"brand": "Toyota",
30+
"make": "Corolla",
31+
"color": "Blue"
32+
},
33+
{
34+
"brand": "Ford",
35+
"make": "K",
36+
"color": "Yellow"
37+
},
38+
{
39+
"brand": "Porche",
40+
"make": "Cayenne",
41+
"color": "White"
42+
},
43+
{
44+
"brand": "Tesla",
45+
"make": "Model S",
46+
"color": "Red"
47+
}
48+
49+
]
50+
df = pd.DataFrame(data)
51+
print(df)
52+
"""
53+
54+
# 5.2
55+
"""
56+
data_frame = pd.read_csv('.learn/assets/pokemon_data.csv')
57+
print(data_frame.iloc[133, 6])
58+
"""
59+
60+
# 5.3
61+
"""
62+
data_frame = pd.read_csv('.learn/assets/pokemon_data.csv')
63+
print(data_frame.head(3))
64+
"""
65+
66+
# 5.4
67+
"""
68+
data_frame = pd.read_csv('.learn/assets/pokemon_data.csv')
69+
print(data_frame.tail(3))
70+
"""
71+
72+
# 5.5
73+
"""
74+
data_frame = pd.read_csv('.learn/assets/pokemon_data.csv')
75+
print(data_frame[['Name', 'Type 1']][0:10])
76+
"""
77+
78+
# 5.6
79+
"""
80+
data_frame = pd.read_csv('.learn/assets/pokemon_data.csv')
81+
print(data_frame.loc[data_frame['Attack'] > 80])
82+
"""
83+
84+
# 5.7
85+
"""
86+
data_frame = pd.read_csv('.learn/assets/pokemon_data.csv')
87+
print(len(data_frame.loc[data_frame['Legendary'] == True]))
88+
"""
89+
90+
# 6
91+
"""
92+
data_frame = pd.read_csv('.learn/assets/us_baby_names_right.csv')
93+
print(data_frame.head())
94+
"""
95+
96+
# 6.1
97+
"""
98+
data_frame = pd.read_csv('.learn/assets/us_baby_names_right.csv')
99+
del data_frame[data_frame.columns[0]]
100+
print(data_frame.head())
101+
"""
102+
103+
# 6.3
104+
"""
105+
data_frame = pd.read_csv('.learn/assets/us_baby_names_right.csv')
106+
print(data_frame.value_counts('Gender'))
107+
# count = data_frame['Gender'].value_counts()
108+
# count = data_frame.value_counts('Gender')
109+
# print(count)
110+
"""
111+
112+
# 6.2
113+
114+
data_frame=pd.read_csv('.learn/assets/us_baby_names_right.csv')
115+
df=data_frame.groupby(['Name'])
116+
print(len(df.sum()))

‎conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
importsys,os,json
22
ifos.path.isdir("./.venv/lib/"):
3-
sys.path.append('./.venv/lib/python3.8/site-packages')
3+
sys.path.append('null/site-packages')
44
defpytest_addoption(parser):
55
parser.addoption("--stdin",action="append",default=[],
66
help="json with the stdin to pass to test functions")
@@ -24,4 +24,4 @@ def pytest_generate_tests(metafunc):
2424
exceptAttributeError:
2525
metafunc.parametrize("app",[cached_app])
2626
if'configuration'inmetafunc.fixturenames:
27-
metafunc.parametrize("configuration", [json.loads('{"port":3000,"address":"https://kiddopro-pythonpandastu-sjasit3kiuf.ws-us43.gitpod.io","editor":{"mode":"preview","agent":"gitpod","version":"1.0.72"},"dirPath":"./.learn","configPath":"learn.json","outputPath":".learn/dist","publicPath":"/preview","publicUrl":"https://3000-kiddopro-pythonpandastu-sjasit3kiuf.ws-us43.gitpod.io","language":"auto","grading":"incremental","exercisesPath":".learn/exercises","webpackTemplate":null,"disableGrading":false,"disabledActions":["build"],"actions":[],"entries":{"html":"index.html","vanillajs":"index.js","react":"app.jsx","node":"app.js","python3":"app.py","java":"app.java"},"preview":"https://github.com/4GeeksAcademy/python-pandas-tutorial/blob/main/.learn/assets/pandas-preview.jpeg?raw=true","difficulty":"beginner","duration":3,"description":"Learn the basics and become comfortable using pandas for manipulating machine learning datasets .","title":"Pandas for Machine Learning","slug":"pandas-for-machine-learning","session":3182492073098233300,"translations":[]}')])
27+
metafunc.parametrize("configuration", [json.loads('{"port":3000,"editor":{"mode":"preview","agent":"vscode","version":"1.0.72"},"dirPath":"./.learn","configPath":"learn.json","outputPath":".learn/dist","publicPath":"/preview","publicUrl":"http://localhost:3000","contact":"https://github.com/learnpack/learnpack/issues/new","language":"auto","autoPlay":true,"projectType":"tutorial","grading":"incremental","exercisesPath":".learn/exercises","webpackTemplate":null,"disableGrading":false,"disabledActions":["build"],"actions":[],"entries":{"html":"index.html","vanillajs":"index.js","react":"app.jsx","node":"app.js","python3":"app.py","java":"app.java"},"preview":"https://github.com/4GeeksAcademy/python-pandas-tutorial/blob/main/.learn/assets/pandas-preview.jpeg?raw=true","difficulty":"beginner","duration":3,"description":{"us":"Learn the basics and become comfortable using pandas for manipulating machine learning datasets.","es":"Aprende lo básico y empieza a sentirte cómodo usando pandas y manipulando datasets de machine learning."},"title":{"us":"Pandas for Machine Learning","es":"Pandas para Machine Learning"},"slug":"pandas-for-machine-learning","translations":[]}')])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp