We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As outlined in my stackoverflow question, pandas to_html() doesn't behave consistently with a datetime index after being transposed.
to_html()
A simple example:
import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(5, 5), columns = ['a', 'b', 'c', 'd', 'e'], index = ["2015-01-05","2015-01-04","2015-01-03","2015-01-02","2015-01-01"]) df.index = pd.to_datetime(df.index)
Then df.to_html() outputs:
df.to_html()
<table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>a</th> <th>b</th> <th>c</th> <th>d</th> <th>e</th> </tr> </thead> <tbody> <tr> <th>2015-01-05</th> <td>-0.025414</td> <td>0.001241</td> <td>-0.110182</td> <td>0.101301</td> <td>0.904187</td> </tr> <tr> <th>2015-01-04</th> <td>-0.113769</td> <td>1.490484</td> <td>0.386378</td> <td>0.152447</td> <td>0.440914</td> </tr> <tr> <th>2015-01-03</th> <td>-0.807287</td> <td>0.161482</td> <td>-0.255942</td> <td>0.041502</td> <td>-0.314685</td> </tr> <tr> <th>2015-01-02</th> <td>-0.849947</td> <td>0.600126</td> <td>-1.516112</td> <td>-0.571000</td> <td>0.013668</td> </tr> <tr> <th>2015-01-01</th> <td>-0.421461</td> <td>-0.287318</td> <td>-1.411263</td> <td>-0.088717</td> <td>-0.823639</td> </tr> </tbody> </table>
Where as df.T.to_html() adds time (00:00:00) to the column titles:
df.T.to_html()
<table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>2015-01-05 00:00:00</th> <th>2015-01-04 00:00:00</th> <th>2015-01-03 00:00:00</th> <th>2015-01-02 00:00:00</th> <th>2015-01-01 00:00:00</th> </tr> </thead> <tbody> <tr> <th>a</th> <td>-0.025414</td> <td>-0.113769</td> <td>-0.807287</td> <td>-0.849947</td> <td>-0.421461</td> </tr> <tr> <th>b</th> <td>0.001241</td> <td>1.490484</td> <td>0.161482</td> <td>0.600126</td> <td>-0.287318</td> </tr> <tr> <th>c</th> <td>-0.110182</td> <td>0.386378</td> <td>-0.255942</td> <td>-1.516112</td> <td>-1.411263</td> </tr> <tr> <th>d</th> <td>0.101301</td> <td>0.152447</td> <td>0.041502</td> <td>-0.571000</td> <td>-0.088717</td> </tr> <tr> <th>e</th> <td>0.904187</td> <td>0.440914</td> <td>-0.314685</td> <td>0.013668</td> <td>-0.823639</td> </tr> </tbody> </table>
This behaviour is inconsistent.
A remedy was found by EdChum on stackoverflow.
The text was updated successfully, but these errors were encountered:
yeh, these should be the same. The SO soln is ok, but this actually is a bug in that the formatters are not applied to the columns.
Sorry, something went wrong.
pull-requests welcome!
No branches or pull requests
As outlined in my stackoverflow question, pandas
to_html()
doesn't behave consistently with a datetime index after being transposed.A simple example:
Then
df.to_html()
outputs:Where as
df.T.to_html()
adds time (00:00:00) to the column titles:This behaviour is inconsistent.
A remedy was found by EdChum on stackoverflow.
The text was updated successfully, but these errors were encountered: