data.table render.table
https://shiny.posit.co/py/api/core/render.table.html#shiny.render.table
UX : ui.output_data_frame
SRVR: @ render.data_frame
– render.DataGrid
– render.DataTable
UX : ui.output_data_frame
SRVR : render.table
날짜가 숫자로 나오는 문제:
df[‘Date’] = df[‘Date’].dt.strftime(‘%Y-%m-%d’)
from shiny import (App, render, ui, Session, Inputs, Outputs, reactive, module)
import pandas as pd
df = pd.read_csv('./zzz/shiny/mtcars.csv')
app_ui = ui.page_fillable(
ui.layout_columns(
ui.output_data_frame("sixx_data_frame"),
ui.output_data_frame("sixx_DataGrid"),
ui.output_data_frame("sixx_DataTable"),
ui.output_table("sixx_table"),
col_widths= [6, 6, 6, 6]
)
)
def server(input: Inputs, output: Outputs, session: Session):
@render.data_frame
def sixx_data_frame():
return df
@render.data_frame
def sixx_DataGrid():
return render.DataGrid(df, row_selection_mode='single')
@render.data_frame
def sixx_DataTable():
return render.DataTable(df,
width='fit-content',height='200px',
filters=False, row_selection_mode='multiple',
#editable=True,
summary=False,)
@render.table
def sixx_table():
return df
app = App(app_ui, server)
Function | Description | 특징 | |
---|---|---|---|
render.data_frame | DataFrame 형태로 출력 | ||
==> render.DataGrid | 그리드 형태로 출력 | 데이터탐색을 위한 중간크기의 datasets | Offers sorting and filtering capabilities for interactive data exploration. |
==>render.DataTable | HTML 테이블로 변환하여 출력. | interactive기능이 있는 대형 datasets 적합. | advanced features like pagination, searching, sorting, and filtering. |
Function | Description | 특징 | |
---|---|---|---|
render.table | HTML 테이블로 변환하여 출력 | interactive기능이 없는 small datasets | No additional features like sorting, filtering, or pagination. 가장 기본적인 테이블 출력 기능을 제공. dataframe을 Simple and straightforward 형태로 렌더링할 때 사용. 고급 기능 없음 (정렬, 페이징, 검색) |
@output
@render.table
def ehist_df_excel_1():
area = input.ehist_select_area()
print("--------------------------------------->", area)
#df = pd.read_excel(f"{DATA_DIR}/process/{area}_daily.csv")
df = pd.DataFrame()
return df
if area is not None:
#ddf = ddf.fillna('')
ddf['분류'] = ddf['분류'].fillna('')
ddf['반송건수'] = ddf['반송건수'].fillna(0).astype(int)
# return dd류
return (
ddf.style.set_table_attributes(
'class="dataframe shiny-table table w-auto"'
)
.hide(axis="index")
.format(
{
'반송건수': "{:.0f}",#"{:,.0f}",
# "Total": "{0:0.1f}",
# "Tip": "{0:0.2f}",
# "Total_bill": "{0:0.3f}",
# "Tip_rate": "{0:0.2%}",
}
)
.set_table_styles(
[dict(selector="th", props=[("text-align", "right")])]
)
)
else:
return None
itable
https://mwouts.github.io/itables/quick_start.html