3. Size, Shape & Type

static_frame.Series and static_frame.Frame store underlying data in one or two-dimensional NumPy arrays. Attributes similar to those found on NumPy arrays are available to describe the characteristics of the container.

3.1. Series

Series.shape

Return a tuple describing the shape of the underlying NumPy array.

Returns

tp.Tuple[int]

Series.ndim

Return the number of dimensions, which for a Series is always 1.

Returns

int

Series.size

Return the size of the underlying NumPy array.

Returns

int

Series.nbytes

Return the total bytes of the underlying NumPy array.

Returns

int

Series.dtype

Return the dtype of the underlying NumPy array.

Returns

numpy.dtype

3.1.1. Examples

>>> s = sf.Series((1, 2, 67, 62, 27, 14), index=('Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune'), dtype=np.int64)
>>> s
<Series>
<Index>
Earth    1
Mars     2
Jupiter  67
Saturn   62
Uranus   27
Neptune  14
<<U7>    <int64>
>>> s.shape
(6,)
>>> s.ndim
1
>>> s.size
6
>>> s.nbytes
48
>>> s.dtype
dtype('int64')

3.2. Frame

Frame.shape

Return a tuple describing the shape of the underlying NumPy array.

Returns

tp.Tuple[int]

Frame.ndim

Return the number of dimensions, which for a Frame is always 2.

Returns

int

Frame.size

Return the size of the underlying NumPy array.

Returns

int

Frame.nbytes

Return the total bytes of the underlying NumPy array.

Returns

int

Frame.dtypes

Return a Series of dytpes for each realizable column.

Returns

static_frame.Series

3.2.1. Examples

>>> f = sf.Frame.from_items((('diameter', (12756, 142984, 120536)), ('mass', (5.97, 1898, 568))), index=('Earth', 'Jupiter', 'Saturn'), dtypes=dict(diameter=np.int64))
>>> f
<Frame>
<Index> diameter mass      <<U8>
<Index>
Earth   12756    5.97
Jupiter 142984   1898.0
Saturn  120536   568.0
<<U7>   <int64>  <float64>
>>> f.shape
(3, 2)
>>> f.ndim
2
>>> f.size
6
>>> f.nbytes
48
>>> f.dtypes
<Series>
<Index>
diameter int64
mass     float64
<<U8>    <object>