Skip to content

BUG: DatetimeIndex.delete with tz raises ValueError #7608

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
Jul 3, 2014

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Jun 29, 2014

Found and fixed DatetimeIndex.delete (#7302) results in ValueError when it has tz and freq is less than daily..

idx = pd.date_range(start='2011-01-01 09:00', periods=40, freq='H', tz='Asia/Tokyo')
idx.delete(0)
# ValueError: Inferred frequency None from passed dates does notconform to passed frequency H

insert (#7299) and take don't have problems, but changed test case to use hourly frequencies to detect this kind of problem.

@@ -1645,7 +1645,8 @@ def delete(self, loc):
freq = self.freq

if self.tz is not None:
new_dates = tslib.date_normalize(new_dates, self.tz)
f = lambda x: tslib.tz_convert_single(x, 'UTC', self.tz)
new_dates = np.vectorize(f)(new_dates)
Copy link
Contributor

Choose a reason for hiding this comment

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

any better way to do this?
this is pretty slow

Copy link
Member Author

Choose a reason for hiding this comment

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

Using tslib.tz_convert is better to handle array. But it looks having a bug in DST I don't fully understand. I'll try to dig in.

@jreback jreback added this to the 0.14.1 milestone Jun 29, 2014
@jreback
Copy link
Contributor

jreback commented Jul 1, 2014

@sinhrks update?

@sinhrks
Copy link
Member Author

sinhrks commented Jul 3, 2014

@jreback updated to use tz_convert_with_transition.

jreback added a commit that referenced this pull request Jul 3, 2014
BUG: DatetimeIndex.delete with tz raises ValueError
@jreback jreback merged commit 03bbed5 into pandas-dev:master Jul 3, 2014
@jreback
Copy link
Contributor

jreback commented Jul 3, 2014

gr8 thanks!

@sinhrks sinhrks deleted the delete2 branch July 5, 2014 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Frequency DateOffsets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants