Dataframe date display issue using shiny with python

35 Views Asked by At

i'm new to programming, with objective to learn some basics using Python and R skills for data processing and machine learning. I already made one first project using R and shiny package to implement dashboard for results consultation. few time ago, i decided to switch to Python.

I'm currently facing an issue, trying to display a dataset extracted from an excel file. i don't understand the dates values displayed like presented in the picture.

enter image description here

here the correponding code

from shiny.express import input, render, ui
import pandas as pd
import xlrd 


df_patient = pd.read_excel(r"C:\Users\rdesb\OneDrive\Bureau\MyAPP\dashboard\db_patient.xlsx", 
                           index_col="Indice")


#INTERFACE GRAPHIQUE

ui.page_opts(title="DashBoard Plume", fillable=True)

with ui.nav_panel("Informations Patients"):
    ui.h2("Informations Patients")
    @render.data_frame  
    def patients_df():
        return render.DataGrid(df_patient)  

        
with ui.nav_panel("Plot2"):

    with ui.layout_columns():  

        with ui.card():  
            ui.card_header("Card 1 header")
            ui.p("Card 1 body")
            

        with ui.card():  
            ui.card_header("Card 2 header")
            ui.p("Card 2 body")

I tried in a python console to reproduce the code, but seems okay. i tried to convert using several method the initial date value before, but nothing really change. Maybe something i don't get in the method.

Thanks a lot for the help

Greetings

i tried to convert the date column using xlrd package , didn't work.

i also tried to convert the date values in the excel file as str following : "dd-mm-yyyy" and then converting it using the following code :

df_patient["Date de naissance"] = pd.to_datetime(df_patient["Date de naissance"], format='%d-%m-%Y')

and that went even worst.

0

There are 0 best solutions below