o
    …ôjµÅ ã                	   @  sÒ  U d Z ddlmZ ddlmZ ddlZddlmZmZ ddl	Z	ddl
Z
ddlZddlmZ ddlmZmZmZmZmZmZmZ ddlZddlZddlmZmZmZmZ dd	lmZm Z! dd
l"m#Z# ddl$m%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/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=m>Z>m?Z?m@Z@mAZA ddlBmCZC ddlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZO ddlPmQZQmRZRmSZS ddlTmUZU ddlVmW  mXZY ddlZm[Z[m\Z\ ddl]m^Z_m`Z` ddlambZb ddlcmdZdmeZe ddlfmgZg ddlhmiZimjZj e�rKddlkmlZlmmZmmnZn ddlompZp dd lqmrZrmsZsmtZt dd!lumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z} dd"lcm~Z~ d#Zd$Z€d%d&„ Z�dÕd+d,„Z‚d-d.„ Zƒe[Z„dÖd1d2„Z…d3Z†d4e‡d5< d6Zˆd4e‡d7< d8Z‰d4e‡d9< d:d:d;d;d<œZŠeEdgiZ‹d=ZŒd4e‡d>< d?Z�d4e‡d@< e ŽdA¡�  ej�dBdCeŒej�dD� ej�dEde�e ‘g dF¢¡dD� W d  ƒ n	1 �s¶w   Y  da’dCa“dGdH„ Z”	I			C		J					K	$d×dØdadb„Z•		c	K					C	dÙdÚdldm„Z–dÛdqdr„Z—G dsdt„ dtƒZ˜G dudv„ dvƒZ™G dwdx„ dxƒZšG dydz„ dzešƒZ›G d{d|„ d|ešƒZœG d}d~„ d~eœƒZ�G dd€„ d€e�ƒZžG d�d‚„ d‚ƒZŸG dƒd„„ d„eŸƒZ G d…d†„ d†e ƒZ¡G d‡dˆ„ dˆe ƒZ¢G d‰dŠ„ dŠe¢ƒZ£G d‹dŒ„ dŒeŸƒZ¤G d�dŽ„ dŽe¤ƒZ¥G d�d�„ d�e¤ƒZ¦G d‘d’„ d’e¦ƒZ§G d“d”„ d”e§ƒZ¨G d•d–„ d–e¨ƒZ©G d—d˜„ d˜e§ƒZªG d™dš„ dše§ƒZ«	dÜdÝd¡d¢„Z¬dÞd¦d§„Z­e	Cdßdàd¬d­„ƒZ®edßdád¯d­„ƒZ®	Cdßdâd²d­„Z®dãd´dµ„Z¯däd·d¸„Z°dåd¼d½„Z±dæd¿dÀ„Z²dædÁdÂ„Z³dçdÄdÅ„Z´dèdÆdÇ„ZµdédÈdÉ„Z¶dêdÌdÍ„Z·dëdÏdÐ„Z¸dìdÑdÒ„Z¹G dÓdÔ„ dÔƒZºdS )ízY
High level interface to PyTables for reading and writing pandas data structures
to disk
é    )Úannotations)ÚsuppressN)ÚdateÚtzinfo)Údedent)ÚTYPE_CHECKINGÚAnyÚCallableÚFinalÚLiteralÚcastÚoverload)ÚconfigÚ
get_optionÚusing_copy_on_writeÚusing_string_dtype)ÚlibÚwriters)Úis_string_array)Ú	timezones)ÚHAS_PYARROW)Úimport_optional_dependency)Úpatch_pickle)ÚAttributeConflictWarningÚClosedFileErrorÚIncompatibilityWarningÚPerformanceWarningÚPossibleDataLossError)Úcache_readonly)Úfind_stack_level)Úensure_objectÚis_bool_dtypeÚis_complex_dtypeÚis_list_likeÚis_string_dtypeÚneeds_i8_conversion)ÚCategoricalDtypeÚDatetimeTZDtypeÚExtensionDtypeÚPeriodDtype)Úarray_equivalent)Ú	DataFrameÚDatetimeIndexÚIndexÚ
MultiIndexÚPeriodIndexÚ
RangeIndexÚSeriesÚStringDtypeÚTimedeltaIndexÚconcatÚisna)ÚCategoricalÚDatetimeArrayÚPeriodArray)ÚBaseStringArray)ÚPyTablesExprÚmaybe_expression)ÚarrayÚextract_array)Úensure_index)ÚArrayManagerÚBlockManager)Ústringify_path)ÚadjoinÚpprint_thing)ÚHashableÚIteratorÚSequence)ÚTracebackType)ÚColÚFileÚNode)ÚAnyArrayLikeÚ	ArrayLikeÚAxisIntÚDtypeArgÚFilePathÚSelfÚShapeÚnpt)ÚBlockz0.15.2úUTF-8c                 C  s   t | tjƒr|  d¡} | S )z(if we have bytes, decode them to unicoderT   )Ú
isinstanceÚnpÚbytes_Údecode)Ús© rZ   úe/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/pandas/io/pytables.pyÚ_ensure_decoded’   s   
r\   Úencodingú
str | NoneÚreturnÚstrc                 C  s   | d u rt } | S ©N)Ú_default_encoding©r]   rZ   rZ   r[   Ú_ensure_encoding™   s   rd   c                 C  s   t | tƒr	t| ƒ} | S )zÓ
    Ensure that an index / column name is a str (python 3); otherwise they
    may be np.string dtype. Non-string dtypes are passed through unchanged.

    https://github.com/pandas-dev/pandas/issues/13492
    )rU   r`   ©ÚnamerZ   rZ   r[   Ú_ensure_str¡   s   
rg   Úscope_levelÚintc                   sV   |d ‰ t | ttfƒr‡ fdd„| D ƒ} n
t| ƒrt| ˆ d�} | du s't| ƒr)| S dS )zÔ
    Ensure that the where is a Term or a list of Term.

    This makes sure that we are capturing the scope of variables that are
    passed create the terms here with a frame_level=2 (we are 2 levels down)
    é   c                   s0   g | ]}|d urt |ƒrt|ˆ d d�n|‘qS )Nrj   ©rh   )r;   ÚTerm)Ú.0Úterm©ÚlevelrZ   r[   Ú
<listcomp>»   s
    þz _ensure_term.<locals>.<listcomp>rk   N)rU   ÚlistÚtupler;   rl   Úlen)Úwhererh   rZ   ro   r[   Ú_ensure_term°   s   	
þrv   z¨
where criteria is being ignored as this version [%s] is too old (or
not-defined), read the file in and write it out to a new file to upgrade (with
the copy_to method)
r
   Úincompatibility_doczu
the [%s] attribute of the existing index is [%s] which conflicts with the new
[%s], resetting the attribute to None
Úattribute_conflict_docz‘
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->%s,key->%s] [items->%s]
Úperformance_docÚfixedÚtable)Úfrz   Útr{   z;
: boolean
    drop ALL nan rows when appending to a table
Ú
dropna_docz~
: format
    default format writing format, if None, then
    put will default to 'fixed' and append will default to 'table'
Ú
format_doczio.hdfZdropna_tableF)Ú	validatorÚdefault_format)rz   r{   Nc                  C  sN   t d u r%dd l} | a ttƒ� | jjdkaW d   ƒ t S 1 s w   Y  t S )Nr   Ústrict)Ú
_table_modÚtablesr   ÚAttributeErrorÚfileZ_FILE_OPEN_POLICYÚ!_table_file_open_policy_is_strict)r„   rZ   rZ   r[   Ú_tablesô   s   

ÿ
ÿûrˆ   ÚaTr‚   Úpath_or_bufúFilePath | HDFStoreÚkeyÚvalueúDataFrame | SeriesÚmodeÚ	complevelú
int | NoneÚcomplibÚappendÚboolÚformatÚindexÚmin_itemsizeúint | dict[str, int] | NoneÚdropnaúbool | NoneÚdata_columnsú Literal[True] | list[str] | NoneÚerrorsÚNonec              
     sž   |r‡ ‡‡‡‡‡‡‡‡‡	f
dd„}n‡ ‡‡‡‡‡‡‡‡‡	f
dd„}t | ƒ} t| tƒrIt| |||d��}||ƒ W d  ƒ dS 1 sBw   Y  dS || ƒ dS )z+store this object, close it if we opened itc                   s   | j ˆˆ	ˆˆˆˆˆˆ ˆˆd�
S )N)r•   r–   r—   Únan_repr™   r›   r�   r]   )r“   ©Ústore©
r›   r™   r]   r�   r•   r–   rŒ   r—   rŸ   r�   rZ   r[   Ú<lambda>  ó    özto_hdf.<locals>.<lambda>c                   s   | j ˆˆ	ˆˆˆˆˆ ˆˆˆd�
S )N)r•   r–   r—   rŸ   r›   r�   r]   r™   ©Úputr    r¢   rZ   r[   r£   +  r¤   )r�   r�   r’   N)rA   rU   r`   ÚHDFStore)rŠ   rŒ   r�   r�   r�   r’   r“   r•   r–   r—   rŸ   r™   r›   r�   r]   r|   r¡   rZ   r¢   r[   Úto_hdf
  s    
ÿ
"ýr¨   Úrru   ústr | list | NoneÚstartÚstopÚcolumnsúlist[str] | NoneÚiteratorÚ	chunksizec
                 K  s†  |dvrt d|› d�ƒ‚|durt|dd�}t| tƒr'| js"tdƒ‚| }d}n:t| ƒ} t| tƒs4td	ƒ‚zt	j
 | ¡}W n tt fyI   d}Y nw |sTtd
| › d�ƒ‚t| f||dœ|
¤Ž}d}z9|du r�| ¡ }t|ƒdkrtt dƒ‚|d }|dd… D ]}t||ƒs‰t dƒ‚q~|j}|j|||||||	|d�W S  t ttfyÂ   t| tƒsÁttƒ� | ¡  W d  ƒ ‚ 1 s¼w   Y  ‚ w )a>
  
    Read from the store, close it if we opened it.

    Retrieve pandas object stored in file, optionally based on where
    criteria.

    .. warning::

       Pandas uses PyTables for reading and writing HDF5 files, which allows
       serializing object-dtype data with pickle when using the "fixed" format.
       Loading pickled data received from untrusted sources can be unsafe.

       See: https://docs.python.org/3/library/pickle.html for more.

    Parameters
    ----------
    path_or_buf : str, path object, pandas.HDFStore
        Any valid string path is acceptable. Only supports the local file system,
        remote URLs and file-like objects are not supported.

        If you want to pass in a path object, pandas accepts any
        ``os.PathLike``.

        Alternatively, pandas accepts an open :class:`pandas.HDFStore` object.

    key : object, optional
        The group identifier in the store. Can be omitted if the HDF file
        contains a single pandas object.
    mode : {'r', 'r+', 'a'}, default 'r'
        Mode to use when opening the file. Ignored if path_or_buf is a
        :class:`pandas.HDFStore`. Default is 'r'.
    errors : str, default 'strict'
        Specifies how encoding and decoding errors are to be handled.
        See the errors argument for :func:`open` for a full list
        of options.
    where : list, optional
        A list of Term (or convertible) objects.
    start : int, optional
        Row number to start selection.
    stop  : int, optional
        Row number to stop selection.
    columns : list, optional
        A list of columns names to return.
    iterator : bool, optional
        Return an iterator object.
    chunksize : int, optional
        Number of rows to include in an iteration when using an iterator.
    **kwargs
        Additional keyword arguments passed to HDFStore.

    Returns
    -------
    object
        The selected object. Return type depends on the object stored.

    See Also
    --------
    DataFrame.to_hdf : Write a HDF file from a DataFrame.
    HDFStore : Low-level access to HDF files.

    Notes
    -----
    When ``errors="surrogatepass"``, ``pd.options.future.infer_string`` is true,
    and PyArrow is installed, if a UTF-16 surrogate is encountered when decoding
    to UTF-8, the resulting dtype will be
    ``pd.StringDtype(storage="python", na_value=np.nan)``.

    Examples
    --------
    >>> df = pd.DataFrame([[1, 1.0, 'a']], columns=['x', 'y', 'z'])  # doctest: +SKIP
    >>> df.to_hdf('./store.h5', 'data')  # doctest: +SKIP
    >>> reread = pd.read_hdf('./store.h5')  # doctest: +SKIP
    )r©   úr+r‰   zmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.Nrj   rk   z&The HDFStore must be open for reading.Fz5Support for generic buffers has not been implemented.zFile z does not exist)r�   r�   Tr   z]Dataset(s) incompatible with Pandas data types, not table, or no datasets found in HDF5 file.z?key must be provided when HDF5 file contains multiple datasets.)ru   r«   r¬   r­   r¯   r°   Ú
auto_close)Ú
ValueErrorrv   rU   r§   Úis_openÚOSErrorrA   r`   ÚNotImplementedErrorÚosÚpathÚexistsÚ	TypeErrorÚFileNotFoundErrorÚgroupsrt   Ú_is_metadata_ofÚ_v_pathnameÚselectÚLookupErrorr   r…   Úclose)rŠ   rŒ   r�   r�   ru   r«   r¬   r­   r¯   r°   Úkwargsr¡   r²   r¹   r¼   Zcandidate_only_groupZgroup_to_checkrZ   rZ   r[   Úread_hdfB  sv   V
ÿ

ÿÿÿ
ÿÿø




ÿýúrÃ   ÚgrouprJ   Úparent_groupc                 C  sN   | j |j krdS | }|j dkr%|j}||kr|jdkrdS |j}|j dksdS )zDCheck if a given group is a metadata group for a given parent_group.Frj   ÚmetaT)Z_v_depthZ	_v_parentÚ_v_name)rÄ   rÅ   ÚcurrentÚparentrZ   rZ   r[   r½   ä  s   

ür½   c                   @  s¢  e Zd ZU dZded< ded< 				dŸd dd„Zd¡dd„Zedd„ ƒZed¡dd„ƒZ	d¢dd„Z
d£dd„Zd£dd„Zd¤d d!„Zd¥d"d#„Zd¦d%d&„Zd¡d'd(„Zd§d*d+„Zd¨d2d3„Zd©dªd7d8„Zd«d:d;„Zd¬d=d>„Zd­d®d?d@„Zd¯dAdB„Zed°dCdD„ƒZd±d²dFdG„Zd¢dHdI„Z							d³d´dMdN„Z			dµd¶dQdR„Z		d·d¸dTdU„Z								d¹dºdVdW„Z		X								Y	X	d»d¼dedf„Zdµd£dgdh„Z 			X	X											Yd½d¾dkdl„Z!			d¿dÀdodp„Z"			dµdÁdtdu„Z#dÂdwdx„Z$dÃdÄd|d}„Z%dÅdd€„Z&dÆd‚dƒ„Z'	„	X					XdÇdÈd‡dˆ„Z(d¡d‰dŠ„Z)d¯d‹dŒ„Z*dÉdŽd�„Z+			�	YdÊdËd“d”„Z,		X												Y	XdÌdÍd•d–„Z-dÎd™dš„Z.dÏd›dœ„Z/dÐd�dž„Z0dS )Ñr§   aS	  
    Dict-like IO interface for storing pandas objects in PyTables.

    Either Fixed or Table format.

    .. warning::

       Pandas uses PyTables for reading and writing HDF5 files, which allows
       serializing object-dtype data with pickle when using the "fixed" format.
       Loading pickled data received from untrusted sources can be unsafe.

       See: https://docs.python.org/3/library/pickle.html for more.

    Parameters
    ----------
    path : str
        File path to HDF5 file.
    mode : {'a', 'w', 'r', 'r+'}, default 'a'

        ``'r'``
            Read-only; no data can be modified.
        ``'w'``
            Write; a new file is created (an existing file with the same
            name would be deleted).
        ``'a'``
            Append; an existing file is opened for reading and writing,
            and if the file does not exist it is created.
        ``'r+'``
            It is similar to ``'a'``, but the file must already exist.
    complevel : int, 0-9, default None
        Specifies a compression level for data.
        A value of 0 or None disables compression.
    complib : {'zlib', 'lzo', 'bzip2', 'blosc'}, default 'zlib'
        Specifies the compression library to be used.
        These additional compressors for Blosc are supported
        (default if no compressor specified: 'blosc:blosclz'):
        {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy',
         'blosc:zlib', 'blosc:zstd'}.
        Specifying a compression library which is not available issues
        a ValueError.
    fletcher32 : bool, default False
        If applying compression use the fletcher32 checksum.
    **kwargs
        These parameters will be passed to the PyTables open_file method.

    Examples
    --------
    >>> bar = pd.DataFrame(np.random.randn(10, 4))
    >>> store = pd.HDFStore('test.h5')
    >>> store['foo'] = bar   # write to HDF5
    >>> bar = store['foo']   # retrieve
    >>> store.close()

    **Create or load HDF5 file in-memory**

    When passing the `driver` option to the PyTables open_file method through
    **kwargs, the HDF5 file is loaded or created in-memory and will only be
    written when closed:

    >>> bar = pd.DataFrame(np.random.randn(10, 4))
    >>> store = pd.HDFStore('test.h5', driver='H5FD_CORE')
    >>> store['foo'] = bar
    >>> store.close()   # only now, data is written to disk
    zFile | NoneÚ_handler`   Ú_moder‰   NFr�   r�   r‘   Ú
fletcher32r”   r_   rž   c                 K  s²   d|v rt dƒ‚tdƒ}|d ur ||jjvr t d|jj› d�ƒ‚|d u r,|d ur,|jj}t|ƒ| _|d u r7d}|| _d | _|rA|nd| _	|| _
|| _d | _| jd	d|i|¤Ž d S )
Nr•   z-format is not a defined argument for HDFStorer„   zcomplib only supports z compression.r‰   r   r�   rZ   )r³   r   ÚfiltersZall_complibsZdefault_complibrA   Ú_pathrË   rÊ   Ú
_complevelÚ_complibÚ_fletcher32Ú_filtersÚopen)Úselfr¸   r�   r�   r’   rÌ   rÂ   r„   rZ   rZ   r[   Ú__init__7  s&   	ÿ
zHDFStore.__init__c                 C  ó   | j S ra   ©rÎ   ©rÔ   rZ   rZ   r[   Ú
__fspath__X  s   zHDFStore.__fspath__c                 C  s   |   ¡  | jdusJ ‚| jjS )zreturn the root nodeN)Ú_check_if_openrÊ   ÚrootrØ   rZ   rZ   r[   rÛ   [  s   zHDFStore.rootc                 C  rÖ   ra   r×   rØ   rZ   rZ   r[   Úfilenameb  ó   zHDFStore.filenamerŒ   c                 C  ó
   |   |¡S ra   )Úget©rÔ   rŒ   rZ   rZ   r[   Ú__getitem__f  ó   
zHDFStore.__getitem__c                 C  s   |   ||¡ d S ra   r¥   )rÔ   rŒ   r�   rZ   rZ   r[   Ú__setitem__i  s   zHDFStore.__setitem__c                 C  rÞ   ra   )Úremoverà   rZ   rZ   r[   Ú__delitem__l  râ   zHDFStore.__delitem__rf   c              	   C  s@   z|   |¡W S  ttfy   Y nw tdt| ƒj› d|› d�ƒ‚)z$allow attribute access to get storesú'z' object has no attribute ')rß   ÚKeyErrorr   r…   ÚtypeÚ__name__)rÔ   rf   rZ   rZ   r[   Ú__getattr__o  s   ÿÿzHDFStore.__getattr__c                 C  s4   |   |¡}|dur|j}|||dd… fv rdS dS )zx
        check for existence of this key
        can match the exact pathname or the pathnm w/o the leading '/'
        Nrj   TF)Úget_noder¾   )rÔ   rŒ   Únoderf   rZ   rZ   r[   Ú__contains__y  s   
zHDFStore.__contains__ri   c                 C  ó   t |  ¡ ƒS ra   )rt   r¼   rØ   rZ   rZ   r[   Ú__len__…  ó   zHDFStore.__len__c                 C  s   t | jƒ}t| ƒ› d|› d�S )Nú
File path: Ú
)rC   rÎ   rè   )rÔ   ZpstrrZ   rZ   r[   Ú__repr__ˆ  s   
zHDFStore.__repr__rP   c                 C  s   | S ra   rZ   rØ   rZ   rZ   r[   Ú	__enter__Œ  ó   zHDFStore.__enter__Úexc_typeútype[BaseException] | NoneÚ	exc_valueúBaseException | NoneÚ	tracebackúTracebackType | Nonec                 C  ó   |   ¡  d S ra   )rÁ   )rÔ   rö   rø   rú   rZ   rZ   r[   Ú__exit__�  s   zHDFStore.__exit__ÚpandasÚincludeú	list[str]c                 C  sZ   |dkrdd„ |   ¡ D ƒS |dkr%| jdusJ ‚dd„ | jjddd	�D ƒS td
|› d�ƒ‚)aƒ  
        Return a list of keys corresponding to objects stored in HDFStore.

        Parameters
        ----------

        include : str, default 'pandas'
                When kind equals 'pandas' return pandas objects.
                When kind equals 'native' return native HDF5 Table objects.

        Returns
        -------
        list
            List of ABSOLUTE path-names (e.g. have the leading '/').

        Raises
        ------
        raises ValueError if kind has an illegal value

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> store.get('data')  # doctest: +SKIP
        >>> print(store.keys())  # doctest: +SKIP
        ['/data1', '/data2']
        >>> store.close()  # doctest: +SKIP
        rþ   c                 S  ó   g | ]}|j ‘qS rZ   ©r¾   ©rm   ÚnrZ   rZ   r[   rq   ¶  ó    z!HDFStore.keys.<locals>.<listcomp>ÚnativeNc                 S  r  rZ   r  r  rZ   rZ   r[   rq   º  s    ÿú/ÚTable)Ú	classnamez8`include` should be either 'pandas' or 'native' but is 'ræ   )r¼   rÊ   Z
walk_nodesr³   )rÔ   rÿ   rZ   rZ   r[   Úkeys—  s   ÿ
ÿzHDFStore.keysúIterator[str]c                 C  rî   ra   )Úiterr
  rØ   rZ   rZ   r[   Ú__iter__Á  rð   zHDFStore.__iter__úIterator[tuple[str, list]]c                 c  s    � |   ¡ D ]}|j|fV  qdS )z'
        iterate on key->group
        N)r¼   r¾   )rÔ   ÚgrZ   rZ   r[   ÚitemsÄ  s   €ÿzHDFStore.itemsc                 K  s¾   t ƒ }| j|kr)| jdv r|dv rn|dv r&| jr&td| j› d| j› d�ƒ‚|| _| jr0|  ¡  | jrE| jdkrEt ƒ j| j| j| j	d�| _
trP| jrPd	}t|ƒ‚|j| j| jfi |¤Ž| _d
S )a9  
        Open the file in the specified mode

        Parameters
        ----------
        mode : {'a', 'w', 'r', 'r+'}, default 'a'
            See HDFStore docstring or tables.open_file for info about modes
        **kwargs
            These parameters will be passed to the PyTables open_file method.
        )r‰   Úw)r©   r±   )r  zRe-opening the file [z] with mode [z] will delete the current file!r   )rÌ   zGCannot open HDF5 file, which is already opened, even in read-only mode.N)rˆ   rË   r´   r   rÎ   rÁ   rÏ   ÚFiltersrÐ   rÑ   rÒ   r‡   r³   Ú	open_filerÊ   )rÔ   r�   rÂ   r„   ÚmsgrZ   rZ   r[   rÓ   Ë  s*   
ÿÿ
ÿzHDFStore.openc                 C  s   | j dur
| j  ¡  d| _ dS )z0
        Close the PyTables file handle
        N)rÊ   rÁ   rØ   rZ   rZ   r[   rÁ   ø  s   


zHDFStore.closec                 C  s   | j du rdS t| j jƒS )zF
        return a boolean indicating whether the file is open
        NF)rÊ   r”   ZisopenrØ   rZ   rZ   r[   r´      s   
zHDFStore.is_openÚfsyncc                 C  s^   | j dur+| j  ¡  |r-ttƒ� t | j  ¡ ¡ W d  ƒ dS 1 s$w   Y  dS dS dS )aó  
        Force all buffered modifications to be written to disk.

        Parameters
        ----------
        fsync : bool (default False)
          call ``os.fsync()`` on the file handle to force writing to disk.

        Notes
        -----
        Without ``fsync=True``, flushing may not guarantee that the OS writes
        to disk. With fsync, the operation will block until the OS claims the
        file has been written; however, other caching layers may still
        interfere.
        N)rÊ   Úflushr   rµ   r·   r  Úfileno)rÔ   r  rZ   rZ   r[   r  	  s   


"ÿýzHDFStore.flushc                 C  sV   t ƒ � |  |¡}|du rtd|› d�ƒ‚|  |¡W  d  ƒ S 1 s$w   Y  dS )a  
        Retrieve pandas object stored in file.

        Parameters
        ----------
        key : str

        Returns
        -------
        object
            Same type as object stored in file.

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> store.get('data')  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        NúNo object named ú in the file)r   rë   rç   Ú_read_group©rÔ   rŒ   rÄ   rZ   rZ   r[   rß     s   
$úzHDFStore.getr¯   r°   r²   c	                   st   |   |¡}	|	du rtd|› d�ƒ‚t|dd�}|  |	¡‰ˆ ¡  ‡ ‡fdd„}
t| ˆ|
|ˆj|||||d�
}| ¡ S )	a6  
        Retrieve pandas object stored in file, optionally based on where criteria.

        .. warning::

           Pandas uses PyTables for reading and writing HDF5 files, which allows
           serializing object-dtype data with pickle when using the "fixed" format.
           Loading pickled data received from untrusted sources can be unsafe.

           See: https://docs.python.org/3/library/pickle.html for more.

        Parameters
        ----------
        key : str
            Object being retrieved from file.
        where : list or None
            List of Term (or convertible) objects, optional.
        start : int or None
            Row number to start selection.
        stop : int, default None
            Row number to stop selection.
        columns : list or None
            A list of columns that if not None, will limit the return columns.
        iterator : bool or False
            Returns an iterator.
        chunksize : int or None
            Number or rows to include in iteration, return an iterator.
        auto_close : bool or False
            Should automatically close the store when finished.

        Returns
        -------
        object
            Retrieved object from file.

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> store.get('data')  # doctest: +SKIP
        >>> print(store.keys())  # doctest: +SKIP
        ['/data1', '/data2']
        >>> store.select('/data1')  # doctest: +SKIP
           A  B
        0  1  2
        1  3  4
        >>> store.select('/data1', where='columns == A')  # doctest: +SKIP
           A
        0  1
        1  3
        >>> store.close()  # doctest: +SKIP
        Nr  r  rj   rk   c                   s   ˆj | ||ˆ d�S )N)r«   r¬   ru   r­   ©Úread©Ú_startÚ_stopÚ_where©r­   rY   rZ   r[   Úfunc†  s   zHDFStore.select.<locals>.func©ru   Únrowsr«   r¬   r¯   r°   r²   )rë   rç   rv   Ú_create_storerÚ
infer_axesÚTableIteratorr%  Ú
get_result)rÔ   rŒ   ru   r«   r¬   r­   r¯   r°   r²   rÄ   r#  ÚitrZ   r"  r[   r¿   <  s(   
@
özHDFStore.selectr«   r¬   c                 C  s8   t |dd�}|  |¡}t|tƒstdƒ‚|j|||d�S )a“  
        return the selection as an Index

        .. warning::

           Pandas uses PyTables for reading and writing HDF5 files, which allows
           serializing object-dtype data with pickle when using the "fixed" format.
           Loading pickled data received from untrusted sources can be unsafe.

           See: https://docs.python.org/3/library/pickle.html for more.


        Parameters
        ----------
        key : str
        where : list of Term (or convertible) objects, optional
        start : integer (defaults to None), row number to start selection
        stop  : integer (defaults to None), row number to stop selection
        rj   rk   z&can only read_coordinates with a table©ru   r«   r¬   )rv   Ú
get_storerrU   r  rº   Úread_coordinates)rÔ   rŒ   ru   r«   r¬   ÚtblrZ   rZ   r[   Úselect_as_coordinates™  s
   

zHDFStore.select_as_coordinatesÚcolumnc                 C  s,   |   |¡}t|tƒstdƒ‚|j|||d�S )a~  
        return a single column from the table. This is generally only useful to
        select an indexable

        .. warning::

           Pandas uses PyTables for reading and writing HDF5 files, which allows
           serializing object-dtype data with pickle when using the "fixed" format.
           Loading pickled data received from untrusted sources can be unsafe.

           See: https://docs.python.org/3/library/pickle.html for more.

        Parameters
        ----------
        key : str
        column : str
            The column of interest.
        start : int or None, default None
        stop : int or None, default None

        Raises
        ------
        raises KeyError if the column is not found (or key is not a valid
            store)
        raises ValueError if the column can not be extracted individually (it
            is part of a data block)

        z!can only read_column with a table)r0  r«   r¬   )r,  rU   r  rº   Úread_column)rÔ   rŒ   r0  r«   r¬   r.  rZ   rZ   r[   Úselect_column¹  s   
#
zHDFStore.select_columnc
                   st  t |dd�}t|ttfƒrt|ƒdkr|d }t|tƒr)ˆj||ˆ|||||	d�S t|ttfƒs4tdƒ‚t|ƒs<tdƒ‚|du rD|d }‡fdd	„|D ƒ‰ˆ 	|¡}
d}t
 |
|fgtˆ|ƒ¡D ]-\}}|du rptd
|› d�ƒ‚|js|td|j› d�ƒ‚|du r„|j}q`|j|kr�tdƒ‚q`dd	„ ˆD ƒ}dd„ |D ƒ ¡ ‰ ‡ ‡‡fdd„}tˆ|
||||||||	d�
}|jdd�S )aÙ  
        Retrieve pandas objects from multiple tables.

        .. warning::

           Pandas uses PyTables for reading and writing HDF5 files, which allows
           serializing object-dtype data with pickle when using the "fixed" format.
           Loading pickled data received from untrusted sources can be unsafe.

           See: https://docs.python.org/3/library/pickle.html for more.

        Parameters
        ----------
        keys : a list of the tables
        selector : the table to apply the where criteria (defaults to keys[0]
            if not supplied)
        columns : the columns I want back
        start : integer (defaults to None), row number to start selection
        stop  : integer (defaults to None), row number to stop selection
        iterator : bool, return an iterator, default False
        chunksize : nrows to include in iteration, return an iterator
        auto_close : bool, default False
            Should automatically close the store when finished.

        Raises
        ------
        raises KeyError if keys or selector is not found or keys is empty
        raises TypeError if keys is not a list or tuple
        raises ValueError if the tables are not ALL THE SAME DIMENSIONS
        rj   rk   r   )rŒ   ru   r­   r«   r¬   r¯   r°   r²   zkeys must be a list/tuplez keys must have a non-zero lengthNc                   ó   g | ]}ˆ   |¡‘qS rZ   )r,  ©rm   ÚkrØ   rZ   r[   rq   %  ó    z/HDFStore.select_as_multiple.<locals>.<listcomp>zInvalid table [Ú]zobject [z>] is not a table, and cannot be used in all select as multiplez,all tables must have exactly the same nrows!c                 S  s   g | ]	}t |tƒr|‘qS rZ   )rU   r  ©rm   ÚxrZ   rZ   r[   rq   :  ó    c                 S  s   h | ]	}|j d  d  ’qS ©r   )Únon_index_axes©rm   r}   rZ   rZ   r[   Ú	<setcomp>=  r:  z.HDFStore.select_as_multiple.<locals>.<setcomp>c                   s*   ‡ ‡‡‡fdd„ˆD ƒ}t |ˆdd� ¡ S )Nc                   s   g | ]}|j ˆˆˆ ˆd �‘qS )©ru   r­   r«   r¬   r  r=  )r  r   r!  r­   rZ   r[   rq   B  s    ÿÿz=HDFStore.select_as_multiple.<locals>.func.<locals>.<listcomp>F)ÚaxisÚverify_integrity)r4   Ú_consolidate)r  r   r!  Úobjs)r@  r­   Útblsr  r[   r#  ?  s   þz)HDFStore.select_as_multiple.<locals>.funcr$  T)Úcoordinates)rv   rU   rr   rs   rt   r`   r¿   rº   r³   r,  Ú	itertoolsÚchainÚziprç   Úis_tableÚpathnamer%  Úpopr(  r)  )rÔ   r
  ru   Úselectorr­   r«   r¬   r¯   r°   r²   rY   r%  r}   r5  Z_tblsr#  r*  rZ   )r@  r­   rÔ   rD  r[   Úselect_as_multipleá  sf   +
ø
 ÿ
ÿözHDFStore.select_as_multipleTr‚   r�   rŽ   r–   r“   r—   r˜   r›   rœ   r�   Útrack_timesr™   c                 C  sH   |du r
t dƒp	d}|  |¡}| j|||||||||	|
||||d� dS )a¬  
        Store object in HDFStore.

        Parameters
        ----------
        key : str
        value : {Series, DataFrame}
        format : 'fixed(f)|table(t)', default is 'fixed'
            Format to use when storing object in HDFStore. Value can be one of:

            ``'fixed'``
                Fixed format.  Fast writing/reading. Not-appendable, nor searchable.
            ``'table'``
                Table format.  Write as a PyTables Table structure which may perform
                worse but allow more flexible operations like searching / selecting
                subsets of the data.
        index : bool, default True
            Write DataFrame index as a column.
        append : bool, default False
            This will force Table format, append the input data to the existing.
        data_columns : list of columns or True, default None
            List of columns to create as data columns, or True to use all columns.
            See `here
            <https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#query-via-data-columns>`__.
        encoding : str, default None
            Provide an encoding for strings.
        track_times : bool, default True
            Parameter is propagated to 'create_table' method of 'PyTables'.
            If set to False it enables to have the same h5 files (same hashes)
            independent on creation time.
        dropna : bool, default False, optional
            Remove missing values.

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        Núio.hdf.default_formatrz   )r•   r–   r“   r’   r�   r—   rŸ   r›   r]   r�   rN  r™   )r   Ú_validate_formatÚ_write_to_group)rÔ   rŒ   r�   r•   r–   r“   r’   r�   r—   rŸ   r›   r]   r�   rN  r™   rZ   rZ   r[   r¦   Z  s&   8

òzHDFStore.putc              
   C  sØ   t |dd�}z|  |¡}W n? ty   ‚  ty   ‚  tyL } z%|dur,tdƒ|‚|  |¡}|durB|jdd� W Y d}~dS W Y d}~nd}~ww t 	|||¡r]|j
jdd� dS |jsdtdƒ‚|j|||d�S )	a:  
        Remove pandas object partially by specifying the where condition

        Parameters
        ----------
        key : str
            Node to remove or delete rows from
        where : list of Term (or convertible) objects, optional
        start : integer (defaults to None), row number to start selection
        stop  : integer (defaults to None), row number to stop selection

        Returns
        -------
        number of rows removed (or None if not a Table)

        Raises
        ------
        raises KeyError if key is not a valid store

        rj   rk   Nz5trying to remove a node with a non-None where clause!T©Ú	recursivez7can only remove with where on objects written as tablesr+  )rv   r,  rç   ÚAssertionErrorÚ	Exceptionr³   rë   Z	_f_removeÚcomÚall_nonerÄ   rI  Údelete)rÔ   rŒ   ru   r«   r¬   rY   Úerrrì   rZ   rZ   r[   rä   ¦  s8   ÿþ
þ€õÿzHDFStore.removeúbool | list[str]rš   c                 C  sl   |	durt dƒ‚|du rtdƒ}|du rtdƒpd}|  |¡}| j|||||||||
|||||||d� dS )a|  
        Append to Table in file.

        Node must already exist and be Table format.

        Parameters
        ----------
        key : str
        value : {Series, DataFrame}
        format : 'table' is the default
            Format to use when storing object in HDFStore.  Value can be one of:

            ``'table'``
                Table format. Write as a PyTables Table structure which may perform
                worse but allow more flexible operations like searching / selecting
                subsets of the data.
        index : bool, default True
            Write DataFrame index as a column.
        append       : bool, default True
            Append the input data to the existing.
        data_columns : list of columns, or True, default None
            List of columns to create as indexed data columns for on-disk
            queries, or True to use all columns. By default only the axes
            of the object are indexed. See `here
            <https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#query-via-data-columns>`__.
        min_itemsize : dict of columns that specify minimum str sizes
        nan_rep      : str to use as str nan representation
        chunksize    : size to chunk the writing
        expectedrows : expected TOTAL row size of this table
        encoding     : default None, provide an encoding for str
        dropna : bool, default False, optional
            Do not write an ALL nan row to the store settable
            by the option 'io.hdf.dropna_table'.

        Notes
        -----
        Does *not* check if data being appended overlaps with existing
        data in the table, so be careful

        Examples
        --------
        >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df1, format='table')  # doctest: +SKIP
        >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B'])
        >>> store.append('data', df2)  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
           A  B
        0  1  2
        1  3  4
        0  5  6
        1  7  8
        Nz>columns is not a supported keyword in append, try data_columnszio.hdf.dropna_tablerO  r{   )r•   Úaxesr–   r“   r’   r�   r—   rŸ   r°   Úexpectedrowsr™   r›   r]   r�   )rº   r   rP  rQ  )rÔ   rŒ   r�   r•   r[  r–   r“   r’   r�   r­   r—   rŸ   r°   r\  r™   r›   r]   r�   rZ   rZ   r[   r“   ß  s6   Iÿ

ðzHDFStore.appendÚdÚdictc                   s¢  |durt dƒ‚t|tƒstdƒ‚||vrtdƒ‚ttttˆjƒƒtt	t
ˆƒ ƒ ƒƒ}d}	g }
| ¡ D ]\}‰ ˆ du rG|	durDtdƒ‚|}	q4|
 ˆ ¡ q4|	durkˆj| }| t|
ƒ¡}t| |¡ƒ}| |¡||	< |du rs|| }|r“‡fdd„| ¡ D ƒ}t|ƒ}|D ]}| |¡}q†ˆj| ‰| dd¡}| ¡ D ]1\}‰ ||kr§|nd}ˆjˆ |d	�}|dur¿‡ fd
d„| ¡ D ƒnd}| j||f||dœ|¤Ž q�dS )a  
        Append to multiple tables

        Parameters
        ----------
        d : a dict of table_name to table_columns, None is acceptable as the
            values of one node (this will get all the remaining columns)
        value : a pandas object
        selector : a string that designates the indexable table; all of its
            columns will be designed as data_columns, unless data_columns is
            passed, in which case these are used
        data_columns : list of columns to create as data columns, or True to
            use all columns
        dropna : if evaluates to True, drop rows from all tables if any single
                 row in each table has all NaN. Default False.

        Notes
        -----
        axes parameter is currently not accepted

        Nztaxes is currently not accepted as a parameter to append_to_multiple; you can create the tables independently insteadzQappend_to_multiple must have a dictionary specified as the way to split the valuez=append_to_multiple requires a selector that is in passed dictz<append_to_multiple can only have one value in d that is Nonec                 3  s"   � | ]}ˆ | j d d�jV  qdS )Úall)ÚhowN)r™   r–   )rm   Úcols)r�   rZ   r[   Ú	<genexpr>�  s   €  z.HDFStore.append_to_multiple.<locals>.<genexpr>r—   ©r@  c                   s   i | ]\}}|ˆ v r||“qS rZ   rZ   ©rm   rŒ   r�   )ÚvrZ   r[   Ú
<dictcomp>   s    z/HDFStore.append_to_multiple.<locals>.<dictcomp>)r›   r—   )rº   rU   r^  r³   Únextr  ÚsetÚrangeÚndimÚ	_AXES_MAPrè   r  Úextendr[  Ú
differencer-   ÚsortedÚget_indexerÚtakeÚvaluesÚintersectionÚlocrK  Úreindexr“   )rÔ   r]  r�   rL  r›   r[  r™   rÂ   r@  Z
remain_keyZremain_valuesr5  ÚorderedZorddÚidxsÚvalid_indexr–   r—   ÚdcÚvalÚfilteredrZ   )re  r�   r[   Úappend_to_multipleE  s\   ÿ
ÿÿ&ÿ

ÿýõzHDFStore.append_to_multipleÚoptlevelÚkindr^   c                 C  sB   t ƒ  |  |¡}|du rdS t|tƒstdƒ‚|j|||d� dS )aà  
        Create a pytables index on the table.

        Parameters
        ----------
        key : str
        columns : None, bool, or listlike[str]
            Indicate which columns to create an index on.

            * False : Do not create any indexes.
            * True : Create indexes on all columns.
            * None : Create indexes on all columns.
            * listlike : Create indexes on the given columns.

        optlevel : int or None, default None
            Optimization level, if None, pytables defaults to 6.
        kind : str or None, default None
            Kind of index, if None, pytables defaults to "medium".

        Raises
        ------
        TypeError: raises if the node is not a table
        Nz1cannot create table index on a Fixed format store)r­   r|  r}  )rˆ   r,  rU   r  rº   Úcreate_index)rÔ   rŒ   r­   r|  r}  rY   rZ   rZ   r[   Úcreate_table_index¦  s   

zHDFStore.create_table_indexrr   c                 C  s<   t ƒ  |  ¡  | jdusJ ‚tdusJ ‚dd„ | j ¡ D ƒS )a�  
        Return a list of all the top-level nodes.

        Each node returned is not a pandas storage object.

        Returns
        -------
        list
            List of objects.

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> print(store.groups())  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        [/data (Group) ''
          children := ['axis0' (Array), 'axis1' (Array), 'block0_values' (Array),
          'block0_items' (Array)]]
        Nc                 S  sP   g | ]$}t |tjjƒs&t|jd dƒs$t|ddƒs$t |tjjƒr&|jdkr|‘qS )Úpandas_typeNr{   )	rU   rƒ   ÚlinkZLinkÚgetattrÚ_v_attrsr{   r  rÇ   )rm   r  rZ   rZ   r[   rq   è  s    üú
ùø
ùz#HDFStore.groups.<locals>.<listcomp>)rˆ   rÚ   rÊ   rƒ   Úwalk_groupsrØ   rZ   rZ   r[   r¼   Î  s   þzHDFStore.groupsr  ru   ú*Iterator[tuple[str, list[str], list[str]]]c                 c  s¾   � t ƒ  |  ¡  | jdusJ ‚tdusJ ‚| j |¡D ]A}t|jddƒdur'qg }g }|j ¡ D ]!}t|jddƒ}|du rKt	|tj
jƒrJ| |j¡ q0| |j¡ q0|j d¡||fV  qdS )a€  
        Walk the pytables group hierarchy for pandas objects.

        This generator will yield the group path, subgroups and pandas object
        names for each group.

        Any non-pandas PyTables objects that are not a group will be ignored.

        The `where` group itself is listed first (preorder), then each of its
        child groups (following an alphanumerical order) is also traversed,
        following the same procedure.

        Parameters
        ----------
        where : str, default "/"
            Group where to start walking.

        Yields
        ------
        path : str
            Full path to a group (without trailing '/').
        groups : list
            Names (strings) of the groups contained in `path`.
        leaves : list
            Names (strings) of the pandas objects contained in `path`.

        Examples
        --------
        >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df1, format='table')  # doctest: +SKIP
        >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B'])
        >>> store.append('data', df2)  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        >>> for group in store.walk():  # doctest: +SKIP
        ...     print(group)  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        Nr€  r  )rˆ   rÚ   rÊ   rƒ   r„  r‚  rƒ  Z_v_childrenrq  rU   rÄ   ZGroupr“   rÇ   r¾   Úrstrip)rÔ   ru   r  r¼   ÚleavesÚchildr€  rZ   rZ   r[   Úwalkõ  s&   €'€òzHDFStore.walkúNode | Nonec                 C  s~   |   ¡  | d¡sd| }| jdusJ ‚tdusJ ‚z
| j | j|¡}W n tjjy0   Y dS w t|tj	ƒs=J t
|ƒƒ‚|S )z9return the node with the key or None if it does not existr  N)rÚ   Ú
startswithrÊ   rƒ   rë   rÛ   Ú
exceptionsZNoSuchNodeErrorrU   rJ   rè   )rÔ   rŒ   rì   rZ   rZ   r[   rë   1  s   
ÿzHDFStore.get_nodeúGenericFixed | Tablec                 C  s8   |   |¡}|du rtd|› d�ƒ‚|  |¡}| ¡  |S )z<return the storer object for a key, raise if not in the fileNr  r  )rë   rç   r&  r'  )rÔ   rŒ   rÄ   rY   rZ   rZ   r[   r,  A  s   

zHDFStore.get_storerr  ÚpropindexesÚ	overwritec	              	   C  sÎ   t |||||d�}	|du rt|  ¡ ƒ}t|ttfƒs|g}|D ]E}
|  |
¡}|durd|
|	v r5|r5|	 |
¡ |  |
¡}t|tƒr[d}|rKdd„ |j	D ƒ}|	j
|
||t|ddƒ|jd� q|	j|
||jd� q|	S )	a;  
        Copy the existing store to a new file, updating in place.

        Parameters
        ----------
        propindexes : bool, default True
            Restore indexes in copied file.
        keys : list, optional
            List of keys to include in the copy (defaults to all).
        overwrite : bool, default True
            Whether to overwrite (remove and replace) existing nodes in the new store.
        mode, complib, complevel, fletcher32 same as in HDFStore.__init__

        Returns
        -------
        open file handle of the new store
        )r�   r’   r�   rÌ   NFc                 S  ó   g | ]}|j r|j‘qS rZ   )Ú
is_indexedrf   ©rm   r‰   rZ   rZ   r[   rq   y  ó    z!HDFStore.copy.<locals>.<listcomp>r›   )r–   r›   r]   rc   )r§   rr   r
  rU   rs   r,  rä   r¿   r  r[  r“   r‚  r]   r¦   )rÔ   r†   r�   rŽ  r
  r’   r�   rÌ   r�  Z	new_storer5  rY   Údatar–   rZ   rZ   r[   ÚcopyK  s8   
ÿ




û€zHDFStore.copyc           
      C  s  t | jƒ}t| ƒ› d|› d�}| jr~t|  ¡ ƒ}t|ƒrxg }g }|D ]K}z|  |¡}|durA| t |j	p5|ƒ¡ | t |p>dƒ¡ W q" t
yJ   ‚  tym } z| |¡ t |ƒ}	| d|	› d�¡ W Y d}~q"d}~ww |td||ƒ7 }|S |d7 }|S |d	7 }|S )
a  
        Print detailed information on the store.

        Returns
        -------
        str

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> print(store.info())  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        <class 'pandas.io.pytables.HDFStore'>
        File path: store.h5
        /data    frame    (shape->[2,2])
        rñ   rò   Nzinvalid_HDFStore nodez[invalid_HDFStore node: r7  é   ÚEmptyzFile is CLOSED)rC   rÎ   rè   r´   rn  r
  rt   r,  r“   rJ  rT  rU  rB   )
rÔ   r¸   ÚoutputZlkeysr
  rq  r5  rY   ÚdetailÚdstrrZ   rZ   r[   Úinfo†  s8   

€
€ýüþzHDFStore.infoc                 C  s   | j st| j› d�ƒ‚d S )Nz file is not open!)r´   r   rÎ   rØ   rZ   rZ   r[   rÚ   »  s   ÿzHDFStore._check_if_openr•   c              
   C  s>   z	t | ¡  }W |S  ty } z	td|› d�ƒ|‚d}~ww )zvalidate / deprecate formatsz#invalid HDFStore format specified [r7  N)Ú_FORMAT_MAPÚlowerrç   rº   )rÔ   r•   rY  rZ   rZ   r[   rP  ¿  s   ý€ÿzHDFStore._validate_formatrT   úDataFrame | Series | Noner]   c              
   C  s
  |durt |ttfƒstdƒ‚tt|jddƒƒ}tt|jddƒƒ}|du rZ|du rHtƒ  tdus2J ‚t|ddƒs?t |tj	j
ƒrDd}d}ntdƒ‚t |tƒrPd	}nd
}|dkrZ|d7 }d|vrŽttdœ}z|| }	W n ty… }
 ztd|› dt|ƒ› d|› �ƒ|
‚d}
~
ww |	| |||d�S |du rÑ|durÑ|dkr´t|ddƒ}|dur³|jdkr¬d}n%|jdkr³d}n|dkrÑt|ddƒ}|durÑ|jdkrÊd}n|jdkrÑd}ttttttdœ}z|| }	W n tyü }
 ztd|› dt|ƒ› d|› �ƒ|
‚d}
~
ww |	| |||d�S )z"return a suitable class to operateNz(value must be None, Series, or DataFramer€  Ú
table_typer{   Úframe_tableÚgeneric_tablezKcannot create a storer if the object is not existing nor a value are passedÚseriesÚframeÚ_table)r¢  r£  z=cannot properly create the storer for: [_STORER_MAP] [group->ú,value->z	,format->©r]   r�   Úseries_tabler–   rj   Úappendable_seriesÚappendable_multiseriesÚappendable_frameÚappendable_multiframe)r¡  r¨  r©  rª  r«  Úwormz<cannot properly create the storer for: [_TABLE_MAP] [group->)rU   r1   r+   rº   r\   r‚  rƒ  rˆ   rƒ   r{   r  ÚSeriesFixedÚ
FrameFixedrç   rè   ÚnlevelsÚGenericTableÚAppendableSeriesTableÚAppendableMultiSeriesTableÚAppendableFrameTableÚAppendableMultiFrameTableÚ	WORMTable)rÔ   rÄ   r•   r�   r]   r�   ÚptÚttZ_STORER_MAPÚclsrY  r–   Z
_TABLE_MAPrZ   rZ   r[   r&  É  s¢   ÿÿ

ÿÿÿÿý€ÿ

€

úÿÿÿÿý€ÿzHDFStore._create_storerc                 C  sÖ   t |dd ƒr|dks|rd S |  ||¡}| j|||||d�}|r9|jr-|jr1|dkr1|jr1tdƒ‚|js8| ¡  n| ¡  |jsF|rFtdƒ‚|j||||||	|
||||||d� t|t	ƒrg|ri|j
|d� d S d S d S )	NÚemptyr{   r¦  rz   zCan only append to Tablesz0Compression not supported on Fixed format stores)Úobjr[  r“   r’   r�   rÌ   r—   r°   r\  r™   rŸ   r›   rN  )r­   )r‚  Ú_identify_groupr&  rI  Ú	is_existsr³   Úset_object_infoÚwriterU   r  r~  )rÔ   rŒ   r�   r•   r[  r–   r“   r’   r�   rÌ   r—   r°   r\  r™   rŸ   r›   r]   r�   rN  rÄ   rY   rZ   rZ   r[   rQ  $  s>   €
óÿzHDFStore._write_to_grouprÄ   rJ   c                 C  s   |   |¡}| ¡  | ¡ S ra   )r&  r'  r  )rÔ   rÄ   rY   rZ   rZ   r[   r  b  s   
zHDFStore._read_groupc                 C  sN   |   |¡}| jdusJ ‚|dur|s| jj|dd� d}|du r%|  |¡}|S )z@Identify HDF5 group based on key, delete/create group if needed.NTrR  )rë   rÊ   Úremove_nodeÚ_create_nodes_and_group)rÔ   rŒ   r“   rÄ   rZ   rZ   r[   r»  g  s   

zHDFStore._identify_groupc                 C  sv   | j dusJ ‚| d¡}d}|D ](}t|ƒsq|}| d¡s"|d7 }||7 }|  |¡}|du r6| j  ||¡}|}q|S )z,Create nodes from key and return group name.Nr  )rÊ   Úsplitrt   Úendswithrë   Úcreate_group)rÔ   rŒ   Úpathsr¸   ÚpÚnew_pathrÄ   rZ   rZ   r[   rÀ  y  s   


z HDFStore._create_nodes_and_group)r‰   NNF)r�   r`   r�   r‘   rÌ   r”   r_   rž   ©r_   r`   ©rŒ   r`   )rŒ   r`   r_   rž   )rf   r`   )rŒ   r`   r_   r”   ©r_   ri   )r_   rP   )rö   r÷   rø   rù   rú   rû   r_   rž   )rþ   )rÿ   r`   r_   r   )r_   r  )r_   r  )r‰   )r�   r`   r_   rž   ©r_   rž   ©r_   r”   ©F)r  r”   r_   rž   )NNNNFNF)rŒ   r`   r¯   r”   r°   r‘   r²   r”   ©NNN©rŒ   r`   r«   r‘   r¬   r‘   ©NN)rŒ   r`   r0  r`   r«   r‘   r¬   r‘   )NNNNNFNF)r¯   r”   r°   r‘   r²   r”   )NTFNNNNNNr‚   TF)rŒ   r`   r�   rŽ   r–   r”   r“   r”   r�   r‘   r—   r˜   r›   rœ   r�   r`   rN  r”   r™   r”   r_   rž   )NNTTNNNNNNNNNNr‚   )rŒ   r`   r�   rŽ   r–   rZ  r“   r”   r�   r‘   r—   r˜   r°   r‘   r™   rš   r›   rœ   r�   r`   r_   rž   )NNF)r]  r^  r™   r”   r_   rž   )rŒ   r`   r|  r‘   r}  r^   r_   rž   )r_   rr   )r  )ru   r`   r_   r…  )rŒ   r`   r_   rŠ  )rŒ   r`   r_   r�  )r  TNNNFT)r�   r`   rŽ  r”   r�   r‘   rÌ   r”   r�  r”   r_   r§   )r•   r`   r_   r`   )NNrT   r‚   )r�   rž  r]   r`   r�   r`   r_   r�  )NTFNNNNNNFNNNr‚   T)rŒ   r`   r�   rŽ   r–   rZ  r“   r”   r�   r‘   r—   r˜   r°   r‘   r™   r”   r�   r`   rN  r”   r_   rž   )rÄ   rJ   )rŒ   r`   r“   r”   r_   rJ   )rŒ   r`   r_   rJ   )1ré   Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__rÕ   rÙ   ÚpropertyrÛ   rÜ   rá   rã   rå   rê   rí   rï   ró   rô   rý   r
  r  r  rÓ   rÁ   r´   r  rß   r¿   r/  r2  rM  r¦   rä   r“   r{  r  r¼   r‰  rë   r,  r•  r›  rÚ   rP  r&  rQ  r  r»  rÀ  rZ   rZ   rZ   r[   r§   ò  s
  
 Aú
!











*

-
 ÷`û$û+ö}ñL=îkùdû
('
<
÷
;
5
ú`í
>
r§   c                   @  s`   e Zd ZU dZded< ded< ded< 							dddd„Zddd„Zddd„Zdddd„ZdS )r(  aa  
    Define the iteration interface on a table

    Parameters
    ----------
    store : HDFStore
    s     : the referred storer
    func  : the function to execute the query
    where : the where of the query
    nrows : the rows to iterate on
    start : the passed start value (default is None)
    stop  : the passed stop value (default is None)
    iterator : bool, default False
        Whether to use the default iterator.
    chunksize : the passed chunking value (default is 100000)
    auto_close : bool, default False
        Whether to automatically close the store at the end of iteration.
    r‘   r°   r§   r¡   r�  rY   NFr¯   r”   r²   r_   rž   c                 C  sš   || _ || _|| _|| _| jjr'|d u rd}|d u rd}|d u r"|}t||ƒ}|| _|| _|| _d | _	|s9|	d urE|	d u r?d}	t
|	ƒ| _nd | _|
| _d S )Nr   é † )r¡   rY   r#  ru   rI  Úminr%  r«   r¬   rE  ri   r°   r²   )rÔ   r¡   rY   r#  ru   r%  r«   r¬   r¯   r°   r²   rZ   rZ   r[   rÕ   §  s,   

zTableIterator.__init__rE   c                 c  s€   � | j }| jd u rtdƒ‚|| jk r:t|| j | jƒ}|  d d | j||… ¡}|}|d u s1t|ƒs2q|V  || jk s|  ¡  d S )Nz*Cannot iterate until get_result is called.)	r«   rE  r³   r¬   rÖ  r°   r#  rt   rÁ   )rÔ   rÈ   r¬   r�   rZ   rZ   r[   r  Ñ  s   €


ù	zTableIterator.__iter__c                 C  s   | j r
| j ¡  d S d S ra   )r²   r¡   rÁ   rØ   rZ   rZ   r[   rÁ   á  s   ÿzTableIterator.closerE  c                 C  sŠ   | j d urt| jtƒstdƒ‚| jj| jd�| _| S |r3t| jtƒs&tdƒ‚| jj| j| j| j	d�}n| j}|  
| j| j	|¡}|  ¡  |S )Nz0can only use an iterator or chunksize on a table)ru   z$can only read_coordinates on a tabler+  )r°   rU   rY   r  rº   r-  ru   rE  r«   r¬   r#  rÁ   )rÔ   rE  ru   ÚresultsrZ   rZ   r[   r)  å  s   
ÿzTableIterator.get_result)NNFNF)r¡   r§   rY   r�  r¯   r”   r°   r‘   r²   r”   r_   rž   ©r_   rE   rÊ  rÌ  )rE  r”   )	ré   rÐ  rÑ  rÒ  rÓ  rÕ   r  rÁ   r)  rZ   rZ   rZ   r[   r(  �  s   
 	õ
*
r(  c                   @  s\  e Zd ZU dZdZded< dZded< g d¢Z													dMdNdd„Ze	dOdd„ƒZ
e	dPdd„ƒZdQdd„ZdPdd„ZdRdd„ZdSdd„Ze	dSd d!„ƒZdTd'd(„Zd)d*„ Ze	d+d,„ ƒZe	d-d.„ ƒZe	d/d0„ ƒZe	d1d2„ ƒZdUd4d5„ZdVdWd6d7„ZdWd8d9„ZdXd=d>„ZdVd?d@„ZdYdAdB„ZdWdCdD„ZdWdEdF„ZdWdGdH„ZdZdIdJ„Z dZdKdL„Z!dS )[ÚIndexCola  
    an index column description class

    Parameters
    ----------
    axis   : axis which I reference
    values : the ndarray like converted values
    kind   : a string description of this type
    typ    : the pytables type
    pos    : the position in the pytables

    Tr”   Úis_an_indexableÚis_data_indexable)ÚfreqÚtzÚ
index_nameNrf   r`   Úcnamer^   r_   rž   c                 C  s    t |tƒs	tdƒ‚|| _|| _|| _|| _|p|| _|| _|| _	|| _
|	| _|
| _|| _|| _|| _|| _|d ur>|  |¡ t | jtƒsFJ ‚t | jtƒsNJ ‚d S )Nz`name` must be a str.)rU   r`   r³   rq  r}  Útyprf   rß  r@  ÚposrÜ  rÝ  rÞ  ru  r{   rÆ   ÚmetadataÚset_pos)rÔ   rf   rq  r}  rà  rß  r@  rá  rÜ  rÝ  rÞ  ru  r{   rÆ   râ  rZ   rZ   r[   rÕ     s(   


zIndexCol.__init__ri   c                 C  ó   | j jS ra   )rà  ÚitemsizerØ   rZ   rZ   r[   rå  <  s   zIndexCol.itemsizec                 C  ó   | j › d�S )NÚ_kindre   rØ   rZ   rZ   r[   Ú	kind_attrA  ó   zIndexCol.kind_attrrá  c                 C  s,   || _ |dur| jdur|| j_dS dS dS )z,set the position of this column in the TableN)rá  rà  Z_v_pos)rÔ   rá  rZ   rZ   r[   rã  E  s   ÿzIndexCol.set_posc                 C  ó@   t tt| j| j| j| j| jfƒƒ}d dd„ t	g d¢|ƒD ƒ¡S )Nú,c                 S  ó   g | ]\}}|› d |› �‘qS ©z->rZ   rd  rZ   rZ   r[   rq   P  ó    ÿÿz%IndexCol.__repr__.<locals>.<listcomp>)rf   rß  r@  rá  r}  )
rs   ÚmaprC   rf   rß  r@  rá  r}  ÚjoinrH  ©rÔ   ÚtemprZ   rZ   r[   ró   K  s   ÿþÿzIndexCol.__repr__ÚotherÚobjectc                   ó   t ‡ ‡fdd„dD ƒƒS )úcompare 2 col itemsc                 3  ó(   � | ]}t ˆ|d ƒt ˆ |d ƒkV  qd S ra   ©r‚  r’  ©ró  rÔ   rZ   r[   rb  X  ó
   € ÿ
ÿz"IndexCol.__eq__.<locals>.<genexpr>)rf   rß  r@  rá  ©r_  ©rÔ   ró  rZ   rù  r[   Ú__eq__V  ó   þzIndexCol.__eq__c                 C  s   |   |¡ S ra   )rý  rü  rZ   rZ   r[   Ú__ne__]  rð   zIndexCol.__ne__c                 C  s"   t | jdƒsdS t| jj| jƒjS )z%return whether I am an indexed columnra  F)Úhasattrr{   r‚  ra  rß  r‘  rØ   rZ   rZ   r[   r‘  `  s   zIndexCol.is_indexedrq  ú
np.ndarrayr]   r�   ú3tuple[np.ndarray, np.ndarray] | tuple[Index, Index]c              
   C  st  t |tjƒsJ t|ƒƒ‚|jjdur|| j  ¡ }t| j	ƒ}t
||||ƒ}i }t| jƒ|d< | jdur:t| jƒ|d< t}t |jd¡sIt |jtƒrLt}n|jdkrYd|v rYdd„ }z
||fi |¤Ž}W nL ty— }	 z(|dkrŒtd	ƒrŒt|	ƒ d
¡rŒtrŒ||fdtdtjd�i|¤Ž}n‚ W Y d}	~	nd}	~	w ty¯   d|v r¥d|d< ||fi |¤Ž}Y nw t|| jƒ}
|
|
fS )zV
        Convert the data from this selection to the appropriate pandas type.
        Nrf   rÜ  ÚMÚi8c                 [  s    t j| | dd ¡d� |d ¡S )NrÜ  )rÜ  rf   )r/   Úfrom_ordinalsrß   Ú_rename)r9  ÚkwdsrZ   rZ   r[   r£   ˆ  s    ÿÿz"IndexCol.convert.<locals>.<lambda>Úsurrogatepassúfuture.infer_stringúsurrogates not allowedÚdtypeÚpython©ÚstorageÚna_value)rU   rV   Úndarrayrè   r  Úfieldsrß  r•  r\   r}  Ú_maybe_convertrÞ  rÜ  r-   r   Úis_np_dtyper'   r,   ÚUnicodeEncodeErrorr   r`   rÂ  r   r2   Únanr³   Ú_set_tzrÝ  )rÔ   rq  rŸ   r]   r�   Úval_kindrÂ   ÚfactoryZnew_pd_indexrY  Zfinal_pd_indexrZ   rZ   r[   Úconverth  sV   

ÿÿþýÿþýú€ûzIndexCol.convertc                 C  rÖ   )zreturn the values©rq  rØ   rZ   rZ   r[   Ú	take_data¨  rÝ   zIndexCol.take_datac                 C  rä  ra   )r{   rƒ  rØ   rZ   rZ   r[   Úattrs¬  ó   zIndexCol.attrsc                 C  rä  ra   ©r{   ÚdescriptionrØ   rZ   rZ   r[   r  °  r  zIndexCol.descriptionc                 C  s   t | j| jdƒS )z!return my current col descriptionN)r‚  r  rß  rØ   rZ   rZ   r[   Úcol´  ó   zIndexCol.colc                 C  rÖ   ©zreturn my cython valuesr  rØ   rZ   rZ   r[   Úcvalues¹  ó   zIndexCol.cvaluesrE   c                 C  s
   t | jƒS ra   )r  rq  rØ   rZ   rZ   r[   r  ¾  râ   zIndexCol.__iter__c                 C  s\   t | jƒdkr(t|tƒr| | j¡}|dur*| jj|k r,tƒ j	|| j
d�| _dS dS dS dS )zŸ
        maybe set a string col itemsize:
            min_itemsize can be an integer or a dict with this columns name
            with an integer size
        ÚstringN)rå  rá  )r\   r}  rU   r^  rß   rf   rà  rå  rˆ   Ú	StringColrá  )rÔ   r—   rZ   rZ   r[   Úmaybe_set_sizeÁ  s   
ûzIndexCol.maybe_set_sizec                 C  ó   d S ra   rZ   rØ   rZ   rZ   r[   Úvalidate_namesÎ  rõ   zIndexCol.validate_namesÚhandlerÚAppendableTabler“   c                 C  s:   |j | _ |  ¡  |  |¡ |  |¡ |  |¡ |  ¡  d S ra   )r{   Úvalidate_colÚvalidate_attrÚvalidate_metadataÚwrite_metadataÚset_attr)rÔ   r*  r“   rZ   rZ   r[   Úvalidate_and_setÑ  s   


zIndexCol.validate_and_setc                 C  s^   t | jƒdkr-| j}|dur-|du r| j}|j|k r*td|› d| j› d|j› d�ƒ‚|jS dS )z:validate this column: return the compared against itemsizer%  Nz#Trying to store a string with len [z] in [z)] column but
this column has a limit of [zC]!
Consider using min_itemsize to preset the sizes on these columns)r\   r}  r   rå  r³   rß  )rÔ   rå  ÚcrZ   rZ   r[   r,  Ù  s   
ÿþÿzIndexCol.validate_colc                 C  sJ   |rt | j| jd ƒ}|d ur!|| jkr#td|› d| j› d�ƒ‚d S d S d S )Nzincompatible kind in col [ú - r7  )r‚  r  rè  r}  rº   )rÔ   r“   Zexisting_kindrZ   rZ   r[   r-  ì  s   ÿýzIndexCol.validate_attrc                 C  sÆ   | j D ]]}t| |dƒ}| | ji ¡}| |¡}||v rT|durT||krT|dv rBt|||f }tj|tt	ƒ d� d||< t
| |dƒ qtd| j› d|› d|› d|› d�	ƒ‚|dus\|dur`|||< qdS )	z
        set/update the info for this indexable with the key/value
        if there is a conflict raise/warn as needed
        N)rÜ  rÞ  ©Ú
stacklevelzinvalid info for [z] for [z], existing_value [z] conflicts with new value [r7  )Ú_info_fieldsr‚  Ú
setdefaultrf   rß   rx   ÚwarningsÚwarnr   r   Úsetattrr³   )rÔ   r›  rŒ   r�   ÚidxZexisting_valueÚwsrZ   rZ   r[   Úupdate_infoõ  s.   

ÿÿþÿ€èzIndexCol.update_infoc                 C  s(   |  | j¡}|dur| j |¡ dS dS )z!set my state from the passed infoN)rß   rf   Ú__dict__Úupdate)rÔ   r›  r;  rZ   rZ   r[   Úset_info	  s   ÿzIndexCol.set_infoc                 C  s   t | j| j| jƒ dS )zset the kind for this columnN)r:  r  rè  r}  rØ   rZ   rZ   r[   r0  	  ó   zIndexCol.set_attrc                 C  sT   | j dkr"| j}| | j¡}|dur$|dur&t||ddd�s(tdƒ‚dS dS dS dS )z:validate that kind=category does not change the categoriesÚcategoryNT©Ú
strict_nanÚdtype_equalzEcannot append a categorical with different categories to the existing)rÆ   râ  Úread_metadatarß  r*   r³   )rÔ   r*  Znew_metadataZcur_metadatarZ   rZ   r[   r.  	  s   
ÿÿÿözIndexCol.validate_metadatac                 C  s"   | j dur| | j| j ¡ dS dS )zset the meta dataN)râ  r/  rß  )rÔ   r*  rZ   rZ   r[   r/  /	  s   
ÿzIndexCol.write_metadata)NNNNNNNNNNNNN)rf   r`   rß  r^   r_   rž   rÉ  rÇ  )rá  ri   r_   rž   ©ró  rô  r_   r”   rË  )rq  r  r]   r`   r�   r`   r_   r  rØ  ra   rÊ  )r*  r+  r“   r”   r_   rž   )r“   r”   r_   rž   )r*  r+  r_   rž   )"ré   rÐ  rÑ  rÒ  rÚ  rÓ  rÛ  r6  rÕ   rÔ  rå  rè  rã  ró   rý  rÿ  r‘  r  r  r  r  r   r#  r  r'  r)  r1  r,  r-  r=  r@  r0  r.  r/  rZ   rZ   rZ   r[   rÙ  ÿ  sd   
 ñ+




@









	


rÙ  c                   @  s2   e Zd ZdZeddd„ƒZddd„Zddd„ZdS )ÚGenericIndexColz:an index which is not represented in the data of the tabler_   r”   c                 C  ó   dS ©NFrZ   rØ   rZ   rZ   r[   r‘  8	  ó   zGenericIndexCol.is_indexedrq  r  r]   r`   r�   útuple[Index, Index]c                 C  s,   t |tjƒsJ t|ƒƒ‚tt|ƒƒ}||fS )zÛ
        Convert the data from this selection to the appropriate pandas type.

        Parameters
        ----------
        values : np.ndarray
        nan_rep : str
        encoding : str
        errors : str
        )rU   rV   r  rè   r0   rt   )rÔ   rq  rŸ   r]   r�   r–   rZ   rZ   r[   r  <	  s   zGenericIndexCol.convertrž   c                 C  r(  ra   rZ   rØ   rZ   rZ   r[   r0  N	  rõ   zGenericIndexCol.set_attrNrË  )rq  r  r]   r`   r�   r`   r_   rL  rÊ  )ré   rÐ  rÑ  rÒ  rÔ  r‘  r  r0  rZ   rZ   rZ   r[   rH  5	  s    
rH  c                      s  e Zd ZdZdZdZddgZ												d>d?‡ fdd„Zed@dd„ƒZ	ed@dd„ƒZ
d@dd„ZdAdd„ZdBdd„Zdd „ ZedCd#d$„ƒZed%d&„ ƒZedDd)d*„ƒZedEd+d,„ƒZed-d.„ ƒZed/d0„ ƒZed1d2„ ƒZed3d4„ ƒZdFd5d6„ZdGd:d;„ZdFd<d=„Z‡  ZS )HÚDataCola3  
    a data holding column, by definition this is not indexable

    Parameters
    ----------
    data   : the actual data
    cname  : the column name in the table to hold the data (typically
                values)
    meta   : a string description of the metadata
    metadata : the actual metadata
    FrÝ  ru  Nrf   r`   rß  r^   r  úDtypeArg | Noner_   rž   c                   s2   t ƒ j|||||||||	|
|d� || _|| _d S )N)rf   rq  r}  rà  rá  rß  rÝ  ru  r{   rÆ   râ  )ÚsuperrÕ   r  r”  )rÔ   rf   rq  r}  rà  rß  rá  rÝ  ru  r{   rÆ   râ  r  r”  ©Ú	__class__rZ   r[   rÕ   c	  s   õ
zDataCol.__init__c                 C  ræ  )NÚ_dtypere   rØ   rZ   rZ   r[   Ú
dtype_attrƒ	  ré  zDataCol.dtype_attrc                 C  ræ  )NÚ_metare   rØ   rZ   rZ   r[   Ú	meta_attr‡	  ré  zDataCol.meta_attrc                 C  rê  )Nrë  c                 S  rì  rí  rZ   rd  rZ   rZ   r[   rq   ’	  rî  z$DataCol.__repr__.<locals>.<listcomp>)rf   rß  r  r}  Úshape)
rs   rï  rC   rf   rß  r  r}  rV  rð  rH  rñ  rZ   rZ   r[   ró   ‹	  s   ÿÿþÿzDataCol.__repr__ró  rô  r”   c                   rõ  )rö  c                 3  r÷  ra   rø  r’  rù  rZ   r[   rb  š	  rú  z!DataCol.__eq__.<locals>.<genexpr>)rf   rß  r  rá  rû  rü  rZ   rù  r[   rý  ˜	  rþ  zDataCol.__eq__r”  rL   c                 C  s@   |d usJ ‚| j d u sJ ‚t|ƒ\}}|| _|| _ t|ƒ| _d S ra   )r  Ú_get_data_and_dtype_namer”  Ú_dtype_to_kindr}  )rÔ   r”  Ú
dtype_namerZ   rZ   r[   Úset_dataŸ	  s   zDataCol.set_datac                 C  rÖ   )zreturn the data©r”  rØ   rZ   rZ   r[   r  ©	  rÝ   zDataCol.take_datarq  rH   c                 C  sÖ   |j }|j}|j}|jdkrd|jf}t|tƒr&|j}| j||j j	d�}|S t
 |d¡s1t|tƒr8|  |¡}|S t
 |d¡rE|  |¡}|S t|ƒrUtƒ j||d d�}|S t|ƒra|  ||¡}|S | j||j	d�}|S )zW
        Get an appropriately typed and shaped pytables.Col object for values.
        rj   ©r}  r  Úmr   ©rå  rV  )r  rå  rV  rj  ÚsizerU   r6   ÚcodesÚget_atom_datarf   r   r  r'   Úget_atom_datetime64Úget_atom_timedelta64r"   rˆ   Z
ComplexColr$   Úget_atom_string)r¸  rq  r  rå  rV  r`  ÚatomrZ   rZ   r[   Ú	_get_atom­	  s.   


õ

÷
ùûþzDataCol._get_atomc                 C  s   t ƒ j||d d�S )Nr   r^  ©rˆ   r&  ©r¸  rV  rå  rZ   rZ   r[   rd  Í	  ó   zDataCol.get_atom_stringr}  ú	type[Col]c                 C  sR   |  d¡r|dd… }d|› d�}n|  d¡rd}n	| ¡ }|› d�}ttƒ |ƒS )z0return the PyTables column class for this columnÚuinté   NÚUIntrH   ÚperiodÚInt64Col)r‹  Ú
capitalizer‚  rˆ   )r¸  r}  Úk4Úcol_nameZkcaprZ   rZ   r[   Úget_atom_coltypeÑ	  s   


zDataCol.get_atom_coltypec                 C  s   | j |d�|d d�S )Nr\  r   ©rV  ©rs  ©r¸  rV  r}  rZ   rZ   r[   ra  à	  rA  zDataCol.get_atom_datac                 C  ó   t ƒ j|d d�S ©Nr   rt  ©rˆ   ro  ©r¸  rV  rZ   rZ   r[   rb  ä	  ó   zDataCol.get_atom_datetime64c                 C  rw  rx  ry  rz  rZ   rZ   r[   rc  è	  r{  zDataCol.get_atom_timedelta64c                 C  ó   t | jdd ƒS )NrV  )r‚  r”  rØ   rZ   rZ   r[   rV  ì	  ó   zDataCol.shapec                 C  rÖ   r"  r[  rØ   rZ   rZ   r[   r#  ð	  r$  zDataCol.cvaluesc                 C  sh   |r.t | j| jdƒ}|dur|t| jƒkrtdƒ‚t | j| jdƒ}|dur0|| jkr2tdƒ‚dS dS dS )zAvalidate that we have the same order as the existing & same dtypeNz4appended items do not match existing items in table!z@appended items dtype do not match existing items dtype in table!)r‚  r  rè  rr   rq  r³   rS  r  )rÔ   r“   Zexisting_fieldsZexisting_dtyperZ   rZ   r[   r-  õ	  s   ÿùzDataCol.validate_attrr  r]   r�   c                 C  s  t |tjƒsJ t|ƒƒ‚|jjdur|| j }| jdusJ ‚| jdu r.t|ƒ\}}t	|ƒ}n|}| j}| j
}t |tjƒs>J ‚t| jƒ}| j}	| j}
| j}|dusRJ ‚t|ƒ}| d¡rct||dd�}n‹|dkrotj|dd�}n|dkr—ztjd	d
„ |D ƒtd�}W nl ty–   tjdd
„ |D ƒtd�}Y nXw |dkrÔ|	}| ¡ }|du r­tg tjd�}nt|ƒ}| ¡ rÊ||  }||dk  | t¡ ¡ j8  < tj|||
dd�}nz	|j|dd�}W n t yí   |jddd�}Y nw t|ƒdkrüt!||||d�}| j"|fS )aR  
        Convert the data from this selection to the appropriate pandas type.

        Parameters
        ----------
        values : np.ndarray
        nan_rep :
        encoding : str
        errors : str

        Returns
        -------
        index : listlike to become an Index
        data : ndarraylike to become a column
        NÚ
datetime64T©ÚcoerceÚtimedelta64úm8[ns]©r  r   c                 S  ó   g | ]}t  |¡‘qS rZ   ©r   Úfromordinal©rm   re  rZ   rZ   r[   rq   9
  r6  z#DataCol.convert.<locals>.<listcomp>c                 S  r„  rZ   ©r   Úfromtimestampr‡  rZ   rZ   r[   rq   =
  r6  rB  éÿÿÿÿF)Ú
categoriesru  Úvalidate©r•  ÚOr%  ©rŸ   r]   r�   )#rU   rV   r  rè   r  r  rß  rà  rW  rX  r}  r\   rÆ   râ  ru  rÝ  r‹  r  Úasarrayrô  r³   Úravelr-   Úfloat64r5   ÚanyÚastyperi   ÚcumsumÚ_valuesr6   Ú
from_codesrº   Ú_unconvert_string_arrayrq  )rÔ   rq  rŸ   r]   r�   Ú	convertedrY  r}  rÆ   râ  ru  rÝ  r  r‹  r`  ÚmaskrZ   rZ   r[   r  
  sj   





ÿ
ÿÿ
 ÿÿÿ
zDataCol.convertc                 C  sH   t | j| j| jƒ t | j| j| jƒ | jdusJ ‚t | j| j| jƒ dS )zset the data for this columnN)r:  r  rè  rq  rU  rÆ   r  rS  rØ   rZ   rZ   r[   r0  f
  s   zDataCol.set_attr)NNNNNNNNNNNN)rf   r`   rß  r^   r  rN  r_   rž   rÇ  rG  )r”  rL   r_   rž   )rq  rL   r_   rH   )r}  r`   r_   rj  ©r}  r`   r_   rH   rÊ  )rq  r  r]   r`   r�   r`   )ré   rÐ  rÑ  rÒ  rÚ  rÛ  r6  rÕ   rÔ  rS  rU  ró   rý  rZ  r  Úclassmethodrf  rd  rs  ra  rb  rc  rV  r#  r-  r  r0  Ú__classcell__rZ   rZ   rP  r[   rM  R	  sZ    ò 










drM  c                   @  sP   e Zd ZdZdZddd„Zedd„ ƒZeddd„ƒZedd„ ƒZ	edd„ ƒZ
dS )ÚDataIndexableColz+represent a data column that can be indexedTr_   rž   c                 C  s   t t| jƒjƒstdƒ‚d S )Nú-cannot have non-object label DataIndexableCol)r$   r-   rq  r  r³   rØ   rZ   rZ   r[   r)  s
  s   þzDataIndexableCol.validate_namesc                 C  s   t ƒ j|d�S )N)rå  rg  rh  rZ   rZ   r[   rd  x
  r}  z DataIndexableCol.get_atom_stringr}  r`   rH   c                 C  s   | j |d�ƒ S )Nr\  ru  rv  rZ   rZ   r[   ra  |
  r}  zDataIndexableCol.get_atom_datac                 C  ó
   t ƒ  ¡ S ra   ry  rz  rZ   rZ   r[   rb  €
  ó   
z$DataIndexableCol.get_atom_datetime64c                 C  r   ra   ry  rz  rZ   rZ   r[   rc  „
  r¡  z%DataIndexableCol.get_atom_timedelta64NrÊ  r›  )ré   rÐ  rÑ  rÒ  rÛ  r)  rœ  rd  ra  rb  rc  rZ   rZ   rZ   r[   rž  n
  s    


rž  c                   @  s   e Zd ZdZdS )ÚGenericDataIndexableColz(represent a generic pytables data columnN)ré   rÐ  rÑ  rÒ  rZ   rZ   rZ   r[   r¢  ‰
  s    r¢  c                   @  s~  e Zd ZU dZded< dZded< ded< ded	< d
ed< dZded< 		dPdQdd„ZedRdd„ƒZ	edSdd„ƒZ
edd „ ƒZdTd!d"„ZdUd#d$„ZdVd%d&„Zed'd(„ ƒZed)d*„ ƒZed+d,„ ƒZed-d.„ ƒZedWd/d0„ƒZedRd1d2„ƒZed3d4„ ƒZdUd5d6„ZdUd7d8„Zed9d:„ ƒZedRd;d<„ƒZed=d>„ ƒZdXd@dA„ZdYdUdCdD„ZdRdEdF„Z	B	B	B	BdZd[dJdK„ZdUdLdM„Z	Bd\d]dNdO„Z dBS )^ÚFixedzø
    represent an object in my store
    facilitate read/write of various types of objects
    this is an abstract base class

    Parameters
    ----------
    parent : HDFStore
    group : Node
        The group node where the table resides.
    r`   Úpandas_kindrz   Úformat_typeútype[DataFrame | Series]Úobj_typeri   rj  r§   rÉ   Fr”   rI  rT   r‚   rÄ   rJ   r]   r^   r�   r_   rž   c                 C  sZ   t |tƒsJ t|ƒƒ‚td usJ ‚t |tjƒsJ t|ƒƒ‚|| _|| _t|ƒ| _|| _	d S ra   )
rU   r§   rè   rƒ   rJ   rÉ   rÄ   rd   r]   r�   )rÔ   rÉ   rÄ   r]   r�   rZ   rZ   r[   rÕ   ¡
  s   

zFixed.__init__c                 C  s*   | j d dko| j d dko| j d dk S )Nr   rj   é
   é   )ÚversionrØ   rZ   rZ   r[   Úis_old_version°
  s   *zFixed.is_old_versionútuple[int, int, int]c                 C  sf   t t| jjddƒƒ}ztdd„ | d¡D ƒƒ}t|ƒdkr$|d }W |S W |S  ty2   d}Y |S w )	zcompute and set our versionÚpandas_versionNc                 s  s   � | ]}t |ƒV  qd S ra   ©ri   r8  rZ   rZ   r[   rb  ¹
  s   € z Fixed.version.<locals>.<genexpr>Ú.r©  r;  )r   r   r   )r\   r‚  rÄ   rƒ  rs   rÁ  rt   r…   )rÔ   rª  rZ   rZ   r[   rª  ´
  s   
üþþzFixed.versionc                 C  s   t t| jjdd ƒƒS )Nr€  )r\   r‚  rÄ   rƒ  rØ   rZ   rZ   r[   r€  À
  ri  zFixed.pandas_typec                 C  s^   |   ¡  | j}|dur,t|ttfƒr"d dd„ |D ƒ¡}d|› d�}| jd›d|› d	�S | jS )
ú(return a pretty representation of myselfNrë  c                 S  ó   g | ]}t |ƒ‘qS rZ   ©rC   r8  rZ   rZ   r[   rq   Ê
  ó    z"Fixed.__repr__.<locals>.<listcomp>Ú[r7  ú12.12z	 (shape->ú))r'  rV  rU   rr   rs   rð  r€  )rÔ   rY   ZjshaperZ   rZ   r[   ró   Ä
  s   zFixed.__repr__c                 C  s   t | jƒ| j_t tƒ| j_dS )zset my pandas type & versionN)r`   r¤  r  r€  Ú_versionr­  rØ   rZ   rZ   r[   r½  Ï
  s   zFixed.set_object_infoc                 C  s   t   | ¡}|S ra   r�  )rÔ   Únew_selfrZ   rZ   r[   r•  Ô
  s   
z
Fixed.copyc                 C  rÖ   ra   )r%  rØ   rZ   rZ   r[   rV  Ø
  rÝ   zFixed.shapec                 C  rä  ra   ©rÄ   r¾   rØ   rZ   rZ   r[   rJ  Ü
  r  zFixed.pathnamec                 C  rä  ra   )rÉ   rÊ   rØ   rZ   rZ   r[   rÊ   à
  r  zFixed._handlec                 C  rä  ra   )rÉ   rÒ   rØ   rZ   rZ   r[   rÒ   ä
  r  zFixed._filtersc                 C  rä  ra   )rÉ   rÏ   rØ   rZ   rZ   r[   rÏ   è
  r  zFixed._complevelc                 C  rä  ra   )rÉ   rÑ   rØ   rZ   rZ   r[   rÑ   ì
  r  zFixed._fletcher32c                 C  rä  ra   )rÄ   rƒ  rØ   rZ   rZ   r[   r  ð
  r  zFixed.attrsc                 C  rI  ©zset our object attributesNrZ   rØ   rZ   rZ   r[   Ú	set_attrsô
  ó    zFixed.set_attrsc                 C  rI  )zget our object attributesNrZ   rØ   rZ   rZ   r[   Ú	get_attrs÷
  r¼  zFixed.get_attrsc                 C  rÖ   )zreturn my storable©rÄ   rØ   rZ   rZ   r[   Ústorableú
  r$  zFixed.storablec                 C  rI  rJ  rZ   rØ   rZ   rZ   r[   r¼  ÿ
  rK  zFixed.is_existsc                 C  r|  )Nr%  )r‚  r¿  rØ   rZ   rZ   r[   r%    r}  zFixed.nrowsúLiteral[True] | Nonec                 C  s   |du rdS dS )z%validate against an existing storableNTrZ   rü  rZ   rZ   r[   rŒ    s   zFixed.validateNc                 C  rI  )ú+are we trying to operate on an old version?NrZ   )rÔ   ru   rZ   rZ   r[   Úvalidate_version  r¼  zFixed.validate_versionc                 C  s   | j }|du r	dS |  ¡  dS )zr
        infer the axes of my storer
        return a boolean indicating if we have a valid storer or not
        NFT)r¿  r½  )rÔ   rY   rZ   rZ   r[   r'    s
   zFixed.infer_axesr«   r‘   r¬   c                 C  ó   t dƒ‚)Nz>cannot read on an abstract storer: subclasses should implement©r¶   ©rÔ   ru   r­   r«   r¬   rZ   rZ   r[   r    s   ÿz
Fixed.readc                 K  rÃ  )Nz?cannot write on an abstract storer: subclasses should implementrÄ  ©rÔ   rº  rÂ   rZ   rZ   r[   r¾  &  s   ÿzFixed.writec                 C  s,   t  |||¡r| jj| jdd� dS tdƒ‚)zs
        support fully deleting the node in its entirety (only) - where
        specification must be None
        TrR  Nz#cannot delete on an abstract storer)rV  rW  rÊ   r¿  rÄ   rº   )rÔ   ru   r«   r¬   rZ   rZ   r[   rX  +  s   zFixed.delete)rT   r‚   )
rÉ   r§   rÄ   rJ   r]   r^   r�   r`   r_   rž   rË  )r_   r¬  rÇ  rÊ  )r_   r£  rÉ  )r_   rÀ  ra   ©NNNN©r«   r‘   r¬   r‘   rÍ  )r«   r‘   r¬   r‘   r_   rž   )!ré   rÐ  rÑ  rÒ  rÓ  r¥  rI  rÕ   rÔ  r«  rª  r€  ró   r½  r•  rV  rJ  rÊ   rÒ   rÏ   rÑ   r  r»  r½  r¿  r¼  r%  rŒ  rÂ  r'  r  r¾  rX  rZ   rZ   rZ   r[   r£  �
  sj   
 û














û
ÿr£  c                   @  sî   e Zd ZU dZedediZdd„ e ¡ D ƒZg Z	de
d< d<d
d„Zdd„ Zdd„ Zd=dd„Zed>dd„ƒZd=dd„Zd=dd„Zd=dd„Zd?d@d!d"„Z	d?dAd$d%„ZdBd'd(„ZdCd*d+„Z	d?dDd,d-„Z	d?dEd0d1„ZdFd4d5„Z	dGdHd:d;„ZdS )IÚGenericFixedza generified fixed versionÚdatetimern  c                 C  s   i | ]\}}||“qS rZ   rZ   )rm   r5  re  rZ   rZ   r[   rf  =  r6  zGenericFixed.<dictcomp>r   Ú
attributesr_   r`   c                 C  s   | j  |d¡S )NÚ )Ú_index_type_maprß   )rÔ   r¸  rZ   rZ   r[   Ú_class_to_aliasA  s   zGenericFixed._class_to_aliasc                 C  s   t |tƒr|S | j |t¡S ra   )rU   rè   Ú_reverse_index_maprß   r-   )rÔ   ÚaliasrZ   rZ   r[   Ú_alias_to_classD  s   
zGenericFixed._alias_to_classc                 C  s¸   |   tt|ddƒƒ¡}|tkrd	dd„}|}n|tkr#d	dd„}|}n|}i }d|v r7|d |d< |tu r7t}d|v rXt|d tƒrL|d  	d¡|d< n|d |d< |tu sXJ ‚||fS )
NÚindex_classrÌ  c                 S  s>   t j| j| j|d�}tj|d d�}|d ur| d¡ |¡}|S )N)r  rÜ  re   ÚUTC)r7   Ú_simple_newrq  r  r,   Útz_localizeÚ
tz_convert)rq  rÜ  rÝ  ÚdtaÚresultrZ   rZ   r[   r|   S  s   
ÿz*GenericFixed._get_index_factory.<locals>.fc                 S  s$   t |ƒ}tj| |d�}tj|d d�S )Nrƒ  re   )r)   r8   rÔ  r/   )rq  rÜ  rÝ  r  ÚparrrZ   rZ   r[   r|   `  s   rÜ  rÝ  zutf-8rÏ  )
rÑ  r\   r‚  r,   r/   r-   r3   rU   ÚbytesrX   )rÔ   r  rÒ  r|   r  rÂ   rZ   rZ   r[   Ú_get_index_factoryJ  s*   ÿ


zGenericFixed._get_index_factoryrž   c                 C  s$   |durt dƒ‚|durt dƒ‚dS )zE
        raise if any keywords are passed which are not-None
        Nzqcannot pass a column specification when reading a Fixed format store. this store must be selected in its entiretyzucannot pass a where specification when reading from a Fixed format store. this store must be selected in its entirety)rº   )rÔ   r­   ru   rZ   rZ   r[   Úvalidate_read{  s   ÿÿÿzGenericFixed.validate_readr”   c                 C  rI  )NTrZ   rØ   rZ   rZ   r[   r¼  Š  rK  zGenericFixed.is_existsc                 C  s   | j | j_ | j| j_dS rº  )r]   r  r�   rØ   rZ   rZ   r[   r»  Ž  s   
zGenericFixed.set_attrsc              	   C  sR   t t| jddƒƒ| _tt| jddƒƒ| _| jD ]}t| |tt| j|dƒƒƒ qdS )úretrieve our attributesr]   Nr�   r‚   )rd   r‚  r  r]   r\   r�   rË  r:  )rÔ   r  rZ   rZ   r[   r½  “  s
   
ÿzGenericFixed.get_attrsc                 K  rü   ra   )r»  rÆ  rZ   rZ   r[   r¾  š  rð   zGenericFixed.writeNrŒ   r«   r‘   r¬   c                 C  sò   ddl }t| j|ƒ}|j}t|ddƒ}t||jƒr2|d ||… }t|ddƒ}	|	dur1t||	d�}n@tt|ddƒƒ}	t|ddƒ}
|
durLtj	|
|	d�}n|||… }|	rg|	 
d¡rgt|d	dƒ}t||d
d�}n|	dkrrtj|dd�}|rw|jS |S )z2read an array for the specified node (off of groupr   NÚ
transposedFÚ
value_typerƒ  rV  r~  rÝ  Tr  r�  r‚  )r„   r‚  rÄ   rƒ  rU   ZVLArrayÚpd_arrayr\   rV   r¹  r‹  r  r�  ÚT)rÔ   rŒ   r«   r¬   r„   rì   r  rÞ  Úretr  rV  rÝ  rZ   rZ   r[   Ú
read_array�  s.   €zGenericFixed.read_arrayr-   c                 C  sd   t t| j|› d�ƒƒ}|dkr| j|||d�S |dkr+t| j|ƒ}| j|||d�}|S td|› �ƒ‚)NÚ_varietyÚmulti©r«   r¬   Úregularzunrecognized index variety: )r\   r‚  r  Úread_multi_indexrÄ   Úread_index_noderº   )rÔ   rŒ   r«   r¬   Zvarietyrì   r–   rZ   rZ   r[   Ú
read_indexÂ  s   zGenericFixed.read_indexr–   c                 C  sê   t |tƒrt| j|› d�dƒ |  ||¡ d S t| j|› d�dƒ td|| j| jƒ}|  ||j	¡ t
| j|ƒ}|j|j_|j|j_t |ttfƒrQ|  t|ƒ¡|j_t |tttfƒr^|j|j_t |tƒrq|jd urst|jƒ|j_d S d S d S )Nrä  rå  rç  r–   )rU   r.   r:  r  Úwrite_multi_indexÚ_convert_indexr]   r�   Úwrite_arrayrq  r‚  rÄ   r}  rƒ  rf   r,   r/   rÎ  rè   rÒ  r3   rÜ  rÝ  Ú_get_tz)rÔ   rŒ   r–   r™  rì   rZ   rZ   r[   Úwrite_indexÐ  s    



ÿzGenericFixed.write_indexr.   c                 C  sÒ   t | j|› d�|jƒ tt|j|j|jƒƒD ]P\}\}}}t|j	t
ƒr'tdƒ‚|› d|› �}t||| j| jƒ}|  ||j¡ t| j|ƒ}	|j|	j_||	j_t |	j|› d|› �|ƒ |› d|› �}
|  |
|¡ qd S )NÚ_nlevelsz=Saving a MultiIndex with an extension dtype is not supported.Ú_levelÚ_nameÚ_label)r:  r  r¯  Ú	enumeraterH  Úlevelsr`  ÚnamesrU   r  r(   r¶   rì  r]   r�   rí  rq  r‚  rÄ   r}  rƒ  rf   )rÔ   rŒ   r–   ÚiÚlevÚlevel_codesrf   Ú	level_keyZ
conv_levelrì   Ú	label_keyrZ   rZ   r[   rë  ç  s$   ÿÿ
ìzGenericFixed.write_multi_indexc                 C  s¤   t | j|› d�ƒ}g }g }g }t|ƒD ]6}|› d|› �}	t | j|	ƒ}
| j|
||d�}| |¡ | |j¡ |› d|› �}| j|||d�}| |¡ qt|||dd�S )Nrð  rñ  ræ  ró  T)rõ  r`  rö  rA  )	r‚  r  ri  rÄ   ré  r“   rf   rã  r.   )rÔ   rŒ   r«   r¬   r¯  rõ  r`  rö  r÷  rú  rì   rø  rû  rù  rZ   rZ   r[   rè     s    
ÿzGenericFixed.read_multi_indexrì   rJ   c              
   C  sX  |||… }d|j v rt |j j¡dkrtj|j j|j jd�}t|j jƒ}d }d|j v r6t|j j	ƒ}t|ƒ}|j }|  
|¡\}}	|dv rW|t||| j| jd�fdti|	¤Ž}
nPz|t||| j| jd�fi |	¤Ž}
W n= ty¦ } z1| jdkr›td	ƒr›t|ƒ d
¡r›tr›|t||| j| jd�fdtdtjd�i|	¤Ž}
n‚ W Y d }~nd }~ww ||
_	|
S )NrV  r   rƒ  rf   )r   rô  r¦  r  r  r	  r
  r  r  )rƒ  rV   ÚprodrV  r¹  rß  r\   r}  rg   rf   rÛ  Ú_unconvert_indexr]   r�   rô  r  r   r`   rÂ  r   r2   r  )rÔ   rì   r«   r¬   r”  r}  rf   r  r  rÂ   r–   rY  rZ   rZ   r[   ré    sf   
ÿÿüûÿÿ
ü
ÿþýÿÿüûø€ùzGenericFixed.read_index_noder�   rL   c                 C  sJ   t  d|j ¡}| j | j||¡ t| j|ƒ}t|jƒ|j	_
|j|j	_dS )zwrite a 0-len array©rj   N)rV   r¹  rj  rÊ   Úcreate_arrayrÄ   r‚  r`   r  rƒ  rß  rV  )rÔ   rŒ   r�   Úarrrì   rZ   rZ   r[   Úwrite_array_emptyN  s
   zGenericFixed.write_array_emptyrº  rK   r  úIndex | Nonec                 C  sª  t |dd�}|| jv r| j | j|¡ |jdk}d}t|jtƒr$tdƒ‚|s0t	|dƒr0|j
}d}d }| jd urSttƒ� tƒ j |j¡}W d   ƒ n1 sNw   Y  |d uru|sn| jj| j|||j| jd�}||d d …< nÝ|  ||¡ nÖ|jjtjkr­tj|dd�}	|r†n|	d	kr‹nt|	||f }
tj|
ttƒ d
� | j | j|tƒ  ¡ ¡}|  |¡ nžt !|jd¡rÌ| j "| j|| #d¡¡ t$|jƒt%| j|ƒj&_'nt|jt(ƒrô| j "| j||j)¡ t%| j|ƒ}t*|j+ƒ|j&_+d|jj,› d�|j&_'nWt !|jd¡�r| j "| j|| #d¡¡ dt%| j|ƒj&_'n:t|t-ƒ�r8| j | j|tƒ  ¡ ¡}|  | .¡ ¡ t%| j|ƒ}t$|jƒ|j&_'n|�rB|  ||¡ n	| j "| j||¡ |t%| j|ƒj&_/d S )NT)Úextract_numpyr   Fz]Cannot store a category dtype in a HDF5 dataset that uses format="fixed". Use format="table".rá  )rÍ   ©Úskipnar%  r4  r  r  údatetime64[r7  r]  r�  )0r=   rÄ   rÊ   r¿  r_  rU   r  r&   r¶   r   rá  rÒ   r   r³   rˆ   ÚAtomZ
from_dtypeZcreate_carrayrV  r  rè   rV   Úobject_r   Úinfer_dtypery   r8  r9  r   r   Zcreate_vlarrayÚ
ObjectAtomr“   r  rÿ  Úviewr`   r‚  rƒ  rß  r'   Úasi8rî  rÝ  Úunitr9   Úto_numpyrÞ  )rÔ   rŒ   rº  r  r�   Zempty_arrayrÞ  re  ÚcaÚinferred_typer<  Zvlarrrì   rZ   rZ   r[   rí  W  sr   

ÿ


þÿ
ÿzGenericFixed.write_arrayrÇ  rÊ  rË  rÏ  rÎ  )rŒ   r`   r«   r‘   r¬   r‘   r_   r-   )rŒ   r`   r–   r-   r_   rž   )rŒ   r`   r–   r.   r_   rž   )rŒ   r`   r«   r‘   r¬   r‘   r_   r.   )rì   rJ   r«   r‘   r¬   r‘   r_   r-   )rŒ   r`   r�   rL   r_   rž   ra   )rŒ   r`   rº  rK   r  r  r_   rž   )ré   rÐ  rÑ  rÒ  r,   r/   rÍ  r  rÏ  rË  rÓ  rÎ  rÑ  rÛ  rÜ  rÔ  r¼  r»  r½  r¾  rã  rê  rï  rë  rè  ré  r  rí  rZ   rZ   rZ   r[   rÉ  9  s4   
 

1


&ÿ

ÿÿ
7
ÿrÉ  c                      sR   e Zd ZU dZdgZded< edd„ ƒZ				dddd„Zd‡ fdd„Z	‡  Z
S )r­  r¢  rf   rD   c              	   C  s*   zt | jjƒfW S  ttfy   Y d S w ra   )rt   rÄ   rq  rº   r…   rØ   rZ   rZ   r[   rV  ½  s
   ÿzSeriesFixed.shapeNr«   r‘   r¬   r_   r1   c           	      C  s²   |   ||¡ | jd||d�}| jd||d�}zt||| jdd�}W |S  tyX } z*| jdkrLtdƒrLt|ƒ 	d¡rLt
rLt||| jdtd	tjd
�d�}n‚ W Y d }~|S d }~ww )Nr–   ræ  rq  F)r–   rf   r•  r  r	  r
  r  r  )r–   rf   r•  r  )rÜ  rê  rã  r1   rf   r  r�   r   r`   rÂ  r   r2   rV   r  )	rÔ   ru   r­   r«   r¬   r–   rq  rØ  rY  rZ   rZ   r[   r  Ä  s4   ð
ÿþýû
ø	€ðzSeriesFixed.readrž   c                   s<   t ƒ j|fi |¤Ž |  d|j¡ |  d|¡ |j| j_d S )Nr–   rq  )rO  r¾  rï  r–   rí  rf   r  rÆ  rP  rZ   r[   r¾  â  s   zSeriesFixed.writerÇ  ©r«   r‘   r¬   r‘   r_   r1   rÊ  )ré   rÐ  rÑ  r¤  rË  rÓ  rÔ  rV  r  r¾  r�  rZ   rZ   rP  r[   r­  ·  s   
 
ûr­  c                      sR   e Zd ZU ddgZded< eddd„ƒZ				dddd„Zd‡ fdd„Z‡  Z	S )ÚBlockManagerFixedrj  Únblocksri   r_   úShape | Nonec                 C  sª   zJ| j }d}t| jƒD ]}t| jd|› d�ƒ}t|dd ƒ}|d ur'||d 7 }q| jj}t|dd ƒ}|d urAt|d|d … ƒ}ng }| |¡ |W S  tyT   Y d S w )Nr   ÚblockÚ_itemsrV  rj   )	rj  ri  r  r‚  rÄ   Zblock0_valuesrr   r“   r…   )rÔ   rj  r  r÷  rì   rV  rZ   rZ   r[   rV  î  s&   €
ÿzBlockManagerFixed.shapeNr«   r‘   r¬   r+   c                 C  sX  |   ||¡ |  ¡  d¡}g }t| jƒD ]}||kr||fnd\}}	| jd|› �||	d�}
| |
¡ q|d }g }t| jƒD ]F}|  d|› d�¡}| jd|› d�||	d�}|| 	|¡ }t
|j||d d	d
�}tƒ rt|tjƒrt|dd�r| ttjd�¡}| |¡ q>t|ƒdkr¢t|ddd�}tƒ r™| ¡ }|j|d	d�}|S t
|d |d d�S )Nr   rÏ  r@  ræ  r  r  r–  rj   F©r­   r–   r•  Tr  )r  )r@  r•  )r­   r•  ©r­   r–   )rÜ  r§  Ú_get_block_manager_axisri  rj  rê  r“   r  rã  ro  r+   rá  r   rU   rV   r  r   r”  r2   r  rt   r4   r   r•  rt  )rÔ   ru   r­   r«   r¬   Zselect_axisr[  r÷  r  r   Úaxr  ÚdfsÚ	blk_itemsrq  ÚdfÚoutrZ   rZ   r[   r  	  s:   ÿ
þ
ýzBlockManagerFixed.readrž   c                   sè   t ƒ j|fi |¤Ž t|jtƒr| d¡}|j}| ¡ s | ¡ }|j| j	_t
|jƒD ]\}}|dkr9|js9tdƒ‚|  d|› �|¡ q*t|jƒ| j	_t
|jƒD ]"\}}|j |j¡}| jd|› d�|j|d� |  d|› d�|¡ qOd S )Nr  r   z/Columns index has to be unique for fixed formatr@  r–  )r  r  )rO  r¾  rU   Ú_mgrr?   Ú_as_managerÚis_consolidatedÚconsolidaterj  r  rô  r[  Ú	is_uniquer³   rï  rt   Úblocksr  r  rp  Úmgr_locsrí  rq  )rÔ   rº  rÂ   r”  r÷  r  Úblkr  rP  rZ   r[   r¾  6  s"   

üzBlockManagerFixed.write)r_   r  rÇ  )r«   r‘   r¬   r‘   r_   r+   rÊ  )
ré   rÐ  rÑ  rË  rÓ  rÔ  rV  r  r¾  r�  rZ   rZ   rP  r[   r  é  s   
 û-r  c                   @  s   e Zd ZdZeZdS )r®  r£  N)ré   rÐ  rÑ  r¤  r+   r§  rZ   rZ   rZ   r[   r®  P  s    r®  c                      s(  e Zd ZU dZdZdZded< ded< dZded	< d
Zded< 								d‹dŒ‡ fd"d#„Z	e
d�d$d%„ƒZd�d&d'„ZdŽd)d*„Zd�d+d,„Ze
d�d.d/„ƒZd‘d3d4„Ze
d’d6d7„ƒZe
d�d8d9„ƒZe
d:d;„ ƒZe
d<d=„ ƒZe
d>d?„ ƒZe
d@dA„ ƒZe
d“dCdD„ƒZe
d’dEdF„ƒZe
d�dGdH„ƒZe
d”dJdK„ƒZd•dMdN„ZdOdP„ Zd–dRdS„Zd—dUdV„Zd˜dYdZ„Zd™d[d\„Z d�d]d^„Z!d�d_d`„Z"dšd�dadb„Z#d�dcdd„Z$e%dedf„ ƒZ&	d›dœdhdi„Z'	d�dždndo„Z(e)dŸdqdr„ƒZ*dsdt„ Z+	
			d d¡dwdx„Z,e-d¢d{d|„ƒZ.dšd£dd€„Z/d¤d„d…„Z0	d›d¥d†d‡„Z1			d›d¦d‰dŠ„Z2‡  Z3S )§r  aa  
    represent a table:
        facilitate read/write of various types of tables

    Attrs in Table Node
    -------------------
    These are attributes that are store in the main table node, they are
    necessary to recreate these tables when read back in.

    index_axes    : a list of tuples of the (original indexing axis and
        index column)
    non_index_axes: a list of tuples of the (original index axis and
        columns on a non-indexing axis)
    values_axes   : a list of the columns which comprise the data of this
        table
    data_columns  : a list of the columns that we are allowing indexing
        (these become single columns in values_axes)
    nan_rep       : the string to use for nan representations for string
        objects
    levels        : the names of levels
    metadata      : the names of the metadata columns
    Z
wide_tabler{   r`   r¥  rŸ  rj   zint | list[Hashable]rõ  Trr   râ  Nr‚   rÉ   r§   rÄ   rJ   r]   r^   r�   Ú
index_axesúlist[IndexCol] | Noner<  ú list[tuple[AxisInt, Any]] | NoneÚvalues_axesúlist[DataCol] | Noner›   úlist | Noner›  údict | Noner_   rž   c                   sP   t ƒ j||||d� |pg | _|pg | _|pg | _|pg | _|	p!i | _|
| _d S )Nr¦  )rO  rÕ   r'  r<  r*  r›   r›  rŸ   )rÔ   rÉ   rÄ   r]   r�   r'  r<  r*  r›   r›  rŸ   rP  rZ   r[   rÕ   u  s   





zTable.__init__c                 C  s   | j  d¡d S )NÚ_r   )rŸ  rÁ  rØ   rZ   rZ   r[   Útable_type_shortŠ  ó   zTable.table_type_shortc                 C  s¦   |   ¡  t| jƒrd | j¡nd}d|› d�}d}| jr-d dd„ | jD ƒ¡}d|› d�}d d	d„ | jD ƒ¡}| jd
›|› d| j› d| j	› d| j
› d|› d|› d�S )r°  rë  rÌ  z,dc->[r7  r¯  c                 S  r±  rZ   ©r`   r8  rZ   rZ   r[   rq   –  r³  z"Table.__repr__.<locals>.<listcomp>r´  c                 S  r  rZ   re   r’  rZ   rZ   r[   rq   ™  r  rµ  z (typ->z,nrows->z,ncols->z,indexers->[r¶  )r'  rt   r›   rð  r«  rª  r'  r€  r/  r%  Úncols)rÔ   Zjdcrx  ÚverZjverZjindex_axesrZ   rZ   r[   ró   Ž  s(   ÿÿþþþÿzTable.__repr__r2  c                 C  s"   | j D ]}||jkr|  S qdS )zreturn the axis for cN)r[  rf   )rÔ   r2  r‰   rZ   rZ   r[   rá      s
   

ÿzTable.__getitem__c              
   C  sô   |du rdS |j | j krtd|j › d| j › d�ƒ‚dD ]\}t| |dƒ}t||dƒ}||krwt|ƒD ]7\}}|| }||krh|dkrZ|j|jkrZtd|jd › d	|j› d
|j› d�ƒ‚td|› d|› d|› d�ƒ‚q1td|› d|› d|› d�ƒ‚qdS )z"validate against an existing tableNz'incompatible table_type with existing [r3  r7  )r'  r<  r*  r*  úCannot serialize the column [r   z%] because its data contents are not [z] but [ú] object dtypezinvalid combination of [z] on appending data [z] vs current table [)rŸ  rº   r‚  rô  r}  r³   rq  rU  )rÔ   ró  r2  ÚsvÚovr÷  ZsaxZoaxrZ   rZ   r[   rŒ  §  sP   ÿÿÿÿþÿÿÿÿùÿÿìýzTable.validater”   c                 C  s   t | jtƒS )z@the levels attribute is 1 or a list in the case of a multi-index)rU   rõ  rr   rØ   rZ   rZ   r[   Úis_multi_indexÎ  s   zTable.is_multi_indexrº  rŽ   ú tuple[DataFrame, list[Hashable]]c              
   C  sT   t  |jj¡}z| ¡ }W n ty } ztdƒ|‚d}~ww t|tƒs&J ‚||fS )ze
        validate that we can store the multi-index; reset and return the
        new object
        zBduplicate names/columns in the multi-index when storing as a tableN)rV  Úfill_missing_namesr–   rö  Úreset_indexr³   rU   r+   )rÔ   rº  rõ  Z	reset_objrY  rZ   rZ   r[   Úvalidate_multiindexÓ  s   ÿþ€ÿzTable.validate_multiindexri   c                 C  s   t  dd„ | jD ƒ¡S )z-based on our axes, compute the expected nrowsc                 S  s   g | ]}|j jd  ‘qS r;  )r#  rV  ©rm   r÷  rZ   rZ   r[   rq   ç  r“  z(Table.nrows_expected.<locals>.<listcomp>)rV   rü  r'  rØ   rZ   rZ   r[   Únrows_expectedä  s   zTable.nrows_expectedc                 C  s
   d| j v S )zhas this table been createdr{   r¾  rØ   rZ   rZ   r[   r¼  é  s   
zTable.is_existsc                 C  r|  ©Nr{   ©r‚  rÄ   rØ   rZ   rZ   r[   r¿  î  r}  zTable.storablec                 C  rÖ   )z,return the table group (this is my storable))r¿  rØ   rZ   rZ   r[   r{   ò  r$  zTable.tablec                 C  rä  ra   )r{   r  rØ   rZ   rZ   r[   r  ÷  r  zTable.dtypec                 C  rä  ra   r  rØ   rZ   rZ   r[   r  û  r  zTable.descriptionúitertools.chain[IndexCol]c                 C  s   t  | j| j¡S ra   )rF  rG  r'  r*  rØ   rZ   rZ   r[   r[  ÿ  r0  z
Table.axesc                 C  s   t dd„ | jD ƒƒS )z.the number of total columns in the values axesc                 s  s   � | ]}t |jƒV  qd S ra   )rt   rq  r’  rZ   rZ   r[   rb    s   € zTable.ncols.<locals>.<genexpr>)Úsumr*  rØ   rZ   rZ   r[   r2    s   zTable.ncolsc                 C  rI  rJ  rZ   rØ   rZ   rZ   r[   Úis_transposed  rK  zTable.is_transposedútuple[int, ...]c                 C  s(   t t dd„ | jD ƒdd„ | jD ƒ¡ƒS )z@return a tuple of my permutated axes, non_indexable at the frontc                 S  s   g | ]}t |d  ƒ‘qS r;  r®  r’  rZ   rZ   r[   rq     r“  z*Table.data_orientation.<locals>.<listcomp>c                 S  s   g | ]}t |jƒ‘qS rZ   )ri   r@  r’  rZ   rZ   r[   rq     r6  )rs   rF  rG  r<  r'  rØ   rZ   rZ   r[   Údata_orientation  s   þÿzTable.data_orientationúdict[str, Any]c                   sR   dddœ‰ dd„ ˆj D ƒ}‡ fdd„ˆjD ƒ}‡fdd„ˆjD ƒ}t|| | ƒS )z<return a dict of the kinds allowable columns for this objectr–   r­   ©r   rj   c                 S  s   g | ]}|j |f‘qS rZ   ©rß  r’  rZ   rZ   r[   rq     r6  z$Table.queryables.<locals>.<listcomp>c                   s   g | ]
\}}ˆ | d f‘qS ra   rZ   )rm   r@  rq  )Ú
axis_namesrZ   r[   rq     s    c                   s&   g | ]}|j tˆ jƒv r|j|f‘qS rZ   )rf   rh  r›   rß  r‡  rØ   rZ   r[   rq     s     )r'  r<  r*  r^  )rÔ   Úd1Úd2Úd3rZ   )rI  rÔ   r[   Ú
queryables  s   

ÿzTable.queryablesc                 C  ó   dd„ | j D ƒS )zreturn a list of my index colsc                 S  s   g | ]}|j |jf‘qS rZ   )r@  rß  r=  rZ   rZ   r[   rq   '  r“  z$Table.index_cols.<locals>.<listcomp>©r'  rØ   rZ   rZ   r[   Ú
index_cols$  r!  zTable.index_colsr   c                 C  rN  )zreturn a list of my values colsc                 S  r  rZ   rH  r=  rZ   rZ   r[   rq   +  r  z%Table.values_cols.<locals>.<listcomp>)r*  rØ   rZ   rZ   r[   Úvalues_cols)  r0  zTable.values_colsrŒ   c                 C  s   | j j}|› d|› d�S )z)return the metadata pathname for this keyz/meta/z/metar¹  r  rZ   rZ   r[   Ú_get_metadata_path-  s   zTable._get_metadata_pathrq  r  c                 C  s0   | j j|  |¡t|dd�d| j| j| jd� dS )z£
        Write out a metadata array to the key as a fixed-format Series.

        Parameters
        ----------
        key : str
        values : ndarray
        Fr�  r{   )r•   r]   r�   rŸ   N)rÉ   r¦   rR  r1   r]   r�   rŸ   )rÔ   rŒ   rq  rZ   rZ   r[   r/  2  s   	

úzTable.write_metadatac                 C  s0   t t | jddƒ|dƒdur| j |  |¡¡S dS )z'return the meta data array for this keyrÆ   N)r‚  rÄ   rÉ   r¿   rR  rà   rZ   rZ   r[   rF  D  s   zTable.read_metadatac                 C  sp   t | jƒ| j_|  ¡ | j_|  ¡ | j_| j| j_| j| j_| j| j_| j| j_| j	| j_	| j
| j_
| j| j_dS )zset our table type & indexablesN)r`   rŸ  r  rP  rQ  r<  r›   rŸ   r]   r�   rõ  r›  rØ   rZ   rZ   r[   r»  J  s   





zTable.set_attrsc                 C  s°   t | jddƒpg | _t | jddƒpg | _t | jddƒpi | _t | jddƒ| _tt | jddƒƒ| _tt | jddƒƒ| _	t | jd	dƒpBg | _
d
d„ | jD ƒ| _dd„ | jD ƒ| _dS )rÝ  r<  Nr›   r›  rŸ   r]   r�   r‚   rõ  c                 S  ó   g | ]}|j r|‘qS rZ   ©rÚ  r’  rZ   rZ   r[   rq   `  r6  z#Table.get_attrs.<locals>.<listcomp>c                 S  ó   g | ]}|j s|‘qS rZ   rT  r’  rZ   rZ   r[   rq   a  r6  )r‚  r  r<  r›   r›  rŸ   rd   r]   r\   r�   rõ  Ú
indexablesr'  r*  rØ   rZ   rZ   r[   r½  W  s   zTable.get_attrsc                 C  sF   |dur| j r!td dd„ | jD ƒ¡ }tj|ttƒ d� dS dS dS )rÁ  Nr¯  c                 S  r±  rZ   r1  r8  rZ   rZ   r[   rq   g  r³  z*Table.validate_version.<locals>.<listcomp>r4  )r«  rw   rð  rª  r8  r9  r   r   )rÔ   ru   r<  rZ   rZ   r[   rÂ  c  s   
ýýzTable.validate_versionc                 C  sR   |du rdS t |tƒsdS |  ¡ }|D ]}|dkrq||vr&td|› d�ƒ‚qdS )zˆ
        validate the min_itemsize doesn't contain items that are not in the
        axes this needs data_columns to be defined
        Nrq  zmin_itemsize has the key [z%] which is not an axis or data_column)rU   r^  rM  r³   )rÔ   r—   Úqr5  rZ   rZ   r[   Úvalidate_min_itemsizen  s   

ÿÿüzTable.validate_min_itemsizec                   sÔ   g }ˆj ‰ˆjj‰tˆjjƒD ]5\}\}}tˆ|ƒ}ˆ |¡}|dur%dnd}|› d�}tˆ|dƒ}	t||||	|ˆj||d�}
| |
¡ qt	ˆj
ƒ‰t|ƒ‰ ‡ ‡‡‡‡fdd„‰| ‡fdd„tˆjjƒD ƒ¡ |S )	z/create/cache the indexables if they don't existNrB  rç  )rf   r@  rá  r}  rà  r{   rÆ   râ  c                   s¢   t |tƒsJ ‚t}|ˆv rt}tˆ|ƒ}t|ˆjƒ}tˆ|› d�d ƒ}tˆ|› d�d ƒ}t|ƒ}ˆ |¡}tˆ|› d�d ƒ}	|||||ˆ |  |ˆj	|	||d�
}
|
S )Nrç  rR  rT  )
rf   rß  rq  r}  rá  rà  r{   rÆ   râ  r  )
rU   r`   rM  rž  r‚  Ú_maybe_adjust_namerª  rX  rF  r{   )r÷  r2  Úklassre  Úadj_namerq  r  r}  ÚmdrÆ   rº  )Úbase_posrx  ÚdescrÔ   Útable_attrsrZ   r[   r|   ¦  s0   

özTable.indexables.<locals>.fc                   s   g | ]	\}}ˆ ||ƒ‘qS rZ   rZ   )rm   r÷  r2  )r|   rZ   r[   rq   Ë  r:  z$Table.indexables.<locals>.<listcomp>)r  r{   r  rô  rP  r‚  rF  rÙ  r“   rh  r›   rt   rl  rQ  )rÔ   Ú_indexablesr÷  r@  rf   re  r\  rÆ   rè  r}  Ú	index_colrZ   )r]  rx  r^  r|   rÔ   r_  r[   rV  ƒ  s2   


ø

 %zTable.indexablesr}  c              	   C  sP  |   ¡ sdS |du rdS |du s|du rdd„ | jD ƒ}t|ttfƒs&|g}i }|dur0||d< |dur8||d< | j}|D ]h}t|j|dƒ}|durŽ|jrx|j	}|j
}	|j}
|durc|
|krc| ¡  n|
|d< |durt|	|krt| ¡  n|	|d< |js�|j d¡r…td	ƒ‚|jdi |¤Ž q=|| jd
 d v r¥td|› d|› d|› d�ƒ‚q=dS )aZ  
        Create a pytables index on the specified columns.

        Parameters
        ----------
        columns : None, bool, or listlike[str]
            Indicate which columns to create an index on.

            * False : Do not create any indexes.
            * True : Create indexes on all columns.
            * None : Create indexes on all columns.
            * listlike : Create indexes on the given columns.

        optlevel : int or None, default None
            Optimization level, if None, pytables defaults to 6.
        kind : str or None, default None
            Kind of index, if None, pytables defaults to "medium".

        Raises
        ------
        TypeError if trying to create an index on a complex-type column.

        Notes
        -----
        Cannot index Time64Col or ComplexCol.
        Pytables must be >= 3.0.
        NFTc                 S  r�  rZ   )rÛ  rß  r’  rZ   rZ   r[   rq   ô  r“  z&Table.create_index.<locals>.<listcomp>r|  r}  ÚcomplexzíColumns containing complex values can be stored but cannot be indexed when using table format. Either use fixed format, set index=False, or do not include the columns containing complex values to data_columns when initializing the table.r   rj   zcolumn z/ is not a data_column.
In order to read column z: you must reload the dataframe 
into HDFStore and include z  with the data_columns argument.rZ   )r'  r[  rU   rs   rr   r{   r‚  ra  r‘  r–   r|  r}  Zremove_indexrè   r‹  rº   r~  r<  r…   )rÔ   r­   r|  r}  Úkwr{   r2  re  r–   Zcur_optlevelZcur_kindrZ   rZ   r[   r~  Ï  sX   

ÿ€ÿþÿþâzTable.create_indexr«   r‘   r¬   ú9list[tuple[np.ndarray, np.ndarray] | tuple[Index, Index]]c           	      C  sZ   t | |||d�}| ¡ }g }| jD ]}| | j¡ |j|| j| j| jd�}| 	|¡ q|S )a  
        Create the axes sniffed from the table.

        Parameters
        ----------
        where : ???
        start : int or None, default None
        stop : int or None, default None

        Returns
        -------
        List[Tuple[index_values, column_values]]
        r+  r�  )
Ú	Selectionr¿   r[  r@  r›  r  rŸ   r]   r�   r“   )	rÔ   ru   r«   r¬   Ú	selectionrq  r×  r‰   ÚresrZ   rZ   r[   Ú
_read_axes%  s   
üzTable._read_axesrÞ  c                 C  ó   |S )zreturn the data for this objrZ   ©r¸  rº  rÞ  rZ   rZ   r[   Ú
get_objectG  s   zTable.get_objectc                   s²   t |ƒsg S |d \}‰ | j |i ¡}| d¡dkr&|r&td|› d|› �ƒ‚|du r/tˆ ƒ}n|du r5g }t|tƒrPt|ƒ‰t|ƒ}| ‡fdd	„| 	¡ D ƒ¡ ‡ fd
d	„|D ƒS )zd
        take the input data_columns and min_itemize and create a data
        columns spec
        r   rè   r.   z"cannot use a multi-index on axis [z] with data_columns TNc                   s    g | ]}|d kr|ˆ vr|‘qS r  rZ   r4  )Úexisting_data_columnsrZ   r[   rq   h  s
    þz/Table.validate_data_columns.<locals>.<listcomp>c                   s   g | ]}|ˆ v r|‘qS rZ   rZ   )rm   r2  )Úaxis_labelsrZ   r[   rq   p  r“  )
rt   r›  rß   r³   rr   rU   r^  rh  rl  r
  )rÔ   r›   r—   r<  r@  r›  rZ   )rm  rl  r[   Úvalidate_data_columnsL  s.   ÿÿ


þÿ	zTable.validate_data_columnsr+   rŒ  c           /        s˜  t ˆtƒs| jj}td|› dtˆƒ› d�ƒ‚ˆ du rdg‰ ‡fdd„ˆ D ƒ‰ |  ¡ r=d}d	d„ | jD ƒ‰ t| j	ƒ}| j
}nd
}| j}	| jdksIJ ‚tˆ ƒ| jd krVtdƒ‚g }
|du r^d}t‡ fdd„dD ƒƒ}ˆj| }t|ƒ}|r¡t|
ƒ}| j| d }tt |¡t |¡ddd�s¡tt t|ƒ¡t t|ƒ¡ddd�r¡|}|	 |i ¡}t|jƒ|d< t|ƒj|d< |
 ||f¡ ˆ d }ˆj| }ˆ |¡}t||| j| jƒ}||_| d¡ |  |	¡ | !|¡ |g}t|ƒ}|dksòJ ‚t|
ƒdksúJ ‚|
D ]}t"ˆ|d |d ƒ‰qü|jdk}|  #|||
¡}|  $ˆ|¡ %¡ }|  &|||
| j'|¡\}}g }t(t)||ƒƒD ]â\}\}}t*}d}|�rbt|ƒdk�rb|d |v �rbt+}|d }|du �sbt |t,ƒ�sbtdƒ‚|�rŒ|�rŒz| j'| }W n t-t.f�y‹ }  ztd|› d| j'› d�ƒ| ‚d} ~ ww d}|�p•d|› �}!t/|!|j0|||| j| j|d�}"t1|!| j2ƒ}#| 3|"¡}$t4|"j5j6ƒ}%d}&t7|"ddƒdu�rÆt8|"j9ƒ}&d }' }(})t |"j5t:ƒ�rá|"j;})d}'t <|"j=¡ >¡ }(nt |j5t?ƒ�rít,|j5ƒ}'t@|"ƒ\}*}+||#|!t|ƒ|$||%|&|)|'|(|+|*d�},|,  |	¡ | |,¡ |d7 }�q2dd„ |D ƒ}-t| ƒ| jA| j| j| j||
||-|	|d�
}.tB| dƒ�r:| jC|._C|. D|¡ |�rJ|�rJ|. E| ¡ |.S ) a0  
        Create and return the axes.

        Parameters
        ----------
        axes: list or None
            The names or numbers of the axes to create.
        obj : DataFrame
            The object to create axes on.
        validate: bool, default True
            Whether to validate the obj against an existing object already written.
        nan_rep :
            A value to use for string column nan_rep.
        data_columns : List[str], True, or None, default None
            Specify the columns that we want to create to allow indexing on.

            * True : Use all available columns.
            * None : Use no columns.
            * List[str] : Use the specified columns.

        min_itemsize: Dict[str, int] or None, default None
            The min itemsize for a column in bytes.
        z/cannot properly create the storer for: [group->r¥  r7  Nr   c                   r3  rZ   )Ú_get_axis_numberr’  )rº  rZ   r[   rq   ž  r6  z&Table._create_axes.<locals>.<listcomp>Tc                 S  r  rZ   rc  r’  rZ   rZ   r[   rq   £  r  Fr©  rj   z<currently only support ndim-1 indexers in an AppendableTabler  c                 3  s   � | ]	}|ˆ vr|V  qd S ra   rZ   r8  )r[  rZ   r[   rb  »  s   € z%Table._create_axes.<locals>.<genexpr>rG  rC  rö  rè   rŸ  zIncompatible appended table [z]with existing table [Zvalues_block_)Úexisting_colr—   rŸ   r]   r�   r­   rÝ  rB  )rf   rß  rq  rà  rá  r}  rÝ  ru  rÆ   râ  r  r”  c                 S  r�  rZ   )rÛ  rf   )rm   r   rZ   rZ   r[   rq   K  r“  )
rÉ   rÄ   r]   r�   r'  r<  r*  r›   r›  rŸ   rõ  )FrU   r+   rÄ   rÇ   rº   rè   r'  r'  rr   r›   rŸ   r›  rj  rt   r³   rg  r[  r<  r*   rV   r<   rn  r7  rö  ré   r“   Ú_get_axis_namerì  r]   r�   r@  rã  r=  r'  Ú_reindex_axisrn  rk  rB  Ú_get_blocks_and_itemsr*  rô  rH  rM  rž  r`   Ú
IndexErrorrç   Ú_maybe_convert_for_string_atomrq  rY  rª  rf  rX  r  rf   r‚  rî  rÝ  r&   ru  r�  r‹  r‘  r2   rW  rÉ   r   rõ  rX  rŒ  )/rÔ   r[  rº  rŒ  rŸ   r›   r—   rÄ   Útable_existsZnew_infoÚnew_non_index_axesr;  r‰   Zappend_axisÚindexerZ
exist_axisr›  Ú	axis_nameÚ	new_indexZnew_index_axesÚjrÞ  r£  r$  r  Zvaxesr÷  r&  Úb_itemsrZ  rf   rp  rY  Únew_nameÚdata_convertedr[  rà  r}  rÝ  rÆ   râ  ru  r”  rY  r   ÚdcsZ	new_tablerZ   )r[  rº  r[   Ú_create_axesr  s4  
 ÿÿ
ÿ
üü





ÿÿ"ÿÿý€ÿø



ô

ö

zTable._create_axesr£  rv  c                 C  s~  t | jtƒr|  d¡} dd„ }| j}tt|ƒ}t|jƒ}||ƒ}t|ƒri|d \}	}
t	|
ƒ 
t	|ƒ¡}| j||	d�j}tt|ƒ}t|jƒ}||ƒ}|D ]}| j|g|	d�j}tt|ƒ}| |j¡ | ||ƒ¡ qK|r»dd„ t||ƒD ƒ}g }g }|D ];}t|jƒ}z| |¡\}}| |¡ | |¡ W q{ ttfy¶ } zd d	d
„ |D ƒ¡}td|› d�ƒ|‚d }~ww |}|}||fS )Nr  c                   s   ‡ fdd„ˆ j D ƒS )Nc                   s   g | ]	}ˆ j  |j¡‘qS rZ   )r  rp  r%  )rm   r&  ©ÚmgrrZ   r[   rq   s  r:  zFTable._get_blocks_and_items.<locals>.get_blk_items.<locals>.<listcomp>)r$  r�  rZ   r�  r[   Úget_blk_itemsr  s   z2Table._get_blocks_and_items.<locals>.get_blk_itemsr   rc  c                 S  s"   i | ]\}}t | ¡ ƒ||f“qS rZ   )rs   Útolist)rm   Úbr|  rZ   rZ   r[   rf  ‘  s    ÿÿz/Table._get_blocks_and_items.<locals>.<dictcomp>rë  c                 S  r±  rZ   r²  )rm   ÚitemrZ   rZ   r[   rq   ž  r³  z/Table._get_blocks_and_items.<locals>.<listcomp>z+cannot match existing table structure for [z] on appending data)rU   r  r?   r   r   r@   rr   r$  rt   r-   rm  rt  rl  rH  rs   rq  rK  r“   rt  rç   rð  r³   )r£  rv  rw  r*  r›   rƒ  r‚  r$  r  r@  rm  Ú
new_labelsr2  Zby_itemsÚ
new_blocksZnew_blk_itemsÚear  r…  r|  rY  ZjitemsrZ   rZ   r[   rs  d  sV   





þ


ÿý€þzTable._get_blocks_and_itemsrf  re  c                   sª   |durt |ƒ}|dur'ˆjr'tˆjt ƒsJ ‚ˆjD ]}||vr&| d|¡ qˆjD ]\}}tˆ |||ƒ‰ ‡ ‡fdd„}q*|jdurS|j ¡ D ]\}}	}
|||
|	ƒ‰ qGˆ S )zprocess axes filtersNr   c                   sÈ   ˆ j D ]X}ˆ  |¡}ˆ  |¡}|d usJ ‚| |kr3ˆjr$| tˆjƒ¡}|||ƒ}ˆ j|d�|   S | |v r[tt	ˆ | ƒj
ƒ}t|ƒ}tˆ tƒrLd| }|||ƒ}ˆ j|d�|   S qtd| › d�ƒ‚)Nrc  rj   zcannot find the field [z] for filtering!)Ú_AXIS_ORDERSro  Ú	_get_axisr8  Úunionr-   rõ  rs  r>   r‚  rq  rU   r+   r³   )ÚfieldÚfiltÚopry  Úaxis_numberZaxis_valuesZtakersrq  ©rº  rÔ   rZ   r[   Úprocess_filter¹  s$   





öz*Table.process_axes.<locals>.process_filter)	rr   r8  rU   rõ  Úinsertr<  rr  Úfilterr•   )rÔ   rº  rf  r­   r  r@  Úlabelsr’  r�  r�  rŽ  rZ   r‘  r[   Úprocess_axes¨  s   
€
 zTable.process_axesr�   rÌ   r\  c                 C  s„   |du r
t | jdƒ}d|dœ}dd„ | jD ƒ|d< |r6|du r$| jp#d}tƒ j|||p-| jd	�}||d
< |S | jdur@| j|d
< |S )z:create the description of the table from the axes & valuesNi'  r{   )rf   r\  c                 S  s   i | ]}|j |j“qS rZ   )rß  rà  r’  rZ   rZ   r[   rf  î  r6  z,Table.create_description.<locals>.<dictcomp>r  é	   )r�   r’   rÌ   rÍ   )Úmaxr>  r[  rÏ   rˆ   r  rÑ   rÒ   )rÔ   r’   r�   rÌ   r\  r]  rÍ   rZ   rZ   r[   Úcreate_descriptionß  s"   	

ý
ý
zTable.create_descriptionc           
      C  s�   |   |¡ |  ¡ sdS t| |||d�}| ¡ }|jdurD|j ¡ D ]"\}}}| j|| ¡ | ¡ d d�}	|||	j	|| ¡   |ƒj
 }q!t|ƒS )zf
        select coordinates (row numbers) from a table; return the
        coordinates object
        Fr+  Nrj   ræ  )rÂ  r'  re  Úselect_coordsr”  r•   r1  rÖ  r˜  Úilocrq  r-   )
rÔ   ru   r«   r¬   rf  Úcoordsr�  r�  rŽ  r”  rZ   rZ   r[   r-  þ  s   

ÿ zTable.read_coordinatesr0  c           
      C  sÔ   |   ¡  |  ¡ s
dS |durtdƒ‚| jD ]L}||jkra|js'td|› d�ƒ‚t| jj	|ƒ}| 
| j¡ |j|||… | j| j| jd�}t|d |jƒ}t| jj|› d�dƒ}	t||d|	d	�  S qtd|› d
�ƒ‚)zj
        return a single column from the table, generally only indexables
        are interesting
        FNz4read_column does not currently accept a where clausezcolumn [z=] can not be extracted individually; it is not data indexabler�  rj   rT  )rf   r•  r  z] not found in the table)rÂ  r'  rº   r[  rf   rÛ  r³   r‚  r{   ra  r@  r›  r  rŸ   r]   r�   r  rÝ  r  r1   rç   )
rÔ   r0  ru   r«   r¬   r‰   r2  Z
col_valuesZcvsr  rZ   rZ   r[   r1    s0   


ÿ
üîzTable.read_column)Nr‚   NNNNNN)rÉ   r§   rÄ   rJ   r]   r^   r�   r`   r'  r(  r<  r)  r*  r+  r›   r,  r›  r-  r_   rž   rÇ  )r2  r`   rÊ  rË  )rº  rŽ   r_   r9  rÉ  )r_   rA  )r_   rD  )r_   rF  )r_   r   )rŒ   r`   r_   r`   )rŒ   r`   rq  r  r_   rž   rÈ  ra   rÍ  )r}  r^   r_   rž   rÏ  )r«   r‘   r¬   r‘   r_   rd  ©rÞ  r”   )TNNN)rº  r+   rŒ  r”   )r£  r+   rv  r”   )rf  re  r_   r+   )r�   r‘   rÌ   r”   r\  r‘   r_   rF  rÈ  )r0  r`   r«   r‘   r¬   r‘   )4ré   rÐ  rÑ  rÒ  r¤  r¥  rÓ  rõ  rI  rÕ   rÔ  r/  ró   rá   rŒ  r8  r<  r>  r¼  r¿  r{   r  r  r[  r2  rC  rE  rM  rP  rQ  rR  r/  rF  r»  r½  rÂ  rX  r   rV  r~  rh  rœ  rk  rn  r€  Ústaticmethodrs  r–  r™  r-  r1  r�  rZ   rZ   rP  r[   r  U  s    
 õ


'





	







LÿWÿ"*ù sC
7 ÿûr  c                   @  s2   e Zd ZdZdZ				dddd„Zddd„ZdS )rµ  zË
    a write-once read-many table: this format DOES NOT ALLOW appending to a
    table. writing is a one-time operation the data are stored in a format
    that allows for searching the data on disk
    r¬  Nr«   r‘   r¬   c                 C  rÃ  )z[
        read the indices and the indexing array, calculate offset rows and return
        z!WORMTable needs to implement readrÄ  rÅ  rZ   rZ   r[   r  O  s   
zWORMTable.readr_   rž   c                 K  rÃ  )zÞ
        write in a format that we can search later on (but cannot append
        to): write out the indices and the values using _write_array
        (e.g. a CArray) create an indexing table so that we can search
        z"WORMTable needs to implement writerÄ  rÆ  rZ   rZ   r[   r¾  [  s   zWORMTable.writerÇ  rÈ  rÊ  )ré   rÐ  rÑ  rÒ  rŸ  r  r¾  rZ   rZ   rZ   r[   rµ  F  s    ûrµ  c                   @  sZ   e Zd ZdZdZ												dd dd„Zd!d"dd„Zd#dd„Zd$d%dd„ZdS )&r+  ú(support the new appendable table formatsZ
appendableNFTr“   r”   r°   r‘   r™   rN  r_   rž   c                 C  s¶   |s| j r| j | jd¡ | j||||||d�}|jD ]}| ¡  q|j sA|j||||	d�}| ¡  ||d< |jj	|jfi |¤Ž |j
|j_
|jD ]}| ||¡ qI|j||
d� d S )Nr{   )r[  rº  rŒ  r—   rŸ   r›   )r’   r�   rÌ   r\  rN  )r™   )r¼  rÊ   r¿  rÄ   r€  r[  r)  r™  r»  Zcreate_tabler›  r  r1  Ú
write_data)rÔ   rº  r[  r“   r’   r�   rÌ   r—   r°   r\  r™   rŸ   r›   rN  r{   r‰   ÚoptionsrZ   rZ   r[   r¾  j  s4   
ú
	
ü

zAppendableTable.writec                   sÀ  | j j}| j}g }|r*| jD ]}t|jƒjdd�}t|tj	ƒr)| 
|jddd�¡ qt|ƒrD|d }|dd… D ]}||@ }q8| ¡ }nd}dd	„ | jD ƒ}	t|	ƒ}
|
dksZJ |
ƒ‚d
d	„ | jD ƒ}dd	„ |D ƒ}g }t|ƒD ]\}}|f| j ||
|   j }| 
| |¡¡ qo|du r�d}tjt||ƒ| j d�}|| d }t|ƒD ]9}|| ‰t|d | |ƒ‰ ˆˆ krº dS | j|‡ ‡fdd	„|	D ƒ|durÐ|ˆˆ … nd‡ ‡fdd	„|D ƒd� q¤dS )z`
        we form the data into a 2-d including indexes,values,mask write chunk-by-chunk
        r   rc  Úu1Fr�  rj   Nc                 S  r  rZ   )r#  r’  rZ   rZ   r[   rq   À  r  z.AppendableTable.write_data.<locals>.<listcomp>c                 S  ó   g | ]}|  ¡ ‘qS rZ   )r  r’  rZ   rZ   r[   rq   Æ  r³  c              	   S  s,   g | ]}|  t t |j¡|jd  ¡¡‘qS rþ  )Ú	transposerV   ÚrollÚarangerj  r‡  rZ   rZ   r[   rq   Ç  s   , rÕ  rƒ  c                   ó   g | ]}|ˆˆ … ‘qS rZ   rZ   r’  ©Úend_iÚstart_irZ   r[   rq   Û  r“  c                   r§  rZ   rZ   r‡  r¨  rZ   r[   rq   Ý  r“  )Úindexesrš  rq  )r  rö  r>  r*  r5   r”  r_  rU   rV   r  r“   r”  rt   r‘  r'  rô  rV  Úreshaper¹  rÖ  ri  Úwrite_data_chunk)rÔ   r°   r™   rö  r%  Úmasksr‰   rš  r]  r«  Únindexesrq  Úbvaluesr÷  re  Ú	new_shapeÚrowsÚchunksrZ   r¨  r[   r   ¥  sP   
€

üúzAppendableTable.write_datar²  r  r«  úlist[np.ndarray]rš  únpt.NDArray[np.bool_] | Nonerq  c                 C  sè   |D ]}t  |j¡s dS q|d jd }|t|ƒkr#t j|| jd�}| jj}t|ƒ}t|ƒD ]
\}	}
|
|||	 < q/t|ƒD ]\}	}||||	|  < q>|dura| ¡ j	t
dd� }| ¡ sa|| }t|ƒrr| j |¡ | j ¡  dS dS )zê
        Parameters
        ----------
        rows : an empty memory space where we are putting the chunk
        indexes : an array of the indexes
        mask : an array of the masks
        values : an array of the values
        Nr   rƒ  Fr�  )rV   rü  rV  rt   r¹  r  rö  rô  r‘  r”  r”   r_  r{   r“   r  )rÔ   r²  r«  rš  rq  re  r%  rö  r¯  r÷  r;  r]  rZ   rZ   r[   r­  à  s*   ÿþz AppendableTable.write_data_chunkr«   r¬   c                 C  sb  |d u st |ƒs4|d u r|d u r| j}| jj| jdd� |S |d u r%| j}| jj||d�}| j ¡  |S |  ¡ s:d S | j}t	| |||d�}| 
¡ }t|dd� ¡ }t |ƒ}	|	r¯| ¡ }
t|
|
dk jƒ}t |ƒskdg}|d |	krv| |	¡ |d dkr‚| dd¡ | ¡ }t|ƒD ]}| t||ƒ¡}|j||jd  ||jd  d d� |}qŠ| j ¡  |	S )	NTrR  ræ  Fr�  rj   r   rŠ  )rt   r%  rÊ   r¿  rÄ   r{   Zremove_rowsr  r'  re  rš  r1   Úsort_valuesÚdiffrr   r–   r“   r“  rK  Úreversedrp  ri  )rÔ   ru   r«   r¬   r%  r{   rf  rq  Zsorted_seriesÚlnr·  r¼   Úpgr  r²  rZ   rZ   r[   rX    sF   ü

ÿ
zAppendableTable.delete)NFNNNNNNFNNT)
r“   r”   r°   r‘   r™   r”   rN  r”   r_   rž   rÌ  )r°   r‘   r™   r”   r_   rž   )
r²  r  r«  r´  rš  rµ  rq  r´  r_   rž   rÍ  rÈ  )	ré   rÐ  rÑ  rÒ  rŸ  r¾  r   r­  rX  rZ   rZ   rZ   r[   r+  d  s&    ò;
;,r+  c                   @  sZ   e Zd ZU dZdZdZdZeZde	d< e
dd	d
„ƒZeddd„ƒZ				dddd„ZdS )r³  rŸ  r   rª  r©  r¦  r§  r_   r”   c                 C  s   | j d jdkS )Nr   rj   )r'  r@  rØ   rZ   rZ   r[   rC  O  r0  z"AppendableFrameTable.is_transposedrÞ  c                 C  s   |r|j }|S )zthese are written transposed)rá  rj  rZ   rZ   r[   rk  S  s   zAppendableFrameTable.get_objectNr«   r‘   r¬   c                   sì  ˆ   |¡ ˆ  ¡ sd S ˆ j|||d�}tˆ jƒr$ˆ j ˆ jd d i ¡ni }‡ fdd„tˆ jƒD ƒ}t|ƒdks:J ‚|d }|| d }	g }
tˆ jƒD �]\}}|ˆ j	vrVqK|| \}}| d¡dkrht
|ƒ}nt |¡}| d¡}|d ur}|j|d	d
� ˆ jr�|}|}t
|	t|	dd ƒd�}n|j}t
|	t|	dd ƒd�}|}|jdkr³t|tjƒr³| d|jd f¡}t|tjƒrúzt|j||dd�}W nL tyù } z)ˆ jdkrîtdƒrît|ƒ d¡rîtrît|j||dtdtjd�d�}n‚ W Y d }~nd }~ww t|t
ƒ�rt|||d�}n	tj |g||d�}t!ƒ �r|j"j#dk�s-|j$|j"k %¡ �s-J |j$|j"fƒ‚|D ]}tˆ j&j'|› d�d ƒ}|dv �rJ||  (|¡||< �q/|
 )|¡ qKt|
ƒdk�r^|
d }nt*|
dd�}t+ˆ |||d�}ˆ j,|||d�}|S )Nr+  r   c                   s"   g | ]\}}|ˆ j d  u r|‘qS r;  rO  )rm   r÷  r  rØ   rZ   r[   rq   p  s   " z-AppendableFrameTable.read.<locals>.<listcomp>rj   rè   r.   rö  T©Úinplacerf   re   Fr  r  r	  r
  r  r  )r­   r–   r•  r  r  rŽ  rT  )r`   r%  rc  )rf  r­   )-rÂ  r'  rh  rt   r<  r›  rß   rô  r[  r*  r-   r.   Úfrom_tuplesÚ	set_namesrC  r‚  rá  rj  rU   rV   r  r¬  rV  r+   r  r�   r   r`   rÂ  r   r2   r  Ú_from_arraysr   r  r}  Údtypesr_  r{   r  r”  r“   r4   re  r–  )rÔ   ru   r­   r«   r¬   rØ  r›  ÚindsÚindr–   Úframesr÷  r‰   Z
index_valsr#  ra  rö  rq  Úindex_Zcols_r  rY  r0  r  rf  rZ   rØ   r[   r  Z  sŽ   
ÿý




ÿþýûø€ù"
€
zAppendableFrameTable.readrË  r�  rÇ  rÈ  )ré   rÐ  rÑ  rÒ  r¤  rŸ  rj  r+   r§  rÓ  rÔ  rC  rœ  rk  r  rZ   rZ   rZ   r[   r³  G  s   
 ûr³  c                      sh   e Zd ZdZdZdZdZeZe	ddd„ƒZ
edd
d„ƒZdd‡ fdd„Z				dd‡ fdd„Z‡  ZS )r±  rŸ  r§  r¨  r©  r_   r”   c                 C  rI  rJ  rZ   rØ   rZ   rZ   r[   rC  É  rK  z#AppendableSeriesTable.is_transposedrÞ  c                 C  ri  ra   rZ   rj  rZ   rZ   r[   rk  Í  rK  z AppendableSeriesTable.get_objectNrž   c                   s@   t |tƒs|jp	d}| |¡}tƒ jd||j ¡ dœ|¤Ž dS )ú+we are going to write this as a frame tablerq  ©rº  r›   NrZ   )rU   r+   rf   Úto_framerO  r¾  r­   r„  )rÔ   rº  r›   rÂ   rf   rP  rZ   r[   r¾  Ò  s   


"zAppendableSeriesTable.writer«   r‘   r¬   r1   c                   s�   | j }|d ur!|r!t| jtƒsJ ‚| jD ]}||vr | d|¡ qtƒ j||||d�}|r5|j| jdd� |jd d …df }|j	dkrFd |_	|S )Nr   r?  Tr»  rq  )
r8  rU   rõ  rr   r“  rO  r  Ú	set_indexr›  rf   )rÔ   ru   r­   r«   r¬   r8  r  rY   rP  rZ   r[   r  Ù  s   
€
zAppendableSeriesTable.readrË  r�  ra   rÊ  rÇ  r  )ré   rÐ  rÑ  rÒ  r¤  rŸ  rj  r1   r§  rÔ  rC  rœ  rk  r¾  r  r�  rZ   rZ   rP  r[   r±  Á  s     	ûr±  c                      s*   e Zd ZdZdZdZd‡ fdd„Z‡  ZS )	r²  rŸ  r§  r©  r_   rž   c                   sb   |j pd}|  |¡\}| _t| jtƒsJ ‚t| jƒ}| |¡ t|ƒ|_tƒ j	dd|i|¤Ž dS )rÅ  rq  rº  NrZ   )
rf   r<  rõ  rU   rr   r“   r-   r­   rO  r¾  )rÔ   rº  rÂ   rf   Únewobjra  rP  rZ   r[   r¾  ù  s   



z AppendableMultiSeriesTable.writerÊ  )ré   rÐ  rÑ  rÒ  r¤  rŸ  r¾  r�  rZ   rZ   rP  r[   r²  ò  s
    r²  c                   @  sd   e Zd ZU dZdZdZdZeZde	d< e
dd	d
„ƒZe
dd„ ƒZddd„Zedd„ ƒZddd„ZdS )r°  z:a table that read/writes the generic pytables table formatr   r¡  r©  zlist[Hashable]rõ  r_   r`   c                 C  rÖ   ra   )r¤  rØ   rZ   rZ   r[   r€    rÝ   zGenericTable.pandas_typec                 C  s   t | jdd ƒp	| jS r?  r@  rØ   rZ   rZ   r[   r¿    ri  zGenericTable.storablerž   c                 C  sL   g | _ d| _g | _dd„ | jD ƒ| _dd„ | jD ƒ| _dd„ | jD ƒ| _dS )rÝ  Nc                 S  rS  rZ   rT  r’  rZ   rZ   r[   rq     r6  z*GenericTable.get_attrs.<locals>.<listcomp>c                 S  rU  rZ   rT  r’  rZ   rZ   r[   rq     r6  c                 S  r  rZ   re   r’  rZ   rZ   r[   rq     r  )r<  rŸ   rõ  rV  r'  r*  r›   rØ   rZ   rZ   r[   r½    s   zGenericTable.get_attrsc           
   
   C  s¨   | j }|  d¡}|durdnd}tdd| j||d�}|g}t|jƒD ]/\}}t|tƒs-J ‚t||ƒ}|  |¡}|dur=dnd}t	|||g|| j||d�}	| 
|	¡ q"|S )z0create the indexables from the table descriptionr–   NrB  r   )rf   r@  r{   rÆ   râ  )rf   rá  rq  rà  r{   rÆ   râ  )r  rF  rH  r{   rô  Z_v_namesrU   r`   r‚  r¢  r“   )
rÔ   r]  r\  rÆ   ra  r`  r÷  r  re  rx  rZ   rZ   r[   rV    s.   
ÿ

ù	zGenericTable.indexablesc                 K  rÃ  )Nz cannot write on an generic tablerÄ  )rÔ   rÂ   rZ   rZ   r[   r¾  C  s   zGenericTable.writeNrÇ  rÊ  )ré   rÐ  rÑ  rÒ  r¤  rŸ  rj  r+   r§  rÓ  rÔ  r€  r¿  r½  r   rV  r¾  rZ   rZ   rZ   r[   r°    s   
 



#r°  c                      s`   e Zd ZdZdZeZdZe 	d¡Z
eddd„ƒZdd‡ fdd„Z								dd‡ fdd„Z‡  ZS )r´  za frame with a multi-indexr«  r©  z^level_\d+$r_   r`   c                 C  rI  )NZappendable_multirZ   rØ   rZ   rZ   r[   r/  O  rK  z*AppendableMultiFrameTable.table_type_shortNrž   c                   s|   |d u rg }n	|du r|j  ¡ }|  |¡\}| _t| jtƒs J ‚| jD ]}||vr/| d|¡ q#tƒ jd||dœ|¤Ž d S )NTr   rÆ  rZ   )	r­   r„  r<  rõ  rU   rr   r“  rO  r¾  )rÔ   rº  r›   rÂ   r  rP  rZ   r[   r¾  T  s   

€zAppendableMultiFrameTable.writer«   r‘   r¬   c                   sD   t ƒ j||||d�}| ˆ j¡}|j ‡ fdd„|jjD ƒ¡|_|S )Nr?  c                   s    g | ]}ˆ j  |¡rd n|‘qS ra   )Ú
_re_levelsÚsearch)rm   rf   rØ   rZ   r[   rq   l  s     z2AppendableMultiFrameTable.read.<locals>.<listcomp>)rO  r  rÈ  rõ  r–   r¾  rö  )rÔ   ru   r­   r«   r¬   r  rP  rØ   r[   r  `  s   ÿzAppendableMultiFrameTable.readrÇ  ra   rÊ  rÇ  rÈ  )ré   rÐ  rÑ  rÒ  rŸ  r+   r§  rj  ÚreÚcompilerÊ  rÔ  r/  r¾  r  r�  rZ   rZ   rP  r[   r´  G  s    
ûr´  rº  r+   r@  rM   r•  r-   c                 C  s¢   |   |¡}t|ƒ}|d urt|ƒ}|d u s| |¡r!| |¡r!| S t| ¡ ƒ}|d ur6t| ¡ ƒj|dd�}| |¡sOtd d ƒg| j }|||< | jt|ƒ } | S )NF)Úsort)	r‹  r>   ÚequalsÚuniquerr  Úslicerj  rs  rs   )rº  r@  r•  ró  r  ÚslicerrZ   rZ   r[   rr  r  s   

rr  rÝ  r   ústr | tzinfoc                 C  s   t  | ¡}|S )z+for a tz-aware type, return an encoded zone)r   Úget_timezone)rÝ  ÚzonerZ   rZ   r[   rî  Œ  s   
rî  rq  únp.ndarray | Indexr€  r,   c                 C  r(  ra   rZ   ©rq  rÝ  r€  rZ   rZ   r[   r  ’  s   r  r  c                 C  r(  ra   rZ   r×  rZ   rZ   r[   r  ™  rK  ústr | tzinfo | Noneúnp.ndarray | DatetimeIndexc                 C  s”   t | tƒr| jdu s| j|ksJ ‚| jdur| S |dur?t | tƒr%| j}nd}|  ¡ } t|ƒ}t| |d�} |  d¡ |¡} | S |rHtj	| dd�} | S )a  
    coerce the values to a DatetimeIndex if tz is set
    preserve the input shape if possible

    Parameters
    ----------
    values : ndarray or Index
    tz : str or tzinfo
    coerce : if we do not have a passed timezone, coerce to M8[ns] ndarray
    Nre   rÓ  úM8[ns]rƒ  )
rU   r,   rÝ  rf   r‘  r\   rÕ  rÖ  rV   r�  )rq  rÝ  r€  rf   rZ   rZ   r[   r  ž  s    


ûrf   c              
   C  st  t | tƒsJ ‚|j}t|ƒ\}}t|ƒ}t |¡}t |j	d¡s*t
|j	ƒs*t|j	ƒr=t| |||t|dd ƒt|dd ƒ|d�S t |tƒrFtdƒ‚tj|dd�}	t |¡}
|	dkrotjd	d
„ |
D ƒtjd�}t| |dtƒ  ¡ |d�S |	dkrŠt|
||ƒ}|j	j}t| |dtƒ  |¡|d�S |	dv r—t| ||||d�S t |tjƒr¢|j	tks¤J ‚|dks¬J |ƒ‚tƒ  ¡ }t| ||||d�S )NÚiurÜ  rÝ  )rq  r}  rà  rÜ  rÝ  rÞ  zMultiIndex not supported here!Fr  r   c                 S  r£  rZ   )Ú	toordinalr‡  rZ   rZ   r[   rq   ë  r³  z"_convert_index.<locals>.<listcomp>rƒ  )rÞ  r%  )ÚintegerÚfloating)rq  r}  rà  rÞ  rô  )rU   r`   rf   rW  rX  rž  rf  r   r  r  r%   r!   rÙ  r‚  r.   rº   r	  rV   r�  Úint32rˆ   Z	Time32ColÚ_convert_string_arrayrå  r&  r  rô  r
  )rf   r–   r]   r�   rÞ  r™  rY  r}  re  r  rq  rå  rZ   rZ   r[   rì  Å  s^   
ÿþý

ù


ÿ
û
ÿ
rì  r}  c                 C  sò   |  d¡r|dkrt| ƒ}|S t|  |¡ƒ}|S |dkr"t| ƒ}|S |dkrLztjdd„ | D ƒtd�}W |S  tyK   tjdd„ | D ƒtd�}Y |S w |dv rWt | ¡}|S |d	v ret| d ||d
�}|S |dkrrt | d ¡}|S td|› �ƒ‚)Nr~  r�  r   c                 S  r„  rZ   r…  r‡  rZ   rZ   r[   rq     r6  z$_unconvert_index.<locals>.<listcomp>rƒ  c                 S  r„  rZ   rˆ  r‡  rZ   rZ   r[   rq     r6  )rÝ  Úfloatr”   r%  r�  rô  r   zunrecognized index type )	r‹  r,   r  r3   rV   r�  rô  r³   r˜  )r”  r}  r]   r�   r–   rZ   rZ   r[   rý    s:   
îïñôô
	øÿüÿrý  r°  rL   r   c                 C  sº  t |jtƒr
| ¡ }|jtkr|S ttj|ƒ}|jj}t	j
|dd�}	|	dkr*tdƒ‚|	dkr2tdƒ‚|	dks<|dks<|S t|ƒ}
| ¡ }|||
< |rY|
 ¡ rYt|ƒ|jkrYtd	ƒ‚t	j
|dd�}	|	dkr—t|jd
 ƒD ]+}|| }t	j
|dd�}	|	dkr–t|ƒ|kr†|| nd|› �}td|› d|	› d�ƒ‚qkt|||ƒ |j¡}|j}t |tƒr·t| | ¡pµ| d¡pµd
ƒ}t|p»d
|ƒ}|d urÑ| |¡}|d urÑ||krÑ|}|jd|› �dd�}|S )NFr  r   z+[date] is not implemented as a table columnrÊ  z>too many timezones in this block, create separate data columnsr%  rô  z8NaN representation is too large for existing column sizer   zNo.r4  z2]
because its data contents are not [string] but [r5  rq  z|Sr�  )rU   r  r2   r  rô  r   rV   r  rf   r   r	  rº   r5   r•  r“  rt   rå  r³   ri  rV  rà  r¬  r^  ri   rß   r˜  r,  r”  )rf   r°  rp  r—   rŸ   r]   r�   r­   rY  r  rš  r”  r÷  r   Zerror_column_labelr~  rå  ZecirZ   rZ   r[   ru  "  sX   

ÿþÿþ


ru  r”  c                 C  sb   t | ƒrt|  ¡ ddd�j ||¡j | j¡} t|  ¡ ƒ}t	dt
 |¡ƒ}tj| d|› �d�} | S )a  
    Take a string-like that is object dtype and coerce to a fixed size string type.

    Parameters
    ----------
    data : np.ndarray[object]
    encoding : str
    errors : str
        Handler for encoding errors.

    Returns
    -------
    np.ndarray[fixed-length-string]
    Frô  )r•  r  rj   ÚSrƒ  )rt   r1   r‘  r`   Úencoder–  r¬  rV  r    r˜  Ú
libwritersÚmax_len_string_arrayrV   r�  )r”  r]   r�   Zensuredrå  rZ   rZ   r[   rà  q  s   

ýrà  c                 C  s¬   | j }tj|  ¡ td�} t| ƒrEt t| ƒ¡}d|› �}t	| d t
ƒr9t| dd�jj||dd�}| ¡ } d| j_n| j|dd�jtdd�} |d	u rKd
}t | |¡ |  |¡S )a*  
    Inverse of _convert_string_array.

    Parameters
    ----------
    data : np.ndarray[fixed-length-string]
    nan_rep : the storage repr of NaN
    encoding : str
    errors : str
        Handler for encoding errors.

    Returns
    -------
    np.ndarray[object]
        Decoded data.
    rƒ  ÚUr   Fr�  rô  )r�   r  TNr  )rV  rV   r�  r‘  rô  rt   rä  rå  r    rU   rÚ  r1   r`   rX   r  ÚflagsÚ	writeabler”  Ú!string_array_replace_from_nan_repr¬  )r”  rŸ   r]   r�   rV  rå  r  ÚserrZ   rZ   r[   r˜  �  s    
ÿ

r˜  r  c                 C  s6   t |tƒsJ t|ƒƒ‚t|ƒrt|||ƒ}|| ƒ} | S ra   )rU   r`   rè   Ú_need_convertÚ_get_converter)rq  r  r]   r�   ÚconvrZ   rZ   r[   r  º  s
   r  c                   sH   ˆdkrdd„ S dˆv r‡fdd„S ˆdkr‡ ‡fdd„S t dˆ› �ƒ‚)Nr~  c                 S  s   t j| dd�S )NrÚ  rƒ  ©rV   r�  ©r9  rZ   rZ   r[   r£   Ä  ó    z _get_converter.<locals>.<lambda>c                   s   t j| ˆ d�S )Nrƒ  rî  rï  r\  rZ   r[   r£   Æ  rð  r%  c                   s   t | d ˆ ˆd�S )Nr�  )r˜  rï  r¦  rZ   r[   r£   È  s    ÿzinvalid kind )r³   )r}  r]   r�   rZ   )r]   r�   r}  r[   rì  Â  s   rì  c                 C  s   | dv sd| v r
dS dS )N)r~  r%  r~  TFrZ   r\  rZ   rZ   r[   rë  Ï  s   rë  rª  úSequence[int]c                 C  sl   t |tƒst|ƒdk rtdƒ‚|d dkr4|d dkr4|d dkr4t d| ¡}|r4| ¡ d }d|› �} | S )	zö
    Prior to 0.10.1, we named values blocks like: values_block_0 an the
    name values_0, adjust the given name if necessary.

    Parameters
    ----------
    name : str
    version : Tuple[int, int, int]

    Returns
    -------
    str
    é   z6Version is incorrect, expected sequence of 3 integers.r   rj   r¨  r©  zvalues_block_(\d+)Úvalues_)rU   r`   rt   r³   rÌ  rË  r¼   )rf   rª  r]  ÚgrprZ   rZ   r[   rY  Õ  s   $
rY  Ú	dtype_strc                 C  sÚ   t | ƒ} |  d¡rd}|S |  d¡rd}|S |  d¡rd}|S |  d¡r(d}|S |  d¡r1| }|S |  d¡r:d	}|S |  d
¡rCd
}|S |  d¡rLd}|S |  d¡rUd}|S | dkr]d}|S | dkred}|S td| › d�ƒ‚)zA
    Find the "kind" string describing the given dtype name.
    )r%  rÚ  r%  rá  rb  )ri   rk  rÝ  r~  Ú	timedeltar�  r”   rB  rn  rô  r`   zcannot interpret dtype of [r7  )r\   r‹  r³   )rõ  r}  rZ   rZ   r[   rX  î  sF   

è
ê
ì
î
ð
ò
ô
öùûþrX  c                 C  sv   t | tƒr| j} t | jtƒrd| jj› d�}n| jj}| jjdv r*t 	|  
d¡¡} nt | tƒr2| j} t 	| ¡} | |fS )zJ
    Convert the passed data into a storable form and a dtype string.
    r  r7  ÚmMr  )rU   r6   r`  r  r'   r  rf   r}  rV   r�  r  r/   r  )r”  rY  rZ   rZ   r[   rW    s   


rW  c                   @  s:   e Zd ZdZ			ddd
d„Zdd„ Zdd„ Zdd„ ZdS )re  zæ
    Carries out a selection operation on a tables.Table object.

    Parameters
    ----------
    table : a Table object
    where : list of Terms (or convertible to)
    start, stop: indices to start and/or stop selection

    Nr{   r  r«   r‘   r¬   r_   rž   c                 C  sV  || _ || _|| _|| _d | _d | _d | _d | _t|ƒrŒt	t
ƒ�d tj|dd�}|dv r}t |¡}|jtjkrV| j| j}}|d u rDd}|d u rL| j j}t ||¡| | _n't|jjtjƒr}| jd urj|| jk  ¡ sv| jd urz|| jk ¡ rzt
dƒ‚|| _W d   ƒ n1 s‡w   Y  | jd u r§|  |¡| _| jd ur©| j ¡ \| _| _d S d S d S )NFr  )rÝ  Úbooleanr   z3where must have index locations >= start and < stop)r{   ru   r«   r¬   Ú	conditionr”  ÚtermsrE  r#   r   r³   r   r	  rV   r�  r  Úbool_r%  r¦  Ú
issubclassrè   rÝ  r“  ÚgenerateÚevaluate)rÔ   r{   ru   r«   r¬   ÚinferredrZ   rZ   r[   rÕ   6  sF   

ÿ€î

ûzSelection.__init__c              
   C  sr   |du rdS | j  ¡ }z
t||| j jd�W S  ty8 } zd | ¡ ¡}td|› d|› d�ƒ}t|ƒ|‚d}~ww )z'where can be a : dict,list,tuple,stringN)rM  r]   rë  z-                The passed where expression: a*  
                            contains an invalid variable reference
                            all of the variable references must be a reference to
                            an axis (e.g. 'index' or 'columns'), or a data_column
                            The currently defined references are: z
                )	r{   rM  r:   r]   Ú	NameErrorrð  r
  r   r³   )rÔ   ru   rW  rY  Zqkeysr  rZ   rZ   r[   rý  c  s"   
ÿûÿ
	€ózSelection.generatec                 C  sX   | j dur| jjj| j  ¡ | j| jd�S | jdur!| jj | j¡S | jjj| j| jd�S )ú(
        generate the selection
        Nræ  )	rù  r{   Z
read_wherer•   r«   r¬   rE  r-  r  rØ   rZ   rZ   r[   r¿   z  s   
ÿ
zSelection.selectc                 C  s”   | j | j}}| jj}|du rd}n|dk r||7 }|du r!|}n|dk r)||7 }| jdur<| jjj| j ¡ ||dd�S | jdurD| jS t 	||¡S )r  Nr   T)r«   r¬   rÎ  )
r«   r¬   r{   r%  rù  Zget_where_listr•   rE  rV   r¦  )rÔ   r«   r¬   r%  rZ   rZ   r[   rš  †  s"   
ÿ
zSelection.select_coordsrÍ  )r{   r  r«   r‘   r¬   r‘   r_   rž   )ré   rÐ  rÑ  rÒ  rÕ   rý  r¿   rš  rZ   rZ   rZ   r[   re  *  s    û-re  )r]   r^   r_   r`   )rh   ri   )r‰   NNFNTNNNNr‚   rT   )rŠ   r‹   rŒ   r`   r�   rŽ   r�   r`   r�   r‘   r’   r^   r“   r”   r•   r^   r–   r”   r—   r˜   r™   rš   r›   rœ   r�   r`   r]   r`   r_   rž   )	Nr©   r‚   NNNNFN)rŠ   r‹   r�   r`   r�   r`   ru   rª   r«   r‘   r¬   r‘   r­   r®   r¯   r”   r°   r‘   )rÄ   rJ   rÅ   rJ   r_   r”   ra   )rº  r+   r@  rM   r•  r-   r_   r+   )rÝ  r   r_   rÓ  rÌ  )rq  rÖ  rÝ  rÓ  r€  r”   r_   r,   )rq  rÖ  rÝ  rž   r€  r”   r_   r  )rq  rÖ  rÝ  rØ  r€  r”   r_   rÙ  )
rf   r`   r–   r-   r]   r`   r�   r`   r_   rÙ  )r}  r`   r]   r`   r�   r`   r_   rÖ  )rf   r`   r°  rL   r­   r   )r”  r  r]   r`   r�   r`   r_   r  )rq  r  r  r`   r]   r`   r�   r`   )r}  r`   r]   r`   r�   r`   )r}  r`   r_   r”   )rf   r`   rª  rñ  r_   r`   )rõ  r`   r_   r`   )r”  rL   )»rÒ  Ú
__future__r   Ú
contextlibr   r•  rÊ  r   r   rF  r·   rÌ  Útextwrapr   Útypingr   r   r	   r
   r   r   r   r8  ÚnumpyrV   Úpandas._configr   r   r   r   Úpandas._libsr   r   rä  Úpandas._libs.libr   Úpandas._libs.tslibsr   Úpandas.compatr   Úpandas.compat._optionalr   Zpandas.compat.pickle_compatr   Úpandas.errorsr   r   r   r   r   Úpandas.util._decoratorsr   Úpandas.util._exceptionsr   Úpandas.core.dtypes.commonr    r!   r"   r#   r$   r%   Úpandas.core.dtypes.dtypesr&   r'   r(   r)   Úpandas.core.dtypes.missingr*   rþ   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   Úpandas.core.arraysr6   r7   r8   Úpandas.core.arrays.string_r9   Úpandas.core.commonÚcoreÚcommonrV  Z pandas.core.computation.pytablesr:   r;   Úpandas.core.constructionr<   rà  r=   Úpandas.core.indexes.apir>   Úpandas.core.internalsr?   r@   Úpandas.io.commonrA   Úpandas.io.formats.printingrB   rC   Úcollections.abcrD   rE   rF   ÚtypesrG   r„   rH   rI   rJ   Úpandas._typingrK   rL   rM   rN   rO   rP   rQ   rR   rS   r·  rb   r\   rd   rg   rl   rv   rw   rÓ  rx   ry   rœ  rk  r~   r   Úconfig_prefixÚregister_optionÚis_boolÚis_one_of_factoryrƒ   r‡   rˆ   r¨   rÃ   r½   r§   r(  rÙ  rH  rM  rž  r¢  r£  rÉ  r­  r  r®  r  rµ  r+  r³  r±  r²  r°  r´  rr  rî  r  rì  rý  ru  rà  r˜  r  rì  rë  rY  rX  rW  re  rZ   rZ   rZ   r[   Ú<module>   sB   $	 4(


üþ
ñ:ö 
#           (p  8   -   2g       x dz1C,ÿ
ÿÿ
'
@

O

*




#