Skip to content

BUG: Series.fillna is altering None values of unspecified columns #40498

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

Open
2 tasks done
RSchweiger opened this issue Mar 18, 2021 · 6 comments
Open
2 tasks done

BUG: Series.fillna is altering None values of unspecified columns #40498

RSchweiger opened this issue Mar 18, 2021 · 6 comments
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Series Series data structure

Comments

@RSchweiger
Copy link

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandas (1.0.5)

series = pd.Series({'1':1,'2':None,'3':np.nan, '4':''})

will create a series which looks like:

1       1
2    None
3     NaN
4        
dtype: object

When using the fillna method on this series on index 3 it changes also the entry in index 2!

series.fillna({'3':0})

This will result in a output as follows:

1      1
2    NaN
3      0
4       
dtype: object

Problem:
The value at index 2 changed from None to NaN.

Expected Behaviour:
The value at index 2 should never be touched when using fillna and specifying the indices you want to alter.

@mzeitlin11
Copy link
Member

Hi @RSchweiger, thanks for the clear report! I can reproduce this on current master, investigations welcome to fix.

@mzeitlin11 mzeitlin11 added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Series Series data structure labels Mar 18, 2021
@mzeitlin11 mzeitlin11 added this to the Contributions Welcome milestone Mar 18, 2021
@jreback
Copy link
Contributor

jreback commented Mar 23, 2021

I don't buy this is a bug at all: #40509 (review)

@ghost
Copy link

ghost commented Jul 27, 2021

@jreback @RSchweiger @mzeitlin11 I saw that this is still reproducible on Master, labeled as a 'Bug', and Unassigned. I was wondering if I could work on this?

@mzeitlin11
Copy link
Member

Go ahead! Commentary in #40509 might be helpful.

@ghost
Copy link

ghost commented Jul 27, 2021

take

@github-actions github-actions bot assigned ghost Jul 27, 2021
@jreback jreback modified the milestones: Contributions Welcome, 1.4 Aug 4, 2021
@ghost ghost removed their assignment Oct 26, 2021
@simonjayhawkins simonjayhawkins removed this from the 1.4 milestone Jan 20, 2022
@simonjayhawkins
Copy link
Member

removed milestone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Series Series data structure
Projects
None yet
4 participants