Detail: FrameGO: Accessor Datetime

Overview: FrameGO: Accessor Datetime

FrameGO.via_dt.__call__(*, fill_value)
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         1620    1976
q         -1      1954
r         1620    -1
<<U1>     <int64> <int64>
FrameGO.via_dt.year
FrameGO.via_dt

Interface for applying datetime properties and methods to elements in this container.

InterfaceDatetime.year

Return the year of each element.

>>> f = sf.FrameGO.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
<FrameGO>
<IndexGO> 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
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         1517    2022
q         1517    2021
r         1517    2022
<<U1>     <int64> <int64>
FrameGO.via_dt.year_month
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         1517-04 2022-04
q         1517-12 2021-12
r         1517-06 2022-06
<<U1>     <<U7>   <<U7>
FrameGO.via_dt.month
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         4       4
q         12      12
r         6       6
<<U1>     <int64> <int64>
FrameGO.via_dt.day
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         1       1
q         31      31
r         30      30
<<U1>     <int64> <int64>
FrameGO.via_dt.hour
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         0       0
q         0       0
r         0       0
<<U1>     <int64> <int64>
FrameGO.via_dt.minute
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         0       0
q         0       0
r         0       0
<<U1>     <int64> <int64>
FrameGO.via_dt.second
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         0       0
q         0       0
r         0       0
<<U1>     <int64> <int64>
FrameGO.via_dt.weekday
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         6       4
q         0       4
r         5       3
<<U1>     <int64> <int64>
FrameGO.via_dt.quarter
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> a       b       <<U1>
<Index>
p         2       2
q         4       4
r         2       2
<<U1>     <int64> <int64>
FrameGO.via_dt.is_month_end
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> a      b      <<U1>
<Index>
p         False  False
q         True   True
r         True   True
<<U1>     <bool> <bool>
FrameGO.via_dt.is_month_start
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> a      b      <<U1>
<Index>
p         True   True
q         False  False
r         False  False
<<U1>     <bool> <bool>
FrameGO.via_dt.is_year_end
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> a      b      <<U1>
<Index>
p         False  False
q         True   True
r         False  False
<<U1>     <bool> <bool>
FrameGO.via_dt.is_year_start
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> a      b      <<U1>
<Index>
p         False  False
q         False  False
r         False  False
<<U1>     <bool> <bool>
FrameGO.via_dt.is_quarter_end
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> a      b      <<U1>
<Index>
p         False  False
q         True   True
r         True   True
<<U1>     <bool> <bool>
FrameGO.via_dt.is_quarter_start
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> a      b      <<U1>
<Index>
p         True   True
q         False  False
r         False  False
<<U1>     <bool> <bool>
FrameGO.via_dt.timetuple
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> 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>
FrameGO.via_dt.isoformat(sep, timespec)
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> 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>
FrameGO.via_dt.fromisoformat
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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()
<FrameGO>
<IndexGO> 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>
FrameGO.via_dt.strftime(format)
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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")
<FrameGO>
<IndexGO> a                 b                 <<U1>
<Index>
p         Sunday | April    Friday | April
q         Monday | December Friday | December
r         Saturday | June   Thursday | June
<<U1>     <<U17>            <<U17>
FrameGO.via_dt.strptime(format)
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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")
<FrameGO>
<IndexGO> 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>
FrameGO.via_dt.strpdate(format)
FrameGO.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.FrameGO.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
<FrameGO>
<IndexGO> 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")
<FrameGO>
<IndexGO> 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>

FrameGO: 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