o
    i                 	   @  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mZmZmZ ddlZddlZddlmZmZ dd	lm Z m!Z" dd
l#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZE ddlFmGZG ddlHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQ ddlRmSZS ddlTmUZUmVZVmWZW ddlXmY  mZZ[ ddl\m]Z]m^Z^ ddl_m`Z` ddlambZb ddlcmdZdmeZe ddlfmgZg ddlhmiZimjZj er%ddlkmlZlmmZmmnZn ddlcmoZo dZpdZqd d! Zrd"d# Zsd$d% Zte]Zudd(d)Zvd*Zwd+exd,< d-Zyd+exd.< d/Zzd+exd0< d1d1d2d2d3Z{eIdgiZ|d4Z}d+exd5< d6Z~d+exd7< ed8  ejd9d:e}ejd; ejd<de~eg d=d; W d   n	1 sw   Y  dad:ad>d? Z	@			:		A					B	ddd\d]Z		^	B					:	dddgdhZddldmZG dndo doZG dpdq dqZG drds dsZG dtdu dueZG dvdw dweZG dxdy dyeZG dzd{ d{eZG d|d} d}ZG d~d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZddddZdddZe	:ddddZeddddZ	:ddddZdddZdddZdddZdddZdddZdddZdddZdddÄZdddǄZdddʄZddd̄ZG dd΄ d΃Zd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HashableIteratorLiteralSequencecastoverload)config
get_option)libwriters)	timezones)AnyArrayLike	ArrayLikeDtypeArgFilePathShapenpt)import_optional_dependency)patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly)find_stack_level)ensure_objectis_bool_dtypeis_categorical_dtypeis_complex_dtypeis_datetime64_dtypeis_datetime64tz_dtypeis_extension_array_dtypeis_list_likeis_string_dtypeis_timedelta64_dtypeneeds_i8_conversion)array_equivalent)		DataFrameDatetimeIndexIndex
MultiIndexPeriodIndexSeriesTimedeltaIndexconcatisna)
Int64Index)CategoricalDatetimeArrayPeriodArray)PyTablesExprmaybe_expression)extract_array)ensure_index)ArrayManagerBlockManager)stringify_path)adjoinpprint_thing)ColFileNode)Blockz0.15.2UTF-8c                 C  s   t | tjr| d} | S )z(if we have bytes, decode them to unicoderK   )
isinstancenpbytes_decode)s rQ   M/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/pandas/io/pytables.py_ensure_decoded   s   
rS   c                 C  s   | d u rt } | S N)_default_encodingencodingrQ   rQ   rR   _ensure_encoding   s   rX   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
    )rL   strnamerQ   rQ   rR   _ensure_str   s   
r\   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 )Nr_   r]   )r?   Term).0termlevelrQ   rR   
<listcomp>   s
    z _ensure_term.<locals>.<listcomp>r`   N)rL   listtupler?   ra   len)wherer]   rQ   rd   rR   _ensure_term   s   	
rk   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)fro   trp   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.hdfdropna_tableF)	validatordefault_format)ro   rp   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file_FILE_OPEN_POLICY!_table_file_open_policy_is_strict)rz   rQ   rQ   rR   _tables   s   


r   aTrx   path_or_bufFilePath | HDFStorekeyrY   valueDataFrame | Seriesmode	complevel
int | Nonecomplib
str | Noneappendboolformatindexmin_itemsizeint | dict[str, int] | Nonedropnabool | Nonedata_columns Literal[True] | list[str] | NoneerrorsrW   return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   rW   )r   store
r   r   rW   r   r   r   r   r   r   r   rQ   rR   <lambda>      zto_hdf.<locals>.<lambda>c                   s   | j 	 d
S )N)r   r   r   r   r   r   rW   r   putr   r   rQ   rR   r     r   )r   r   r   N)rD   rL   rY   HDFStore)r   r   r   r   r   r   r   r   r   r   r   r   r   r   rW   rq   r   rQ   r   rR   to_hdf   s    

"r   rrj   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||st dq~|j}|j|||||||	|dW S  t ttfy   t| tstt |  W d    1 sw   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
    -------
    item : 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.

    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.Nr_   r`   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.)rj   r   r   r   r   r   
auto_close)
ValueErrorrk   rL   r   is_openOSErrorrD   rY   NotImplementedErrorospathexists	TypeErrorFileNotFoundErrorgroupsri   _is_metadata_of_v_pathnameselectKeyErrorr   r{   close)r   r   r   r   rj   r   r   r   r   r   kwargsr   r   r   r   candidate_only_groupgroup_to_checkrQ   rQ   rR   read_hdf2  sv   O








r   grouprI   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.Fr_   metaT)_v_depth	_v_parent_v_name)r   r   currentparentrQ   rQ   rR   r     s   

r   c                   @  s  e Zd ZU dZded< ded< ded< ded	< 	
			ddddZdddZedd ZedddZ	dddZ
dddZdd d!Zdd#d$Zdd%d&Zdd'd(Zdd)d*Zdd+d,Zdd-d.Zddd2d3Zdd5d6Zdd8d9Zd:d; Zddd<d=Zdd>d?Zedd@dAZdddCdDZddEdFZ							dddHdIZ			dddLdMZ		dddOdPZ								dddQdRZ		S								T	S	ddd^d_Z ddd`daZ!			S	S											TdddcddZ"			dddgdhZ#			dddldmZ$ddodpZ%dddtduZ&ddwdxZ'ddzd{Z(	|	S					Sddd~dZ)dddZ*dd Z+dddZ,				TddddZ-		S												T	SddddZ.dddZ/dddZ0dddZ1dS )r   aa	  
    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.
        As of v0.20.2 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_handlerY   _moder^   
_complevelr   _fletcher32r   NFr   r   r   
fletcher32r   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 HDFStorerz   zcomplib only supports z compression.r   r   r   rQ   )r   r   filtersall_complibsdefault_complibrD   _pathr   r   r   _complibr   _filtersopen)selfr   r   r   r   r   r   rz   rQ   rQ   rR   __init__"  s&   

zHDFStore.__init__c                 C     | j S rT   r   r   rQ   rQ   rR   
__fspath__D  s   zHDFStore.__fspath__c                 C  s   |    | jdusJ | jjS )zreturn the root nodeN)_check_if_openr   rootr   rQ   rQ   rR   r   G  s   zHDFStore.rootc                 C  r   rT   r   r   rQ   rQ   rR   filenameN     zHDFStore.filenamer   c                 C  
   |  |S rT   )getr   r   rQ   rQ   rR   __getitem__R     
zHDFStore.__getitem__c                 C  s   |  || d S rT   r   )r   r   r   rQ   rQ   rR   __setitem__U  s   zHDFStore.__setitem__c                 C  r   rT   )remover   rQ   rQ   rR   __delitem__X  r   zHDFStore.__delitem__r[   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   r   r   r{   type__name__)r   r[   rQ   rQ   rR   __getattr__[  s   zHDFStore.__getattr__c                 C  s8   |  |}|dur|j}||ks|dd |krdS dS )zx
        check for existence of this key
        can match the exact pathname or the pathnm w/o the leading '/'
        Nr_   TF)get_noder   )r   r   noder[   rQ   rQ   rR   __contains__e  s   
zHDFStore.__contains__c                 C     t |  S rT   )ri   r   r   rQ   rQ   rR   __len__q     zHDFStore.__len__c                 C  s   t | j}t|  d| dS )N
File path: 
)rF   r   r   )r   pstrrQ   rQ   rR   __repr__t  s   
zHDFStore.__repr__c                 C  s   | S rT   rQ   r   rQ   rQ   rR   	__enter__x     zHDFStore.__enter__c                 C     |    d S rT   )r   )r   exc_type	exc_value	tracebackrQ   rQ   rR   __exit__{  r   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.

                .. versionadded:: 1.1.0

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

        Raises
        ------
        raises ValueError if kind has an illegal value
        r   c                 S     g | ]}|j qS rQ   r   rb   nrQ   rQ   rR   rf         z!HDFStore.keys.<locals>.<listcomp>nativeNc                 S  r   rQ   r   r   rQ   rQ   rR   rf     s    /Table)	classnamez8`include` should be either 'pandas' or 'native' but is 'r   )r   r   
walk_nodesr   )r   r   rQ   rQ   rR   keys~  s   
zHDFStore.keysIterator[str]c                 C  r   rT   )iterr  r   rQ   rQ   rR   __iter__  r   zHDFStore.__iter__Iterator[tuple[str, list]]c                 c  s     |   D ]}|j|fV  qdS )'
        iterate on key->group
        N)r   r   )r   grQ   rQ   rR   items  s   zHDFStore.itemsc                 c  s&    t jdtt d |  E dH  dS )r  zTiteritems is deprecated and will be removed in a future version. Use .items instead.
stacklevelN)warningswarnFutureWarningr$   r  r   rQ   rQ   rR   	iteritems  s   zHDFStore.iteritemsc                 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   rz   msgrQ   rQ   rR   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   rQ   rQ   rR   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   isopenr   rQ   rQ   rR   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  rQ   rQ   rR   r    s   


"zHDFStore.flushc                 C  sV   t   | |}|du rtd| d| |W  d   S 1 s$w   Y  dS )z
        Retrieve pandas object stored in file.

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

        Returns
        -------
        object
            Same type as object stored in file.
        NNo object named  in the file)r   r   r   _read_groupr   r   r   rQ   rQ   rR   r   
  s   
$zHDFStore.getr   c	                   st   |  |}	|	du rtd| dt|dd}| |	   fdd}
t| |
|j|||||d
}| S )	a  
        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.
        Nr  r  r_   r`   c                   s   j | || dS )N)r   r   rj   r   read_start_stop_wherer   rP   rQ   rR   funcW  s   zHDFStore.select.<locals>.funcrj   nrowsr   r   r   r   r   )r   r   rk   _create_storer
infer_axesTableIteratorr*  
get_result)r   r   rj   r   r   r   r   r   r   r   r(  itrQ   r'  rR   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
        r_   r`   z&can only read_coordinates with a tablerj   r   r   )rk   
get_storerrL   r  r   read_coordinates)r   r   rj   r   r   tblrQ   rQ   rR   select_as_coordinatesj  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)r5  r   r   )r1  rL   r  r   read_column)r   r   r5  r   r   r3  rQ   rQ   rR   select_column  s   
#
zHDFStore.select_columnc
                   sx  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rtdq`dd	 D }t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
        r_   r`   r   )r   rj   r   r   r   r   r   r   zkeys must be a list/tuplez keys must have a non-zero lengthNc                      g | ]}  |qS rQ   )r1  rb   kr   rQ   rR   rf         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 rQ   )rL   r  rb   xrQ   rQ   rR   rf         c                 S  s   h | ]	}|j d  d  qS r   )non_index_axesrb   rr   rQ   rQ   rR   	<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 )rj   r   r   r   r!  rB  )r$  r%  r&  r   rQ   rR   rf     s    z=HDFStore.select_as_multiple.<locals>.func.<locals>.<listcomp>F)axisverify_integrity)r8   _consolidate)r$  r%  r&  objs)rE  r   tblsr#  rR   r(    s   z)HDFStore.select_as_multiple.<locals>.funcr)  T)coordinates)rk   rL   rg   rh   ri   rY   r   r   r   r1  	itertoolschainzipr   is_tablepathnamer*  r-  r.  )r   r  rj   selectorr   r   r   r   r   r   rP   r*  rr   r:  _tblsr(  r/  rQ   )rE  r   r   rI  rR   select_as_multiple  sf   +

 
zHDFStore.select_as_multipleTrx   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.

            .. versionadded:: 1.1.0
        Nio.hdf.default_formatro   )r   r   r   r   r   r   r   r   rW   r   rS  r   )r   _validate_format_write_to_group)r   r   r   r   r   r   r   r   r   r   r   rW   r   rS  r   rQ   rQ   rR   r   ,  s&   4

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

        r_   r`   Nz5trying to remove a node with a non-None where clause!T	recursivez7can only remove with where on objects written as tablesr0  )rk   r1  r   AssertionError	Exceptionr   r   	_f_removecomall_noner   rN  delete)r   r   rj   r   r   rP   errr   rQ   rQ   rR   r   t  s8   
zHDFStore.remover   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
        Nz>columns is not a supported keyword in append, try data_columnszio.hdf.dropna_tablerT  rp   )r   axesr   r   r   r   r   r   r   expectedrowsr   r   rW   r   )r   r   rU  rV  )r   r   r   r   r`  r   r   r   r   r   r   r   r   ra  r   r   rW   r   rQ   rQ   rR   r     s6   ;

zHDFStore.appendddictc                   s  |durt dt|tstd||vrtdtttjttt	  d }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| qd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 dictr   z<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   )rb   cols)r   rQ   rR   	<genexpr>P  s     z.HDFStore.append_to_multiple.<locals>.<genexpr>r   rE  c                   s   i | ]\}}| v r||qS rQ   rQ   rb   r   r   )vrQ   rR   
<dictcomp>`  s    z/HDFStore.append_to_multiple.<locals>.<dictcomp>)r   r   )r   rL   rc  r   rg   setrangendim	_AXES_MAPr   r  extendr`  
differencer3   sortedget_indexertakevaluesnextintersectionlocpopreindexr   )r   rb  r   rP  r   r`  r   r   rE  
remain_keyremain_valuesr:  orderedorddidxsvalid_indexr   r   dcvalfilteredrQ   )rj  r   rR   append_to_multiple  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   r1  rL   r  r   create_index)r   r   r   r  r  rP   rQ   rQ   rR   create_table_indexf  s   

zHDFStore.create_table_indexrg   c                 C  s<   t   |   | jdusJ tdusJ dd | j D S )z
        Return a list of all the top-level nodes.

        Each node returned is not a pandas storage object.

        Returns
        -------
        list
            List of objects.
        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_typeNrp   )	rL   ry   linkLinkgetattr_v_attrsrp   r  r   )rb   r  rQ   rQ   rR   rf     s    

z#HDFStore.groups.<locals>.<listcomp>)r   r   r   ry   walk_groupsr   rQ   rQ   rR   r     s   zHDFStore.groupsr  rj   *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 )aS  
        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`.
        Nr  r  )r   r   r   ry   r  r  r  _v_childrenru  rL   r   Groupr   r   r   rstrip)r   rj   r  r   leaveschildr  rQ   rQ   rR   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   ry   r   r   
exceptionsNoSuchNodeErrorrL   rI   r   )r   r   r   rQ   rQ   rR   r     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   rP   rQ   rQ   rR   r1    s   

zHDFStore.get_storerr  propindexesc	              	   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 rQ   )
is_indexedr[   rb   r   rQ   rQ   rR   rf   $      z!HDFStore.copy.<locals>.<listcomp>r   )r   r   rW   rV   )r   rg   r  rL   rh   r1  r   r   r  r`  r   r  rW   r   )r   r|   r   r  r  r   r   r   	overwrite	new_storer:  rP   datar   rQ   rQ   rR   copy  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 )
zg
        Print detailed information on the store.

        Returns
        -------
        str
        r   r   Nzinvalid_HDFStore nodez[invalid_HDFStore node: r<     EmptyzFile is CLOSED)rF   r   r   r   rr  r  ri   r1  r   rO  rY  rZ  rE   )
r   r   outputlkeysr  ru  r:  rP   detaildstrrQ   rQ   rR   info1  s8   


zHDFStore.infoc                 C  s   | j st| j dd S )Nz file is not open!)r   r   r   r   rQ   rQ   rR   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 [r<  N)_FORMAT_MAPlowerr   r   )r   r   r_  rQ   rQ   rR   rU  _  s   zHDFStore._validate_formatrK   DataFrame | Series | NonerW   c              
     s  durt ttfstd fdd}ttjdd}ttjdd}|du rbdu rPt  tdus:J tddsGt tj	j
rLd}d	}ntd
t trXd}nd} dkrb|d7 }d|vrttd}	z|	| }
W n ty } z|d|d}~ww |
| ||dS |du rΈdur|dkrtdd}|dur|jdkrd}n%|jdkrd}n|dkrtdd}|dur|jdkrd}n|jdkrd}ttttttd}z|| }
W n ty } z|d|d}~ww |
| ||dS )z"return a suitable class to operateNz(value must be None, Series, or DataFramec              	     s$   t d|  d dt d  S )Nz(cannot properly create the storer for: [z
] [group->,value->z	,format->)r   r   )rr   r   r   r   rQ   rR   errorw  s   z&HDFStore._create_storer.<locals>.errorr  
table_typerp   frame_tablegeneric_tablezKcannot create a storer if the object is not existing nor a value are passedseriesframe_table)r  r  _STORER_MAPrW   r   series_tabler   r_   appendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)r  r  r  r  r  worm
_TABLE_MAP)rL   r6   r1   r   rS   r  r  r   ry   rp   r  SeriesFixed
FrameFixedr   nlevelsGenericTableAppendableSeriesTableAppendableMultiSeriesTableAppendableFrameTableAppendableMultiFrameTable	WORMTable)r   r   r   r   rW   r   r  ptttr  clsr_  r   r  rQ   r  rR   r+  i  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emptyrp   r  ro   zCan only append to Tablesz0Compression not supported on Fixed format stores)objr`  r   r   r   r   r   r   ra  r   r   r   rS  )r   )r  _identify_groupr+  rN  	is_existsr   set_object_infowriterL   r  r  )r   r   r   r   r`  r   r   r   r   r   r   r   ra  r   r   r   rW   r   rS  r   rP   rQ   rQ   rR   rV    s>   
zHDFStore._write_to_groupr   rI   c                 C  s   |  |}|  | S rT   )r+  r,  r"  )r   r   rP   rQ   rQ   rR   r    s   
zHDFStore._read_groupr   c                 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.NTrW  )r   r   remove_node_create_nodes_and_group)r   r   r   r   rQ   rQ   rR   r    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   splitri   endswithr   create_group)r   r   pathsr   pnew_pathr   rQ   rQ   rR   r    s   


z HDFStore._create_nodes_and_group)r   NNF)r   rY   r   r   r   r   r   r   r   rY   r   rY   )r   rY   r   r   )r[   rY   )r   rY   r   r   r   r^   )r   r   r   r   )r   )r   rY   r   r   )r   r  )r   r  )r   )r   rY   r   r   r   r   F)r  r   r   r   )NNNNFNF)r   rY   r   r   NNNr   rY   r   r   r   r   NN)r   rY   r5  rY   r   r   r   r   )NNNNNFNF)r   r   )NTFNNNNNNrx   TF)r   rY   r   r   r   r   r   r   r   r   r   rY   rS  r   r   r   r   r   )NNTTNNNNNNNNNNrx   )r   rY   r   r   r   r   r   r   r   r   r   r   r   rY   r   r   )NNF)rb  rc  r   r   )r   rY   r  r   r  r   r   r   )r   rg   )r  )rj   rY   r   r  )r   rY   r   r  )r   rY   r   r  )r  TNNNFT)r  r   r   r   r   r   r   r   )r   rY   r   rY   )NNrK   rx   )r   r  rW   rY   r   rY   r   r  )NTFNNNNNNFNNNrx   T)r   rY   r   r   r   r   r   r   r   rY   rS  r   r   r   )r   rI   )r   rY   r   r   r   rI   )r   rY   r   rI   )2r   
__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   r4  r7  rR  r   r   r   r  r  r   r  r   r1  r  r  r   rU  r+  rV  r  r  r  rQ   rQ   rQ   rR   r     s  
 A
"











"

-
N$+~H=]d
(
0

=*
a
>
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 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  rP   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   rP   r(  rj   rN  minr*  r   r   rJ  r^   r   r   )r   r   rP   r(  rj   r*  r   r   r   r   r   rQ   rQ   rR   r   H  s,   

zTableIterator.__init__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   rJ  r   r   r  r   r(  ri   r   )r   r   r   r   rQ   rQ   rR   r
  r  s   


	zTableIterator.__iter__c                 C  s   | j r
| j  d S d S rT   )r   r   r   r   rQ   rQ   rR   r     s   zTableIterator.closerJ  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)rj   z$can only read_coordinates on a tabler0  )r   rL   rP   r  r   r2  rj   rJ  r   r   r(  r   )r   rJ  rj   resultsrQ   rQ   rR   r.    s   
zTableIterator.get_result)NNFNF)r   r   rP   r  r   r   r   r   r   r   r   r   r  r  )rJ  r   )	r   r  r  r  r  r   r
  r   r.  rQ   rQ   rQ   rR   r-  0  s   
 	*
r-  c                   @  sj  e Zd ZU dZdZded< dZded< g dZded< ded	< 	
	
	
	
	
	
	
	
	
	
	
	
	
dLdMddZe	dNddZ
e	dOddZdPddZdOddZdQddZdRddZe	dRd d!ZdSd'd(Zd)d* Ze	d+d, Ze	d-d. Ze	d/d0 Ze	d1d2 Zd3d4 ZdTdUd5d6ZdUd7d8ZdVd<d=ZdTd>d?ZdWd@dAZdUdBdCZdUdDdEZdUdFdGZdXdHdIZ dXdJdKZ!d
S )Y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_namerY   r[   cnameNr   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.)rL   rY   r   ru  r  typr[   r  rE  posr  r  r  r}  rp   r   metadataset_pos)r   r[   ru  r  r  r  rE  r  r  r  r  r}  rp   r   r  rQ   rQ   rR   r     s(   


zIndexCol.__init__r^   c                 C     | j jS rT   )r  itemsizer   rQ   rQ   rR   r    s   zIndexCol.itemsizec                 C     | j  dS )N_kindrZ   r   rQ   rQ   rR   	kind_attr     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  _v_pos)r   r  rQ   rQ   rR   r    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->rQ   ri  rQ   rQ   rR   rf         z%IndexCol.__repr__.<locals>.<listcomp>)r[   r  rE  r  r  )
rh   maprF   r[   r  rE  r  r  joinrM  r   temprQ   rQ   rR   r     s   zIndexCol.__repr__otherr   c                      t  fdddD S )compare 2 col itemsc                 3  (    | ]}t |d t  |d kV  qd S rT   r  r  r  r   rQ   rR   rg    
    
z"IndexCol.__eq__.<locals>.<genexpr>)r[   r  rE  r  rd  r   r  rQ   r  rR   __eq__     zIndexCol.__eq__c                 C  s   |  | S rT   )r  r  rQ   rQ   rR   __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 columnrf  F)hasattrrp   r  rf  r  r  r   rQ   rQ   rR   r    s   zIndexCol.is_indexedru  
np.ndarrayrW   r   Ctuple[np.ndarray, np.ndarray] | tuple[DatetimeIndex, DatetimeIndex]c           
      C  s  t |tjsJ t||jjdur|| j }t| j}t	||||}i }t| j
|d< | jdur8t| j|d< t}t|jsDt|jrGt}n|jdkrTd|v rTdd }z
||fi |}W n tyw   d|v rmd|d< ||fi |}Y nw t|| j}	|	|	fS )zV
        Convert the data from this selection to the appropriate pandas type.
        Nr[   r  i8c                 [  s   t dd| i|S )NordinalrQ   )r5   )r>  kwdsrQ   rQ   rR   r   *  s
    z"IndexCol.convert.<locals>.<lambda>)rL   rM   ndarrayr   dtypefieldsr  rS   r  _maybe_convertr  r  r3   r)   r*   r2   r   _set_tzr  )
r   ru  r   rW   r   val_kindr   factorynew_pd_indexfinal_pd_indexrQ   rQ   rR   convert  s.   


zIndexCol.convertc                 C  r   )zreturn the valuesru  r   rQ   rQ   rR   	take_data:  r   zIndexCol.take_datac                 C  r  rT   )rp   r  r   rQ   rQ   rR   attrs>     zIndexCol.attrsc                 C  r  rT   rp   descriptionr   rQ   rQ   rR   r'  B  r%  zIndexCol.descriptionc                 C  s   t | j| jdS )z!return my current col descriptionN)r  r'  r  r   rQ   rQ   rR   colF     zIndexCol.colc                 C  r   zreturn my cython valuesr"  r   rQ   rQ   rR   cvaluesK     zIndexCol.cvaluesc                 C  s
   t | jS rT   )r	  ru  r   rQ   rQ   rR   r
  P  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  )rS   r  rL   rc  r   r[   r  r  r   	StringColr  )r   r   rQ   rQ   rR   maybe_set_sizeS  s   
zIndexCol.maybe_set_sizec                 C     d S rT   rQ   r   rQ   rQ   rR   validate_names`  r   zIndexCol.validate_nameshandlerAppendableTabler   c                 C  s:   |j | _ |   | | | | | | |   d S rT   )rp   validate_colvalidate_attrvalidate_metadatawrite_metadataset_attr)r   r2  r   rQ   rQ   rR   validate_and_setc  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)rS   r  r(  r  r   r  )r   r  crQ   rQ   rR   r4  k  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 [ - r<  )r  r$  r  r  r   )r   r   existing_kindrQ   rQ   rR   r5  ~  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  r  zinvalid info for [z] for [z], existing_value [z] conflicts with new value [r<  )_info_fieldsr  
setdefaultr[   r   rm   r  r  r   r$   setattrr   )r   r  r   r   idxexisting_valuewsrQ   rQ   rR   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   r[   __dict__update)r   r  r@  rQ   rQ   rR   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   rQ   rQ   rR   r8       zIndexCol.set_attrc                 C  sN   | j dkr| j}|| j}|dur!|dur#t||s%tddS dS dS dS )z:validate that kind=category does not change the categoriescategoryNzEcannot append a categorical with different categories to the existing)r   r  read_metadatar  r0   r   )r   r2  new_metadatacur_metadatarQ   rQ   rR   r6    s   
zIndexCol.validate_metadatac                 C  s"   | j dur|| j| j  dS dS )zset the meta dataN)r  r7  r  )r   r2  rQ   rQ   rR   r7    s   
zIndexCol.write_metadata)NNNNNNNNNNNNN)r[   rY   r  r   r   r   r  r  )r  r^   r   r   r  r   r   r   r  )ru  r  rW   rY   r   rY   r   r  rT   r  )r2  r3  r   r   r   r   )r   r   r   r   )r2  r3  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/  r1  r9  r4  r5  rC  rF  r8  r6  r7  rQ   rQ   rQ   rR   r    sh   
 ,




-








	
!

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 NFrQ   r   rQ   rQ   rR   r       zGenericIndexCol.is_indexedru  r  rW   rY   r   tuple[Int64Index, Int64Index]c                 C  s2   t |tjsJ t|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
        )rL   rM   r  r   r:   arangeri   )r   ru  r   rW   r   r   rQ   rQ   rR   r!    s   zGenericIndexCol.convertr   c                 C  r0  rT   rQ   r   rQ   rQ   rR   r8    r   zGenericIndexCol.set_attrNr  )ru  r  rW   rY   r   rY   r   rQ  r  )r   r  r  r  r  r  r!  r8  rQ   rQ   rQ   rR   rM    s    
rM  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d?ddZd@ddZdd ZedAd!d"Zed#d$ ZedBd'd(ZedCd)d*Zed+d, Zed-d. Zed/d0 Zed1d2 ZdDd3d4ZdEd8d9ZdDd:d;Z  ZS )F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  r}  Nr[   rY   r  DtypeArg | Noner   r   c                   s2   t  j|||||||||	|
|d || _|| _d S )N)r[   ru  r  r  r  r  r  r}  rp   r   r  )superr   r  r  )r   r[   ru  r  r  r  r  r  r}  rp   r   r  r  r  	__class__rQ   rR   r     s   
zDataCol.__init__c                 C  r  )N_dtyperZ   r   rQ   rQ   rR   
dtype_attr	  r  zDataCol.dtype_attrc                 C  r  )N_metarZ   r   rQ   rQ   rR   	meta_attr	  r  zDataCol.meta_attrc                 C  r  )Nr  c                 S  r  r   rQ   ri  rQ   rQ   rR   rf   (	  r  z$DataCol.__repr__.<locals>.<listcomp>)r[   r  r  r  shape)
rh   r  rF   r[   r  r  r  r\  r  rM  r  rQ   rQ   rR   r   !	  s   zDataCol.__repr__r  r   r   c                   r  )r  c                 3  r	  rT   r
  r  r  rQ   rR   rg  0	  r  z!DataCol.__eq__.<locals>.<genexpr>)r[   r  r  r  r  r  rQ   r  rR   r  .	  r  zDataCol.__eq__r  r   c                 C  s@   |d usJ | j d u sJ t|\}}|| _|| _ t|| _d S rT   )r  _get_data_and_dtype_namer  _dtype_to_kindr  )r   r  
dtype_namerQ   rQ   rR   set_data5	  s   zDataCol.set_datac                 C  r   )zreturn the datar  r   rQ   rQ   rR   r#  ?	  r   zDataCol.take_dataru  rG   c                 C  s   |j }|j}|j}|jdkrd|jf}t|tr&|j}| j||j j	d}|S t
|s.t|r5| |}|S t|r@| |}|S t|rPt j||d d}|S t|r\| ||}|S | j||j	d}|S )zW
        Get an appropriately typed and shaped pytables.Col object for values.
        r_   r  r   r  r\  )r  r  r\  rn  sizerL   r;   codesget_atom_datar[   r)   r*   get_atom_datetime64r.   get_atom_timedelta64r(   r   
ComplexColr-   get_atom_string)r  ru  r  r  r\  re  atomrQ   rQ   rR   	_get_atomC	  s.   





zDataCol._get_atomc                 C  s   t  j||d dS )Nr   rc  r   r.  r  r\  r  rQ   rQ   rR   rj  c	     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UIntrG   periodInt64Col)r  
capitalizer  r   )r  r  k4col_namekcaprQ   rQ   rR   get_atom_coltypeg	  s   


zDataCol.get_atom_coltypec                 C  s   | j |d|d dS )Nrb  r   r\  rz  r  r\  r  rQ   rQ   rR   rf  v	  rG  zDataCol.get_atom_datac                 C     t  j|d dS Nr   r{  r   ru  r  r\  rQ   rQ   rR   rg  z	     zDataCol.get_atom_datetime64c                 C  r~  r  r  r  rQ   rQ   rR   rh  ~	  r  zDataCol.get_atom_timedelta64c                 C     t | jdd S )Nr\  )r  r  r   rQ   rQ   rR   r\  	     zDataCol.shapec                 C  r   r*  ra  r   rQ   rQ   rR   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  rg   ru  r   rY  r  )r   r   existing_fieldsexisting_dtyperQ   rQ   rR   r5  	  s   zDataCol.validate_attrr  rW   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krbt||dd}n|dkrntj|dd}n~|dkrztjd	d
 |D td}W nk ty   tjdd
 |D td}Y nWw |dkr|	}| }|du rtg tjd}nt|}| r||  }||dk  |t j8  < tj|||
d}nz	|j|dd}W n ty   |jddd}Y nw t|dkrt ||||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 rQ   r   fromordinalrb   rj  rQ   rQ   rR   rf   	  r;  z#DataCol.convert.<locals>.<listcomp>c                 S  r  rQ   r   fromtimestampr  rQ   rQ   rR   rf   	  r;  rH  )
categoriesr}  Fr  Or-  r   rW   r   )"rL   rM   r  r   r  r  r  r  r]  r^  r  rS   r   r  r}  r  r  asarrayobjectr   ravelr3   float64r9   anyastyper^   cumsum_valuesr;   
from_codesr   _unconvert_string_arrayru  )r   ru  r   rW   r   	convertedr_  r  r   r  r}  r  r  r  re  maskrQ   rQ   rR   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  ru  r[  r   r  rY  r   rQ   rQ   rR   r8  	  s   zDataCol.set_attr)NNNNNNNNNNNN)r[   rY   r  rT  r   r   r  rL  )r  r   r   r   )ru  r   r   rG   )r  rY   r   rp  r  rY   r   rG   r  )ru  r  rW   rY   r   rY   )r   r  r  r  r  r  r=  r   r  rY  r[  r   r  r`  r#  classmethodrl  rj  rz  rf  rg  rh  r\  r+  r5  r!  r8  __classcell__rQ   rQ   rV  rR   rS    sZ     










erS  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 | j stdd S )N-cannot have non-object label DataIndexableCol)r3   ru  	is_objectr   r   rQ   rQ   rR   r1  

  s   zDataIndexableCol.validate_namesc                 C  s   t  j|dS )N)r  rm  rn  rQ   rQ   rR   rj  
  r  z DataIndexableCol.get_atom_stringr  rY   rG   c                 C  s   | j |d S )Nrb  r|  r}  rQ   rQ   rR   rf  
  r  zDataIndexableCol.get_atom_datac                 C  
   t   S rT   r  r  rQ   rQ   rR   rg  
     
z$DataIndexableCol.get_atom_datetime64c                 C  r  rT   r  r  rQ   rQ   rR   rh  
  r  z%DataIndexableCol.get_atom_timedelta64Nr  r  )r   r  r  r  r  r1  r  rj  rf  rg  rh  rQ   rQ   rQ   rR   r  
  s    


r  c                   @  s   e Zd ZdZdS )GenericDataIndexableColz(represent a generic pytables data columnN)r   r  r  r  rQ   rQ   rQ   rR   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ed< ded< ded< dZded< 		dOdPddZedQddZ	edRddZ
edd ZdSd d!ZdTd"d#ZdUd$d%Zed&d' Zed(d) Zed*d+ Zed,d- ZedVd.d/ZedQd0d1Zed2d3 ZdTd4d5ZdTd6d7Zed8d9 ZedQd:d;Zed<d= ZdWd?d@ZdXdTdBdCZdQdDdEZ	A	A	A	AdYdZdIdJZdKdL Z	Ad[d\dMdNZ dAS )]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.
    rY   pandas_kindro   format_typetype[DataFrame | Series]obj_typer^   rn  rW   r   r   rI   r   r   Fr   rN  rK   rx   r   r   c                 C  sZ   t |tsJ t|td usJ t |tjsJ t||| _|| _t|| _|| _	d S rT   )
rL   r   r   ry   rI   r   r   rX   rW   r   )r   r   r   rW   r   rQ   rQ   rR   r   =
  s   

zFixed.__init__c                 C  s*   | j d dko| j d dko| j d dk S )Nr   r_   
      )versionr   rQ   rQ   rR   is_old_versionL
  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 rT   r^   r=  rQ   rQ   rR   rg  U
  s    z Fixed.version.<locals>.<genexpr>.r  r@  )r   r   r   )rS   r  r   r  rh   r  ri   r{   )r   r  rQ   rQ   rR   r  P
  s   
zFixed.versionc                 C  s   t t| jjdd S )Nr  )rS   r  r   r  r   rQ   rQ   rR   r  \
  ro  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 rQ   rF   r=  rQ   rQ   rR   rf   f
      z"Fixed.__repr__.<locals>.<listcomp>[r<  12.12z	 (shape->))r,  r\  rL   rg   rh   r  r  )r   rP   jshaperQ   rQ   rR   r   `
  s   zFixed.__repr__c                 C  s   t | j| j_t t| j_dS )zset my pandas type & versionN)rY   r  r$  r  _versionr  r   rQ   rQ   rR   r  k
  s   zFixed.set_object_infoc                 C  s   t  | }|S rT   r  )r   new_selfrQ   rQ   rR   r  p
  s   
z
Fixed.copyc                 C  r   rT   )r*  r   rQ   rQ   rR   r\  t
  r   zFixed.shapec                 C  r  rT   r   r   r   rQ   rQ   rR   rO  x
  r%  zFixed.pathnamec                 C  r  rT   )r   r   r   rQ   rQ   rR   r   |
  r%  zFixed._handlec                 C  r  rT   )r   r   r   rQ   rQ   rR   r   
  r%  zFixed._filtersc                 C  r  rT   )r   r   r   rQ   rQ   rR   r   
  r%  zFixed._complevelc                 C  r  rT   )r   r   r   rQ   rQ   rR   r   
  r%  zFixed._fletcher32c                 C  r  rT   )r   r  r   rQ   rQ   rR   r$  
  r%  zFixed.attrsc                 C  rN  zset our object attributesNrQ   r   rQ   rQ   rR   	set_attrs
  rP  zFixed.set_attrsc                 C  rN  )zget our object attributesNrQ   r   rQ   rQ   rR   	get_attrs
  rP  zFixed.get_attrsc                 C  r   )zreturn my storabler   r   rQ   rQ   rR   storable
  r,  zFixed.storablec                 C  rN  rO  rQ   r   rQ   rQ   rR   r  
  rP  zFixed.is_existsc                 C  r  )Nr*  )r  r  r   rQ   rQ   rR   r*  
  r  zFixed.nrowsLiteral[True] | Nonec                 C  s   |du rdS dS )z%validate against an existing storableNTrQ   r  rQ   rQ   rR   validate
  s   zFixed.validateNc                 C  rN  )+are we trying to operate on an old version?NrQ   )r   rj   rQ   rQ   rR   validate_version
  rP  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   rP   rQ   rQ   rR   r,  
  s
   zFixed.infer_axesr   r   r   c                 C     t d)Nz>cannot read on an abstract storer: subclasses should implementr   r   rj   r   r   r   rQ   rQ   rR   r"  
  s   z
Fixed.readc                 K  r  )Nz?cannot write on an abstract storer: subclasses should implementr  r   r   rQ   rQ   rR   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
        TrW  Nz#cannot delete on an abstract storer)r\  r]  r   r  r   r   )r   rj   r   r   rQ   rQ   rR   r^  
  s   zFixed.delete)rK   rx   )
r   r   r   rI   rW   rY   r   rY   r   r   r  )r   r  r  r  )r   r  r  )r   r  rT   NNNNr   r   r   r   r  )r   r   r   r   r   r   )!r   r  r  r  r  r  rN  r   r  r  r  r  r   r  r  r\  rO  r   r   r   r   r$  r  r  r  r  r*  r  r  r,  r"  r  r^  rQ   rQ   rQ   rR   r  &
  sp   
 














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datetimert  c                 C  s   i | ]\}}||qS rQ   rQ   )rb   r:  rj  rQ   rQ   rR   rk  
  r;  zGenericFixed.<dictcomp>r   
attributesr   rY   c                 C  s   | j |dS )N )_index_type_mapr   )r   r  rQ   rQ   rR   _class_to_alias
  s   zGenericFixed._class_to_aliasc                 C  s   t |tr|S | j|tS rT   )rL   r   _reverse_index_mapr   r3   )r   aliasrQ   rQ   rR   _alias_to_class
  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|d}tj|d d}|d ur|d|}|S )Nr  rZ   UTC)r<   _simple_newru  r2   tz_localize
tz_convert)ru  r  r  dtaresultrQ   rQ   rR   rq   
  s
   z*GenericFixed._get_index_factory.<locals>.fc                 S  s   t j| |d}tj|d dS )Nr  rZ   )r=   r  r5   )ru  r  r  parrrQ   rQ   rR   rq   
  s   r  r  zutf-8r  )
r  rS   r  r2   r5   r3   r7   rL   bytesrO   )r   r$  r  rq   r  r   rQ   rQ   rR   _get_index_factory
  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   rj   rQ   rQ   rR   validate_read  s   zGenericFixed.validate_readr   c                 C  rN  )NTrQ   r   rQ   rQ   rR   r  &  rP  zGenericFixed.is_existsc                 C  s   | j | j_ | j| j_dS r  )rW   r$  r   r   rQ   rQ   rR   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 attributesrW   Nr   rx   )rX   r  r$  rW   rS   r   r  r?  )r   r   rQ   rQ   rR   r  /  s
   
zGenericFixed.get_attrsc                 K  r   rT   )r  r   r  r   rQ   rQ   rR   r  7  r   zGenericFixed.writeNr   r   r   r   c                 C  s   ddl }t| j|}|j}t|dd}t||jr"|d || }n=tt|dd}	t|dd}
|
dur<tj|
|	d}n||| }|	dkrTt|d	d}t	||d
d}n|	dkr_tj
|dd}|rd|jS |S )z2read an array for the specified node (off of groupr   N
transposedF
value_typer\  r  r  r  Tr  r  r  )rz   r  r   r  rL   VLArrayrS   rM   r  r  r  T)r   r   r   r   rz   r   r$  r  retr  r\  r  rQ   rQ   rR   
read_array:  s&   zGenericFixed.read_arrayr3   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: )rS   r  r$  read_multi_indexr   read_index_noder   )r   r   r   r   varietyr   r   rQ   rQ   rR   
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   )rL   r4   r?  r$  write_multi_index_convert_indexrW   r   write_arrayru  r  r   r  r  r[   r2   r5   r  r   r  r7   r  r  _get_tz)r   r   r   r  r   rQ   rQ   rR   write_indexj  s    



zGenericFixed.write_indexr4   c                 C  s   t | j| d|j tt|j|j|jD ]N\}\}}}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  	enumeraterM  levelsre  namesr+   r   r  rW   r   r  ru  r  r   r  r  r[   )r   r   r   ilevlevel_codesr[   	level_key
conv_levelr   	label_keyrQ   rQ   rR   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  re  r  rF  )	r  r$  rm  r   r  r   r[   r  r4   )r   r   r   r   r  r  re  r  r  r  r   r  r
  r  rQ   rQ   rR   r    s    
zGenericFixed.read_multi_indexr   rI   c                 C  s   ||| }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krW|t||| j| jdfdti|	}
n|t||| j| jdfi |	}
||
_	|
S )Nr\  r   r  r[   r   r  r  )r  rM   prodr\  r  r  rS   r  r\   r[   r  _unconvert_indexrW   r   r  )r   r   r   r   r  r  r[   r$  r  r   r   rQ   rQ   rR   r    s:   
zGenericFixed.read_index_noder   r   c                 C  sJ   t d|j }| j| j|| t| j|}t|j|j	_
|j|j	_dS )zwrite a 0-len arrayr_   N)rM   r  rn  r   create_arrayr   r  rY   r  r  r  r\  )r   r   r   arrr   rQ   rQ   rR   write_array_empty  s
   zGenericFixed.write_array_emptyr  r   r  Index | Nonec                 C  s>  t |dd}|| jv r| j| j| |jdk}d}t|jr#td|s/t|dr/|j	}d}d }| j
d urRtt t j|j}W d    n1 sMw   Y  |d urt|sm| jj| j|||j| j
d}||d d < n| || n|jjtjkrtj|dd}	|rn|	d	krnt|	||f }
tj|
tt d
 | j| j|t  }|| nit |jr| j!| j||"d dt#| j|j$_%nOt&|jr| j!| j||j' t#| j|}t(|j)|j$_)d|j$_%n.t*|jr| j!| j||"d dt#| j|j$_%n|r| || 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-  r  r  r  r  ),r@   r   r   r  rd  r'   r  r   r  r  r   r   r   r   Atom
from_dtypecreate_carrayr\  r  r   rM   object_r   infer_dtypern   r  r  r!   r$   create_vlarray
ObjectAtomr   r)   r  viewr  r  r  r*   asi8r  r  r.   r  )r   r   r  r  r   empty_arrayr  rk  cainferred_typerB  vlarrr   rQ   rQ   rR   r    sh   









zGenericFixed.write_arrayr  r  r  r  r  )r   rY   r   r   r   r   r   r3   )r   rY   r   r3   r   r   )r   rY   r   r4   r   r   )r   rY   r   r   r   r   r   r4   )r   rI   r   r   r   r   r   r3   )r   rY   r   r   r   r   rT   )r   rY   r  r   r  r  r   r   )r   r  r  r  r2   r5   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rQ   rQ   rQ   rR   r  
  s4   
 

.


#


&
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  r[   r   c              	   C  s*   zt | jjfW S  ttfy   Y d S w rT   )ri   r   ru  r   r{   r   rQ   rQ   rR   r\  A  s
   zSeriesFixed.shapeNr   r   r   r   r6   c                 C  s<   |  || | jd||d}| jd||d}t||| jdS )Nr   r  ru  )r   r[   )r  r  r  r6   r[   )r   rj   r   r   r   r   ru  rQ   rQ   rR   r"  H  s   zSeriesFixed.readr   c                   s<   t  j|fi | | d|j | d| |j| j_d S )Nr   ru  )rU  r  r  r   r  r[   r$  r  rV  rQ   rR   r  U  s   zSeriesFixed.writer  r   r   r   r   r   r6   r  )r   r  r  r  r  r  r  r\  r"  r  r  rQ   rQ   rV  rR   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 )BlockManagerFixedrn  nblocksr^   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_itemsr\  r_   )	rn  rm  r$  r  r   block0_valuesrg   r   r{   )r   rn  r  r  r   r\  rQ   rQ   rR   r\  a  s&   
zBlockManagerFixed.shapeNr   r   r   r1   c                 C  s  |  || |  d}g }t| jD ]}||kr||fnd\}}	| jd| ||	d}
||
 q|d }g }t| jD ]-}| d| d}| jd| d||	d}||	| }t
|j||d d	}|| q>t|dkrt|dd
}|j|dd}|S t
|d |d d	S )Nr   r  rE  r  r&  r'  r  r_   r   r   rh  F)r   r  )r  r  _get_block_manager_axisrm  rn  r  r   r$  r  rs  r1   r  ri   r8   rz  )r   rj   r   r   r   select_axisr`  r  r$  r%  axr  dfs	blk_itemsru  dfoutrQ   rQ   rR   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 formatrE  r  )r  r'  )rU  r  rL   _mgrrB   _as_manageris_consolidatedconsolidatern  r$  r  r`  	is_uniquer   r  ri   blocksr$  r  rt  mgr_locsr  ru  )r   r  r   r  r  r,  blkr.  rV  rQ   rR   r    s"   

zBlockManagerFixed.write)r   r%  r  )r   r   r   r   r   r1   r  )
r   r  r  r  r  r  r\  r"  r  r  rQ   rQ   rV  rR   r#  \  s   
 &r#  c                   @  s   e Zd ZdZeZdS )r  r  N)r   r  r  r  r1   r  rQ   rQ   rQ   rR   r    s    r  c                      sN  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ed< ded< ded< ded< ded< 								dd fdd Z	e
dd!d"Zdd#d$Zdd&d'Zdd(d)Ze
dd+d,Zdd0d1Ze
dd3d4Ze
dd5d6Ze
d7d8 Ze
d9d: Ze
d;d< Ze
d=d> Ze
d?d@ Ze
ddAdBZe
ddCdDZe
ddFdGZddIdJZdKdL ZddNdOZddQdRZddUdVZddWdXZ ddYdZZ!dd[d\Z"ddd]d^Z#dd_d`Z$e%dadb Z&	dddedfZ'	dddkdlZ(e)ddndoZ*dpdq Z+	
			dddtduZ,e-ddxdyZ.ddd|d}Z/dddZ0	ddddZ1			dddd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
    
wide_tablerp   rY   r  r  r_   zint | list[Hashable]r  Tzlist[IndexCol]
index_axeszlist[tuple[int, Any]]rA  zlist[DataCol]values_axesrg   r   r  rc  r  Nrx   r   r   r   rI   r   r   r   c                   sP   t  j||||d |pg | _|pg | _|pg | _|pg | _|	p!i | _|
| _d S )Nr  )rU  r   r:  rA  r;  r   r  r   )r   r   r   rW   r   r:  rA  r;  r   r  r   rV  rQ   rR   r     s   





zTable.__init__c                 C  s   | j dd S )N_r   )r  r  r   rQ   rQ   rR   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->[r<  r  c                 S  r  rQ   rY   r=  rQ   rQ   rR   rf     r  z"Table.__repr__.<locals>.<listcomp>r  c                 S  r   rQ   rZ   r  rQ   rQ   rR   rf   
  r  r  z (typ->z,nrows->z,ncols->z,indexers->[r  )r,  ri   r   r  r  r  r:  r  r=  r*  ncols)r   jdcr  verjverjindex_axesrQ   rQ   rR   r     s(   zTable.__repr__r:  c                 C  s"   | j D ]}||jkr|  S qdS )zreturn the axis for cN)r`  r[   )r   r:  r   rQ   rQ   rR   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rZt|D ]\}}|| }||krKtd| d| d| dq1td| d| d| dqdS )	z"validate against an existing tableNz'incompatible table_type with existing [r;  r<  )r:  rA  r;  zinvalid combination of [z] on appending data [z] vs current table [)r  r   r  r  r   rZ  )r   r  r:  svovr  saxoaxrQ   rQ   rR   r    s@   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)rL   r  rg   r   rQ   rQ   rR   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)r\  fill_missing_namesr   r  reset_indexr   rL   r1   )r   r  r  	reset_objr_  rQ   rQ   rR   validate_multiindex?  s   zTable.validate_multiindexr^   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+  r\  rb   r  rQ   rQ   rR   rf   S  r  z(Table.nrows_expected.<locals>.<listcomp>)rM   r  r:  r   rQ   rQ   rR   nrows_expectedP  s   zTable.nrows_expectedc                 C  s
   d| j v S )zhas this table been createdrp   r  r   rQ   rQ   rR   r  U  s   
zTable.is_existsc                 C  r  Nrp   r  r   r   rQ   rQ   rR   r  Z  r  zTable.storablec                 C  r   )z,return the table group (this is my storable))r  r   rQ   rQ   rR   rp   ^  r,  zTable.tablec                 C  r  rT   )rp   r  r   rQ   rQ   rR   r  c  r%  zTable.dtypec                 C  r  rT   r&  r   rQ   rQ   rR   r'  g  r%  zTable.descriptionc                 C  s   t | j| jS rT   )rK  rL  r:  r;  r   rQ   rQ   rR   r`  k  r>  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 rT   )ri   ru  r  rQ   rQ   rR   rg  r  s    zTable.ncols.<locals>.<genexpr>)sumr;  r   rQ   rQ   rR   r@  o  s   zTable.ncolsc                 C  rN  rO  rQ   r   rQ   rQ   rR   is_transposedt  rP  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  rQ   rQ   rR   rf   }  r  z*Table.data_orientation.<locals>.<listcomp>c                 S  s   g | ]}t |jqS rQ   )r^   rE  r  rQ   rQ   rR   rf   ~  r;  )rh   rK  rL  rA  r:  r   rQ   rQ   rR   data_orientationx  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   r_   c                 S  s   g | ]}|j |fqS rQ   r  r  rQ   rQ   rR   rf     r;  z$Table.queryables.<locals>.<listcomp>c                   s   g | ]
\}} | d fqS rT   rQ   )rb   rE  ru  )
axis_namesrQ   rR   rf     s    c                   s&   g | ]}|j t jv r|j|fqS rQ   )r[   rl  r   r  r  r   rQ   rR   rf     s     )r:  rA  r;  rc  )r   d1d2d3rQ   )rZ  r   rR   
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 rQ   )rE  r  rO  rQ   rQ   rR   rf     r  z$Table.index_cols.<locals>.<listcomp>r:  r   rQ   rQ   rR   
index_cols  r)  zTable.index_colsr   c                 C  r_  )zreturn a list of my values colsc                 S  r   rQ   rY  rO  rQ   rQ   rR   rf     r  z%Table.values_cols.<locals>.<listcomp>)r;  r   rQ   rQ   rR   values_cols  r>  zTable.values_colsr   c                 C  s   | j j}| d| dS )z)return the metadata pathname for this keyz/meta/z/metar  r   rQ   rQ   rR   _get_metadata_path  s   zTable._get_metadata_pathru  r  c                 C  s,   | j j| |t|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
        rp   )r   rW   r   r   N)r   r   rc  r6   rW   r   r   )r   r   ru  rQ   rQ   rR   r7    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   rc  r   rQ   rQ   rR   rI    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)rY   r  r$  ra  rb  rA  r   r   rW   r   r  r  r   rQ   rQ   rR   r    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  rA  Nr   r  r   rW   r   rx   r  c                 S     g | ]}|j r|qS rQ   r  r  rQ   rQ   rR   rf     r;  z#Table.get_attrs.<locals>.<listcomp>c                 S     g | ]}|j s|qS rQ   re  r  rQ   rQ   rR   rf     r;  )r  r$  rA  r   r  r   rX   rW   rS   r   r  
indexablesr:  r;  r   rQ   rQ   rR   r    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  rQ   r?  r=  rQ   rQ   rR   rf     r  z*Table.validate_version.<locals>.<listcomp>r  )r  rl   r  r  r  r  r    r$   )r   rj   rB  rQ   rQ   rR   r    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
        Nru  zmin_itemsize has the key [z%] which is not an axis or data_column)rL   rc  r^  r   )r   r   qr:  rQ   rQ   rR   validate_min_itemsize  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 existNrH  r  )r[   rE  r  r  r  rp   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  rX  rZ  )
r[   r  ru  r  r  r  rp   r   r  r  )
rL   rY   rS  r  r  _maybe_adjust_namer  r^  rI  rp   )r  r:  klassrk  adj_nameru  r  r  mdr   r  )base_posr  descr   table_attrsrQ   rR   rq     s0   

zTable.indexables.<locals>.fc                   s   g | ]	\}} ||qS rQ   rQ   )rb   r  r:  )rq   rQ   rR   rf   :  r?  z$Table.indexables.<locals>.<listcomp>)r'  rp   r$  r  ra  r  rI  r  r   rl  r   ri   rp  rb  )r   _indexablesr  rE  r[   rk  rm  r   r  r  	index_colrQ   )rn  r  ro  rq   r   rp  rR   rg    s2   




 %zTable.indexablesr  r   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rtd	|jdi | q=|| jd
 d v rt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  rQ   )r  r  r  rQ   rQ   rR   rf   c  r  z&Table.create_index.<locals>.<listcomp>r  r  complexzColumns 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   r_   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.rQ   )r,  r`  rL   rh   rg   rp   r  rf  r  r   r  r  remove_indexr   r  r   r  rA  r{   )r   r   r  r  kwrp   r:  rj  r   cur_optlevelcur_kindrQ   rQ   rR   r  >  sX   

zTable.create_indexr   r   r   !list[tuple[ArrayLike, ArrayLike]]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]]
        r0  r  )
	Selectionr   r`  rF  r  r!  r   rW   r   r   )	r   rj   r   r   	selectionru  r  r   resrQ   rQ   rR   
_read_axes  s   
zTable._read_axesr  c                 C     |S )zreturn the data for this objrQ   r  r  r  rQ   rQ   rR   
get_object  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   r4   z"cannot use a multi-index on axis [z] with data_columns TNc                   s    g | ]}|d kr| vr|qS r"  rQ   r9  )existing_data_columnsrQ   rR   rf     s
    z/Table.validate_data_columns.<locals>.<listcomp>c                   s   g | ]}| v r|qS rQ   rQ   )rb   r:  )axis_labelsrQ   rR   rf     r  )
ri   r  r   r   rg   rL   rc  rl  rp  r  )r   r   r   rA  rE  r  rQ   )r  r  rR   validate_data_columns  s.   


	zTable.validate_data_columnsr1   r  c           /        st  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} fdddD d }j| }t|}|rt|
}| j| d }tt|t|sttt|tt|r|}|	|i }t|j|d< t|j|d< |
||f  d }j| }|}t||| j| j}||_|d ||	 | | |g}t|}|dksJ t|
dksJ |
D ]}t!|d |d q|jdk}| "|||
}| #|$ }| %|||
| j&|\}}g }t't(||D ]\}\}}t)}d}|r\t|dkr\|d |v r\t*}|d }|du s\t |t+s\td|r|rz| j&| }W n t,t-fy }  ztd| d| j& d| d} ~ ww d}|pd| }!t.|!|j/|||| j| j|d}"t0|!| j1}#|2|"}$t3|"j4j5}%d}&t6|"dddurt7|"j8}&d }' }(})t9|"j4r|"j:})d}'tj|"j;d
d< }(t=|"\}*}+||#|!t||$||%|&|)|'|(|+|*d},|,|	 ||, |d7 }q,dd |D }-t| | j>| j| j| j||
||-|	|d
}.t?| dr(| j@|._@|.A| |r8|r8|.B|  |.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  r<  Nr   c                   r8  rQ   )_get_axis_numberr  )r  rQ   rR   rf     r;  z&Table._create_axes.<locals>.<listcomp>Tc                 S  r   rQ   rh  r  rQ   rQ   rR   rf     r  Fr  r_   z<currently only support ndim-1 indexers in an AppendableTablenanc                   s   g | ]}| vr|qS rQ   rQ   r=  )r`  rQ   rR   rf   *  r  rX  r  r   r  zIncompatible appended table [z]with existing table [values_block_)existing_colr   r   rW   r   r   r  rH  r  )r[   r  ru  r  r  r  r  r}  r   r  r  r  c                 S  r  rQ   )r  r[   )rb   r(  rQ   rQ   rR   rf     r  )
r   r   rW   r   r:  rA  r;  r   r  r   r  )CrL   r1   r   r   r   r   r,  r:  rg   r   r   r  rn  ri   r   r`  rA  r0   rM   arrayrr  r>  r  r   r   _get_axis_namer  rW   r   rE  r  rC  r/  _reindex_axisr  r  rG  _get_blocks_and_itemsr;  r  rM  rS  r  rY   
IndexErrorr   _maybe_convert_for_string_atomru  rj  r  rl  r^  r  r[   r  r  r  r'   r}  r  r  r]  r   r  r  ri  r  )/r   r`  r  r  r   r   r   r   table_existsnew_infonew_non_index_axesr@  r   append_axisindexer
exist_axisr  	axis_name	new_indexnew_index_axesjr  r  r6  r.  vaxesr  r8  b_itemsrk  r[   r  r_  new_namedata_convertedrl  r  r  r  r   r  r}  r  r_  r(  dcs	new_tablerQ   )r`  r  rR   _create_axes  s   
 







"






zTable._create_axesr  r  c                 C  sj  t | jtr| d} dd }| j}tt|}t|j}||}t|r_|d \}	}
t	|

t	|}| j||	dj}t|j}||}|D ]}| j|g|	dj}||j ||| qF|rdd t||D }g }g }|D ];}t|j}z||\}}|| || W qq 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 rQ   )r  rt  r7  )rb   r8  mgrrQ   rR   rf     r?  zFTable._get_blocks_and_items.<locals>.get_blk_items.<locals>.<listcomp>)r6  r  rQ   r  rR   get_blk_items  s   z2Table._get_blocks_and_items.<locals>.get_blk_itemsr   rh  c                 S  s"   i | ]\}}t | ||fqS rQ   )rh   tolist)rb   br  rQ   rQ   rR   rk    s    z/Table._get_blocks_and_items.<locals>.<dictcomp>r  c                 S  r  rQ   r  )rb   itemrQ   rQ   rR   rf      r  z/Table._get_blocks_and_items.<locals>.<listcomp>z+cannot match existing table structure for [z] on appending data)rL   r1  rB   r2  r   rC   rg   r6  ri   r3   rq  rz  rp  rM  rh   ru  ry  r   r  r   r  r   )r  r  r  r;  r   r  r  r6  r.  rE  r  
new_labelsr:  by_items
new_blocksnew_blk_itemsear  r  r  r_  jitemsrQ   rQ   rR   r    sR   






zTable._get_blocks_and_itemsrz  ry  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 ||| q*|jdurS|j D ]\}} fdd}	|	|| q@ 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)Nrh  r_   zcannot find the field [z] for filtering!)_AXIS_ORDERSr  	_get_axisrI  unionr3   r  rx  rA   r  ru  rL   r1   r   )fieldfiltr  axis_numberaxis_valuestakersru  r  opr   rQ   rR   process_filter  s$   





z*Table.process_axes.<locals>.process_filter)	rg   rI  rL   r  insertrA  r  filterr   )
r   r  rz  r   r   rE  labelsr  r  r  rQ   r  rR   process_axes
  s   

!zTable.process_axesr   r   ra  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'  rp   )r[   ra  c                 S  s   i | ]}|j |jqS rQ   )r  r  r  rQ   rQ   rR   rk  S  r;  z,Table.create_description.<locals>.<dictcomp>r'  	   )r   r   r   r   )maxrP  r`  r   r   r  r   r   )r   r   r   r   ra  rb  r   rQ   rQ   rR   create_descriptionD  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
        Fr0  Nr_   r  )r  r,  ry  select_coordsr  r   r6  r  r  ilocru  r3   )
r   rj   r   r   rz  coordsr  r  r  r  rQ   rQ   rR   r2  c  s   

 zTable.read_coordinatesr5  c                 C  s   |    |  s
dS |durtd| jD ]=}||jkrR|js'td| dt| jj	|}|
| j |j||| | j| j| jd}tt|d |j|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  r_   rZ   z] not found in the table)r  r,  r   r`  r[   r  r   r  rp   rf  rF  r  r!  r   rW   r   r6   r  r  r   )r   r5  rj   r   r   r   r:  
col_valuesrQ   rQ   rR   r6  }  s,   



zTable.read_column)Nrx   NNNNNN)r   r   r   rI   r   rY   r   r   r  )r:  rY   r  r  )r  r   r   rJ  r  )r   rU  )r   rW  )r   r   )r   rY   r   rY   )r   rY   ru  r  r   r   r  rT   r  )r  r   r   r   r  )r   r   r   r   r   rx  r  r   )TNNN)r  r1   r  r   )r  r1   r  r   )rz  ry  r   r1   )r   r   r   r   ra  r   r   rW  r  )r5  rY   r   r   r   r   )4r   r  r  r  r  r  r  r  rN  r   r  r=  r   r   r  rI  rN  rP  r  r  rp   r  r'  r`  r@  rT  rV  r^  ra  rb  rc  r7  rI  r  r  r  ri  r#   rg  r  r|  r  r  r  r  staticmethodr  r  r  r2  r6  r  rQ   rQ   rV  rR   r    s   
 


"






	







LW"* k>
: 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  rQ   rQ   rR   r"    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  rQ   rQ   rR   r    s   zWORMTable.writer  r  r  )r   r  r  r  r  r"  r  rQ   rQ   rQ   rR   r    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 )%r3  (support the new appendable table formats
appendableNFTr   r   r   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 )Nrp   )r`  r  r  r   r   r   )r   r   r   ra  rS  )r   )r  r   r  r   r  r`  r1  r  r  create_tabler  r$  r9  
write_data)r   r  r`  r   r   r   r   r   r   ra  r   r   r   rS  rp   r   optionsrQ   rQ   rR   r    s4   

	


zAppendableTable.writer   r   c                   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 rd}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 qdS )z`
        we form the data into a 2-d including indexes,values,mask write chunk-by-chunk
        r   rh  u1Fr  r_   Nc                 S  r   rQ   )r+  r  rQ   rQ   rR   rf   $  r  z.AppendableTable.write_data.<locals>.<listcomp>c                 S     g | ]}|  qS rQ   )r#  r  rQ   rQ   rR   rf   *  r  c              	   S  s,   g | ]}| tt|j|jd  qS r  )	transposerM   rollrR  rn  r  rQ   rQ   rR   rf   +  s   , r  r  c                      g | ]}|  qS rQ   rQ   r  end_istart_irQ   rR   rf   ?  r  c                   r  rQ   rQ   r  r  rQ   rR   rf   A  r  )indexesr  ru  )r  r  rP  r;  r9   r  rd  rL   rM   r  r   r  ri   r  r:  r  r\  reshaper  r  rm  write_data_chunk)r   r   r   r  r*  masksr   r  mr  nindexesru  bvaluesr  rj  	new_shaperowschunksrQ   r  rR   r  	  sP   


zAppendableTable.write_datar  r  r  list[np.ndarray]r  npt.NDArray[np.bool_] | Noneru  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  )rM   r  r\  ri   r  r  r  r  r  r  r   rd  rp   r   r  )r   r  r  r  ru  rj  r*  r  r  r  r@  r  rQ   rQ   rR   r  D  s*   z AppendableTable.write_data_chunkr   r   c                 C  s^  |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| }t |}	|	r| }
t|
|
dk j}t |sidg}|d |	krt||	 |d dkr|dd | }t|D ]}|t||}|j||jd  ||jd  d d |}q| j  |	S )NTrW  r  r_   r   r  )ri   r*  r   r  r   rp   remove_rowsr  r,  ry  r  r6   sort_valuesdiffrg   r   r   r  ry  reversedrt  rm  )r   rj   r   r   r*  rp   rz  ru  sorted_serieslnr  r   pgr  r  rQ   rQ   rR   r^  p  sF   


zAppendableTable.delete)NFNNNNNNFNNT)r   r   r   r   r   r   r  )r   r   r   r   r   r   )
r  r  r  r  r  r  ru  r  r   r   r  r  )	r   r  r  r  r  r  r  r  r^  rQ   rQ   rQ   rR   r3    s&    <
;,r3  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   r_   )r:  rE  r   rQ   rQ   rR   rT    r>  z"AppendableFrameTable.is_transposedr  c                 C  s   |r|j }|S )zthese are written transposed)r  r~  rQ   rQ   rR   r    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rUqK|| \}}|ddkrgt
|}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rt|tjr|d|jd f}t|tjrt|j||d}nt|t
rt|||d}n	tj|g||d}|j|jk sJ |j|jf|
| qKt|
dkr|
d }nt|
dd}t |||d} j|||d}|S )Nr0  r   c                   s"   g | ]\}}| j d  u r|qS r@  r`  )rb   r  r,  r   rQ   rR   rf     s   " z-AppendableFrameTable.read.<locals>.<listcomp>r_   r   r4   r  Tinplacer[   rZ   r)  rh  )rz  r   ) r  r,  r|  ri   rA  r  r   r  r`  r;  r3   r4   from_tuples	set_namesrT  r  r  rn  rL   rM   r  r  r\  r1   _from_arraysdtypesr  rd  r   r8   ry  r  )r   rj   r   r   r   r  r  indsindr   framesr  r   
index_valsr+  rf  r  ru  index_cols_r/  rz  rQ   r   rR   r"    sZ   
	




 
zAppendableFrameTable.readr  r  r  r  )r   r  r  r  r  r  rn  r1   r  r  r  rT  r  r  r"  rQ   rQ   rQ   rR   r    s   
 r  c                      sf   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 fdd	Z				dd fddZ  ZS )r  r  r  r  r  r   r   c                 C  rN  rO  rQ   r   rQ   rQ   rR   rT    rP  z#AppendableSeriesTable.is_transposedr  c                 C  r}  rT   rQ   r~  rQ   rQ   rR   r    rP  z AppendableSeriesTable.get_objectNc                   s<   t |ts|jp	d}||}t jd||j d|S )+we are going to write this as a frame tableru  r  r   NrQ   )rL   r1   r[   to_framerU  r  r   r  )r   r  r   r   r[   rV  rQ   rR   r  !  s   


zAppendableSeriesTable.writer   r   r   r6   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   rD  Tr  ru  )
rI  rL   r  rg   r  rU  r"  	set_indexr  r[   )r   rj   r   r   r   rI  r   rP   rV  rQ   rR   r"  (  s   

zAppendableSeriesTable.readr  r  rT   r  r"  )r   r  r  r  r  r  rn  r6   r  r  rT  r  r  r  r"  r  rQ   rQ   rV  rR   r    s     	r  c                      s(   e Zd ZdZdZdZ fddZ  ZS )r  r  r  r  c                   s^   |j pd}| |\}| _t| jtsJ t| j}|| t||_t j	dd|i|S )r  ru  r  NrQ   )
r[   rN  r  rL   rg   r   r3   r   rU  r  )r   r  r   r[   newobjrf  rV  rQ   rR   r  H  s   



z AppendableMultiSeriesTable.write)r   r  r  r  r  r  r  r  rQ   rQ   rV  rR   r  B  s
    r  c                   @  sb   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 ZdS )r  z:a table that read/writes the generic pytables table formatr  r  r  zlist[Hashable]r  r   rY   c                 C  r   rT   )r  r   rQ   rQ   rR   r  \  r   zGenericTable.pandas_typec                 C  s   t | jdd p	| jS rQ  rR  r   rQ   rQ   rR   r  `  ro  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  rd  rQ   re  r  rQ   rQ   rR   rf   j  r;  z*GenericTable.get_attrs.<locals>.<listcomp>c                 S  rf  rQ   re  r  rQ   rQ   rR   rf   k  r;  c                 S  r   rQ   rZ   r  rQ   rQ   rR   rf   l  r  )rA  r   r  rg  r:  r;  r   r   rQ   rQ   rR   r  d  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   NrH  r   )r[   rE  rp   r   r  )r[   r  ru  r  rp   r   r  )r'  rI  rM  rp   r  _v_namesrL   rY   r  r  r   )
r   rb  rm  r   rr  rq  r  r   rk  r  rQ   rQ   rR   rg  n  s.   


	zGenericTable.indexablesc                 K  r  )Nz cannot write on an generic tabler  r  rQ   rQ   rR   r    s   zGenericTable.writeNr  r  )r   r  r  r  r  r  rn  r1   r  r  r  r  r  r  r#   rg  r  rQ   rQ   rQ   rR   r  S  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 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   rY   c                 C  rN  )Nappendable_multirQ   r   rQ   rQ   rR   r=    rP  z*AppendableMultiFrameTable.table_type_shortNc                   sx   |d u rg }n	|du r|j  }| |\}| _t| jts J | jD ]}||vr/|d| q#t jd||d|S )NTr   r  rQ   )	r   r  rN  r  rL   rg   r  rU  r  )r   r  r   r   r   rV  rQ   rR   r    s   

zAppendableMultiFrameTable.writer   r   r   c                   sD   t  j||||d}| j}|j fdd|jjD |_|S )NrD  c                   s    g | ]} j |rd n|qS rT   )
_re_levelssearch)rb   r[   r   rQ   rR   rf     s     z2AppendableMultiFrameTable.read.<locals>.<listcomp>)rU  r"  r  r  r   r  r  )r   rj   r   r   r   r/  rV  r   rR   r"    s   zAppendableMultiFrameTable.readr  rT   r  r  )r   r  r  r  r  r1   r  rn  recompiler  r  r=  r  r"  r  rQ   rQ   rV  rR   r    s    
r  r  r1   rE  r  r3   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  rA   equalsuniquerw  slicern  rx  rh   )r  rE  r  r  r,  slicerrQ   rQ   rR   r    s   

r  r  r   str | tzinfoc                 C  s   t | }|S )z+for a tz-aware type, return an encoded zone)r   get_timezone)r  zonerQ   rQ   rR   r    s   
r  ru  np.ndarray | Indexr  r2   c                 C  r0  rT   rQ   ru  r  r  rQ   rQ   rR   r    s   r  r  c                 C  r0  rT   rQ   r  rQ   rQ   rR   r    rP  str | tzinfo | Nonenp.ndarray | DatetimeIndexc                 C  s   t | tr| jdu s| j|ksJ |dur;t | tr!| j}| j} nd}|  } t|}t| |d} | d|} | S |rDt	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
    NrZ   r  M8[ns]r  )rL   r2   r  r[   r  r  rS   r  r  rM   r  )ru  r  r  r[   rQ   rQ   rR   r    s   

r[   c              
   C  sp  t | tsJ |j}t|\}}t|}t|}t |ts(t|j	s(t
|j	r;t| |||t|dd t|dd |dS t |trDtdtj|dd}	t|}
|	dkrmtjdd	 |
D tjd
}t| |dt  |dS |	dkrt|
||}|j	j}t| |dt ||dS |	dv rt| ||||dS t |tjr|j	tksJ |dksJ |t  }t| ||||dS )Nr  r  )ru  r  r  r  r  r  zMultiIndex not supported here!Fr  r   c                 S  r  rQ   )	toordinalr  rQ   rQ   rR   rf   6  r  z"_convert_index.<locals>.<listcomp>r  )r  r-  )integerfloating)ru  r  r  r  r  )rL   rY   r[   r]  r^  r  rl  r:   r/   r  r&   r  r  r4   r   r   r  rM   r  int32r   	Time32Col_convert_string_arrayr  r.  r  r  r  )r[   r   rW   r   r  r  r_  r  rk  r   ru  r  rQ   rQ   rR   r    s^   








r  r  c                 C  s   |dkr
t | }|S |dkrt| }|S |dkr>ztjdd | D td}W |S  ty=   tjdd | D td}Y |S w |dv rIt| }|S |d	v rWt| d ||d
}|S |dkrdt| d }|S td| )Nr  r  r   c                 S  r  rQ   r  r  rQ   rQ   rR   rf   Z  r;  z$_unconvert_index.<locals>.<listcomp>r  c                 S  r  rQ   r  r  rQ   rQ   rR   rf   \  r;  )r  floatr   r-  r  r  r   zunrecognized index type )r2   r7   rM   r  r  r   r  )r  r  rW   r   r   rQ   rQ   rR   r  Q  s4   
	r  r  r   r   c                 C  s  |j tkr|S ttj|}|j j}tj|dd}	|	dkr td|	dkr(td|	dks2|dks2|S t	|}
|
 }|||
< tj|dd}	|	dkr|t|jd	 D ]+}|| }tj|dd}	|	dkr{t||krk|| nd
| }td| d|	 dqPt||||j}|j}t|trt|| p|dpd	}t|pd	|}|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  r   zNo.zCannot serialize the column [z2]
because its data contents are not [string] but [z] object dtyperu  z|Sr  )r  r  r   rM   r  r[   r   r  r   r9   r  rm  r\  ri   r  r  r  rL   rc  r^   r   r  r4  r  )r[   r  r  r   r   rW   r   r   r_  r   r  r  r  r(  error_column_labelr  r  ecirQ   rQ   rR   r  j  sP   



r  r  c                 C  s\   t | rt|  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]
    r_   Sr  )ri   r6   r  rY   encoder  r  r\  r%   r  
libwritersmax_len_string_arrayrM   r  )r  rW   r   ensuredr  rQ   rQ   rR   r    s   


r  c                 C  s   | j }tj|  td} t| r;tt| }d| }t	| d t
r/t| jj||dj} n| j|ddjtdd} |du rAd}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   )r   Fr  Nr  )r\  rM   r  r  r  ri   r  r  r%   rL   r  r6   rY   rO   r  r  !string_array_replace_from_nan_repr  )r  r   rW   r   r\  r  r  rQ   rQ   rR   r    s   

r  r  c                 C  s6   t |tsJ t|t|rt|||}|| } | S rT   )rL   rY   r   _need_convert_get_converter)ru  r  rW   r   convrQ   rQ   rR   r    s
   r  c                   s4   | dkrdd S | dkr fddS t d|  )Nr  c                 S  s   t j| ddS )Nr  r  )rM   r  r>  rQ   rQ   rR   r     s    z _get_converter.<locals>.<lambda>r-  c                   s   t | d  dS )Nr  )r  r  r  rQ   rR   r     s    zinvalid kind )r   )r  rW   r   rQ   r  rR   r    s
   r  c                 C  s   | dv rdS dS )N)r  r-  TFrQ   rb  rQ   rQ   rR   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   r_   r  r  zvalues_block_(\d+)values_)rL   rY   ri   r   r  r  r   )r[   r  r  grprQ   rQ   rR   rj    s   $
rj  	dtype_strc                 C  s   t | } | ds| drd}|S | drd}|S | dr$d}|S | ds.| dr2d}|S | dr;d}|S | d	rDd
}|S | drMd}|S | drVd}|S | dr_d}|S | dkrgd}|S td|  d)zA
    Find the "kind" string describing the given dtype name.
    r-  r  r  rs  r^   rq  r  r  	timedeltar  r   rH  rt  r  zcannot interpret dtype of [r<  )rS   r  r   )r  r  rQ   rQ   rR   r^  -  s@   





	
r^  c                 C  sb   t | tr| j} | jjdd }| jjdv r t| 	d} nt | t
r(| j} t| } | |fS )zJ
    Convert the passed data into a storable form and a dtype string.
    r  r   )r  Mr  )rL   r;   re  r  r[   r  r  rM   r  r  r5   r  )r  r_  rQ   rQ   rR   r]  N  s   


r]  c                   @  s:   e Zd ZdZ			ddd
dZdd Zdd Zdd ZdS )ry  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

    Nrp   r  r   r   r   r   r   c                 C  s^  || _ || _|| _|| _d | _d | _d | _d | _t|rt	t
h tj|dd}|dks0|dkrt|}|jtjkrZ| j| j}}|d u rHd}|d u rP| j j}t||| | _n't|jjtjr| jd urn|| jk  sz| jd ur~|| jk r~t
d|| _W d    n1 sw   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)rp   rj   r   r   	conditionr  termsrJ  r,   r   r   r   r  rM   r  r  bool_r*  rR  
issubclassr   r  r  generateevaluate)r   rp   rj   r   r   inferredrQ   rQ   rR   r   p  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)r^  rW   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
                )	rp   r^  r>   rW   	NameErrorr  r  r   r   )r   rj   rh  r_  qkeysr  rQ   rQ   rR   r&    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"  rp   
read_wherer   r   r   rJ  r2  r"  r   rQ   rQ   rR   r     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   rp   r*  r"  get_where_listr   rJ  rM   rR  )r   r   r   r*  rQ   rQ   rR   r    s"   

zSelection.select_coordsr  )rp   r  r   r   r   r   r   r   )r   r  r  r  r   r&  r   r  rQ   rQ   rQ   rR   ry  d  s    /ry  )r]   r^   )r   NNFNTNNNNrx   rK   )r   r   r   rY   r   r   r   rY   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rY   rW   rY   r   r   )	Nr   rx   NNNNFN)r   r   r   rY   r   rY   rj   r   r   r   r   r   r   r   r   r   r   r   )r   rI   r   rI   r   r   rT   )r  r1   rE  r^   r  r3   r   r1   )r  r   r   r  r  )ru  r  r  r  r  r   r   r2   )ru  r  r  r   r  r   r   r  )ru  r  r  r  r  r   r   r  )
r[   rY   r   r3   rW   rY   r   rY   r   r  )r  rY   rW   rY   r   rY   r   r  )r[   rY   r  r   r   r   )r  r  rW   rY   r   rY   r   r  )ru  r  r  rY   rW   rY   r   rY   )r  rY   rW   rY   r   rY   )r  rY   r   r   )r[   rY   r  r  r   rY   )r  rY   r   rY   )r  r   )r  
__future__r   
contextlibr   r  r  r   r   rK  r   r  textwrapr   typingr   r   r	   r
   r   r   r   r   r   r   r  numpyrM   pandas._configr   r   pandas._libsr   r   r  pandas._libs.tslibsr   pandas._typingr   r   r   r   r   r   pandas.compat._optionalr   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*   r+   r,   r-   r.   r/   pandas.core.dtypes.missingr0   r   r1   r2   r3   r4   r5   r6   r7   r8   r9   pandas.core.apir:   pandas.core.arraysr;   r<   r=   pandas.core.commoncorecommonr\   pandas.core.computation.pytablesr>   r?   pandas.core.constructionr@   pandas.core.indexes.apirA   pandas.core.internalsrB   rC   pandas.io.commonrD   pandas.io.formats.printingrE   rF   rz   rG   rH   rI   rJ   r  rU   rS   rX   r\   ra   rk   rl   r  rm   rn   r  ro  rs   rt   config_prefixregister_optionis_boolis_one_of_factoryry   r~   r   r   r   r   r   r-  r  rM  rS  r  r  r  r  r  r#  r  r  r  r3  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rj  r^  r]  ry  rQ   rQ   rQ   rR   <module>   s2   0 4,


: 
          _p  )!   3  e!`       o gd1B+

&
A

K

'




!