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
{{ message }}
Repository navigation
[Python] Table.to_pandas() converts a replaced non-string column to strings with pandas 3 when the pandas metadata describes it as a string column #55700
Describe the bug, including details regarding any error messages, version, and platform.
With pandas 3, Table.from_pandas records every string column as numpy_type: "str" in the schema metadata, and to_pandas turns that back into the pandas string dtype without looking at the Arrow type of the column. Table methods that replace a column (set_column, ...) keep the schema metadata, so after set_column swaps a string column for a non-string one, to_pandas converts the new values to strings:
Any non-string type is affected, for example floating point ([1.5, 2.0, 3.0] becomes ['1.5', '2', '3']), boolean, timestamps, dates and decimals. pd.read_parquet goes through the same code, so a parquet file written from such a table is read back with strings as well. A typical way to hit it is parsing a string column into numbers with pyarrow.compute and putting it back under the same name. Passing ignore_metadata=True to to_pandas avoids it.
With pandas 2 and plain object strings the metadata says object, and the same code returns [1, 2, 3]. With pandas 2.3.3 the string dtype gives the same wrong strings as above, and with pd.set_option("future.infer_string", True) it raises ValueError: ArrowStringArray requires a PyArrow (chunked) array of large_string type. So pandas 3 makes this reachable with plain str columns.
to_pandas already has a defensive check in _get_extension_dtypes that ignores the string dtype from the metadata when the column is dictionary encoded (GH-43683 / #44195). I propose extending that check so the metadata dtype is only used when the Arrow column is a string, large string, string view, binary type (the string dtype decodes binary, so from_pandas(df, schema=...) with a binary field keeps reading back as strings) or null, instead of keeping the metadata in sync when columns are replaced (see #15178, where that was ruled out).
Reproduced with pyarrow 26.0.1 with pandas 3.1.1 and 2.3.3 (macOS arm64, Python 3.13); the check in _get_extension_dtypes (pandas_compat.py) is unchanged on current main.
Activity
sohailshk commentedon Nov 21, 2026
take