Giter Site home page Giter Site logo

Comments (5)

phofl avatar phofl commented on July 3, 2024 1

the doc string is incorrect, sorry about this

the behaviour is correct

from pandas.

rhshadrach avatar rhshadrach commented on July 3, 2024

Thanks for the report. I'd guess that this is the intention as integers with NA values cannot be stored in a NumPy array (they would be coerced to float or object). If that is the case, the docstring could be improved to include this (or a more generic description of it).

This was originally added in #50505; @phofl - was this case considered?

from pandas.

luke396 avatar luke396 commented on July 3, 2024

take

from pandas.

luke396 avatar luke396 commented on July 3, 2024

It is observed that the resulting data type is not solely dependent on the presence of NaN values.

ser2 = pd.Series(['150.0', '2'])
print(pd.to_numeric(ser2, dtype_backend='numpy_nullable'))
print(pd.to_numeric(ser2, dtype_backend='pyarrow'))
print(pd.to_numeric(ser2))

# 0    150.0
# 1      2.0
# dtype: Float64
# 0    150.0
# 1      2.0
# dtype: double[pyarrow]
# 0    150.0
# 1      2.0
# dtype: float64

The default dtype_backend value of NO_DEFAULT does not yield results similar to those obtained with numpy_nullable or pyarrow.

dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,

values, new_mask = lib.maybe_convert_numeric( # type: ignore[call-overload]
values,
set(),
coerce_numeric=coerce_numeric,
convert_to_masked_nullable=dtype_backend is not lib.no_default
or isinstance(values_dtype, StringDtype)
and not values_dtype.storage == "pyarrow_numpy",
)

from pandas.

rhshadrach avatar rhshadrach commented on July 3, 2024

Good find @luke396 - this documentation became incorrect in #54104. We should fix that as well!

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.