Skip to content

Commit 60e3dc2

Browse files
committed
revise docstring for several functions and properties
1 parent 52cffa3 commit 60e3dc2

File tree

2 files changed

+84
-21
lines changed

2 files changed

+84
-21
lines changed

pandas/core/frame.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -2432,8 +2432,8 @@ def eval(self, expr, inplace=False, **kwargs):
24322432
return _eval(expr, inplace=inplace, **kwargs)
24332433

24342434
def select_dtypes(self, include=None, exclude=None):
2435-
"""Return a subset of a DataFrame including/excluding columns based on
2436-
their ``dtype``.
2435+
"""
2436+
Return a subset of the DataFrame based on the column dtypes.
24372437
24382438
Parameters
24392439
----------
@@ -2471,19 +2471,19 @@ def select_dtypes(self, include=None, exclude=None):
24712471
24722472
Examples
24732473
--------
2474-
>>> df = pd.DataFrame({'a': np.random.randn(6).astype('f4'),
2474+
>>> df = pd.DataFrame({'a': [1, 2] * 3,
24752475
... 'b': [True, False] * 3,
24762476
... 'c': [1.0, 2.0] * 3})
24772477
>>> df
24782478
a b c
2479-
0 0.3962 True 1.0
2480-
1 0.1459 False 2.0
2481-
2 0.2623 True 1.0
2482-
3 0.0764 False 2.0
2483-
4 -0.9703 True 1.0
2484-
5 -1.2094 False 2.0
2479+
0 1 True 1.0
2480+
1 2 False 2.0
2481+
2 1 True 1.0
2482+
3 2 False 2.0
2483+
4 1 True 1.0
2484+
5 2 False 2.0
24852485
>>> df.select_dtypes(include='bool')
2486-
c
2486+
b
24872487
0 True
24882488
1 False
24892489
2 True
@@ -2498,14 +2498,14 @@ def select_dtypes(self, include=None, exclude=None):
24982498
3 2.0
24992499
4 1.0
25002500
5 2.0
2501-
>>> df.select_dtypes(exclude=['floating'])
2502-
b
2503-
0 True
2504-
1 False
2505-
2 True
2506-
3 False
2507-
4 True
2508-
5 False
2501+
>>> df.select_dtypes(exclude=['int'])
2502+
b c
2503+
0 True 1.0
2504+
1 False 2.0
2505+
2 True 1.0
2506+
3 False 2.0
2507+
4 True 1.0
2508+
5 False 2.0
25092509
"""
25102510

25112511
if not is_list_like(include):

pandas/core/generic.py

+66-3
Original file line numberDiff line numberDiff line change
@@ -4260,16 +4260,79 @@ def _get_values(self):
42604260
return self.values
42614261

42624262
def get_values(self):
4263-
"""same as values (but handles sparseness conversions)"""
4263+
"""
4264+
Return a NumPy representation of the data
4265+
after converting sparse to dense.
4266+
4267+
Returns
4268+
-------
4269+
numpy.ndarray
4270+
Numpy representation of DataFrame
4271+
4272+
See Also
4273+
--------
4274+
values : Numpy representation of DataFrame
4275+
4276+
Examples
4277+
--------
4278+
>>> df = pd.DataFrame({'a': [1, 2], 'b': [True, False],
4279+
... 'c': [1.0, 2.0]})
4280+
>>> df.get_values()
4281+
array([[1, True, 1.0], [2, False, 2.0]], dtype=object)
4282+
"""
42644283
return self.values
42654284

42664285
def get_dtype_counts(self):
4267-
"""Return the counts of dtypes in this object."""
4286+
"""
4287+
Return counts of unique dtypes in this object.
4288+
4289+
Returns
4290+
-------
4291+
dtype : Series
4292+
Series with the count of columns with each dtype
4293+
4294+
See Also
4295+
--------
4296+
dtypes : Return the dtypes in this object.
4297+
4298+
Examples
4299+
--------
4300+
>>> a = [['a', 1, 1.0], ['b', 2, 2.0], ['c', 3, 3.0]]
4301+
>>> df = pd.DataFrame(a, columns=['str', 'int', 'float'])
4302+
>>> df.get_dtype_counts()
4303+
float64 1
4304+
int64 1
4305+
object 1
4306+
dtype: int64
4307+
"""
42684308
from pandas import Series
42694309
return Series(self._data.get_dtype_counts())
42704310

42714311
def get_ftype_counts(self):
4272-
"""Return the counts of ftypes in this object."""
4312+
"""
4313+
Return counts of unique ftypes in this object.
4314+
4315+
Returns
4316+
-------
4317+
dtype : Series
4318+
Series with the count of columns
4319+
with each type and sparcity(dense/sparse)
4320+
4321+
See Also
4322+
--------
4323+
ftypes : Return
4324+
ftypes (indication of sparse/dense and dtype) in this object.
4325+
4326+
Examples
4327+
--------
4328+
>>> a = [['a', 1, 1.0], ['b', 2, 2.0], ['c', 3, 3.0]]
4329+
>>> df = pd.DataFrame(a, columns=['str', 'int', 'float'])
4330+
>>> df.get_ftype_counts()
4331+
float64:dense 1
4332+
int64:dense 1
4333+
object:dense 1
4334+
dtype: int64
4335+
"""
42734336
from pandas import Series
42744337
return Series(self._data.get_ftype_counts())
42754338

0 commit comments

Comments
 (0)