Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,21 @@ def transpose(self: _T, *args, **kwargs) -> _T:
def shape(self) -> Shape:
"""
Return a tuple of the shape of the underlying data.

Returns
--------
tuple
Shape of the Series.

See Also
--------
Series.size : Returns the size of the Series as an int.

Examples
--------
>>> s = pd.Series(['Cat', 'Dog', 'Cow', 'Zebra', 'Monkey'])
>>> s.shape
(5,)
"""
return self._values.shape

Expand Down Expand Up @@ -360,6 +375,21 @@ def nbytes(self) -> int:
def size(self) -> int:
"""
Return the number of elements in the underlying data.

Returns
--------
int
Size of the array.

See Also
--------
Series.shape : Returns the shape of the Series as a tuple.

Examples
--------
>>> s = pd.Series(['Cat', 'Dog', 'Cow', 'Zebra', 'Monkey'])
>>> s.size
5
"""
return len(self._values)

Expand Down Expand Up @@ -771,6 +801,17 @@ def hasnans(self) -> bool:
Return True if there are any NaNs.

Enables various performance speedups.

Returns
--------
bool
Whether the Series contains a NaN.

Examples
--------
>> s = pd.Series([0, 1, np.nan, 3, 4])
>> s.hasnans
True
"""
# error: Item "bool" of "Union[bool, ndarray[Any, dtype[bool_]], NDFrame]"
# has no attribute "any"
Expand Down
31 changes: 31 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,44 @@ def _can_hold_na(self) -> bool:
def dtype(self) -> DtypeObj:
"""
Return the dtype object of the underlying data.

Returns
--------
dtype
dtype of the underlying data.

See Also
--------
Series.dtypes : Returns the dtype object of the underlying data.

Examples
--------
>> s = pd.Series([0, 1, 2, 3, 4])
>> s.dtype
dtype('int64')
"""
return self._mgr.dtype

@property
def dtypes(self) -> DtypeObj:
"""
Return the dtype object of the underlying data.

Returns
--------
dtype
dtype of the underlying data.

See Also
--------
Series.dtype : Returns the dtype object of the underlying data, normally used
for DataFrames.

Examples
--------
>> s = pd.Series([0, 1, 2, 3, 4])
>> s.dtypes
dtype('int64')
"""
# DataFrame compatibility
return self.dtype
Expand Down