Skip to content

Conversation

Staudinger0325
Copy link

Added a Helper Function parse_numeric:

Introduced a new internal function parse_numeric that attempts to parse strings with base prefixes:
Uses int(value, 0) to automatically detect the numerical base from the string prefix.
If parsing as an integer fails, it attempts to parse the value as a float.
Returns libmissing.NA if both parsing attempts fail.

Modified the Parsing Logic in to_numeric:

Replaced the call to lib.maybe_convert_numeric with a loop that applies parse_numeric to each element.
Handles errors according to the errors parameter:
Raises a ValueError with informative messaging when errors='raise'.
Sets unparseable values to NaN when errors='coerce'.
Utilizes a mask (new_mask) to track which values could not be parsed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant