Detail: Series: Accessor Datetime

Overview: Series: Accessor Datetime

Series.via_dt.__call__(*, fill_value)
Series.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.

>>> s = sf.Series(('1517-01-01', '', '1517-12-31', '', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        NaT
c        1517-12-31
d        NaT
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt(fill_value=-1).year
<Series>
<Index>
a        1517
b        -1
c        1517
d        -1
e        1517
<<U1>    <int64>
Series.via_dt.year
Series.via_dt

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

InterfaceDatetime.year

Return the year of each element.

>>> s = sf.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.year
<Series>
<Index>
a        1517
b        1517
c        1517
d        1517
e        1517
<<U1>    <int64>
Series.via_dt.year_month
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.year_month
<Series>
<Index>
a        1517-01
b        1517-04
c        1517-12
d        1517-06
e        1517-10
<<U1>    <<U7>
Series.via_dt.month
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.month
<Series>
<Index>
a        1
b        4
c        12
d        6
e        10
<<U1>    <int64>
Series.via_dt.day
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.day
<Series>
<Index>
a        1
b        1
c        31
d        30
e        1
<<U1>    <int64>
Series.via_dt.hour
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.hour
<Series>
<Index>
a        0
b        0
c        0
d        0
e        0
<<U1>    <int64>
Series.via_dt.minute
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.minute
<Series>
<Index>
a        0
b        0
c        0
d        0
e        0
<<U1>    <int64>
Series.via_dt.second
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.second
<Series>
<Index>
a        0
b        0
c        0
d        0
e        0
<<U1>    <int64>
Series.via_dt.weekday
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.weekday()
<Series>
<Index>
a        0
b        6
c        0
d        5
e        0
<<U1>    <int64>
Series.via_dt.quarter
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.quarter()
<Series>
<Index>
a        1
b        2
c        4
d        2
e        4
<<U1>    <int64>
Series.via_dt.is_month_end
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.is_month_end()
<Series>
<Index>
a        False
b        False
c        True
d        True
e        False
<<U1>    <bool>
Series.via_dt.is_month_start
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.is_month_start()
<Series>
<Index>
a        True
b        True
c        False
d        False
e        True
<<U1>    <bool>
Series.via_dt.is_year_end
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.is_year_end()
<Series>
<Index>
a        False
b        False
c        True
d        False
e        False
<<U1>    <bool>
Series.via_dt.is_year_start
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.is_year_start()
<Series>
<Index>
a        True
b        False
c        False
d        False
e        False
<<U1>    <bool>
Series.via_dt.is_quarter_end
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.is_quarter_end()
<Series>
<Index>
a        False
b        False
c        True
d        True
e        False
<<U1>    <bool>
Series.via_dt.is_quarter_start
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.is_quarter_start()
<Series>
<Index>
a        True
b        True
c        False
d        False
e        True
<<U1>    <bool>
Series.via_dt.timetuple
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.timetuple()
<Series>
<Index>
a        time.struct_time(...
b        time.struct_time(...
c        time.struct_time(...
d        time.struct_time(...
e        time.struct_time(...
<<U1>    <object>
Series.via_dt.isoformat(sep, timespec)
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.isoformat()
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <<U10>
Series.via_dt.fromisoformat
Series.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.

>>> s = sf.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <<U10>
>>> s.via_dt.fromisoformat()
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <object>
Series.via_dt.strftime(format)
Series.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.Series(('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30', '1517-10-01'), index=('a', 'b', 'c', 'd', 'e'), dtype=np.datetime64)
>>> s
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-12-31
d        1517-06-30
e        1517-10-01
<<U1>    <datetime64[D]>
>>> s.via_dt.strftime("%A | %B")
<Series>
<Index>
a        Monday | January
b        Sunday | April
c        Monday | December
d        Saturday | June
e        Monday | October
<<U1>    <<U17>
Series.via_dt.strptime(format)
Series.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.

>>> s = sf.Series(('1/1/1517', '4/1/1517', '6/30/1517'), index=('a', 'b', 'c'))
>>> s
<Series>
<Index>
a        1/1/1517
b        4/1/1517
c        6/30/1517
<<U1>    <<U9>
>>> s.via_dt.strptime("%m/%d/%Y")
<Series>
<Index>
a        1517-01-01 00:00:00
b        1517-04-01 00:00:00
c        1517-06-30 00:00:00
<<U1>    <object>
Series.via_dt.strpdate(format)
Series.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.

>>> s = sf.Series(('1/1/1517', '4/1/1517', '6/30/1517'), index=('a', 'b', 'c'))
>>> s
<Series>
<Index>
a        1/1/1517
b        4/1/1517
c        6/30/1517
<<U1>    <<U9>
>>> s.via_dt.strpdate("%m/%d/%Y")
<Series>
<Index>
a        1517-01-01
b        1517-04-01
c        1517-06-30
<<U1>    <object>

Series: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Assignment | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Fill Value | Accessor Regular Expression | Accessor Hashlib | Accessor Type Clinic