Hi Team,
I have a month column in a dataframe. It is a normal column.
I want to make this a clickable column so that if someone clicks on it , I want to load a corresponding data.
Can someone help me with this.
Regards,
Hari
Hi Team,
I have a month column in a dataframe. It is a normal column.
I want to make this a clickable column so that if someone clicks on it , I want to load a corresponding data.
Can someone help me with this.
Regards,
Hari
Hi @HariGan,
Your looking to create buttons, whose names are the titles of your columns in a pandas dataframe, and then when someone clicks the buttons it loads that columns data into a graph or something similar?
I think that the best way to do this is to actually use a selectbox dropdown menu!
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
st.title("Pandas Dataframe selection")
data = pd.read_csv('trial_df.csv')
data
column_names = list(data.columns)
select = st.selectbox("Choose your data", column_names)
st.write("Your selection",select)
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.hist(select)
st.write(fig)
that gives:
Happy Streamlit-ing!
Marisa
Hey @HariGan ,
You might want to look into this, Complete Bokeh DataTable Example using streamlit-bokeh-events
Also, if you want to actually add a hyperlink that routes to some other page you can look into this answer,
Make Streamlit table results hyperlinks or add radio buttons to table? - #2 by ash2shukla
Hope it helps !
Hi @Marisa_Smith ,
In the same example lets say the SKU column. I have different SKUs and i want each Sku to be a hyperlink and when i click on the specific SKU i want to load data specific to that SKU.
I hope this makes my requirement clear. Can you help me with this.
Regards,
Hari
Hi @HariGan,
Ah I think then @ash2shukla’s answer is what your looking for! You can get the unique values from you pandas database and make a brokeh table that the user can click on from there!
Brokeh is a Streamlit component, these are add-ons/additions that the Streamit community members have made themselves! This one was made by @ash2shukla!!
Here is a link to all the available components: Streamlit Components
To install this component in your environment you can run: pip install streamlit-bokeh-events
Happy Streamlit-ing!
Marisa
Hi @Marisa_Smith & @ash2shukla,
Okay guys. I will try it. But let alone this.
If I have a report name lets say XYZ sales report. I want to actually make this XYZ sales report a clickable link or hyperlink and on click this i want to load a different dataframe. Is it possible.
I am able to do it only for actual URLs or website but not to my reqirement.
Regards,
Hari
Hey @HariGan,
With regards to making a hyperlink (using st.markdown("[link](url)")
or st.write("[link](url)")
) that would point back to your current app and do this I don’t believe this is possible in Streamlit at the moment.
But there are a number of widgets you may want to use to do the same thing here!
The radio buttons like so, st.radio("pick a sales report", ('abc','xyz'))
, could work if you have multiple sales reports, and you want the user to select xyz sales or abc sales.
If you only have one option to look at, the using a checkbox is probably more suited to your use: st.checkbox("Click here to see xyz sales report")
Another option is to create a Streamlit app for the xyz sales dataframe and its analysis and launch it (on Sharing perhaps) and link to that hyperlink. This would point the user to a different streamlit app, but it would look like a standard hyperlink in your main app: st.write("[Click to open xyz sales report](https://share.streamlit.io/your/app/link)")
Happy Streamlit-ing!
Marisa
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.