Using .loc method to select multiple Series elements
Select prices between 2018-01-01
and 2018-01-10
using .loc
method.
Solution 1
import numpy as np
import pandas as pd
# Don't change this code. Just run it as it's presented.
price_series = pd.read_csv(
'btc-market-price.csv', header=None, index_col=0, parse_dates=True,
names=['Timestamp', 'Price'], squeeze=True)
selected_prices = price_series.loc['2018-01-01':'2018-01-10']
Files associated with this lesson:
btc-market-price.csv
2017-04-02 00:00:00 | 1099.169125 | |
---|---|---|
0 | 2017-04-03 00:00:00 | 1141.813000 |
1 | 2017-04-04 00:00:00 | 1141.600363 |
2 | 2017-04-05 00:00:00 | 1133.079314 |
3 | 2017-04-06 00:00:00 | 1196.307937 |
4 | 2017-04-07 00:00:00 | 1190.454250 |
5 | 2017-04-08 00:00:00 | 1181.149838 |
6 | 2017-04-09 00:00:00 | 1208.800500 |
7 | 2017-04-10 00:00:00 | 1207.744875 |
8 | 2017-04-11 00:00:00 | 1226.617037 |
9 | 2017-04-12 00:00:00 | 1218.922050 |