§
    	�’j   ã                  ó  — d Z ddlmZ ddlmZ ddlZddlZddlm	Z	 ddl
mZ ddlmZ ddlmZmZmZ dd	lmZmZ dd
lmZ ddlmZmZmZmZmZmZ erddlmZm Z  ddlm!Z! d d„Z" G d„ de¦  «        Z#	 d!d"d„Z$d#d„Z%d#d„Z&dS )$zÚ
This is a pseudo-public API for downstream libraries.  We ask that downstream
authors

1) Try to avoid using internals directly altogether, and failing that,
2) Use only functions exposed here (or in core.internals)

é    )Úannotations)ÚTYPE_CHECKINGN)ÚBlockPlacement)ÚPandas4Warning)Úpandas_dtype)ÚDatetimeTZDtypeÚExtensionDtypeÚPeriodDtype)ÚDatetimeArrayÚTimedeltaArray)Úextract_array)ÚDatetimeLikeBlockÚ
check_ndimÚensure_block_shapeÚextract_pandas_arrayÚget_block_typeÚmaybe_coerce_values)Ú	ArrayLikeÚDtype)ÚBlockÚvaluesr   Ú	placementú
np.ndarrayÚreturnr   c                ó  — | j         }t          |¦  «        }t          |¦  «        }t          |t          ¦  «        r|j        st          | t          t          f¦  «        rt          | d¬¦  «        } t          | ¦  «        }  || d|¬¦  «        S )aö  
    This is an analogue to blocks.new_block(_2d) that ensures:
    1) correct dimension for EAs that support 2D (`ensure_block_shape`), and
    2) correct EA class for datetime64/timedelta64 (`maybe_coerce_values`).

    The input `values` is assumed to be either numpy array or ExtensionArray:
    - In case of a numpy array, it is assumed to already be in the expected
      shape for Blocks (2D, (cols, rows)).
    - In case of an ExtensionArray the input can be 1D, also for EAs that are
      internally stored as 2D.

    For the rest no preprocessing or validation is done, except for those dtypes
    that are internally stored as EAs but have an exact numpy equivalent (and at
    the moment use that numpy dtype), i.e. datetime64/timedelta64.
    é   )Úndim©r   r   )
Údtyper   r   Ú
isinstancer	   Ú_supports_2dr   r   r   r   )r   r   r   ÚklassÚplacement_objs        úGC:\Projects\DSCons\.venv\Lib\site-packages\pandas\core\internals\api.pyÚ_make_blockr%   2   s–   € ð  ŒL€EÝ˜5Ñ!Ô!€EÝ" 9Ñ-Ô-€Må�5�.Ñ)Ô)ð 4¨eÔ.@ð 4ÅZØ•¥Ð/ñFô Fð 4õ $ F°Ð3Ñ3Ô3ˆå  Ñ(Ô(€FØˆ5�˜a¨=Ð9Ñ9Ô9Ð9ó    c                  ó"   — e Zd ZU dZded<   dZdS )Ú_DatetimeTZBlockz0implement a datetime64 block with a tz attributer   r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__Ú	__slots__r)   r&   r$   r(   r(   O   s'   € € € € € € Ø:Ð:àÐÐÑà€I€I€Ir&   r(   r   úDtype | Nonec                óÂ  — t          j        dt          d¬¦  «         |�t          |¦  «        }t	          | ||¦  «        \  } }ddlm} ||u rt          | j        t          ¦  «        rd}|€|p| j        }t          |¦  «        }n9|t          u r0t          | j        t          ¦  «        st          j        | |¬¦  «        } t          |t          ¦  «        st          |¦  «        }t!          | ||¦  «        }t          | j        t          t          f¦  «        r!t#          | d¬	¦  «        } t%          | |¦  «        } t'          | ||¦  «         t)          | ¦  «        }  || ||¬
¦  «        S )a+  
    This is a pseudo-public analogue to blocks.new_block.

    We ask that downstream libraries use this rather than any fully-internal
    APIs, including but not limited to:

    - core.internals.blocks.make_block
    - Block.make_block
    - Block.make_block_same_class
    - Block.__init__
    z¦make_block is deprecated and will be removed in a future version. Use pd.api.internals.create_dataframe_from_blocks or (recommended) higher-level public APIs instead.r   ©Ú
stacklevelNr   )ÚExtensionBlock)r   T)Úextract_numpyr   )ÚwarningsÚwarnr   r   r   Úpandas.core.internals.blocksr4   r    r   r
   r   r(   r   r   Ú_simple_newr   Ú_maybe_infer_ndimr   r   r   r   )r   r   r"   r   r   r4   s         r$   Ú
make_blockr;   W   s‰  € õ „Mð	:õ 	Øðñ ô ð ð ÐÝ˜UÑ#Ô#ˆå(¨°¸Ñ=Ô=�M€FˆEà;Ð;Ð;Ð;Ð;Ð;à�ÐÐ¥:¨f¬l½KÑ#HÔ#HÐð ˆà€}ØÐ%˜œˆÝ˜uÑ%Ô%ˆˆà	Õ"Ð	"Ð	"­:°f´lÅOÑ+TÔ+TÐ	"åÔ*ð Øð
ñ 
ô 
ˆõ �i¥Ñ0Ô0ð .Ý" 9Ñ-Ô-ˆ	å˜V Y°Ñ5Ô5€DÝ�&”,¥­oÐ >Ñ?Ô?ð 2õ ˜v°TÐ:Ñ:Ô:ˆÝ# F¨DÑ1Ô1ˆåˆv�y $Ñ'Ô'Ð'Ý  Ñ(Ô(€FØˆ5�˜d¨iÐ8Ñ8Ô8Ð8r&   r   r   ú
int | NoneÚintc                óˆ   — |€?t          | j        t          j        ¦  «        st          |¦  «        dk    rd}n
d}n| j        }|S )úH
    If `ndim` is not provided, infer it from placement and values.
    Né   r   )r    r   ÚnpÚlenr   ©r   r   r   s      r$   r:   r:   ˜   sJ   € ð €|å˜&œ,­¬Ñ1Ô1ð 	Ý�9‰~Œ~ Ò"Ð"Ø��à��à”;ˆDØ€Kr&   c                ó\   — t          j        dt          d¬¦  «         t          | ||¦  «        S )r?   zGmaybe_infer_ndim is deprecated and will be removed in a future version.r   r2   )r6   r7   r   r:   rC   s      r$   Úmaybe_infer_ndimrE   ¨   s:   € õ „MØQÝØðñ ô ð õ
 ˜V Y°Ñ5Ô5Ð5r&   )r   r   r   r   r   r   )NNN)r   r0   r   r   )r   r   r   r<   r   r=   )'r-   Ú
__future__r   Útypingr   r6   ÚnumpyrA   Úpandas._libs.internalsr   Úpandas.errorsr   Úpandas.core.dtypes.commonr   Úpandas.core.dtypes.dtypesr   r	   r
   Úpandas.core.arraysr   r   Úpandas.core.constructionr   r8   r   r   r   r   r   r   Úpandas._typingr   r   r   r%   r(   r;   r:   rE   r)   r&   r$   ú<module>rP      s  ððð ð #Ð "Ð "Ð "Ð "Ð "à  Ð  Ð  Ð  Ð  Ð  Ø €€€à Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø (Ð (Ð (Ð (Ð (Ð (à 2Ð 2Ð 2Ð 2Ð 2Ð 2ðð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð 3Ð 2Ð 2Ð 2Ð 2Ð 2ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 3ðð ð ð ð ð ð ð ð
 3Ð2Ð2Ð2Ð2Ð2ð:ð :ð :ð :ð:ð ð ð ð Ð(ñ ô ð ð EIð>9ð >9ð >9ð >9ð >9ðBð ð ð ð 	6ð 	6ð 	6ð 	6ð 	6ð 	6r&   