Skip to content

Commit 474a354

Browse files
committed
🐛 dont all get_filepath_or_buffer with buf equal to sys.stdout
1 parent 1ef3709 commit 474a354

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pandas/core/frame.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,14 +1991,12 @@ def to_markdown(
19911991
| 0 | 1 | 3 |
19921992
| 1 | 2 | 4 |
19931993
"""
1994+
tabulate = import_optional_dependency("tabulate")
1995+
result = tabulate.tabulate(self, **kwargs)
19941996
if buf is None:
1995-
buf = sys.stdout
1996-
1997+
return result
19971998
buf, _, _, _ = get_filepath_or_buffer(buf, mode=mode)
1998-
tabulate = import_optional_dependency("tabulate")
1999-
kwargs.setdefault("headers", "keys")
2000-
kwargs.setdefault("tablefmt", "pipe")
2001-
buf.writelines(tabulate.tabulate(self, **kwargs))
1999+
buf.writelines(result)
20022000

20032001
@deprecate_kwarg(old_arg_name="fname", new_arg_name="path")
20042002
def to_parquet(

0 commit comments

Comments
 (0)