Skip to content

Commit 09a46a4

Browse files
sagungrpSang Agungdatapythonista
authoredMar 10, 2020
DOC: Add extended summary, update parameter types desc, update return types desc, and add whitespaces after commas in list declarations to DataFrame.first in core/generic.py (#32018)
Co-authored-by: Sang Agung <[email protected]> Co-authored-by: Marc Garcia <[email protected]>
1 parent 79d3b08 commit 09a46a4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
 

‎pandas/core/generic.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -8014,15 +8014,21 @@ def resample(
80148014

80158015
def first(self: FrameOrSeries, offset) -> FrameOrSeries:
80168016
"""
8017-
Method to subset initial periods of time series data based on a date offset.
8017+
Select initial periods of time series data based on a date offset.
8018+
8019+
When having a DataFrame with dates as index, this function can
8020+
select the first few rows based on a date offset.
80188021
80198022
Parameters
80208023
----------
8021-
offset : str, DateOffset, dateutil.relativedelta
8024+
offset : str, DateOffset or dateutil.relativedelta
8025+
The offset length of the data that will be selected. For instance,
8026+
'1M' will display all the rows having their index within the first month.
80228027
80238028
Returns
80248029
-------
8025-
subset : same type as caller
8030+
Series or DataFrame
8031+
A subset of the caller.
80268032
80278033
Raises
80288034
------
@@ -8038,7 +8044,7 @@ def first(self: FrameOrSeries, offset) -> FrameOrSeries:
80388044
Examples
80398045
--------
80408046
>>> i = pd.date_range('2018-04-09', periods=4, freq='2D')
8041-
>>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
8047+
>>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
80428048
>>> ts
80438049
A
80448050
2018-04-09 1

0 commit comments

Comments
 (0)
Please sign in to comment.