For example, we can construct a
Series
object that has time indexed data:index = pd.DatetimeIndex(['2014-07-04', '2014-08-04',
'2015-07-04', '2015-08-04'])
data = pd.Series([0, 1, 2, 3], index=index)
data
Now that we have this data in a
Series
, we can make use of any of the Series
indexing patterns we discussed in previous sections, passing values that can be coerced into dates:data['2014-07-04':'2015-07-04']
There are additional special date-only indexing operations, such as passing a year to obtain a slice of all data from that year:
data['2015']
Geen opmerkingen:
Een reactie posten