diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d4ff1bc4f35ac..e4dd1a600fccf 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3293,28 +3293,71 @@ def to_html( Examples -------- >>> df = pd.DataFrame(data={"col1": [1, 2], "col2": [4, 3]}) - >>> html_string = ''' - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ... - ...
col1col2
014
123
''' - >>> assert html_string == df.to_html() + >>> html_string = df.to_html() + >>> print(html_string) + + + + + + + + + + + + + + + + + + + + +
col1col2
014
123
+ + HTML output + + +----+-----+-----+ + | |col1 |col2 | + +====+=====+=====+ + |0 |1 |4 | + +----+-----+-----+ + |1 |2 |3 | + +----+-----+-----+ + + >>> df = pd.DataFrame(data={"col1": [1, 2], "col2": [4, 3]}) + >>> html_string = df.to_html(index=False) + >>> print(html_string) + + + + + + + + + + + + + + + + + +
col1col2
14
23
+ + HTML output + + +-----+-----+ + |col1 |col2 | + +=====+=====+ + |1 |4 | + +-----+-----+ + |2 |3 | + +-----+-----+ """ if justify is not None and justify not in fmt.VALID_JUSTIFY_PARAMETERS: raise ValueError("Invalid value for justify parameter")