Skip to content

BUG: to_html doesn't truncate index to max_rows before formatting #5589

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
2 commits merged into from Nov 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,14 @@ def _write_body(self, indent):

def _write_regular_rows(self, fmt_values, indent, truncated):
ncols = min(len(self.columns), self.max_cols)

nrows = min(len(self.frame), self.max_rows)
fmt = self.fmt._get_formatter('__index__')
if fmt is not None:
index_values = self.frame.index.map(fmt)
index_values = self.frame.index[:nrows].map(fmt)
else:
index_values = self.frame.index.format()
index_values = self.frame.index[:nrows].format()

for i in range(min(len(self.frame), self.max_rows)):
for i in range(nrows):
row = []
row.append(index_values[i])
row.extend(fmt_values[j][i] for j in range(ncols))
Expand Down
14 changes: 14 additions & 0 deletions vb_suite/frame_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ def f(x):
frame_to_string_floats = Benchmark('df.to_string()', setup,
start_date=datetime(2010, 6, 1))

#----------------------------------------------------------------------
# to_html

setup = common_setup + """
nrows=500
df = DataFrame(randn(nrows, 10))
df[0]=period_range("2000","2010",nrows)
df[1]=range(nrows)

"""

frame_to_html_mixed = Benchmark('df.to_html()', setup,
start_date=datetime(2010, 6, 1))

# insert many columns

setup = common_setup + """
Expand Down