Skip to content

Conversation

jbrockmendel
Copy link
Member

prelude to deprecating the astype behavior

)
self.times = np.asarray(times.astype(np.int64))
if isna(times).any():
raise ValueError("Cannot convert NaT values to integer")
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test for this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

double-checked and you're right we dont have any. suggestions for what this might look like?

Copy link
Member

Choose a reason for hiding this comment

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

Something simple like

with pytest.raises(ValueError, match=...):
     Series(range(1)).ewm(com=0.1, times=to_datetime(['NaT'])))

works.

@jreback jreback added Clean Datetime Datetime data dtype labels Dec 17, 2020
@jreback
Copy link
Contributor

jreback commented Dec 17, 2020

any perf benefits?

@jbrockmendel
Copy link
Member Author

any perf benefits?

maybe some call overhead, but the existing astype call is already doing view under the hood (which is not great)

@jreback jreback added this to the 1.3 milestone Dec 19, 2020
@jreback jreback merged commit 9b58415 into pandas-dev:master Dec 19, 2020
@jbrockmendel jbrockmendel deleted the ref-astype_nansafe-ints branch December 19, 2020 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Clean Datetime Datetime data dtype

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants