-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Description
pandas.types.common.is_string_dtype is not strict, just checking if its a fixed-width numpy string/unicode type or object dtype. It could be made strict via something like this.
def is_string_dtype(arr_or_dtype): dtype = _get_dtype(arr_or_dtype) if isinstance(arr_or_dtype, np.ndarray): if not lib.infer_dtype(arr_or_dtype) in ['string', 'unicode']: return False return dtype.kind in ('O', 'S', 'U') and not is_period_dtype(dtype) this would need performance checking to see if its a problem. Further this then changes the API a tiny bit (as we allow an object OR a dtype to be passed in). Which is probably ok as long as its documented a bit.