Skip to content

Commit e7ab43f

Browse files
rsm-23mroeschke
authored andcommitted
DEPR: Nonkeyword arguments in to_latex (pandas-dev#54601)
* deprecated non keyword arguments * fixed typo * added test
1 parent 53f0787 commit e7ab43f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

doc/source/whatsnew/v2.2.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Other API changes
9393
Deprecations
9494
~~~~~~~~~~~~
9595
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_hdf` except ``path_or_buf``. (:issue:`54229`)
96+
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_latex` except ``buf``. (:issue:`54229`)
9697
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_pickle` except ``path``. (:issue:`54229`)
9798
-
9899

pandas/core/generic.py

+3
Original file line numberDiff line numberDiff line change
@@ -3306,6 +3306,9 @@ def to_latex(
33063306
...
33073307

33083308
@final
3309+
@deprecate_nonkeyword_arguments(
3310+
version="3.0", allowed_args=["self", "buf"], name="to_latex"
3311+
)
33093312
def to_latex(
33103313
self,
33113314
buf: FilePath | WriteBuffer[str] | None = None,

pandas/tests/io/formats/test_to_latex.py

+16
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@ def test_to_latex_midrule_location(self):
187187
)
188188
assert result == expected
189189

190+
def test_to_latex_pos_args_deprecation(self):
191+
# GH-54229
192+
df = DataFrame(
193+
{
194+
"name": ["Raphael", "Donatello"],
195+
"age": [26, 45],
196+
"height": [181.23, 177.65],
197+
}
198+
)
199+
msg = (
200+
r"Starting with pandas version 3.0 all arguments of to_latex except for "
201+
r"the argument 'buf' will be keyword-only."
202+
)
203+
with tm.assert_produces_warning(FutureWarning, match=msg):
204+
df.to_latex(None, None)
205+
190206

191207
class TestToLatexLongtable:
192208
def test_to_latex_empty_longtable(self):

0 commit comments

Comments
 (0)