From 15af65239a964f71f410cab5bb28504fa1993d3b Mon Sep 17 00:00:00 2001 From: Michele Mattioni Date: Fri, 16 Aug 2013 10:43:58 +0100 Subject: [PATCH 1/2] ENH: Remove the hardcoded border=1 in the to_html dataframe export. The border is impossible to overwrite at later stage, therefore using no border gives the user the possibility to style the table, using CSS Classes. --- pandas/core/format.py | 2 +- pandas/tests/test_format.py | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pandas/core/format.py b/pandas/core/format.py index 30856d371c084..abbd452d9be56 100644 --- a/pandas/core/format.py +++ b/pandas/core/format.py @@ -571,7 +571,7 @@ def write_result(self, buf): 'not %s') % type(self.classes)) _classes.extend(self.classes) - self.write('' % ' '.join(_classes), + self.write('
' % ' '.join(_classes), indent) if len(frame.columns) == 0 or len(frame.index) == 0: diff --git a/pandas/tests/test_format.py b/pandas/tests/test_format.py index e7a52756089cc..ce5aa56a787f1 100644 --- a/pandas/tests/test_format.py +++ b/pandas/tests/test_format.py @@ -387,7 +387,7 @@ def test_to_html_escaped(self): 'co>l2':{a: "", b: ""}} rs = pd.DataFrame(test_dict).to_html() - xp = """
+ xp = """
@@ -419,7 +419,7 @@ def test_to_html_escape_disabled(self): 'co>l2': {a: "bold", b: "bold"}} rs = pd.DataFrame(test_dict).to_html(escape=False) - xp = """
+ xp = """
@@ -451,7 +451,7 @@ def test_to_html_multiindex_sparsify_false_multi_sparse(self): result = df.to_html() expected = """\ -
+
@@ -500,7 +500,7 @@ def test_to_html_multiindex_sparsify_false_multi_sparse(self): result = df.to_html() expected = """\ -
+
@@ -557,7 +557,7 @@ def test_to_html_multiindex_sparsify(self): df = DataFrame([[0, 1], [2, 3], [4, 5], [6, 7]], index=index) result = df.to_html() - expected = """
+ expected = """
@@ -604,7 +604,7 @@ def test_to_html_multiindex_sparsify(self): result = df.to_html() expected = """\ -
+
@@ -659,7 +659,7 @@ def test_to_html_index_formatter(self): f = lambda x: 'abcd'[x] result = df.to_html(formatters={'__index__': f}) expected = """\ -
+
@@ -1255,7 +1255,7 @@ def test_to_html_multiindex(self): names=['CL0', 'CL1']) df = pandas.DataFrame([list('abcd'), list('efgh')], columns=columns) result = df.to_html(justify='left') - expected = ('
\n' + expected = ('
\n' ' \n' ' \n' ' \n' @@ -1295,7 +1295,7 @@ def test_to_html_multiindex(self): df = pandas.DataFrame([list('abcd'), list('efgh')], columns=columns) result = df.to_html(justify='right') - expected = ('
CL0
\n' + expected = ('
\n' ' \n' ' \n' ' \n' @@ -1338,7 +1338,7 @@ def test_to_html_justify(self): 'C': [223442, 0, 1]}, columns=['A', 'B', 'C']) result = df.to_html(justify='left') - expected = ('
\n' + expected = ('
\n' ' \n' ' \n' ' \n' @@ -1372,7 +1372,7 @@ def test_to_html_justify(self): self.assertEqual(result, expected) result = df.to_html(justify='right') - expected = ('
\n' + expected = ('
\n' ' \n' ' \n' ' \n' @@ -1452,7 +1452,7 @@ def test_to_html_with_classes(self): result = df.to_html(classes="sortable draggable") expected = dedent(""" -
+
From 8a8b2f654bec728835351ac0479423b7ebc41b08 Mon Sep 17 00:00:00 2001 From: Michele Mattioni Date: Wed, 21 Aug 2013 14:07:54 +0100 Subject: [PATCH 2/2] ENH: Updated the release notes with the result of issue #4578 --- doc/source/release.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/release.rst b/doc/source/release.rst index b1dfff6988cc3..27e6b2e5bbb5e 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -59,6 +59,8 @@ pandas 0.13 - A Series of dtype ``timedelta64[ns]`` can now be divided by another ``timedelta64[ns]`` object to yield a ``float64`` dtyped Series. This is frequency conversion. + - Border is not anymore hardcoded when a Dataframe is exported to + HTML. (:issue:`4578`) **API Changes**
Index([], dtype=object)