-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
[ENH] Add to_markdown method #30350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[ENH] Add to_markdown method #30350
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
16a3328
:sparkles: Add to_markdown method
8eb96ec
:pushpin: put tabulate in #optional for io, pin dependency
00fd8a4
:recycle: remove call to DataFrame.pipe in DataFrame.to_markdown
65e9f1b
:pushpin: add tabulate to travis-38.yaml
a273560
:pencil: add DataFrame.to_markdown to API reference file
14e36e8
:sparkles: add **kwargs to DataFrame.to_markdown
ee07c68
:white_check_mark: update tests so they work with **kwargs, set skip_…
d99a54f
:sparkles: add to_markdown to Series
57dfb7b
:pencil: document to_markdown in Series API reference
ccb132b
:white_check_mark: update tests so they test Series.to_markdown as well
bac632e
:arrow_down: Set tabulate dependency at 0.8, before which tests fail
557e6dd
:pencil: update failing docstring
01260f2
:pushpin: set tabulate dependency at 0.8.0, not 0.8
b32d54d
:sparkles: add buf and mode arguments to to_markdown
68e84d6
:white_check_mark: update tests so they use buf
882768b
:fire: remove skip_if_no_tabulate, due to module-level fixture
f46edb1
:pencil: add tabulate to install.rst and _optional, capitalise Markdown
32d8762
:push_pin: add tabulate unpinned to travis-37.yaml
c5c3768
:bug: dont all get_filepath_or_buffer with buf equal to sys.stdout
MarcoGorelli df7880c
:ok_hand: return string if buf is set to None, use shared doc, change…
MarcoGorelli 039e6a9
:pushpin: pin tabulate at 0.8.3
MarcoGorelli 093d63a
:pencil: add kwargs to parameters
ec77816
:pencil: link to tabulate docs in install.rst
MarcoGorelli 32650f7
:pencil: fix merge conflict in whatsnew
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ dependencies: | |
- pyarrow | ||
- pytz | ||
- s3fs | ||
- tabulate | ||
- pyreadstat | ||
- pip | ||
- pip: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ dependencies: | |
- nomkl | ||
- pytz | ||
- pip | ||
- tabulate==0.8.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -578,3 +578,4 @@ Serialization / IO / conversion | |
Series.to_string | ||
Series.to_clipboard | ||
Series.to_latex | ||
Series.to_markdown |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from io import StringIO | ||
|
||
import pytest | ||
|
||
import pandas as pd | ||
|
||
pytest.importorskip("tabulate") | ||
|
||
|
||
def test_simple(): | ||
buf = StringIO() | ||
df = pd.DataFrame([1, 2, 3]) | ||
df.to_markdown(buf=buf) | ||
result = buf.getvalue() | ||
assert ( | ||
result == "| | 0 |\n|---:|----:|\n| 0 | 1 |\n| 1 | 2 |\n| 2 | 3 |" | ||
) | ||
|
||
|
||
def test_other_tablefmt(): | ||
buf = StringIO() | ||
df = pd.DataFrame([1, 2, 3]) | ||
df.to_markdown(buf=buf, tablefmt="jira") | ||
result = buf.getvalue() | ||
assert result == "|| || 0 ||\n| 0 | 1 |\n| 1 | 2 |\n| 2 | 3 |" | ||
|
||
|
||
def test_other_headers(): | ||
buf = StringIO() | ||
df = pd.DataFrame([1, 2, 3]) | ||
df.to_markdown(buf=buf, headers=["foo", "bar"]) | ||
result = buf.getvalue() | ||
assert result == ( | ||
"| foo | bar |\n|------:|------:|\n| 0 " | ||
"| 1 |\n| 1 | 2 |\n| 2 | 3 |" | ||
) | ||
|
||
|
||
def test_series(): | ||
buf = StringIO() | ||
s = pd.Series([1, 2, 3], name="foo") | ||
s.to_markdown(buf=buf) | ||
result = buf.getvalue() | ||
assert result == ( | ||
"| | foo |\n|---:|------:|\n| 0 | 1 " | ||
"|\n| 1 | 2 |\n| 2 | 3 |" | ||
) | ||
|
||
|
||
def test_no_buf(capsys): | ||
df = pd.DataFrame([1, 2, 3]) | ||
result = df.to_markdown() | ||
assert ( | ||
result == "| | 0 |\n|---:|----:|\n| 0 | 1 |\n| 1 | 2 |\n| 2 | 3 |" | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.