728x90
In [2]:
import pandas as pd
In [3]:
prices = pd.read_csv('/content/sample_data/prices.csv', squeeze=True); prices
Out[3]:
0 2.55
1 3.39
2 2.75
3 3.39
4 3.39
...
541905 2.10
541906 4.15
541907 4.15
541908 4.95
541909 18.00
Name: Price, Length: 541910, dtype: float64
In [4]:
# Slice elements from a Pandas Series
# starting from index 0 up until and not including stop index
prices[0:5]
Out[4]:
0 2.55
1 3.39
2 2.75
3 3.39
4 3.39
Name: Price, dtype: float64
In [5]:
# index 0 up until and not including index 10
prices[:10]
Out[5]:
0 2.55
1 3.39
2 2.75
3 3.39
4 3.39
5 7.65
6 4.25
7 1.85
8 1.85
9 4.25
Name: Price, dtype: float64
In [6]:
# all elements starting from index5
prices[5:]
Out[6]:
5 7.65
6 4.25
7 1.85
8 1.85
9 4.25
...
541905 2.10
541906 4.15
541907 4.15
541908 4.95
541909 18.00
Name: Price, Length: 541905, dtype: float64
In [7]:
# the last elements
prices[:-1]
Out[7]:
0 2.55
1 3.39
2 2.75
3 3.39
4 3.39
...
541904 0.85
541905 2.10
541906 4.15
541907 4.15
541908 4.95
Name: Price, Length: 541909, dtype: float64
728x90
'Data Analytics with python > [Data Analysis]' 카테고리의 다른 글
[Pandas][DataFrame]S2_02_Inputs (0) | 2023.01.21 |
---|---|
[Pandas][DaraFrame]S2_01_DataFrame (0) | 2023.01.17 |
[Pandas][Series]S1_11_Indexing (0) | 2023.01.17 |
[pandas][Series]S1_10_Checking element (0) | 2023.01.17 |
[pandas][Series] S1_09_Math Operations (0) | 2023.01.17 |
댓글