@@ -4232,7 +4232,8 @@ def as_matrix(self, columns=None):
4232
4232
4233
4233
@property
4234
4234
def values (self ):
4235
- """Numpy representation of NDFrame
4235
+ """
4236
+ Return NDFrame as ndarray or ndarray-like depending on the dtype.
4236
4237
4237
4238
Notes
4238
4239
-----
@@ -4245,6 +4246,16 @@ def values(self):
4245
4246
float32. If dtypes are int32 and uint8, dtype will be upcast to
4246
4247
int32. By numpy.find_common_type convention, mixing int64 and uint64
4247
4248
will result in a flot64 dtype.
4249
+
4250
+ Examples
4251
+ --------
4252
+ >>> df = pd.DataFrame({'a': np.random.randn(2).astype('f4'),
4253
+ ... 'b': [True, False], 'c': [1.0, 2.0]})
4254
+ >>> type(df.values)
4255
+ <class 'numpy.ndarray'>
4256
+ >>> df.values
4257
+ array([[0.25209328532218933, True, 1.0],
4258
+ [0.35383567214012146, False, 2.0]], dtype=object)
4248
4259
"""
4249
4260
self ._consolidate_inplace ()
4250
4261
return self ._data .as_array (transpose = self ._AXIS_REVERSED )
@@ -4260,16 +4271,76 @@ def _get_values(self):
4260
4271
return self .values
4261
4272
4262
4273
def get_values (self ):
4263
- """same as values (but handles sparseness conversions)"""
4274
+ """
4275
+ Same as values (but handles sparseness conversions).
4276
+
4277
+ Returns
4278
+ -------
4279
+ numpy.ndaray
4280
+ Numpy representation of NDFrame
4281
+
4282
+ Examples
4283
+ --------
4284
+ >>> df = pd.DataFrame({'a': np.random.randn(2).astype('f4'),
4285
+ ... 'b': [True, False], 'c': [1.0, 2.0]})
4286
+ >>> df.get_values()
4287
+ array([[0.25209328532218933, True, 1.0],
4288
+ [0.35383567214012146, False, 2.0]], dtype=object)
4289
+ """
4264
4290
return self .values
4265
4291
4266
4292
def get_dtype_counts (self ):
4267
- """Return the counts of dtypes in this object."""
4293
+ """
4294
+ Return counts of unique dtypes in this object.
4295
+
4296
+ Returns
4297
+ -------
4298
+ dtype Number of dtype
4299
+
4300
+ See Also
4301
+ --------
4302
+ dtypes : Return the dtypes in this object.
4303
+
4304
+ Examples
4305
+ --------
4306
+ >>> a = [['a', 1, 1.0], ['b', 2, 2.0], ['c', 3, 3.0]]
4307
+ >>> df = pd.DataFrame(a, columns=['str', 'int', 'float'])
4308
+ >>> df['int'].astype(int)
4309
+ >>> df['float'].astype(float)
4310
+ >>> df.get_dtype_counts()
4311
+ float64 1
4312
+ int64 1
4313
+ object 1
4314
+ dtype: int64
4315
+ """
4268
4316
from pandas import Series
4269
4317
return Series (self ._data .get_dtype_counts ())
4270
4318
4271
4319
def get_ftype_counts (self ):
4272
- """Return the counts of ftypes in this object."""
4320
+ """
4321
+ Return counts of unique ftypes in this object.
4322
+
4323
+ Returns
4324
+ -------
4325
+ dtype Number of dtype:dense|sparse
4326
+
4327
+ See Also
4328
+ --------
4329
+ ftypes : Return
4330
+ ftypes (indication of sparse/dense and dtype) in this object.
4331
+
4332
+ Examples
4333
+ --------
4334
+ >>> a = [['a', 1, 1.0], ['b', 2, 2.0], ['c', 3, 3.0]]
4335
+ >>> df = pd.DataFrame(a, columns=['str', 'int', 'float'])
4336
+ >>> df['int'].astype(int)
4337
+ >>> df['float'].astype(float)
4338
+ >>> df.get_dtype_counts()
4339
+ float64:dense 1
4340
+ int64:dense 1
4341
+ object:dense 1
4342
+ dtype: int64
4343
+ """
4273
4344
from pandas import Series
4274
4345
return Series (self ._data .get_ftype_counts ())
4275
4346
0 commit comments