Skip to content

Conversation

mortada
Copy link
Contributor

@mortada mortada commented Apr 28, 2015

fixes #10002

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put the not implemented yet first? (and maybe also explicitely "for Categorical")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, will update

@jorisvandenbossche
Copy link
Member

Actually, in the way I interpret "maximum size gap to forward or backward fill", this is not fully correct.

I interpret it as "only fill that gap if the gap is not larger as 'limit'", but it is "per gap, fill a maximum numbers of 'limit'":

In [10]: s=pd.Series(range(4), index=[1,2,5,9])

In [11]: s = s.reindex(range(10))

In [12]: s
Out[12]:
0   NaN
1     0
2     1
3   NaN
4   NaN
5     2
6   NaN
7   NaN
8   NaN
9     3
dtype: float64

In [13]: s.fillna(method='ffill', limit=2)
Out[13]:
0   NaN
1     0
2     1
3     1
4     1
5     2
6     2
7     2
8   NaN
9     3
dtype: float64

@mortada
Copy link
Contributor Author

mortada commented Apr 29, 2015

What if we rephrase it to say something like:

"maximum number of consecutive holes to forward or backward fill"

@jreback jreback added the Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate label Apr 29, 2015
@jreback jreback added this to the 0.16.1 milestone Apr 29, 2015
@jreback
Copy link
Contributor

jreback commented Apr 29, 2015

lgtm

@jorisvandenbossche
Copy link
Member

It is a bit subjective, but I would personally still interpret that not fully correct (I see a hole as possibly multiple NaN values if they are consecutive, but maybe this is not correct language?).
Otherwise: "maximum number of consecutive NaN values to forward/backward file per hole"

I think an example in the docstring to show this behaviour would possibly be the most clarifying.

@mortada
Copy link
Contributor Author

mortada commented Apr 29, 2015

Ah yeah I suppose you could interpret a "hole" as multiple NaNs. @jorisvandenbossche please see the updated changes in the diff, I wonder if it's now clear to you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small nitpick: maybe "along the entire axis"

For the rest everything clear now! Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure definitely more clear now, thanks!

jorisvandenbossche added a commit that referenced this pull request Apr 29, 2015
DOC: improve fillna() doc for limit keyword (fixes #10002)
@jorisvandenbossche jorisvandenbossche merged commit e3c7862 into pandas-dev:master Apr 29, 2015
@jorisvandenbossche
Copy link
Member

Thanks!

@mortada mortada deleted the fillna_doc_fix branch April 29, 2015 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage of 'limit' keyword when filling with a value

3 participants