piel.units.string
=================

.. py:module:: piel.units.string


Functions
---------

.. autoapisummary::

   piel.units.string.prefix2int
   piel.units.string.match_unit_abbreviation


Module Contents
---------------

.. py:function:: prefix2int(s: str) -> int

   Converts a string with a number and optional suffix into an integer.

   Supported suffixes:
       'k' or 'K' - Thousand
       'm' or 'M' - Million
       'b' or 'B' - Billion
       't' or 'T' - Trillion

   .. rubric:: Examples

   '17.03k' -> 17030
   '17K'    -> 17000
   '2.5M'   -> 2500000
   '500'    -> 500
   '-3.2B'  -> -3200000000

   :param s: The string to convert.
   :type s: str

   :returns: The integer representation of the input string.
   :rtype: int

   :raises ValueError: If the string format is invalid or contains unsupported suffixes.


.. py:function:: match_unit_abbreviation(unit_str: str) -> piel.types.units.Unit

   Matches a unit string to a predefined Unit instance.

   :param unit_str: The unit abbreviation extracted from a column name (e.g., "s", "v", "dB").
   :type unit_str: str

   :returns: The corresponding Unit instance.
   :rtype: Unit

   :raises ValueError: If the unit string does not match any predefined units.


