ArrowInvalid: ("Could not convert dtype('int64') with type numpy.dtype[int64]: did not recognize Python value type when inferring an Arrow data type", 'Conversion failed for column dtype with type object')

When updated to streamlit 0.86.0

passing few dataframes causing pyarrow error

File "c:\users\krishna\anaconda3\lib\site-packages\streamlit\", line 350, in _run_script
    exec(code, module.__dict__)
File "C:\Users\krishna\Documents\Streamlit\*****\", line 234, in <module>
File "c:\users\krishna\anaconda3\lib\site-packages\streamlit\elements\", line 85, in dataframe
    return self.dg._arrow_dataframe(data, width, height)
File "c:\users\krishna\anaconda3\lib\site-packages\streamlit\elements\", line 82, in _arrow_dataframe
    marshall(proto, data, default_uuid)
File "c:\users\krishna\anaconda3\lib\site-packages\streamlit\elements\", line 160, in marshall = type_util.data_frame_to_bytes(df)
File "c:\users\krishna\anaconda3\lib\site-packages\streamlit\", 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 "c:\users\krishna\anaconda3\lib\site-packages\pyarrow\", line 595, in dataframe_to_arrays
    for c, f in zip(columns_to_convert, convert_fields)]
File "c:\users\krishna\anaconda3\lib\site-packages\pyarrow\", line 595, in <listcomp>
    for c, f in zip(columns_to_convert, convert_fields)]
File "c:\users\krishna\anaconda3\lib\site-packages\pyarrow\", line 581, in convert_column
    raise e
File "c:\users\krishna\anaconda3\lib\site-packages\pyarrow\", 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
1 Like

What is the code? What does the df look like?

1 Like

Do this as a final step

df = df.astype(str)

I found it in other questions of this type and it worked for me

1 Like

Thank you, it works.!