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

Union of index with itself not invariant, sets frequency attribute #11086

Closed
multiloc opened this issue Sep 13, 2015 · 1 comment · Fixed by #11155
Closed

Union of index with itself not invariant, sets frequency attribute #11086

multiloc opened this issue Sep 13, 2015 · 1 comment · Fixed by #11155
Labels
Milestone

Comments

@multiloc
Copy link
Contributor

When creating the union of an index with itself, the frequency may end up being reset. I would have expected the call to union in the following example to be invariant and return the original index:

In [56]: index = pd.bdate_range('20150101', periods=10)
In [57]: index.freq = None
In [58]: index
Out[58]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2015-01-01, ..., 2015-01-14]
Length: 10, Freq: None, Timezone: None

In [59]: index.union(index)
Out[59]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2015-01-01, ..., 2015-01-14]
Length: 10, Freq: B, Timezone: None

This then propagates through to e.g. combine_first, which is also not invariant. This might be desirable behavior in some cases but definitely surprising imo.

@jreback
Copy link
Contributor

jreback commented Sep 13, 2015

so the case is an index that has idx.freq is None with another will NOT take the fast path, but then both compare equal. ok so far.

Then an infererence happens here

I suppose if both have incoming freq is None then don't need to infer.

Not sure what this would break though.

want to do a PR and see?

@jreback jreback added this to the Next Major Release milestone Sep 13, 2015
@jreback jreback modified the milestones: 0.17.0, Next Major Release Sep 20, 2015
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.

2 participants