streamlit: Error: Unrecognized type: "Duration" (18)
Summary
The dataframe shows an error on the frontend if a duration type (timedelta) is used.
Steps to reproduce
import pandas as pd
import streamlit as st
s = pd.Series(pd.date_range("2012-1-1", periods=3, freq="D"))
td = pd.Series([pd.Timedelta(days=i) for i in range(3)])
df = pd.DataFrame(
{
"A": s,
"B": td
}
)
st.table(df)
at Ji (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3064094)
at Function.$n.decode (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3065289)
at Ki (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3062354)
at Function.Yn.decode (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3066440)
at e._createHeader (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3059955)
at e.value (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3059100)
at e.value (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3069443)
at n.value (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3130013)
at n.value (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3125043)
at Function.value (http://localhost:8501/static/js/5.cbb83f60.chunk.js:2:3119592)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 26 (1 by maintainers)
Any update here? Currently running into this problem…
Still hoping for a fix to this issue…
Same problem. Temporarily working with:
st.code(df)Yes, running into this issue as well.
I also did a quick check today into this issue. The duration type is only partially implemented in the javascript/typescript version of Arrow. For example, it is missing here: https://github.com/apache/arrow/blob/f5166fe21969d19adff23fc840ed1d7511348bad/js/src/ipc/metadata/message.ts#L440 I assume it just never got fully implemented yet. Feel free to leave an upvote on this Jira Issue to get some more attention on this.
In the meantime, a workaround would be either to use
legacyserialization as described here or convert thetimedeltavalue tointviadf["delta"].dt.daysordf["delta"].dt.seconds. For example:Hello, I am encountering an issue with my Streamlit application[Chatbot] , where a blank page randomly appears for a random query. I’ve tried using the dataFrameSerialization = “legacy” approach, but the issue persists. When inspecting the page, the errors I’m seeing look like the following: TypeError: Cannot read properties of undefined (reading ‘vertical’) at Di (main, 1661a802.js:2:4213879) at wa (main. 1661a802.js:2:2230016) at wl (main.1661a802.js:2:2287129) at ze (main.1661a802.js:2:2276235) at Oc (main.1661a802.js:2:2276163) at Mc (main. 1661a802.js:2:2276026) at cc (main, 16612802.js:2:2273142) at Uo (moin. 1661a802.js:2:2213737) at rc (main.1661a802.js:2:2270229) at Object.enqueueSetState (main.1661a802.js:2:2220755) Uncaught TypeError: Cannot read properties of undefined (reading ‘vertical’) at Di (main. 1661a802.js:2:4213879) at wa (main.1661a802.js:2:2230016) at wl (moin.1661a802.js:2:2287129) at zc (main.16618802.js:2:2276235) at Oc (main. 1661a802.js:2:2276163) at Mc (main.1661a802.js:2:2276026) at cc (main.1661a802.js:2:2273142) at Uo (main. 1661a802.js:2:2213737) at rc (main.1661a802.js:2:2270229) at Object.enqueueSetState (main, 1661a802.js:2:2220755) Any insights on how to address this would be greatly appreciated.
Thank you!
Thank you @felp99 and @david-huck !
We were able to reproduce the issue and can confirm that the bug exists.
The minimal code snippet that I used for verification is this:
As a workaround for now you can use
dataFrameSerialization = "legacy"config option to switch to a legacy way of data frame serialization. I checked it and with
dataFrameSerialization = "legacy"it works for time delta serialization.Please see https://docs.streamlit.io/library/advanced-features/configuration for more information
@kmcgrady Yes, the new ArrowJS release finally provides support for the Duration type 🎉 However, we still have to do a few things on our side to actually make it work. I’m implementing the changes here: https://github.com/streamlit/streamlit/pull/7689
I’ve had the same issue when trying to use
where the first line prints (among other things
And the error message shown in streamlit is:
A naive approach, renaming the column, did not help…
I see the same thing as @Alli118 - at seemingly random points of interaction with my app I get the
TypeError: Cannot read properties of undefined (reading 'vertical')orTypeError: Cannot read properties of undefined (reading 'tab')I added timezone to my dates which works! to get around this error for displaying timedeltas
est = pytz.timezone(“America/New_York”) s = datetime.datetime.now().astimezone(est) e = datetime.datetime.now().astimezone(est) delta = (e-s)