Skip to content

gr.Dataframe does not support an empty list as its value #3182

Description

@space-nuko

Describe the bug

I sometimes want to display a gr.Dataframe with no elements. But when I try to do that, I get this error:

Traceback (most recent call last):
  File "E:\sd\venv\lib\site-packages\gradio\routes.py", line 337, in run_predict
    output = await app.get_blocks().process_api(
  File "E:\sd\venv\lib\site-packages\gradio\blocks.py", line 1018, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "E:\sd\venv\lib\site-packages\gradio\blocks.py", line 956, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
  File "E:\sd\venv\lib\site-packages\gradio\components.py", line 2629, in postprocess
    if len(self.headers) < len(y[0]):
IndexError: list index out of range

As usual not terribly obvious what the actual error is but it turns out I can't have a gr.Dataframe with an empty list. Seems counterintuitive since a lot of gradio components can have an empty list as a value

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

  1. Create gr.Dataframe
  2. Update the dataframe with value []

Screenshot

No response

Logs

N/A

System Info

gradio 3.16.2, Windows Server 2022, Google Chrome

Severity

serious, but I can work around it

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions