mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[Ray Dataset] fix the type infer of pd.dataframe
(when dtype is object
.) (#25563)
this is a temp fix of #25556. When the dtype from the pandas dataframe gives object, we set the dtype to be None and make use of the auto-inferring of the type in the conversion.
This commit is contained in:
parent
0d8cbb1cae
commit
57d02eec2e
1 changed files with 7 additions and 0 deletions
|
@ -47,6 +47,13 @@ def convert_pandas_to_tf_tensor(
|
|||
# them. If the columns contain different types (for example, `float32`s
|
||||
# and `int32`s), then `tf.concat` raises an error.
|
||||
dtype: np.dtype = np.find_common_type(df.dtypes, [])
|
||||
|
||||
# if the columns are `ray.data.extensions.tensor_extension.TensorArray`,
|
||||
# the dtype will be `object`. In this case, we need to set the dtype to
|
||||
# none, and use the automatic type casting of `tf.convert_to_tensor`.
|
||||
if isinstance(dtype, object):
|
||||
dtype = None
|
||||
|
||||
except TypeError:
|
||||
# `find_common_type` fails if a series has `TensorDtype`. In this case,
|
||||
# don't cast any of the series and continue.
|
||||
|
|
Loading…
Add table
Reference in a new issue