Skip to content

Commit

Permalink
include np.float32 when finding common dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez committed Jan 25, 2022
1 parent 8bf1617 commit 530828b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ def _data_from_pandas(data, feature_name, categorical_feature, pandas_categorica
raise ValueError("DataFrame.dtypes for data must be int, float or bool.\n"
"Did not expect the data types in the following fields: "
f"{bad_index_cols_str}")
target_dtype = np.find_common_type((dtype.type for dtype in data.dtypes), [])
df_dtypes = [dtype.type for dtype in data.dtypes]
df_dtypes.append(np.float32) # so that the target dtype considers floats
target_dtype = np.find_common_type(df_dtypes, [])
data = data.astype(target_dtype, copy=False).values
else:
if feature_name == 'auto':
Expand Down

0 comments on commit 530828b

Please sign in to comment.