Skip to content

Commit f1bc202

Browse files
committed
Fixed docstrings for pandas.DataFrame.keys, pandas.read_clipboard and some of pandas.ExcelFile.parse (issue pandas-dev#27979)
1 parent 75737f5 commit f1bc202

File tree

4 files changed

+106
-10
lines changed

4 files changed

+106
-10
lines changed

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,7 @@ def __iter__(self):
18751875
# can we get a better explanation of this?
18761876
def keys(self):
18771877
"""
1878-
Get the 'info axis' (see Indexing for more)
1878+
Get the 'info axis' (see Indexing for more).
18791879
18801880
This is index for Series, columns for DataFrame.
18811881

pandas/io/clipboards.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99

1010
def read_clipboard(sep=r"\s+", **kwargs): # pragma: no cover
1111
r"""
12-
Read text from clipboard and pass to read_csv. See read_csv for the
13-
full argument list
12+
Read text from clipboard and pass to read_csv.
1413
1514
Parameters
1615
----------
1716
sep : str, default '\s+'
1817
A string or regex delimiter. The default of '\s+' denotes
1918
one or more whitespace characters.
2019
20+
**kwargs
21+
See read_csv for the full argument list.
22+
2123
Returns
2224
-------
23-
parsed : DataFrame
25+
DataFrame
26+
A parsed DataFrame object.
2427
"""
2528
encoding = kwargs.pop("encoding", "utf-8")
2629

pandas/io/excel/_base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,10 @@ def parse(
837837
**kwds
838838
):
839839
"""
840-
Parse specified sheet(s) into a DataFrame
840+
Parse specified sheet(s) into a DataFrame.
841841
842842
Equivalent to read_excel(ExcelFile, ...) See the read_excel
843-
docstring for more info on accepted parameters
843+
docstring for more info on accepted parameters.
844844
845845
Returns
846846
-------

pandas/tseries/offsets.py

+97-4
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ def __add__(date):
204204
normalize : bool, default False
205205
Whether to round the result of a DateOffset addition down to the
206206
previous midnight.
207-
**kwds
208-
Temporal parameter that add to or replace the offset value.
207+
**kwds : Temporal parameter that add to or replace the offset value.
209208
210209
Parameters that **add** to the offset (like Timedelta):
211210
@@ -231,18 +230,21 @@ def __add__(date):
231230
- microsecond
232231
- nanosecond
233232
233+
.
234+
234235
See Also
235236
--------
236-
dateutil.relativedelta.relativedelta
237+
dateutil.relativedelta.relativedelta : The relativedelta type is designed to be applied to an existing datetime an can replace specific components of that datetime, or represents an interval of time.
237238
238239
Examples
239240
--------
241+
>>> from pandas.tseries.offsets import DateOffset
240242
>>> ts = pd.Timestamp('2017-01-01 09:10:11')
241243
>>> ts + DateOffset(months=3)
242244
Timestamp('2017-04-01 09:10:11')
243245
244246
>>> ts = pd.Timestamp('2017-01-01 09:10:11')
245-
>>> ts + DateOffset(month=3)
247+
>>> ts + DateOffset(months=2)
246248
Timestamp('2017-03-01 09:10:11')
247249
"""
248250

@@ -471,6 +473,97 @@ def nanos(self):
471473

472474

473475
class SingleConstructorOffset(DateOffset):
476+
"""
477+
Standard kind of date increment used for a date range.
478+
479+
Works exactly like relativedelta in terms of the keyword args you
480+
pass in, use of the keyword n is discouraged-- you would be better
481+
off specifying n in the keywords you use, but regardless it is
482+
there for you. n is needed for DateOffset subclasses.
483+
484+
DateOffset work as follows. Each offset specify a set of dates
485+
that conform to the DateOffset. For example, Bday defines this
486+
set to be the set of dates that are weekdays (M-F). To test if a
487+
date is in the set of a DateOffset dateOffset we can use the
488+
onOffset method: dateOffset.onOffset(date).
489+
490+
If a date is not on a valid date, the rollback and rollforward
491+
methods can be used to roll the date to the nearest valid date
492+
before/after the date.
493+
494+
DateOffsets can be created to move dates forward a given number of
495+
valid dates. For example, Bday(2) can be added to a date to move
496+
it two business days forward. If the date does not start on a
497+
valid date, first it is moved to a valid date. Thus pseudo code
498+
is:
499+
500+
def __add__(date):
501+
date = rollback(date) # does nothing if date is valid
502+
return date + <n number of periods>
503+
504+
When a date offset is created for a negative number of periods,
505+
the date is first rolled forward. The pseudo code is:
506+
507+
def __add__(date):
508+
date = rollforward(date) # does nothing is date is valid
509+
return date + <n number of periods>
510+
511+
Zero presents a problem. Should it roll forward or back? We
512+
arbitrarily have it rollforward:
513+
514+
date + BDay(0) == BDay.rollforward(date)
515+
516+
Since 0 is a bit weird, we suggest avoiding its use.
517+
518+
Parameters
519+
----------
520+
n : int, default 1
521+
The number of time periods the offset represents.
522+
normalize : bool, default False
523+
Whether to round the result of a DateOffset addition down to the
524+
previous midnight.
525+
**kwds : Temporal parameter that add to or replace the offset value.
526+
527+
Parameters that **add** to the offset (like Timedelta):
528+
529+
- years
530+
- months
531+
- weeks
532+
- days
533+
- hours
534+
- minutes
535+
- seconds
536+
- microseconds
537+
- nanoseconds
538+
539+
Parameters that **replace** the offset value:
540+
541+
- year
542+
- month
543+
- day
544+
- weekday
545+
- hour
546+
- minute
547+
- second
548+
- microsecond
549+
- nanosecond
550+
551+
.
552+
553+
See Also
554+
--------
555+
556+
Examples
557+
--------
558+
>>> from pandas.tseries.offsets import DateOffset
559+
>>> ts = pd.Timestamp('2017-01-01 09:10:11')
560+
>>> ts + DateOffset(months=3)
561+
Timestamp('2017-04-01 09:10:11')
562+
563+
>>> ts = pd.Timestamp('2017-01-01 09:10:11')
564+
>>> ts + DateOffset(months=2)
565+
Timestamp('2017-03-01 09:10:11')
566+
"""
474567
@classmethod
475568
def _from_name(cls, suffix=None):
476569
# default _from_name calls cls with no args

0 commit comments

Comments
 (0)