Skip to content

BUG: DatetimeIndex with freq raises ValueError when passed value is short #7098

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

Merged
merged 1 commit into from
May 14, 2014

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented May 11, 2014

When DatetimeIndex is created by passing freq and check_integrity=True, passed freq and inferred_freq must be identical. But this comparison can fail if length of passed data doesn't have enough length to infer freq.

Added additional logic to determine whether passed values are on the passed freq.

@@ -648,7 +648,8 @@ def infer_freq(index, warn=True):
raise TypeError("cannot infer freq from a non-convertible index type {0}".format(type(index)))
index = index.values

index = pd.DatetimeIndex(index)
if not isinstance(index, pd.DatetimeIndex):
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this necessary? it should just fall thru

Copy link
Member Author

Choose a reason for hiding this comment

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

Not required, removed. (Required in original implementation which I tried to...)

@jreback jreback added this to the 0.14.1 milestone May 12, 2014
@jreback
Copy link
Contributor

jreback commented May 13, 2014

this is fine, rebase and can go in

@jreback jreback modified the milestones: 0.14.0, 0.14.1 May 13, 2014
@jreback jreback merged commit 21bdd1e into pandas-dev:master May 14, 2014
@jreback
Copy link
Contributor

jreback commented May 14, 2014

thanks!

@sinhrks sinhrks deleted the setfreq branch May 14, 2014 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants