@@ -4159,6 +4159,8 @@ def _create_axes(
41594159 ordered = data_converted .ordered
41604160 meta = "category"
41614161 metadata = np .asarray (data_converted .categories ).ravel ()
4162+ elif isinstance (blk .dtype , StringDtype ):
4163+ meta = str (blk .dtype )
41624164
41634165 data , dtype_name = _get_data_and_dtype_name (data_converted )
41644166
@@ -4419,7 +4421,8 @@ def read_column(
44194421 errors = self .errors ,
44204422 )
44214423 cvs = col_values [1 ]
4422- return Series (cvs , name = column , copy = False )
4424+ dtype = getattr (self .table .attrs , f"{ column } _meta" , None )
4425+ return Series (cvs , name = column , copy = False , dtype = dtype )
44234426
44244427 raise KeyError (f"column [{ column } ] not found in the table" )
44254428
@@ -4769,8 +4772,18 @@ def read(
47694772 df = DataFrame ._from_arrays ([values ], columns = cols_ , index = index_ )
47704773 if not (using_string_dtype () and values .dtype .kind == "O" ):
47714774 assert (df .dtypes == values .dtype ).all (), (df .dtypes , values .dtype )
4775+
4776+ # If str / string dtype is stored in meta, use that.
4777+ converted = False
4778+ for column in cols_ :
4779+ dtype = getattr (self .table .attrs , f"{ column } _meta" , None )
4780+ if dtype in ["str" , "string" ]:
4781+ df [column ] = df [column ].astype (dtype )
4782+ converted = True
4783+ # Otherwise try inference.
47724784 if (
4773- using_string_dtype ()
4785+ not converted
4786+ and using_string_dtype ()
47744787 and isinstance (values , np .ndarray )
47754788 and is_string_array (
47764789 values ,
0 commit comments