Skip to content

Commit beab4eb

Browse files
committed
DOC/BUG: Docstring Redesign to fix the problem of unexpected keyword arg (issue10888) (+1 squashed commit)
Squashed commits: [ab61a77] DOC/BUG: Docstring Redesign to fix the problem of unexpected keyword arg (issue10888) (+1 squashed commit) Squashed commits: [ad08eac] DOC/BUG: Docstring Redesign to fix the problem of unexpected keyword arg (issue10888) (+1 squashed commit) Squashed commits: [756ca05] DOC: Docstring Redesign to fix the problem of unexpected keyword arg (issue10888)
1 parent 0e56279 commit beab4eb

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

doc/source/whatsnew/v0.17.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ Bug Fixes
10331033
- Bug in vectorised setting of timestamp columns with python ``datetime.date`` and numpy ``datetime64`` (:issue:`10408`, :issue:`10412`)
10341034
- Bug in ``Index.take`` may add unnecessary ``freq`` attribute (:issue:`10791`)
10351035
- Bug in ``merge`` with empty ``DataFrame`` may raise ``IndexError`` (:issue:`10824`)
1036-
1036+
- Bug in ``to_latex`` where unexpected keyword argument for some documented arguments (:issue:`10888`)
10371037

10381038
- Bug in ``read_csv`` when using the ``nrows`` or ``chunksize`` parameters if file contains only a header line (:issue:`9535`)
10391039
- Bug in serialization of ``category`` types in HDF5 in presence of alternate encodings. (:issue:`10366`)

pandas/core/format.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
import itertools
2525
import csv
2626

27-
docstring_to_string = """
28-
Parameters
29-
----------
30-
frame : DataFrame
31-
object to render
27+
common_docstring = """
28+
Parameters
29+
----------
3230
buf : StringIO-like, optional
3331
buffer to write to
3432
columns : sequence, optional
@@ -51,20 +49,27 @@
5149
sparsify : bool, optional
5250
Set to False for a DataFrame with a hierarchical index to print every
5351
multiindex key at each row, default True
52+
index_names : bool, optional
53+
Prints the names of the indexes, default True"""
54+
55+
justify_docstring = """
5456
justify : {'left', 'right'}, default None
5557
Left or right-justify the column labels. If None uses the option from
5658
the print configuration (controlled by set_option), 'right' out
57-
of the box.
58-
index_names : bool, optional
59-
Prints the names of the indexes, default True
59+
of the box."""
60+
61+
force_unicode_docstring = """
6062
force_unicode : bool, default False
6163
Always return a unicode result. Deprecated in v0.10.0 as string
62-
formatting is now rendered to unicode by default.
64+
formatting is now rendered to unicode by default."""
65+
66+
return_docstring = """
6367
6468
Returns
6569
-------
6670
formatted : string (or unicode, depending on data and options)"""
6771

72+
docstring_to_string = common_docstring + justify_docstring + force_unicode_docstring + return_docstring
6873

6974
class CategoricalFormatter(object):
7075

pandas/core/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ def to_stata(
14131413
write_index=write_index)
14141414
writer.write_file()
14151415

1416-
@Appender(fmt.docstring_to_string, indents=1)
1416+
@Appender(fmt.common_docstring + fmt.justify_docstring + fmt.return_docstring, indents=1)
14171417
def to_string(self, buf=None, columns=None, col_space=None,
14181418
header=True, index=True, na_rep='NaN', formatters=None,
14191419
float_format=None, sparsify=None, index_names=True,
@@ -1441,7 +1441,7 @@ def to_string(self, buf=None, columns=None, col_space=None,
14411441
result = formatter.buf.getvalue()
14421442
return result
14431443

1444-
@Appender(fmt.docstring_to_string, indents=1)
1444+
@Appender(fmt.common_docstring + fmt.justify_docstring + fmt.return_docstring, indents=1)
14451445
def to_html(self, buf=None, columns=None, col_space=None, colSpace=None,
14461446
header=True, index=True, na_rep='NaN', formatters=None,
14471447
float_format=None, sparsify=None, index_names=True,
@@ -1491,7 +1491,7 @@ def to_html(self, buf=None, columns=None, col_space=None, colSpace=None,
14911491
if buf is None:
14921492
return formatter.buf.getvalue()
14931493

1494-
@Appender(fmt.docstring_to_string, indents=1)
1494+
@Appender(fmt.common_docstring + fmt.return_docstring, indents=1)
14951495
def to_latex(self, buf=None, columns=None, col_space=None, colSpace=None,
14961496
header=True, index=True, na_rep='NaN', formatters=None,
14971497
float_format=None, sparsify=None, index_names=True,

0 commit comments

Comments
 (0)