Detail: Frame: Accessor DatetimeΒΆ

Overview: Frame: Accessor Datetime

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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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().

>>> s = 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)
>>> s.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.

>>> s = 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)
>>> s.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.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.

>>> s = 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)
>>> s.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.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.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