API¶
Cyberpandas provides two extension types, IPArray
and MACArray
.
IP Array
¶
-
class
cyberpandas.
IPArray
(values)¶ Holder for IP Addresses.
IPArray is a container for IPv4 or IPv6 addresses. It satisfies pandas’ extension array interface, and so can be stored inside
pandas.Series
andpandas.DataFrame
.See Usage for more.
Constructors¶
The class constructor is flexible, and accepts integers, strings, or bytes. Dedicated alternate constructors are also available.
-
classmethod
IPArray.
from_pyints
(values)¶ Construct an IPArray from a sequence of Python integers.
This can be useful for representing IPv6 addresses, which may be larger than 2**64.
Parameters: - values : Sequence
Sequence of Python integers.
Examples
>>> IPArray.from_pyints([0, 10, 2 ** 64 + 1]) IPArray(['0.0.0.1', '0.0.0.2', '0.0.0.3', '0:0:0:1::'])
-
classmethod
IPArray.
from_bytes
(bytestring)¶ Create an IPArray from a bytestring.
Parameters: - bytestring : bytes
Note that bytestring is a Python 3-style string of bytes, not a sequences of bytes where each element represents an IPAddress.
Returns: - IPArray
See also
Examples
>>> arr = IPArray([10, 20]) >>> buf = arr.to_bytes() >>> buf b'