Skip to content

Cannot convert a datetimelike to 'str' with astype #9757

Closed
@wavexx

Description

@wavexx

I find this surprising:

import pandas as pd
pd.Series([pd.Timestamp('2010-01-04 00:00:00')]).astype(str)
TypeError: cannot astype a datetimelike from [datetime64[ns]] to [|S0]

str(pd.Timestamp) works though, so why astype shouldn't?
Also the type representation "|S0" is not entirely clear to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions