Giter Site home page Giter Site logo

Comments (6)

jbrockmendel avatar jbrockmendel commented on June 26, 2024

I'm very skeptical of making pd.to_datetime more complicated (both as an API and the implementation).

pd.to_datetime(ser).dt.to_period("D") is effectively a date dtype.

Alternately maybe we need to introduce a new pd.to_date

Side-note: I've been kicking around the idea of a pd.to.foo namespace to collect all of the to_foo functions, since the top-level namespace is pretty big. ATM to_offset and to_time are buried and could be included.

from pandas.

mroeschke avatar mroeschke commented on June 26, 2024

to_numeric had a dtype_backend keyword added in 2.0 IIRC. I wouldn't be opposed to adding that keyword to to_datetime for symmetry but return pa.timestamp types and not pa.date types.

from pandas.

jbrockmendel avatar jbrockmendel commented on June 26, 2024

I wasnt aware of the keyword in to_numeric; I would have been -0.75 on that.

In to_datetime it has the added downside of complicating the return type (not just dtype). The base case to_datetime returns a DatetimeIndex. A keyword would change that to be a base class Index.

.convert_dtypes already works for the timestamp dtypes. One Obvious Way.

from pandas.

WillAyd avatar WillAyd commented on June 26, 2024

I also think dtype_backend here is a partial solution that doesn't necessarily clarify how to accomplish the task the best way.

pd.to_datetime(ser).dt.to_period("D") is effectively a date dtype.

That's in interesting idea but I think would be really tough to roundtrip and use effectively with our I/O

AFAIU the only way to specifically get a non-object date in this case is to ser.astype(pd.ArrowDtype(pa.date32())) - is that correct?

from pandas.

mroeschke avatar mroeschke commented on June 26, 2024

AFAIU the only way to specifically get a non-object date in this case is to ser.astype(pd.ArrowDtype(pa.date32())) - is that correct?

Correct

from pandas.

mroeschke avatar mroeschke commented on June 26, 2024

.convert_dtypes already works for the timestamp dtypes. One Obvious Way.

This is a good point. to_numeric with dtype_backend="pyarrow" essentially astypes from nullable numpy types to arrow types which is covered by convert_dtypes

from pandas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.