Skip to content

Commit 35bda99

Browse files
committed
Fix docstring & type annotation for to_markdown buf parameter
1 parent cc1c406 commit 35bda99

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

pandas/core/frame.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,10 @@ def to_feather(self, path) -> None:
20152015
@Substitution(klass="DataFrame")
20162016
@Appender(_shared_docs["to_markdown"])
20172017
def to_markdown(
2018-
self, buf: Optional[IO[str]] = None, mode: Optional[str] = None, **kwargs
2018+
self,
2019+
buf: Optional[FilePathOrBuffer] = None,
2020+
mode: Optional[str] = None,
2021+
**kwargs,
20192022
) -> Optional[str]:
20202023
kwargs.setdefault("headers", "keys")
20212024
kwargs.setdefault("tablefmt", "pipe")

pandas/core/generic.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1922,10 +1922,8 @@ def _repr_data_resource_(self):
19221922
19231923
Parameters
19241924
----------
1925-
buf : writable buffer, defaults to sys.stdout
1926-
Where to send the output. By default, the output is printed to
1927-
sys.stdout. Pass a writable buffer if you need to further process
1928-
the output.
1925+
buf : str, Path or StringIO-like, optional, default None
1926+
Buffer to write to. If None, the output is returned as a string.
19291927
mode : str, optional
19301928
Mode in which file is opened.
19311929
**kwargs

pandas/core/series.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from pandas._config import get_option
2424

2525
from pandas._libs import index as libindex, lib, properties, reshape, tslibs
26-
from pandas._typing import Label
26+
from pandas._typing import FilePathOrBuffer, Label
2727
from pandas.compat.numpy import function as nv
2828
from pandas.util._decorators import Appender, Substitution
2929
from pandas.util._validators import validate_bool_kwarg, validate_percentile
@@ -1454,7 +1454,10 @@ def to_string(
14541454
@Substitution(klass="Series")
14551455
@Appender(generic._shared_docs["to_markdown"])
14561456
def to_markdown(
1457-
self, buf: Optional[IO[str]] = None, mode: Optional[str] = None, **kwargs
1457+
self,
1458+
buf: Optional[FilePathOrBuffer] = None,
1459+
mode: Optional[str] = None,
1460+
**kwargs,
14581461
) -> Optional[str]:
14591462
return self.to_frame().to_markdown(buf, mode, **kwargs)
14601463

0 commit comments

Comments
 (0)