Skip to content

CLN: Static types in pandas/_lib/lib.pyx #33329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 31 additions & 30 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1001,34 +1001,34 @@ cdef inline bint c_is_list_like(object obj, bint allow_sets):


_TYPE_MAP = {
'categorical': 'categorical',
'category': 'categorical',
'int8': 'integer',
'int16': 'integer',
'int32': 'integer',
'int64': 'integer',
'i': 'integer',
'uint8': 'integer',
'uint16': 'integer',
'uint32': 'integer',
'uint64': 'integer',
'u': 'integer',
'float32': 'floating',
'float64': 'floating',
'f': 'floating',
'complex64': 'complex',
'complex128': 'complex',
'c': 'complex',
'string': 'string',
'S': 'bytes',
'U': 'string',
'bool': 'boolean',
'b': 'boolean',
'datetime64[ns]': 'datetime64',
'M': 'datetime64',
'timedelta64[ns]': 'timedelta64',
'm': 'timedelta64',
'interval': 'interval',
"categorical": "categorical",
"category": "categorical",
"int8": "integer",
"int16": "integer",
"int32": "integer",
"int64": "integer",
"i": "integer",
"uint8": "integer",
"uint16": "integer",
"uint32": "integer",
"uint64": "integer",
"u": "integer",
"float32": "floating",
"float64": "floating",
"f": "floating",
"complex64": "complex",
"complex128": "complex",
"c": "complex",
"string": "string",
"S": "bytes",
"U": "string",
"bool": "boolean",
"b": "boolean",
"datetime64[ns]": "datetime64",
"M": "datetime64",
"timedelta64[ns]": "timedelta64",
"m": "timedelta64",
"interval": "interval",
}

# types only exist on certain platform
Expand Down Expand Up @@ -1173,12 +1173,13 @@ cdef class Seen:
or self.nat_)


cdef _try_infer_map(v):
cdef object _try_infer_map(object v):
"""
If its in our map, just return the dtype.
"""
cdef:
object attr, val
object val
str attr
for attr in ['name', 'kind', 'base']:
val = getattr(v.dtype, attr)
if val in _TYPE_MAP:
Expand Down