-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Unrecognized type: "Duration" (18) #4489
Comments
Hello @felp99 . |
I've had the same issue when trying to use st.write(df.dtypes.astype(str))
st.dataframe(df) 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... |
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
config option to switch to a legacy way of data frame serialization. Please see https://docs.streamlit.io/library/advanced-features/configuration for more information |
I had the same problem with However, changing |
Same problem.
|
Any update on this? Has anyone found a solution or temporary work-around? |
It’s solved in GitHub. Check the link
Enviado do meu iPhone
… Em 27 de mai. de 2022, à(s) 20:31, George V Jose ***@***.***> escreveu:
Any update on this? Has anyone found a solution or temporary work-around?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Adding some info I just collected on this, so it's easier to fix later:
|
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 In the meantime, a workaround would be either to use import pandas as pd
import streamlit as st
data = {
"dt1": ["2020-01-03 12:23", "2020-04-12 12:34"],
"dt2": ["2021-03-23 12:13", "2021-12-12 11:04"],
}
df = pd.DataFrame(data)
df["dt1"] = pd.to_datetime(df["dt1"])
df["dt2"] = pd.to_datetime(df["dt2"])
df["delta"] = df["dt2"] - df["dt1"]
# Convert to integer value:
df["delta"] = df["delta"].dt.days
st.dataframe(df) |
I have the same problem when displaying a pd.DataFrame with a column of datetime.timedelta objects. |
I added timezone to my dates which works! to get around this error for displaying timedeltas est = pytz.timezone("America/New_York") |
Append streamlit/lib/streamlit/type_util.py Line 613 in d774bed
In some cases, also need to add df = fix_arrow_incompatible_column_types(df) in front of streamlit/lib/streamlit/type_util.py Line 669 in d774bed
|
Still hoping for a fix to this issue.. |
Yes, running into this issue as well. |
Any update here? Currently running into this problem... |
same here, not able to fix this issue when taking both time and date as input
|
same here. I have problems with timedelta type variables. Funny enough the same code runs ok locally but not when commited to github and deployed on Streamlit cloud. Has anyone heard whether it is being worked on and what priority it has been given? |
The error I get: File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
File "/app/youtube_channels_by_topic_streamlit/YouTube_channels_by_topic_streamlit.py", line 356, in
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/ops/common.py", line 81, in new_method
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/arraylike.py", line 210, in truediv
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/series.py", line 6108, in _arith_method
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/base.py", line 1348, in _arith_method
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/ops/array_ops.py", line 224, in arithmetic_op
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/arrays/datetimelike.py", line 1993, in array_ufunc
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/arrays/base.py", line 1686, in array_ufunc
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/arraylike.py", line 489, in default_array_ufunc
numpy.core._exceptions._UFuncBinaryResolutionError: ufunc 'divide' cannot use operands with types dtype('int64') and dtype('<m8[s]') |
One hack that seems to work is transposing the data such that instead of a column of df.loc[:, 'duration'] = df.time - df.time.shift(-1)
df.head().T # for example |
As a work around you can convert your timedelta to float using total_seconds()
output from your code: |
@lukasmasuch This will be fixed in the new version of PyArrow/Arrow.js. correct? I think the fix is here apache/arrow#37341 |
Hello, Thank you! |
I see the same thing as @Alli118 - at seemingly random points of interaction with my app I get the |
@Alli118 @itsToggle I'm also having the same issue of |
@Alli118 @itsToggle @mimn97 I'm pretty sure that the error you are getting is unrelated to this issue. It would be awesome if someone could open a new issue for this error and, if possible, add some minimum reproducible examples to this. |
Summary
The dataframe shows an error on the frontend if a duration type (timedelta) is used.
Steps to reproduce
The text was updated successfully, but these errors were encountered: