Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "float64" dtypes in DaskExecutor.fit_phase #378

Merged
merged 6 commits into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions merlin/dag/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,26 @@ def transform(
if col_dtype:
output_dtypes[col_name] = md.dtype(col_dtype).to_numpy

if isinstance(output_dtypes, dict) and isinstance(ddf._meta, pd.DataFrame):
dtypes = output_dtypes
output_dtypes = type(ddf._meta)({k: [] for k in columns})
for col_name, col_dtype in dtypes.items():
output_dtypes[col_name] = output_dtypes[col_name].astype(col_dtype)
def make_empty(df, cols):
# Construct an empty DataFrame

elif not output_dtypes:
# TODO: constructing meta like this loses dtype information on the ddf
# and sets it all to 'float64'. We should propagate dtype information along
# with column names in the columngroup graph. This currently only
# happens during intermediate 'fit' transforms, so as long as statoperators
# don't require dtype information on the DDF this doesn't matter all that much
output_dtypes = type(ddf._meta)({k: [] for k in columns})
return df._constructor(
{col: df._constructor_sliced([], dtype="float64") for col in cols}
)

if isinstance(output_dtypes, dict) and isinstance(ddf._meta, pd.DataFrame):
dtypes = output_dtypes
output_dtypes = make_empty(ddf._meta, columns)
for col_name, col_dtype in dtypes.items():
output_dtypes[col_name] = output_dtypes[col_name].astype(col_dtype)

elif not output_dtypes:
output_dtypes = make_empty(ddf._meta, columns)

return ensure_optimize_dataframe_graph(
ddf=ddf.map_partitions(
Expand Down
Loading