Skip to content

BUG: reindex strange behaviour #4604

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

Closed
alefnula opened this issue Aug 18, 2013 · 4 comments · Fixed by #4610
Closed

BUG: reindex strange behaviour #4604

alefnula opened this issue Aug 18, 2013 · 4 comments · Fixed by #4610
Labels
Milestone

Comments

@alefnula
Copy link
Contributor

When I try to reindex a Series object I get a really weird result.

>>> s = pd.Series([1,2,3,4,5], index=['a', 'b', 'c', 'd', 'e'])
>>> s.reindex(['a', 'g', 'c', 'f'], method='ffill')
a     1
g     5
c   NaN
f     5
dtype: float64

According to the documentation I should have got something like:

a   1
g   1
c   3
f   3
dtype: float64

So either the documentation is not valid, or reindex is not working correctly or I haven't understood how this beast works?

@jreback
Copy link
Contributor

jreback commented Aug 18, 2013

is this master or 0.12?

@cpcloud
Copy link
Member

cpcloud commented Aug 18, 2013

Curious. @jreback Should this be a passing test?

(using @alefnula's s)

new_index = list('agcf')
assert_series_equal(s.reindex(new_index, method='ffill'), s.reindex(new_index).ffill())

@cpcloud
Copy link
Member

cpcloud commented Aug 18, 2013

this seems wrong

In [1]: s = Series(range(1,6),index=list(letters[:5]))

In [2]: new_index = list('agcf')

In [3]: s.index.get_indexer(new_index,method='pad')
Out[3]: array([ 0,  4, -1,  4])

@alefnula
Copy link
Contributor Author

I get the same behaviour on master and on 0.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants