@@ -4336,16 +4336,82 @@ def get_ftype_counts(self):
4336
4336
4337
4337
@property
4338
4338
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
+ """
4340
4369
from pandas import Series
4341
4370
return Series (self ._data .get_dtypes (), index = self ._info_axis ,
4342
4371
dtype = np .object_ )
4343
4372
4344
4373
@property
4345
4374
def ftypes (self ):
4346
4375
"""
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
4349
4415
"""
4350
4416
from pandas import Series
4351
4417
return Series (self ._data .get_ftypes (), index = self ._info_axis ,
0 commit comments