Skip to content

Displaying dataframes with many columns can crash the frontend #2991

@akshayka

Description

@akshayka

Describe the bug

Rendering a dataframe with on the order of 1,000 columns makes my browser tab sluggish, and 10,000 columns crashes the browser tab, regardless of how many rows the dataframe has.

It may make sense to reintroduce a limit on the number of columns that ui.table can display.

Related to: #2899 (comment)

Environment

0.9.27, Chrome

Code to reproduce

# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "marimo",
#     "numpy==2.1.3",
#     "pandas==2.2.3",
# ]
# ///

import marimo

__generated_with = "0.9.27"
app = marimo.App(width="medium")


@app.cell
def __():
    import pandas as pd
    return (pd,)


@app.cell
def __():
    import numpy as np
    return (np,)


@app.cell
def __():
    import marimo as mo
    return (mo,)


@app.cell(hide_code=True)
def __(mo):
    mo.md("""Set cols to 10000 to crash the frontend. Number of rows appears to have no effect.""")
    return


@app.cell
def __(mo):
    rows = mo.ui.number(start=1, value=10, label="rows")
    columns = mo.ui.number(start=1, value=10, label="cols")

    mo.hstack([rows, columns], justify="start")
    return columns, rows


@app.cell
def __(columns, np, rows):
    data = np.zeros((rows.value, columns.value))
    return (data,)


@app.cell
def __(data, pd):
    df = pd.DataFrame(data, columns=[str(i) for i in range(data.shape[1])])
    return (df,)


@app.cell
def __(df):
    df
    return


if __name__ == "__main__":
    app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions