Skip to content

BUG: repr_html, fix GH5588 for the MultiIndex case #5649

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 Dec 5, 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: 5 additions & 3 deletions pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,18 +846,20 @@ def _write_hierarchical_rows(self, fmt_values, indent):

frame = self.frame
ncols = min(len(self.columns), self.max_cols)
nrows = min(len(self.frame), self.max_rows)

truncate = (len(frame) > self.max_rows)

idx_values = frame.index.format(sparsify=False, adjoin=False,
idx_values = frame.index[:nrows].format(sparsify=False, adjoin=False,
names=False)
idx_values = lzip(*idx_values)

if self.fmt.sparsify:

# GH3547
sentinal = com.sentinal_factory()
levels = frame.index.format(sparsify=sentinal, adjoin=False,
names=False)
levels = frame.index[:nrows].format(sparsify=sentinal,
adjoin=False, names=False)
# Truncate row names
if truncate:
levels = [lev[:self.max_rows] for lev in levels]
Expand Down
30 changes: 29 additions & 1 deletion vb_suite/frame_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,35 @@ def f(x):
"""

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


# truncated repr_html, single index

setup = common_setup + """
nrows=10000
data=randn(nrows,10)
idx=MultiIndex.from_arrays(np.tile(randn(3,nrows/100),100))
df=DataFrame(data,index=idx)

"""

frame_html_repr_trunc_mi = Benchmark('df._repr_html_()', setup,
start_date=datetime(2013, 11, 25))

# truncated repr_html, MultiIndex

setup = common_setup + """
nrows=10000
data=randn(nrows,10)
idx=randn(nrows)
df=DataFrame(data,index=idx)

"""

frame_html_repr_trunc_si = Benchmark('df._repr_html_()', setup,
start_date=datetime(2013, 11, 25))


# insert many columns

Expand Down