U
    c                     @  s   d Z ddlmZ ddlZddlZddlZddlmZ ddl	Z
ddlmZ G dd dZG dd	 d	Zd
ddddZG dd deZdS )zE
Utility functions and objects for implementing the interchange API.
    )annotationsN)DtypeObj)is_datetime64_dtypec                   @  sX   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdS )ArrowCTypesz
    Enum for Apache Arrow C type format strings.

    The Arrow C data interface:
    https://arrow.apache.org/docs/format/CDataInterface.html#data-type-description-format-strings
    nbcCsSiIlLefguZtdDZtdmzts{resolution}:{tz}ztt{resolution}N)__name__
__module____qualname____doc__ZNULLZBOOLZINT8ZUINT8ZINT16ZUINT16ZINT32ZUINT32INT64ZUINT64ZFLOAT16ZFLOAT32ZFLOAT64STRINGZDATE32ZDATE64	TIMESTAMPZTIME r   r   A/tmp/pip-unpacked-wheel-g7fro6k3/pandas/core/interchange/utils.pyr      s&   r   c                   @  s    e Zd ZdZdZdZdZdZdS )
Endiannessz.Enum indicating the byte-order of a data-type.<>=|N)r   r   r   r   ZLITTLEZBIGZNATIVEZNAr   r   r   r   r   3   s
   r   r   str)dtypereturnc                 C  s   t | tjrtjS | tdkr&tjS tt| j	
 d}|dk	rD|S t| rtdttj| jd dd }tjj|ddS td|  d	dS )
a   
    Represent pandas `dtype` as a format string in Apache Arrow C notation.

    Parameters
    ----------
    dtype : np.dtype
        Datatype of pandas DataFrame to represent.

    Returns
    -------
    str
        Format string in Apache Arrow C notation of the given `dtype`.
    ONz\[(.*)\]r       )
resolutiontzzConversion of z- to Arrow C format string is not implemented.)
isinstancepdZCategoricalDtyper   r   npr#   r   getattrnameupperr   refindalltypingcastr"   r   formatNotImplementedError)r#   Z
format_strr(   r   r   r   dtype_to_arrow_c_fmt<   s    $
r6   c                   @  s   e Zd ZdZdS )NoBufferPresentz6Exception to signal that there is no requested buffer.N)r   r   r   r   r   r   r   r   r7   ^   s   r7   )r   
__future__r   r0   r2   Znumpyr,   Zpandas._typingr   Zpandasr+   Zpandas.api.typesr   r   r   r6   	Exceptionr7   r   r   r   r   <module>   s   !	"