You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using df.dtypes to show the datatypes for a dataframe fails when you're using the Arrow codepath.
Steps to reproduce
Code snippet:
import streamlit as st
import pandas as pd
df = pd.read_json("https://cdn.jsdelivr.net/npm/vega-datasets@2/data/penguins.json")
st.write(df.dtypes)
Expected behavior:
The app should show a table with datatypes for the given dataframe
Actual behavior:
The app shows this exception:
Exception text
ArrowInvalid: ("Could not convert dtype('O') with type numpy.dtype[object_]: did not recognize Python value type when inferring an Arrow data type", 'Conversion failed for column 0 with type object')
Traceback:
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib/python3.9/site-packages/streamlit/script_runner.py", line 350, in _run_script
exec(code, module.__dict__)
File "/media/storage/Projects/streamlit/streamlit-vega-lite-demo/demo.py", line 15, in <module>
df.dtypes
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib/python3.9/site-packages/streamlit/__init__.py", line 478, in _transparent_write
write(*args)
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib/python3.9/site-packages/streamlit/elements/write.py", line 182, in write
self.dg.dataframe(arg)
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib/python3.9/site-packages/streamlit/elements/dataframe_selector.py", line 85, in dataframe
return self.dg._arrow_dataframe(data, width, height)
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib/python3.9/site-packages/streamlit/elements/arrow.py", line 82, in _arrow_dataframe
marshall(proto, data, default_uuid)
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib/python3.9/site-packages/streamlit/elements/arrow.py", line 160, in marshall
proto.data = type_util.data_frame_to_bytes(df)
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib/python3.9/site-packages/streamlit/type_util.py", line 371, in data_frame_to_bytes
table = pa.Table.from_pandas(df)
File "pyarrow/table.pxi", line 1561, in pyarrow.lib.Table.from_pandas
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib64/python3.9/site-packages/pyarrow/pandas_compat.py", line 594, in dataframe_to_arrays
arrays = [convert_column(c, f)
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib64/python3.9/site-packages/pyarrow/pandas_compat.py", line 594, in <listcomp>
arrays = [convert_column(c, f)
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib64/python3.9/site-packages/pyarrow/pandas_compat.py", line 581, in convert_column
raise e
File "/home/tvst/.local/share/virtualenvs/streamlit-vega-lite-demo-Se5mEOd4/lib64/python3.9/site-packages/pyarrow/pandas_compat.py", line 575, in convert_column
result = pa.array(col, type=type_, from_pandas=True, safe=safe)
File "pyarrow/array.pxi", line 302, in pyarrow.lib.array
File "pyarrow/array.pxi", line 83, in pyarrow.lib._ndarray_to_array
File "pyarrow/error.pxi", line 99, in pyarrow.lib.check_status
Is this a regression?
yes (arrow vs legacy)
Debug info
Streamlit version: 0.86.0
The text was updated successfully, but these errors were encountered:
Summary
Using
df.dtypes
to show the datatypes for a dataframe fails when you're using the Arrow codepath.Steps to reproduce
Code snippet:
Expected behavior:
The app should show a table with datatypes for the given dataframe
Actual behavior:
The app shows this exception:
Exception text
Is this a regression?
yes (arrow vs legacy)
Debug info
The text was updated successfully, but these errors were encountered: