ui.table doesn't work with datetime datatypes #1972
-
QuestionHi there, I believe from nicegui import ui
import pandas as pd
df = pd.DataFrame({
"Name": ["John", "Mary", "Peter"],
"DOB": ["1/1/2000", "2/2/2002", "3/3/2003"],
})
df['DOB'] = pd.to_datetime(df['DOB'])
@ui.page('/')
def home():
ui.table(
columns=[{'name': col, 'label': col, 'field': col} for col in df.columns],
rows=df.to_dict('records'),
)
ui.run()
|
Beta Was this translation helpful? Give feedback.
Answered by
falkoschindler
Nov 9, 2023
Replies: 1 comment 5 replies
-
This code converts date and time columns in the DataFrame to strings with the format 'YYYY-MM-DD HH:MM:SS' so that they can be serialized and displayed properly in the NiceGUI table. df['DOB'] = df['DOB'].dt.strftime('%Y-%m-%d %H:%M:%S') |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great, PR #1983 is merged into main and will be part of the next release.