You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/timeseries.rst
+1
Original file line number
Diff line number
Diff line change
@@ -444,6 +444,7 @@ There are several time/date properties that one can access from ``Timestamp`` or
444
444
is_year_start,"Logical indicating if first day of year (defined by frequency)"
445
445
is_year_end,"Logical indicating if last day of year (defined by frequency)"
446
446
447
+
Furthermore, if you have a ``Series`` with datetimelike values, then you can access these properties via the ``.dt`` accessor, see the :ref:`docs <basics.dt_accessors>`
@@ -165,6 +166,37 @@ previously results in ``Exception`` or ``TypeError`` (:issue:`7812`)
165
166
- ``DataFrame.tz_localize`` and ``DataFrame.tz_convert`` now accepts an optional ``level`` argument
166
167
for localizing a specific level of a MultiIndex (:issue:`7846`)
167
168
169
+
.. _whatsnew_0150.dt:
170
+
171
+
.dt accessor
172
+
~~~~~~~~~~~~
173
+
174
+
``Series`` has gained an accessor to succinctly return datetime like properties for the *values* of the Series, if its a datetime/period like Series. (:issue:`7207`)
175
+
This will return a Series, indexed like the existing Series. See the :ref:`docs <basics.dt_accessors>`
176
+
177
+
.. ipython:: python
178
+
179
+
# datetime
180
+
s = Series(date_range('20130101 09:10:12',periods=4))
181
+
s
182
+
s.dt.hour
183
+
s.dt.second
184
+
s.dt.day
185
+
186
+
This enables nice expressions like this:
187
+
188
+
.. ipython:: python
189
+
190
+
s[s.dt.day==2]
191
+
192
+
.. ipython:: python
193
+
194
+
# period
195
+
s = Series(period_range('20130101',periods=4,freq='D').asobject)
0 commit comments