Skip to content

Commit 22b6749

Browse files
jongwonyTomAugspurger
authored andcommitted
DOC: update the dtypes/ftypes docstring (Seoul) (#20100)
1 parent 5e66789 commit 22b6749

File tree

1 file changed

+69
-3
lines changed

1 file changed

+69
-3
lines changed

pandas/core/generic.py

+69-3
Original file line numberDiff line numberDiff line change
@@ -4336,16 +4336,82 @@ def get_ftype_counts(self):
43364336

43374337
@property
43384338
def dtypes(self):
4339-
"""Return the dtypes in this object."""
4339+
"""
4340+
Return the dtypes in the DataFrame.
4341+
4342+
This returns a Series with the data type of each column.
4343+
The result's index is the original DataFrame's columns. Columns
4344+
with mixed types are stored with the ``object`` dtype. See
4345+
:ref:`the User Guide <basics.dtypes>` for more.
4346+
4347+
Returns
4348+
-------
4349+
pandas.Series
4350+
The data type of each column.
4351+
4352+
See Also
4353+
--------
4354+
pandas.DataFrame.ftypes : dtype and sparsity information.
4355+
4356+
Examples
4357+
--------
4358+
>>> df = pd.DataFrame({'float': [1.0],
4359+
... 'int': [1],
4360+
... 'datetime': [pd.Timestamp('20180310')],
4361+
... 'string': ['foo']})
4362+
>>> df.dtypes
4363+
float float64
4364+
int int64
4365+
datetime datetime64[ns]
4366+
string object
4367+
dtype: object
4368+
"""
43404369
from pandas import Series
43414370
return Series(self._data.get_dtypes(), index=self._info_axis,
43424371
dtype=np.object_)
43434372

43444373
@property
43454374
def ftypes(self):
43464375
"""
4347-
Return the ftypes (indication of sparse/dense and dtype)
4348-
in this object.
4376+
Return the ftypes (indication of sparse/dense and dtype) in DataFrame.
4377+
4378+
This returns a Series with the data type of each column.
4379+
The result's index is the original DataFrame's columns. Columns
4380+
with mixed types are stored with the ``object`` dtype. See
4381+
:ref:`the User Guide <basics.dtypes>` for more.
4382+
4383+
Returns
4384+
-------
4385+
pandas.Series
4386+
The data type and indication of sparse/dense of each column.
4387+
4388+
See Also
4389+
--------
4390+
pandas.DataFrame.dtypes: Series with just dtype information.
4391+
pandas.SparseDataFrame : Container for sparse tabular data.
4392+
4393+
Notes
4394+
-----
4395+
Sparse data should have the same dtypes as its dense representation.
4396+
4397+
Examples
4398+
--------
4399+
>>> import numpy as np
4400+
>>> arr = np.random.RandomState(0).randn(100, 4)
4401+
>>> arr[arr < .8] = np.nan
4402+
>>> pd.DataFrame(arr).ftypes
4403+
0 float64:dense
4404+
1 float64:dense
4405+
2 float64:dense
4406+
3 float64:dense
4407+
dtype: object
4408+
4409+
>>> pd.SparseDataFrame(arr).ftypes
4410+
0 float64:sparse
4411+
1 float64:sparse
4412+
2 float64:sparse
4413+
3 float64:sparse
4414+
dtype: object
43494415
"""
43504416
from pandas import Series
43514417
return Series(self._data.get_ftypes(), index=self._info_axis,

0 commit comments

Comments
 (0)