I am not sure why, but I am unable to filter the 开发者_StackOverflow中文版date.
When I filter its either blank or it doesn't filter at all before filter, after filter using greater than, after filter using the equals to filter Below is my code:
st.markdown(hide_menu,unsafe_allow_html=True)
file_upload = st.file_uploader('Upload file','.xlsx')
if file_upload is not None:
df = pd.read_excel(file_upload)
#st.checkbox("Use container width", value=False, key="use_container_width")
#Installation Duration
df['Installation_Actual_End'] = pd.to_datetime(df["Installation_Actual_End"])
df['Installation_Actual_Start'] = pd.to_datetime(df["Installation_Actual_Start"])
df['Installation_Duration'] = df["Installation_Actual_End"] - df["Installation_Actual_Start"]
df["Installation_Duration"] = df["Installation_Duration"]
df1 = df['Installation_Actual_Start','Installation_Actual_End','Integration']
AgGrid(df1)
Add a format parameter in the conversion to datetime see code below.
Code
import streamlit as st
import pandas as pd
from st_aggrid import AgGrid
file_upload = st.file_uploader('Upload file','.xlsx')
if file_upload is not None:
df = pd.read_excel(file_upload)
st.write('### Initial data')
st.dataframe(df)
# Add format parameter based from excel data format.
df['Installation_Actual_Start'] = pd.to_datetime(df['Installation_Actual_Start'], format="%d/%m/%Y")
df['Installation_Actual_End'] = pd.to_datetime(df["Installation_Actual_End"], format="%d/%m/%Y")
df['Installation_Duration_Hr'] = (df["Installation_Actual_End"] - df["Installation_Actual_Start"]).astype('timedelta64[h]')
st.write('### Date conversion')
st.dataframe(df)
# Select column to show.
df1 = df[['Installation_Actual_Start', 'Installation_Actual_End', 'Integration']]
st.write('### AgGrid')
AgGrid(df1)
Output
Excel
test_image1 test_image2
import streamlit as st
import pandas as pd
from st_aggrid import AgGrid
file_upload = st.file_uploader('Upload file','.xlsx')
if file_upload is not None:
df = pd.read_excel(file_upload)
st.write('### Initial data')
st.dataframe(df)
# Add format parameter based from excel data format.
df['Installation_Actual_Start'] = pd.to_datetime(df['Installation_Actual_Start'], format="%d/%m/%Y")
df['Installation_Actual_End'] = pd.to_datetime(df["Installation_Actual_End"], format="%d/%m/%Y")
df['Installation_Duration_Hr'] = (df["Installation_Actual_End"] - df["Installation_Actual_Start"]).astype('timedelta64[h]')
st.write('### Date conversion')
st.dataframe(df)
# Select column to show.
df1 = df[['Installation_Actual_Start', 'Installation_Actual_End']]
st.write('### AgGrid')
AgGrid(df1)
Hi @ferdy, Thank you for taking you time to answer my doubts. I tested the code, but it wasn't working in my end. in the agrid columns it seems the data did not appear full as your screenshot. I've attached the output that im getting.
精彩评论