#6348·nicegui

Table - pandas df tranformation to rows and columns for tables does not handle columns with name duplicates correctly

Author: SeparateThroughTimeCreated Sep 21, 2026Updated Sep 23, 2026
Labelsbugreview

First Check

  • I added a very descriptive title here.
  • This is not a security issue (those should be reported via the security advisory instead).
  • This is not a Q&A. I am sure something is wrong with NiceGUI or its documentation.
  • I used the GitHub search to find a similar issue and came up empty.

Example Code

python
from nicegui import ui
import pandas as pd

df = pd.DataFrame(
    [[1, 2], [3, 4]], columns=["Number", "Number"]
)

ui.table.from_pandas(df)
ui.run()

Description

DataFrames in panda are capable of handling columns with the same name. When a DataFrame with this condition is transformed to a dictionary (pandas to_dict() method) with a 'record' parameter, a UserWarning is raised and only one of the columns remain in the dict. This happens in _niceguis pandas_df_to_rows_and_columns() method of the table class.

The warning is necessary for the pandas method as dictionaries cannot handle entries with the same key. But nicegui tables can handle columns with the same label (wich is the pandon) so the tranformation should also handle it correctly.

The example code shows the smalles code to reproduce the error. It will produce a table with this content:

Number Number
2 2
4 4

The expected table is:

Number Number
1 2
3 4

I already wrote a fix for the method and will try to make a pull request (first time I do this, so I have to figure out how)

NiceGUI Version

3.15.0

Python Version

3.13.15

Browser

Firefox

Operating System

Windows

Additional Context

No response