Convert a Pandas series from 64 bit types to 32 bit types to save
    memory or disk space.

    Parameters
    ----------
    s : The series to convert

    Returns
    -------
    The converted series
483440
def series64bitto32bit(s):
    
    if s.dtype == np.float64:
        return s.astype('float32')
    elif s.dtype == np.int64:
        return s.astype('int32')
    return s
495857
def to_ansi_8bit(self):
        
        res = []
        for i in self.parts:
            res.append(i.to_ansi_8bit())
        return ''.join(res).encode('utf8')
974681
def _convert_option(self):
        '''
        
        '''
        data_endian = 'little'
        if (self._encoding == 1 or self._encoding == 2 or self._encoding == 5 or
            self._encoding == 7 or self._encoding == 9 or self._encoding == 11 or
                self._encoding == 12 or self._encoding == 18):
            data_endian = 'big'
        if sys.byteorder == 'little' and data_endian == 'big':
            # big->little
            order = '>'
        elif sys.byteorder == 'big' and data_endian == 'little':
            # little->big
            order = '<'
        else:
            # no conversion
            order = '='

        return order
593147
def to_bytes(s):
    '''
    '''
    if isinstance(s, six.binary_type):
        return s
    if isinstance(s, six.string_types):
        return s.encode('utf-8')
    raise TypeError('want string or bytes, got {}', type(s))
313609
def _string_to_int(self, s):
        
        base = len(self.alphabet)
        return sum((self._letter_to_int(l) * base**lsb 
                    for lsb, l in enumerate(s)
                   ))
773445
def deserialize_bitarray(ser):
    # type: (str) -> bitarray
    
    ba = bitarray()
    ba.frombytes(base64.b64decode(ser.encode(encoding='UTF-8', errors='strict')))
    return ba
819443
def _convert_to_scale(self):
        
        d = self._d
        s = (self._s - self._offset) % 86400.
        d -= int((s + self._offset) // 86400)
        return d, s
1130861
def _convert_series(self, metric, ts):
        """"""
        series = monitoring_v3.types.TimeSeries()
        series.metric.type = self.get_metric_type(metric.descriptor)

        for lk, lv in self.options.default_monitoring_labels.items():
            series.metric.labels[lk.key] = lv.value

        for key, val in zip(metric.descriptor.label_keys, ts.label_values):
            if val.value is not None:
                safe_key = sanitize_label(key.key)
                series.metric.labels[safe_key] = val.value

        set_monitored_resource(series, self.options.resource)

        for point in ts.points:
            sd_point = series.points.add()
            # this just modifies points, no return
            self._convert_point(metric, ts, point, sd_point)
        return series
854432
def to_number(s):
    
    ret = s
    # try converting to float
    try:
        ret = float(s)
    except ValueError:
        ret = ret.strip('\'').strip()

    # try converting to uid
    try:
        ret = int(s)
    except ValueError:
        pass

    # try converting to boolean
    if ret == 'True':
        ret = True
    elif ret == 'False':
        ret = False
    elif ret == 'None':
        ret = None
    return ret
68264
def to_ansi_24bit(self):
        
        res = []
        for i in self.parts:
            res.append(i.to_ansi_24bit())
        return ''.join(res).encode('utf8')
420008
def writeBytes(self, s):
        
        l = len(s)

        if l > 0xffff:
            self.writeType(TYPE_LONGSTRING)
        else:
            self.writeType(TYPE_STRING)

        if l > 0xffff:
            self.stream.write_ulong(l)
        else:
            self.stream.write_ushort(l)

        self.stream.write(s)
752658
def deserialize_number(s, fmt=SER_BINARY):
    
    ret = gmpy.mpz(0)
    if fmt == SER_BINARY:
        if isinstance(s, six.text_type):
            raise ValueError(
                "Encode `s` to a bytestring yourself to" +
                " prevent problems with different default encodings")
        for c in s:
            ret *= 256
            ret += byte2int(c)
        return ret
    assert fmt == SER_COMPACT
    if isinstance(s, six.text_type):
        s = s.encode('ascii')
    for c in s:
        ret *= len(COMPACT_DIGITS)
        ret += R_COMPACT_DIGITS[c]
    return ret
312998
def _int_size_to_type(size):
    
    if size <= 8:
        return ByteType
    if size <= 16:
        return ShortType
    if size <= 32:
        return IntegerType
    if size <= 64:
        return LongType
1106221
def hex_to_bytes(s):
    
    if len(s) % 2:
        s = b'0' + s
    ia = [int(s[i:i+2], 16) for i in range(0, len(s), 2)]   # int array
    return bs(ia) if PYTHON_MAJOR_VER == 3 else b''.join([chr(c) for c in ia])
235103
def to_bytes(s, encoding=None, errors='strict'):
    """"""
    encoding = encoding or 'utf-8'

    if is_unicode(s):
        return s.encode(encoding, errors)
    elif is_strlike(s):
        return s
    else:
        if six.PY2:
            return str(s)
        else:
            return str(s).encode(encoding, errors)
188615
def to_bytes(s, encoding="utf-8"):
    """"""
    if isinstance(s, six.binary_type):
        return s
    if six.PY3:
        return bytes(s, encoding)
    return s.encode(encoding)
565508
def cast_bytes(s, encoding='utf8', errors='strict'):
    """"""
    if isinstance(s, bytes):
        return s
    elif isinstance(s, str):
        return s.encode(encoding, errors)
    else:
        raise TypeError("Expected unicode or bytes, got %r" % s)