Skip to content

Commit 35d225f

Browse files
committed
more examples
1 parent e91901d commit 35d225f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

pandas/_libs/src/inference.pyx

+48
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,54 @@ def infer_dtype(object value):
254254
------
255255
TypeError if ndarray-like but cannot infer the dtype
256256
257+
Notes
258+
-----
259+
- 'mixed' is the catchall for anything that is not otherwise
260+
specialized
261+
- 'mixed-integer-float' are floats and integers
262+
- 'mixed-integer' are integers mixed with non-integers
263+
264+
Examples
265+
--------
266+
>>> infer_dtype(['foo', 'bar'])
267+
'string'
268+
269+
>>> infer_dtype([b'foo', b'bar'])
270+
'bytes'
271+
272+
>>> infer_dtype([1, 2, 3])
273+
'integer'
274+
275+
>>> infer_dtype([1, 2, 3.5])
276+
'mixed-integer-float'
277+
278+
>>> infer_dtype([1.0, 2.0, 3.5])
279+
'floating'
280+
281+
>>> infer_dtype(['a', 1])
282+
'mixed-integer'
283+
284+
>>> infer_dtype([True, False])
285+
'boolean'
286+
287+
>>> infer_dtype([True, False, np.nan])
288+
'mixed'
289+
290+
>>> infer_dtype([pd.Timestamp('20130101')])
291+
'datetime'
292+
293+
>>> infer_dtype([datetime.date(2013, 1, 1)])
294+
'date'
295+
296+
>>> infer_dtype([np.datetime64('2013-01-01')])
297+
'datetime64'
298+
299+
>>> infer_dtype([datetime.timedelta(0, 1, 1)])
300+
'timedelta'
301+
302+
>>> infer_dtype(pd.Series(list('aabc')).astype('category'))
303+
'categorical'
304+
257305
"""
258306

259307
cdef:

0 commit comments

Comments
 (0)