Skip to content

API: expose to_numeric/to_datetime/to_timedelta methods on Series #15550

Closed
@jreback

Description

@jreback

if we have a string Series, e.g. s = Series(['2013-01-02', '2013-1-03'])

we normally just run this thru pd.to_datetime(s)

it might be convenient to do these operations (.to_numeric,.to_datetime,.to_timedelta)
directly as methods.

  • s.str.to_numeric(....) , IOW in the .str namespace
  • s.to_numeric(...), in main Series namespace
  • s.astype(.., dtype=...) but actually pass thru to using the .to_numeric/.to_datetime functions directly, so you could have something like
    s.astype('datetime', format='%Y-%m-%d') and it would do the right thing. This overloads things a bit though

right now we have a bit of confusion because we support .astype which is pretty much a pass thru to numpy, and the more dtype-aware (and functional) .to_* ones.

Furthermore I think we could update the .astype docs (and the .to_*) ones to cross reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballsEnhancementNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions