question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fillna doesn't work when series object is an argument

See original GitHub issue

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • Modin version (modin.__version__):
  • Python version:
  • Code we can use to reproduce:
import modin.pandas as pd

df = pd.DataFrame({'a': ['a'], 'b': ['b'],}, index=['row1'])
df['c'] = pd.NA
df['c'] = df['c'].fillna(df['b'])   # df['c'].fillna('c') works fine
print(df)

Describe the problem

when fillna is called with series object as argument seems nothing happens while pandas does actual na replacement

Source code / logs

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
noloerinocommented, Jul 11, 2022

As far as I can tell, it seems like something’s going awry in broadcast_axis_partitions, on this line: the value in the partition seems to be changed when the dataframe is reindexed. I’ll let someone more familiar with the codebase weigh in on why this is the case.

Abridged stack trace:
-> print(df['c'].fillna(df['b']))  # df['c'].fillna('c') works fine
  modin/modin/logging/logger_decorator.py(128)run_and_log()
-> return obj(*args, **kwargs)
  modin/modin/pandas/series.py(993)fillna()
-> return super(Series, self)._fillna(
  modin/modin/logging/logger_decorator.py(128)run_and_log()
-> return obj(*args, **kwargs)
  modin/modin/pandas/base.py(1525)_fillna()
-> new_query_compiler = self._query_compiler.fillna(
  modin/modin/logging/logger_decorator.py(128)run_and_log()
-> return obj(*args, **kwargs)
  modin/modin/core/storage_formats/pandas/query_compiler.py(1882)fillna()
-> new_modin_frame = self._modin_frame.binary_op(
  modin/modin/logging/logger_decorator.py(128)run_and_log()
-> return obj(*args, **kwargs)
  modin/modin/core/dataframe/pandas/dataframe/dataframe.py(115)run_f_on_minimally_updated_metadata()
-> result = f(self, *args, **kwargs)
  modin/modin/core/dataframe/pandas/dataframe/dataframe.py(2526)binary_op()
-> ) = new_left_frame._copartition(1, new_right_frame, join_type, sort=True)
  modin/modin/logging/logger_decorator.py(128)run_and_log()
-> return obj(*args, **kwargs)
  modin/modin/core/dataframe/pandas/dataframe/dataframe.py(2471)_copartition()
-> reindexed_other_list[i] = other_frames[
  modin/modin/core/dataframe/pandas/partitioning/partition_manager.py(573)map_axis_partitions()
-> return cls.broadcast_axis_partitions(
> modin/modin/core/dataframe/pandas/partitioning/partition_manager.py(476)broadcast_axis_partitions()
0reactions
anmyachevcommented, Jul 13, 2022

Could you please describe what “reindexing” do you mean?

_copartition calls _join_index_objects, which finds the common index to cast the left and right operand to, but for fillna doesn’t need to do this (this is True for column reindexing). You can see my changes in https://github.com/modin-project/modin/pull/4674.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pandas fillna not working - Stack Overflow
Show activity on this post. Check this why fillna() while iterating over columns does not work. ... Commented lines seem to be working....
Read more >
fillna() does not work when value parameter is a list #3435
So it appears the values in the list are used to fill the 'holes' in order, if the list has the same length...
Read more >
pandas.Series.fillna — pandas 1.5.2 documentation
Fill NA /NaN values using the specified method. Value to use to fill holes (e.g. 0), alternately a dict/Series/DataFrame of values specifying which...
Read more >
pandas: Replace missing values (NaN) with fillna() - nkmk note
Series as the first argument value of fillna() , missing values of the corresponding column are replaced with the mean value.
Read more >
Pandas Fill NA – DataFrame.fillna() - Data Independent
Your data may have NAs (Not Available) values within your DataFrame. Think of these as blank, null, or not present values. Many pandas...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found