Detail: Frame: Accessor Datetime
Overview: Frame: Accessor Datetime
- Frame.via_dt.__call__(*, fill_value)
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.__call__(*, fill_value)[source]
- Parameters:
fill_value – If NAT are encountered, use this value.
>>> f = sf.Frame.from_fields((('1620-04-01', '', '1620-06-30'), ('1976-04-01', '1954-12-31', '')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1620-04-01 1976-04-01 q NaT 1954-12-31 r 1620-06-30 NaT <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt(fill_value=-1).year <Frame> <Index> a b <<U1> <Index> p 1620 1976 q -1 1954 r 1620 -1 <<U1> <int64> <int64>
- Frame.via_dt.year
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.year
Return the year of each element.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.year <Frame> <Index> a b <<U1> <Index> p 1517 2022 q 1517 2021 r 1517 2022 <<U1> <int64> <int64>
- Frame.via_dt.year_month
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.year_month
Return the year and month of each element as string formatted YYYY-MM.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.year_month <Frame> <Index> a b <<U1> <Index> p 1517-04 2022-04 q 1517-12 2021-12 r 1517-06 2022-06 <<U1> <<U7> <<U7>
- Frame.via_dt.year_quarter
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.year_quarter
Return the year and quarter of each element as a string formatted YYYY-QQ.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.year_quarter <Frame> <Index> a b <<U1> <Index> p 1517-Q2 2022-Q2 q 1517-Q4 2021-Q4 r 1517-Q2 2022-Q2 <<U1> <<U7> <<U7>
- Frame.via_dt.month
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.month
Return the month of each element, between 1 and 12 inclusive.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.month <Frame> <Index> a b <<U1> <Index> p 4 4 q 12 12 r 6 6 <<U1> <int64> <int64>
- Frame.via_dt.day
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.day
Return the day of each element, between 1 and the number of days in the given month of the given year.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.day <Frame> <Index> a b <<U1> <Index> p 1 1 q 31 31 r 30 30 <<U1> <int64> <int64>
- Frame.via_dt.hour
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.hour
Return the hour of each element, between 0 and 24.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.hour <Frame> <Index> a b <<U1> <Index> p 0 0 q 0 0 r 0 0 <<U1> <int64> <int64>
- Frame.via_dt.minute
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.minute
Return the minute of each element, between 0 and 60.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.minute <Frame> <Index> a b <<U1> <Index> p 0 0 q 0 0 r 0 0 <<U1> <int64> <int64>
- Frame.via_dt.second
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.second
Return the second of each element, between 0 and 60.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.second <Frame> <Index> a b <<U1> <Index> p 0 0 q 0 0 r 0 0 <<U1> <int64> <int64>
- Frame.via_dt.weekday
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.weekday()[source]
Return the day of the week as an integer, where Monday is 0 and Sunday is 6.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.weekday() <Frame> <Index> a b <<U1> <Index> p 6 4 q 0 4 r 5 3 <<U1> <int64> <int64>
- Frame.via_dt.quarter
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.quarter()[source]
Return the quarter of the year as an integer, where January through March is quarter 1.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.quarter() <Frame> <Index> a b <<U1> <Index> p 2 2 q 4 4 r 2 2 <<U1> <int64> <int64>
- Frame.via_dt.is_month_end
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.is_month_end()[source]
Return Boolean indicators if the day is the month end.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.is_month_end() <Frame> <Index> a b <<U1> <Index> p False False q True True r True True <<U1> <bool> <bool>
- Frame.via_dt.is_month_start
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.is_month_start()[source]
Return Boolean indicators if the day is the month start.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.is_month_start() <Frame> <Index> a b <<U1> <Index> p True True q False False r False False <<U1> <bool> <bool>
- Frame.via_dt.is_year_end
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.is_year_end()[source]
Return Boolean indicators if the day is the year end.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.is_year_end() <Frame> <Index> a b <<U1> <Index> p False False q True True r False False <<U1> <bool> <bool>
- Frame.via_dt.is_year_start
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.is_year_start()[source]
Return Boolean indicators if the day is the year start.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.is_year_start() <Frame> <Index> a b <<U1> <Index> p False False q False False r False False <<U1> <bool> <bool>
- Frame.via_dt.is_quarter_end
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.is_quarter_end()[source]
Return Boolean indicators if the day is the quarter end.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.is_quarter_end() <Frame> <Index> a b <<U1> <Index> p False False q True True r True True <<U1> <bool> <bool>
- Frame.via_dt.is_quarter_start
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.is_quarter_start()[source]
Return Boolean indicators if the day is the quarter start.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.is_quarter_start() <Frame> <Index> a b <<U1> <Index> p True True q False False r False False <<U1> <bool> <bool>
- Frame.via_dt.timetuple
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.timetuple()[source]
Return a
time.struct_time
such as returned by time.localtime().
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.timetuple() <Frame> <Index> a b <<U1> <Index> p time.struct_time(... time.struct_time(... q time.struct_time(... time.struct_time(... r time.struct_time(... time.struct_time(... <<U1> <object> <object>
- Frame.via_dt.isoformat(sep, timespec)
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.isoformat(sep='T', timespec='auto')[source]
Return a string representing the date in ISO 8601 format, YYYY-MM-DD.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.isoformat() <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <<U10> <<U10>
- Frame.via_dt.fromisoformat
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.fromisoformat()[source]
Return a
datetime.date
object from an ISO 8601 format.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b')) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <<U10> <<U10> >>> f.via_dt.fromisoformat() <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <object> <object>
- Frame.via_dt.strftime(format)
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.strftime(format)[source]
Return a string representing the date, controlled by an explicit
format
string.
>>> f = sf.Frame.from_fields((('1517-04-01', '1517-12-31', '1517-06-30'), ('2022-04-01', '2021-12-31', '2022-06-30')), index=('p', 'q', 'r'), columns=('a', 'b'), dtypes=np.datetime64) >>> f <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <datetime64[D]> <datetime64[D]> >>> f.via_dt.strftime("%A | %B") <Frame> <Index> a b <<U1> <Index> p Sunday | April Friday | April q Monday | December Friday | December r Saturday | June Thursday | June <<U1> <<U17> <<U17>
- Frame.via_dt.strptime(format)
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.strptime(format)[source]
Return a Python datetime object from parsing a string defined with
format
.
>>> f = sf.Frame.from_fields((('4/1/1517', '12/31/1517', '6/30/1517'), ('4/1/2022', '12/31/2021', '6/30/2022')), index=('p', 'q', 'r'), columns=('a', 'b')) >>> f <Frame> <Index> a b <<U1> <Index> p 4/1/1517 4/1/2022 q 12/31/1517 12/31/2021 r 6/30/1517 6/30/2022 <<U1> <<U10> <<U10> >>> f.via_dt.strptime("%m/%d/%Y") <Frame> <Index> a b <<U1> <Index> p 1517-04-01 00:00:00 2022-04-01 00:00:00 q 1517-12-31 00:00:00 2021-12-31 00:00:00 r 1517-06-30 00:00:00 2022-06-30 00:00:00 <<U1> <object> <object>
- Frame.via_dt.strpdate(format)
- Frame.via_dt
Interface for applying datetime properties and methods to elements in this container.
- InterfaceDatetime.strpdate(format)[source]
Return a Python date object from parsing a string defined with
format
.
>>> f = sf.Frame.from_fields((('4/1/1517', '12/31/1517', '6/30/1517'), ('4/1/2022', '12/31/2021', '6/30/2022')), index=('p', 'q', 'r'), columns=('a', 'b')) >>> f <Frame> <Index> a b <<U1> <Index> p 4/1/1517 4/1/2022 q 12/31/1517 12/31/2021 r 6/30/1517 6/30/2022 <<U1> <<U10> <<U10> >>> f.via_dt.strpdate("%m/%d/%Y") <Frame> <Index> a b <<U1> <Index> p 1517-04-01 2022-04-01 q 1517-12-31 2021-12-31 r 1517-06-30 2022-06-30 <<U1> <object> <object>
Frame: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Assignment | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Transpose | Accessor Fill Value | Accessor Regular Expression | Accessor Hashlib | Accessor Type Clinic | Accessor Reduce