Hi team, I’m using Streamlit to show my data results in interactive way.
I’ve a dataframe result with Date column as index in format=‘%d-%m-%y’ but st.dataframe show this info as “2024-02-02 00:00:00”, allways show time too. I don’t need the time and can’t find a solution.
Dataframe values
Streamlit table by st.dataframe
Code:
import streamlit as st
import pandas as pd
import datetime
from datetime import date
fin_result = pd.DataFrame(
[
{"Date":date(2024,2,2),"Ticker": "AMZN", "Name": "Amazon.com Inc", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡹","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,8),"Ticker": "NVDA", "Name": "NVIDIA Corp", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡹","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,2,2),"Ticker": "NVDA", "Name": "NVIDIA Corp", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡹","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,2,2),"Ticker": "META", "Name": "Meta Platforms Inc", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡹","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,31),"Ticker": "LLY", "Name": "Eli Lilly and Co", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡹","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,12),"Ticker": "JPM", "Name": "JPMorgan Chase & Co", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡹","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,31),"Ticker": "MA", "Name": "Mastercard Inc", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡹","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,2,2),"Ticker": "AAPL", "Name": "Apple Inc", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡻","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,31),"Ticker": "MSFT", "Name": "Microsoft Corp", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡻","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,31),"Ticker": "GOOGL", "Name": "Alphabeth Inc Class A", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡻","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,25),"Ticker": "TSLA", "Name": "Tesla Inc", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡻","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,26),"Ticker": "V", "Name": "Visa Inc", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡻","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
{"Date":date(2024,1,29),"Ticker": "V", "Name": "Visa Inc", "Market": "Test", "Timeframe":"Daily","Strongest GAP":"🡻","Strongest ERC":NaN,"Gap+ERC":NaN,"Multi ERCs":NaN},
]
)
fin_result['Date'] = pd.to_datetime(fin_result['Date'],format='%d-%m-%y')
fin_result = fin_result.set_index('Date')
print(fin_result[['Ticker','Name','Market','Timeframe','Strongest GAP','Strongest ERC','Gap+ERC','Multi ERCs']])
st.dataframe(fin_result,column_order=('Date','Ticker','Name','Market','Timeframe','Strongest GAP','Strongest ERC','Gap+ERC','Multi ERCs'))
In other way I need to set a default order for this results by “Date” column index.
How is posible to make this settings? Thanks a lot for your help.