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

BUG: raise exception on NaT in DatetimeIndex.astype('O') #1340 #1348

Closed
wants to merge 2 commits into from
Closed

BUG: raise exception on NaT in DatetimeIndex.astype('O') #1340 #1348

wants to merge 2 commits into from

Conversation

changhiskhan
Copy link
Contributor

No description provided.

@@ -513,6 +514,9 @@ def astype(self, dtype):
dtype = np.dtype(dtype)

if dtype == np.object_:
if isnull(self).any():
msg = 'DatetimeIndex with NaT cannot be converted to object'
raise ValueError(msg)
return self.asobject
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is the right place to fix this. Have you seen what asobject returns when you have NaT values?

@changhiskhan
Copy link
Contributor Author

@wesm, I think this makes more sense now: pushed the exception down to asobject and then iter will just call a lower level method that doesn't raise exception

@wesm wesm closed this Jun 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants