A byte string.
tf.experimental.numpy.string_(
*args, **kwargs
)
When used in arrays, this type strips trailing null bytes.
:Character code: 'S' :Alias: numpy.string_
| Attributes | |
|---|---|
T | Scalar attribute identical to the corresponding array attribute. Please see |
base | Scalar attribute identical to the corresponding array attribute. Please see |
data | Pointer to start of data. |
dtype | Get array data-descriptor. |
flags | The integer value of flags. |
flat | A 1-D view of the scalar. |
imag | The imaginary part of the scalar. |
itemsize | The length of one element in bytes. |
nbytes | The length of the scalar in bytes. |
ndim | The number of array dimensions. |
real | The real part of the scalar. |
shape | Tuple of array dimensions. |
size | The number of elements in the gentype. |
strides | Tuple of bytes steps in each dimension. |
allall()
Scalar method identical to the corresponding array attribute.
Please see ndarray.all.
anyany()
Scalar method identical to the corresponding array attribute.
Please see ndarray.any.
argmaxargmax()
Scalar method identical to the corresponding array attribute.
Please see ndarray.argmax.
argminargmin()
Scalar method identical to the corresponding array attribute.
Please see ndarray.argmin.
argsortargsort()
Scalar method identical to the corresponding array attribute.
Please see ndarray.argsort.
astypeastype()
Scalar method identical to the corresponding array attribute.
Please see ndarray.astype.
byteswapbyteswap()
Scalar method identical to the corresponding array attribute.
Please see ndarray.byteswap.
capitalizecapitalize()
B.capitalize() -> copy of B
Return a copy of B with only its first character capitalized (ASCII) and the rest lower-cased.
centercenter(
width, fillchar, /
)
Return a centered string of length width.
Padding is done using the specified fill character.
choosechoose()
Scalar method identical to the corresponding array attribute.
Please see ndarray.choose.
clipclip()
Scalar method identical to the corresponding array attribute.
Please see ndarray.clip.
compresscompress()
Scalar method identical to the corresponding array attribute.
Please see ndarray.compress.
conjconj()
conjugateconjugate()
Scalar method identical to the corresponding array attribute.
Please see ndarray.conjugate.
copycopy()
Scalar method identical to the corresponding array attribute.
Please see ndarray.copy.
countcount()
B.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of subsection sub in bytes B[start:end]. Optional arguments start and end are interpreted as in slice notation.
cumprodcumprod()
Scalar method identical to the corresponding array attribute.
Please see ndarray.cumprod.
cumsumcumsum()
Scalar method identical to the corresponding array attribute.
Please see ndarray.cumsum.
decodedecode(
encoding='utf-8', errors='strict'
)
Decode the bytes using the codec registered for encoding.
encoding The encoding with which to decode the bytes. errors The error handling scheme to use for the handling of decoding errors. The default is 'strict' meaning that decoding errors raise a UnicodeDecodeError. Other possible values are 'ignore' and 'replace' as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.
diagonaldiagonal()
Scalar method identical to the corresponding array attribute.
Please see ndarray.diagonal.
dumpdump()
Scalar method identical to the corresponding array attribute.
Please see ndarray.dump.
dumpsdumps()
Scalar method identical to the corresponding array attribute.
Please see ndarray.dumps.
endswithendswith()
B.endswith(suffix[, start[, end]]) -> bool
Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.
expandtabsexpandtabs(
tabsize=8
)
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
fillfill()
Scalar method identical to the corresponding array attribute.
Please see ndarray.fill.
findfind()
B.find(sub[, start[, end]]) -> int
Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
flattenflatten()
Scalar method identical to the corresponding array attribute.
Please see ndarray.flatten.
fromhexfromhex()
Create a bytes object from a string of hexadecimal numbers.
Spaces between two numbers are accepted. Example: bytes.fromhex('B9 01EF') -> b'\xb9\x01\xef'.
getfieldgetfield()
Scalar method identical to the corresponding array attribute.
Please see ndarray.getfield.
hexhex()
Create a str of hexadecimal numbers from a bytes object.
sep An optional single character or byte to separate hex bytes. bytes_per_sep How many bytes between separators. Positive values count from the right, negative values count from the left.
value = b'\xb9\x01\xef'
value.hex()
'b901ef'
value.hex(':')
'b9:01:ef'
value.hex(':', 2)
'b9:01ef'
value.hex(':', -2)
'b901:ef'indexindex()
B.index(sub[, start[, end]]) -> int
Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the subsection is not found.
isalnumisalnum()
B.isalnum() -> bool
Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.
isalphaisalpha()
B.isalpha() -> bool
Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.
isasciiisascii()
B.isascii() -> bool
Return True if B is empty or all characters in B are ASCII, False otherwise.
isdigitisdigit()
B.isdigit() -> bool
Return True if all characters in B are digits and there is at least one character in B, False otherwise.
islowerislower()
B.islower() -> bool
Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.
isspaceisspace()
B.isspace() -> bool
Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.
istitleistitle()
B.istitle() -> bool
Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.
isupperisupper()
B.isupper() -> bool
Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.
itemitem()
Scalar method identical to the corresponding array attribute.
Please see ndarray.item.
itemsetitemset()
Scalar method identical to the corresponding array attribute.
Please see ndarray.itemset.
joinjoin(
iterable_of_bytes, /
)
Concatenate any number of bytes objects.
The bytes whose method is called is inserted in between each pair.
The result is returned as a new bytes object.
Example: b'.'.join([b'ab', b'pq', b'rs']) -> b'ab.pq.rs'.
ljustljust(
width, fillchar, /
)
Return a left-justified string of length width.
Padding is done using the specified fill character.
lowerlower()
B.lower() -> copy of B
Return a copy of B with all ASCII characters converted to lowercase.
lstriplstrip(
bytes, /
)
Strip leading bytes contained in the argument.
If the argument is omitted or None, strip leading ASCII whitespace.
maketransmaketrans(
frm, to, /
)
Return a translation table useable for the bytes or bytearray translate method.
The returned table will be one where each byte in frm is mapped to the byte at the same position in to.
The bytes objects frm and to must be of the same length.
maxmax()
Scalar method identical to the corresponding array attribute.
Please see ndarray.max.
meanmean()
Scalar method identical to the corresponding array attribute.
Please see ndarray.mean.
minmin()
Scalar method identical to the corresponding array attribute.
Please see ndarray.min.
newbyteordernewbyteorder()
newbyteorder(new_order='S', /)
Return a new dtype with a different byte order.
Changes are also made in all fields and sub-arrays of the data type.
The new_order code can be any from the following:
new_order : str, optional Byte order to force; a value from the byte order specifications above. The default value ('S') results in swapping the current byte order.
new_dtype : dtype New dtype object with the given change to the byte order.
nonzerononzero()
Scalar method identical to the corresponding array attribute.
Please see ndarray.nonzero.
partitionpartition(
sep, /
)
Partition the bytes into three parts using the given separator.
This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.
prodprod()
Scalar method identical to the corresponding array attribute.
Please see ndarray.prod.
ptpptp()
Scalar method identical to the corresponding array attribute.
Please see ndarray.ptp.
putput()
Scalar method identical to the corresponding array attribute.
Please see ndarray.put.
ravelravel()
Scalar method identical to the corresponding array attribute.
Please see ndarray.ravel.
removeprefixremoveprefix(
prefix, /
)
Return a bytes object with the given prefix string removed if present.
If the bytes starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original bytes.
removesuffixremovesuffix(
suffix, /
)
Return a bytes object with the given suffix string removed if present.
If the bytes ends with the suffix string and that suffix is not empty, return bytes[:-len(prefix)]. Otherwise, return a copy of the original bytes.
repeatrepeat()
Scalar method identical to the corresponding array attribute.
Please see ndarray.repeat.
replacereplace(
old, new, count, /
)
Return a copy with all occurrences of substring old replaced by new.
count Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
reshapereshape()
Scalar method identical to the corresponding array attribute.
Please see ndarray.reshape.
resizeresize()
Scalar method identical to the corresponding array attribute.
Please see ndarray.resize.
rfindrfind()
B.rfind(sub[, start[, end]]) -> int
Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
rindexrindex()
B.rindex(sub[, start[, end]]) -> int
Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.
Raise ValueError when the subsection is not found.
rjustrjust(
width, fillchar, /
)
Return a right-justified string of length width.
Padding is done using the specified fill character.
roundround()
Scalar method identical to the corresponding array attribute.
Please see ndarray.round.
rpartitionrpartition(
sep, /
)
Partition the bytes into three parts using the given separator.
This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.
rsplitrsplit(
sep=None, maxsplit=-1
)
Return a list of the sections in the bytes, using sep as the delimiter.
sep The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab). maxsplit Maximum number of splits to do. -1 (the default value) means no limit.
Splitting is done starting at the end of the bytes and working to the front.
rstriprstrip(
bytes, /
)
Strip trailing bytes contained in the argument.
If the argument is omitted or None, strip trailing ASCII whitespace.
searchsortedsearchsorted()
Scalar method identical to the corresponding array attribute.
Please see ndarray.searchsorted.
setfieldsetfield()
Scalar method identical to the corresponding array attribute.
Please see ndarray.setfield.
setflagssetflags()
Scalar method identical to the corresponding array attribute.
Please see ndarray.setflags.
sortsort()
Scalar method identical to the corresponding array attribute.
Please see ndarray.sort.
splitsplit(
sep=None, maxsplit=-1
)
Return a list of the sections in the bytes, using sep as the delimiter.
sep The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab). maxsplit Maximum number of splits to do. -1 (the default value) means no limit.
splitlinessplitlines(
keepends=False
)
Return a list of the lines in the bytes, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
squeezesqueeze()
Scalar method identical to the corresponding array attribute.
Please see ndarray.squeeze.
startswithstartswith()
B.startswith(prefix[, start[, end]]) -> bool
Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.
stdstd()
Scalar method identical to the corresponding array attribute.
Please see ndarray.std.
stripstrip(
bytes, /
)
Strip leading and trailing bytes contained in the argument.
If the argument is omitted or None, strip leading and trailing ASCII whitespace.
sumsum()
Scalar method identical to the corresponding array attribute.
Please see ndarray.sum.
swapaxesswapaxes()
Scalar method identical to the corresponding array attribute.
Please see ndarray.swapaxes.
swapcaseswapcase()
B.swapcase() -> copy of B
Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.
taketake()
Scalar method identical to the corresponding array attribute.
Please see ndarray.take.
titletitle()
B.title() -> copy of B
Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.
tobytestobytes()
tofiletofile()
Scalar method identical to the corresponding array attribute.
Please see ndarray.tofile.
tolisttolist()
Scalar method identical to the corresponding array attribute.
Please see ndarray.tolist.
tostringtostring()
Scalar method identical to the corresponding array attribute.
Please see ndarray.tostring.
tracetrace()
Scalar method identical to the corresponding array attribute.
Please see ndarray.trace.
translatetranslate(
table, /, delete=b''
)
Return a copy with each character mapped by the given translation table.
table Translation table, which must be a bytes object of length 256.
All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.
transposetranspose()
Scalar method identical to the corresponding array attribute.
Please see ndarray.transpose.
upperupper()
B.upper() -> copy of B
Return a copy of B with all ASCII characters converted to uppercase.
varvar()
Scalar method identical to the corresponding array attribute.
Please see ndarray.var.
viewview()
Scalar method identical to the corresponding array attribute.
Please see ndarray.view.
zfillzfill(
width, /
)
Pad a numeric string with zeros on the left, to fill a field of the given width.
The original string is never truncated.
__abs____abs__()
abs(self)
__add____add__(
value, /
)
Return self+value.
__and____and__(
value, /
)
Return self&value.
__array____array__()
sc.array(dtype) return 0-dim array from scalar with specified dtype
__bool____bool__()
True if self else False
__contains____contains__(
key, /
)
Return key in self.
__eq____eq__(
value, /
)
Return self==value.
__floordiv____floordiv__(
value, /
)
Return self//value.
__ge____ge__(
value, /
)
Return self>=value.
__getitem____getitem__(
key, /
)
Return self[key].
__gt____gt__(
value, /
)
Return self>value.
__invert____invert__()
~self
__iter____iter__()
Implement iter(self).
__le____le__(
value, /
)
Return self<=value.
__len____len__()
Return len(self).
__lshift____lshift__(
value, /
)
Return self<<value.
__lt____lt__(
value, /
)
Return self<value.
__mod____mod__(
value, /
)
Return self%value.
__mul____mul__(
value, /
)
Return self*value.
__ne____ne__(
value, /
)
Return self!=value.
__neg____neg__()
-self
__or____or__(
value, /
)
Return self|value.
__pos____pos__()
+self
__pow____pow__(
value, mod, /
)
Return pow(self, value, mod).
__radd____radd__(
value, /
)
Return value+self.
__rand____rand__(
value, /
)
Return value&self.
__rfloordiv____rfloordiv__(
value, /
)
Return value//self.
__rlshift____rlshift__(
value, /
)
Return value<<self.
__rmod____rmod__(
value, /
)
Return value%self.
__rmul____rmul__(
value, /
)
Return value*self.
__ror____ror__(
value, /
)
Return value|self.
__rpow____rpow__(
value, mod, /
)
Return pow(value, self, mod).
__rrshift____rrshift__(
value, /
)
Return value>>self.
__rshift____rshift__(
value, /
)
Return self>>value.
__rsub____rsub__(
value, /
)
Return value-self.
__rtruediv____rtruediv__(
value, /
)
Return value/self.
__rxor____rxor__(
value, /
)
Return value^self.
__sub____sub__(
value, /
)
Return self-value.
__truediv____truediv__(
value, /
)
Return self/value.
__xor____xor__(
value, /
)
Return self^value.
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/experimental/numpy/string_