Numpy Chararray对象

创建chararray对象

>>> charar = np.chararray((3, 3))
>>> charar[:] = 'a'
>>> charar
chararray([['a', 'a', 'a'],
       ['a', 'a', 'a'],
       ['a', 'a', 'a']],
      dtype='|S1')

属性

属性描述
TSame as self.transpose(), except that self is returned if self.ndim < 2.
baseBase object if memory is from some other object.
ctypesAn object to simplify the interaction of the array with the ctypes module.
dataPython buffer object pointing to the start of the array’s data.
dtypeData-type of the array’s elements.
flagsInformation about the memory layout of the array.
flatA 1-D iterator over the array.
imagThe imaginary part of the array.
itemsizeLength of one array element in bytes.
nbytesTotal bytes consumed by the elements of the array.
ndimNumber of array dimensions.
realThe real part of the array.
shapeTuple of array dimensions.
sizeNumber of elements in the array.
stridesTuple of bytes to step in each dimension when traversing an array.

方法

方法描述
astype(dtype[, order, casting, subok, copy])Copy of the array, cast to a specified type.
copy([order])Return a copy of the array.
count(sub[, start, end])Returns an array with the number of non-overlapping occurrences of substring sub in the range [start, end].
decode([encoding, errors])Calls str.decode element-wise.
dump(file)Dump a pickle of the array to the specified file.
dumps()Returns the pickle of the array as a string.
encode([encoding, errors])Calls str.encode element-wise.
endswith(suffix[, start, end])Returns a boolean array which is True where the string element in self ends with suffix, otherwise False.
expandtabs([tabsize])Return a copy of each string element where all tab characters are replaced by one or more spaces.
fill(value)Fill the array with a scalar value.
find(sub[, start, end])For each element, return the lowest index in the string where substring sub is found.
flatten([order])Return a copy of the array collapsed into one dimension.
getfield(dtype[, offset])Returns a field of the given array as a certain type.
index(sub[, start, end])Like find, but raises ValueError when the substring is not found.
isalnum()Returns true for each element if all characters in the string are alphanumeric and there is at least one character, false otherwise.
isalpha()Returns true for each element if all characters in the string are alphabetic and there is at least one character, false otherwise.
isdecimal()For each element in self, return True if there are only decimal characters in the element.
isdigit()Returns true for each element if all characters in the string are digits and there is at least one character, false otherwise.
islower()Returns true for each element if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
isnumeric()For each element in self, return True if there are only numeric characters in the element.
isspace()Returns true for each element if there are only whitespace characters in the string and there is at least one character, false otherwise.
istitle()Returns true for each element if the element is a titlecased string and there is at least one character, false otherwise.
isupper()Returns true for each element if all cased characters in the string are uppercase and there is at least one character, false otherwise.
item(*args)Copy an element of an array to a standard Python scalar and return it.
join(seq)Return a string which is the concatenation of the strings in the sequence seq.
ljust(width[, fillchar])Return an array with the elements of self left-justified in a string of length width.
lower()Return an array with the elements of self converted to lowercase.
lstrip([chars])For each element in self, return a copy with the leading characters removed.
nonzero()Return the indices of the elements that are non-zero.
put(indices, values[, mode])Set a.flat[n] = values[n] for all n in indices.
ravel([order])Return a flattened array.
repeat(repeats[, axis])Repeat elements of an array.
replace(old, new[, count])For each element in self, return a copy of the string with all occurrences of substring old replaced by new.
reshape(shape[, order])Returns an array containing the same data with a new shape.
resize(new_shape[, refcheck])Change shape and size of array in-place.
rfind(sub[, start, end])For each element in self, return the highest index in the string where substring sub is found, such that sub is contained within [start, end].
rindex(sub[, start, end])Like rfind, but raises ValueError when the substring sub is not found.
rjust(width[, fillchar])Return an array with the elements of self right-justified in a string of length width.
rsplit([sep, maxsplit])For each element in self, return a list of the words in the string, using sep as the delimiter string.
rstrip([chars])For each element in self, return a copy with the trailing characters removed.
searchsorted(v[, side, sorter])Find indices where elements of v should be inserted in a to maintain order.
setfield(val, dtype[, offset])Put a value into a specified place in a field defined by a data-type.
setflags([write, align, uic])Set array flags WRITEABLE, ALIGNED, and UPDATEIFCOPY, respectively.
sort([axis, kind, order])Sort an array, in-place.
split([sep, maxsplit])For each element in self, return a list of the words in the string, using sep as the delimiter string.
splitlines([keepends])For each element in self, return a list of the lines in the element, breaking at line boundaries.
squeeze([axis])Remove single-dimensional entries from the shape of a.
startswith(prefix[, start, end])Returns a boolean array which is True where the string element in self starts with prefix, otherwise False.
strip([chars])For each element in self, return a copy with the leading and trailing characters removed.
swapaxes(axis1, axis2)Return a view of the array with axis1 and axis2 interchanged.
swapcase()For each element in self, return a copy of the string with uppercase characters converted to lowercase and vice versa.
take(indices[, axis, out, mode])Return an array formed from the elements of a at the given indices.
title()For each element in self, return a titlecased version of the string: words start with uppercase characters, all remaining cased characters are lowercase.
tofile(fid[, sep, format])Write array to a file as text or binary (default).
tolist()Return the array as a (possibly nested) list.
tostring([order])Construct Python bytes containing the raw data bytes in the array.
translate(table[, deletechars])For each element in self, return a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table.
transpose(*axes)Returns a view of the array with axes transposed.
upper()Return an array with the elements of self converted to uppercase.
view([dtype, type])New view of array with the same data.
zfill(width)Return the numeric string left-filled with zeros in a string of length width.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值