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

Commit9b70a04

Browse files
committed
added exercies about series
1 parent068564a commit9b70a04

File tree

24 files changed

+98
-11
lines changed

24 files changed

+98
-11
lines changed

‎.learn/assets/series_dataframe.png

53.3 KB
Loading

‎.learn/exercises/03-Dataset/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In machine learning "datasets" are the data we use for our experiments, we usual
44

55
Possible datasets based on your objective prediccion:
66

7-
- If sell shoes, how much shoes do I need in my wharehouse for the next month? A good dataset will be sales from the past 2 years.
7+
- Ifwesell shoes, how much shoes do I need in my wharehouse for the next month? A good dataset will be sales from the past 2 years.
88
- I'm we are building a program to diagnost neumonia, a good dataset will be 100 xrays with neumonia and 100 x-rays without neumonia.
99

1010
You have to be creative when creating your datasets, think about all the variables that affect a predicion and try collecting and organizing everthing in one or many datasets.

‎.learn/exercises/04-Series/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#Series
2+
3+
A series is similar to an array or list, it's a one dimentional data structure.
4+
5+
You can create a series like this:
6+
7+
```py
8+
data= pd.Series([1,94,85,31,23,8])
9+
```
10+
11+
The result of printing`data` on the terminal will be something like this:
12+
13+
```shell
14+
0 1
15+
1 94
16+
2 85
17+
3 31
18+
4 23
19+
5 8
20+
dtype: int64
21+
```
22+
23+
##📝 Instructions
24+
25+
Create a series from this list:`ages = [23,45,7,34,6,63,36,78,54,34]`
26+
27+
##💻 Expected output
28+
29+
```
30+
0 23
31+
1 45
32+
2 7
33+
3 34
34+
4 6
35+
5 63
36+
6 36
37+
7 78
38+
8 54
39+
9 34
40+
dtype: int64
41+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
importpandasaspd
2+
# two dimensional array of name,age values.
3+
data=pd.Series([23,45,7,34,6,63,36,78,54,34])
4+
5+
print(data)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#Series Date Range
2+
3+
Use the pd.date_range function to create a series from`05-01-2021` to`05-12-2021`
4+
5+
##💻 Expected output
6+
7+
```
8+
DatetimeIndex(['2021-05-01', '2021-05-02', '2021-05-03', '2021-05-04',
9+
'2021-05-05', '2021-05-06', '2021-05-07', '2021-05-08',
10+
'2021-05-09', '2021-05-10', '2021-05-11', '2021-05-12'],
11+
dtype='datetime64[ns]', freq='D')
12+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
importpandasaspd
2+
3+
date_series=pd.date_range(start='05-01-2021',end='05-12-2021')
4+
5+
print(date_series)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#Series Apply
2+
3+
Given a series variable like:
4+
5+
```py
6+
my_series= pd.Series([2,4,6,8,10])
7+
```
8+
9+
Use the function my_series.apply to divide all numbers on the following series by 2.
10+
11+
##💻 Expected output
12+
13+
```bash
14+
0 1.0
15+
1 2.0
16+
2 3.0
17+
3 4.0
18+
4 5.0
19+
dtype: float64
20+
```
21+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
importpandasaspd
2+
3+
my_series=pd.Series([2,4,6,8,10])
4+
modified_series=my_series.apply(lambdax:x/2)
5+
print(modified_series)

‎.learn/exercises/04.1-iloc/README.mdrenamed to‎.learn/exercises/05.2-iloc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#DataFrame iLoc
22

3-
The iloc
3+
The iloc command lets you retrieve any cel in your data_frame, for example to print the cel in the`x-axis: 2` and`y-axis: 4` we would have to type the following:
44

55
```python
66
# Print only item in the Row: 2, Col: 1

‎.learn/exercises/04.4-print-columns/README.mdrenamed to‎.learn/exercises/05.5-print-columns/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#Print columns
22

3-
You can also print jsut one collumn of your choice, for example:
3+
You can also print just one collumn of your choice, for example:
4+
45
```python
56
print(data_frame['Type 1'])#this will print only the column "Type 1"
67
```
8+
79
You can also use the square brackets`[]` to pick the range of rows you want to print like this:
810

911
```python

‎.learn/exercises/04.5-iloc/README.mdrenamed to‎.learn/exercises/05.6-iloc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#`08`Using the iloc function in Pandas
1+
#Using the iloc function in Pandas
22

33
Pandas has a way to retrieve values by specifying the row and column number, for example: 2,4 (row 2, column 4).
44

‎.learn/vscode_queue.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"name":"initializing","time":101570628280.769},{"name":"reset","time":101570628350.183},{"name":"configuration_loaded","time":101571646051.985}]
1+
[{"name":"initializing","time":442957258393.204},{"name":"reset","time":442957258439.738},{"name":"configuration_loaded","time":442958277103.692},{"name":"start_exercise","time":443015519309.933,"data":"00-welcome"},{"name":"start_exercise","time":443060088697.605,"data":"01-terminal"},{"name":"start_exercise","time":443074953846.711,"data":"01.2-Pipenv"},{"name":"start_exercise","time":443118267987.033,"data":"02-installation"},{"name":"start_exercise","time":443140770208.037,"data":"02.2-create-script"},{"name":"start_exercise","time":443206131153.638,"data":"02.3-import_pandas"},{"name":"start_exercise","time":443230227006.7,"data":"03-Dataset"},{"name":"start_exercise","time":443294961210.749,"data":"04-Data_Frame"},{"name":"start_exercise","time":443317656762.219,"data":"04.1-from_dict"},{"name":"start_exercise","time":443330217152.771,"data":"04.1-iloc"},{"name":"start_exercise","time":443400861084.733,"data":"04.2-head"},{"name":"start_exercise","time":443415968058.695,"data":"04.3-tail"},{"name":"start_exercise","time":443420883130.11,"data":"04.4-print-columns"},{"name":"start_exercise","time":443468150689.343,"data":"04.5-iloc"},{"name":"start_exercise","time":443588107863.337,"data":"04-Data_Frame"}]

‎app.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
importpandasaspd
2-
# two dimensional array of name,age values.
3-
data= [['Alex',10],['Bob',12],['Clarke',13]]
42

5-
# create the dataframe and name the columns
6-
df=pd.DataFrame(data,columns=['Name','Age'])
3+
date_series=pd.date_range(start='05-01-2021',end='05-12-2021')
74

8-
# print the dataframe
9-
print(df)
5+
print(date_series)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp