Hello,
The output looks the identical. But when would you use one over the other?
TIA!
Hello,
The output looks the identical. But when would you use one over the other?
TIA!
Hi Jeisma
In my opinion st.write() is a combination of output function, it output based on what you put in, for example you can use st.write(df), st.write(error) or even st.write(altair_chart). For me the best thing about st.write() is it can output multiple item, such as st.write(df, df[‘col1’].dtype, fig1) in 1 line.
You are correct @oliverjia…st.write
inspects the class of the object, then tries to do what we think the user intent is. So it will go through a hierarchy of the other methods like st.json
, st.dataframe
, st.table
, st.markdown
etc.
So the easy heuristic is, you can use st.write
until it doesn’t do what you want, then be more specific if you want control over the output and a specific function has other arguments you want to pass.
Best,
Randy
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
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.