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

Fix bug where fillna assumes each column is its own partition #51

Merged
merged 2 commits into from
Jul 20, 2018
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
13 changes: 9 additions & 4 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2076,16 +2076,22 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
if isinstance(value, (pandas.Series, dict)):
new_vals = {}
value = dict(value)
partition_dict = {}
for val in value:
# Get the local index for the partition
try:
part, index = coords_obj[val]

if part not in partition_dict:
partition_dict[part] = {}
partition_dict[part][index] = value[val]
# Pandas ignores these errors so we will suppress them too.
except KeyError:
continue

new_vals[val] = _deploy_func.remote(lambda df: df.fillna(
value={index: value[val]},
for part, value_map in partition_dict.items():
new_vals[part] = _deploy_func.remote(lambda df: df.fillna(
value=value_map,
method=method,
axis=axis,
inplace=False,
Expand All @@ -2095,8 +2101,7 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,

# Not every partition was changed, so we put everything back that
# was not changed and update those that were.
new_parts = [parts[i] if coords_obj.index[i] not in new_vals
else new_vals[coords_obj.index[i]]
new_parts = [parts[i] if i not in new_vals else new_vals[i]
for i in range(len(parts))]
else:
new_parts = _map_partitions(lambda df: df.fillna(
Expand Down