pythonbook/实例学习 nicegui/show table.py

20 lines
360 B
Python

from nicegui import ui
import pandas as pd
# 创建一个简单的DataFrame
data = {
'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 35],
'City': ['New York', 'Paris', 'London']
}
df = pd.DataFrame(data)
# 在nicegui中创建并显示表格
ui.label('显示DataFrame')
ui.table.from_pandas(df).classes('max-h-40')
# 启动应用
ui.run()