Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

interp can not handle datetime64, while fix seems easy #14941

Copy link
Copy link
Open
@mbakker7

Description

@mbakker7
Issue body actions

The interp function can not handle datetime64 dtypes (docs are not explicit about this; they state that x and xp should be values). Error message is that array cannot be cast to dtype('float64') according to the rule 'safe'. But conversion seems easy.

Reproducing code example:

import numpy as np
d1 = np.datetime64('2019-01-01')
d2 = np.datetime64('2019-01-03')
xp = np.array([d1, d2])
yp = np.array([1, 3])
x = np.datetime64('2019-01-02')
np.interp(x, xp, yp)  # produces error

while the following works fine

np.interp(x.astype('float64'), xp.astype('float64'), yp)

So why is that not done in the interp function?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.