Skip to content

Series astype() doesn't convert int64 to datetime64 using M8[D] anymore #3969

Closed
@miketkelly

Description

@miketkelly

add units='D' to Timestamp/to_datetime epoch support

I have an int64 series representing days since epoch which I'd like to convert to datetime64.
This works in 11.0 but raises an exception in 0.11.1.dev-964516a. The exception message is "TypeError: cannot convert datetimelike to dtype [datetime64[D]]".

import pandas as pd
s = pd.Series([0,1,2])
print s.astype('M8[D]')

My workaround is:

import pandas as pd
s = pd.Series([0,1,2])
print pd.Series(s.values.astype('M8[D]'))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions