U
    _{f                    @  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 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-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJ ddlKmLZL ddlMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZW ddlXmYZYmZZZm[Z[ ddl\m]  m^Z_ ddl`maZambZb ddlcmdZd ddlemfZf ddlgmhZhmiZi ddljmkZk ddllmmZmmnZn erZddlompZpmqZqmrZr ddlgmsZs dZtdZud d! Zvd"d#d$d%d&Zwd'd( ZxeaZyd)d*d+d,Zzd-Z{d.e|d/< d0Z}d.e|d1< d2Z~d.e|d3< d4d4d5d5d6ZeNdgiZd7Zd.e|d8< d9Zd.e|d:< ed;8 ejd<d=eejd> ejd?deed4d5dgd> W 5 Q R X dad=ad@dA ZddEd#dFd#dGd"dHd"dHdIdJdKd#d#dLdMdNdOZddEd#d#dQdGdGdRdHdGdS	dTdUZdVdVdHdWdXdYZG dZd[ d[ZG d\d] d]ZG d^d_ d_ZG d`da daeZG dbdc dceZG ddde deeZG dfdg dgeZG dhdi diZG djdk dkeZG dldm dmeZG dndo doeZG dpdq dqeZG drds dseZG dtdu dueZG dvdw dweZG dxdy dyeZG dzd{ d{eZG d|d} d}eZG d~d deZG dd deZddddddddZdddddZeddddHddddZedddLdHddddZddddHddddZd#dd#d#d_dddZd#d#d#ddddZd#dddddZdd#d#ddddZdd#d#ddddZdd#d#d#dddZd#d#d#dddZd#dHdddZd#dd#dddZd#d#dddZdddd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)TracebackType)
TYPE_CHECKINGAnyCallableFinalHashableIteratorLiteralSequencecastoverload)config
get_option)libwriters)	timezones)AnyArrayLike	ArrayLikeAxisInt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_integer_dtypeis_list_likeis_object_dtypeis_string_dtypeis_timedelta64_dtypeneeds_i8_conversion)array_equivalent)
	DataFrameDatetimeIndexIndex
MultiIndexPeriodIndex
RangeIndexSeriesTimedeltaIndexconcatisna)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 unicoderO   )
isinstancenpbytes_decode)s rU   Q/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/pandas/io/pytables.py_ensure_decoded   s    
rW   
str | Nonestr)encodingreturnc                 C  s   | d krt } | S N)_default_encodingrZ   rU   rU   rV   _ensure_encoding   s    r_   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
    )rP   rY   namerU   rU   rV   _ensure_str   s    
rb   intscope_levelc                   sV   |d  t | ttfr* fdd| D } nt| r>t|  d} | dksNt| rR| 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 k	rt |r(t| d dn|qS )Nrf   rd   )rC   Term).0termlevelrU   rV   
<listcomp>   s   z _ensure_term.<locals>.<listcomp>rd   N)rP   listtuplerC   rg   len)wherere   rU   rj   rV   _ensure_term   s    	
rq   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)fru   trv   z;
: boolean
    drop ALL nan rows when appending to a table

dropna_docz~
: format
    default format writing format, if None, then
    put will default to 'fixed' and append will default to 'table'

format_doczio.hdfZdropna_tableF)	validatordefault_formatc               	   C  s8   t d kr4dd l} | a tt | jjdkaW 5 Q R X t S )Nr   strict)
_table_modtablesr   AttributeErrorfileZ_FILE_OPEN_POLICY!_table_file_open_policy_is_strict)r   rU   rU   rV   _tables   s    

r   aTr}   zFilePath | HDFStoreDataFrame | Series
int | Noneboolint | dict[str, int] | Nonebool | None Literal[True] | list[str] | NoneNone)path_or_bufkeyvaluemode	complevelcomplibappendformatindexmin_itemsizedropnadata_columnserrorsrZ   r[   c              
     s   |r$ 	f
dd}n 	f
dd}t | } t| trzt| |||d}|| W 5 Q R X n||  dS )z+store this object, close it if we opened itc                   s   | j 	 d
S )N)r   r   r   nan_repr   r   r   rZ   )r   store
r   r   rZ   r   r   r   r   r   r   r   rU   rV   <lambda>  s   zto_hdf.<locals>.<lambda>c                   s   | j 	 d
S )N)r   r   r   r   r   r   rZ   r   putr   r   rU   rV   r     s   )r   r   r   N)rH   rP   rY   HDFStore)r   r   r   r   r   r   r   r   r   r   r   r   r   r   rZ   rw   r   rU   r   rV   to_hdf   s     
   r   rzstr | list | Nonezlist[str] | None)	r   r   r   rp   startstopcolumnsiterator	chunksizec
                 K  s  |dkrt d| d|dk	r,t|dd}t| trN| jsDtd| }d}nvt| } t| tshtd	zt	j
| }W n tt fk
r   d}Y nX |std
|  dt| f||d|
}d}zx|dkr"| }t|dkrt d|d }|dd D ]}t||s t dq |j}|j|||||||	|dW S  t ttfk
r   t| ts|tt |  W 5 Q R X  Y nX dS )a"	  
    Read from the store, close it if we opened it.

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

    .. warning::

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

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

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

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

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

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

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

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

    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.Nrf   rd   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.)rp   r   r   r   r   r   
auto_close)
ValueErrorrq   rP   r   is_openOSErrorrH   rY   NotImplementedErrorospathexists	TypeErrorFileNotFoundErrorgroupsro   _is_metadata_of_v_pathnameselectKeyErrorr   r   close)r   r   r   r   rp   r   r   r   r   r   kwargsr   r   r   r   Zcandidate_only_groupZgroup_to_checkrU   rU   rV   read_hdf6  sj    O






r   rM   )groupparent_groupr[   c                 C  sF   | j |j krdS | }|j dkrB|j}||kr:|jdkr:dS |j}qdS )zDCheck if a given group is a metadata group for a given parent_group.Frf   metaT)Z_v_depthZ	_v_parent_v_name)r   r   currentparentrU   rU   rV   r     s    
r   c                   @  s(  e Zd ZU dZded< ded< ddd	d
ddddZddddZedd ZeddddZ	ddddZ
dddddZdddddZdddd Zdd
dd!d"Zd#dd$d%Zddd&d'Zd dd(d)Zd*d+d,dd-d.d/Zddd1d2d3d4Zd5dd6d7Zd8dd9d:Zdddd;d<d=Zddd>d?Zed
dd@dAZdd
ddBdCdDZdddEdFZddd
d
dGdHdIZddd	d	dJdKdLZdddd	d	dMdNdOZdd
d
dPdQdRZdddUd
d
d	dVdWdd
d
ddXdYdZZddddd[d\Z dddUd]d
d	dVd^dWddd_
d`daZ!ddbd
ddcdddeZ"ddd	dfddgdhdiZ#djddkdlZ$dddndodpdqZ%ddrddsdtZ&dduddvdwZ'ddd
d	d
d
d dydzd{Z(ddd|d}Z)d~d Z*dddddZ+dddddudddZ,dddUd]d
d	dVd
dd
dd
ddZ-ddddZ.dd
ddddZ/dddddZ0d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   NFr   r   r   )r   r   
fletcher32r[   c                 K  s   d|krt dtd}|d k	r@||jjkr@t d|jj d|d krX|d k	rX|jj}t|| _|d krnd}|| _d | _|r|nd| _	|| _
|| _d | _| jf d|i| d S )	Nr   z-format is not a defined argument for HDFStorer   zcomplib only supports z compression.r   r   r   )r   r   filtersZall_complibsZdefault_complibrH   _pathr   r   
_complevel_complib_fletcher32_filtersopen)selfr   r   r   r   r   r   r   rU   rU   rV   __init__$  s&    	
zHDFStore.__init__r[   c                 C  s   | j S r\   r   r   rU   rU   rV   
__fspath__E  s    zHDFStore.__fspath__c                 C  s   |    | jdk	st| jjS )zreturn the root nodeN)_check_if_openr   AssertionErrorrootr   rU   rU   rV   r   H  s    zHDFStore.rootc                 C  s   | j S r\   r   r   rU   rU   rV   filenameO  s    zHDFStore.filenamer   c                 C  s
   |  |S r\   )getr   r   rU   rU   rV   __getitem__S  s    zHDFStore.__getitem__r   r[   c                 C  s   |  || d S r\   r   )r   r   r   rU   rU   rV   __setitem__V  s    zHDFStore.__setitem__c                 C  s
   |  |S r\   )remover   rU   rU   rV   __delitem__Y  s    zHDFStore.__delitem__r`   c              	   C  sF   z|  |W S  ttfk
r$   Y nX tdt| j d| ddS )z$allow attribute access to get stores'z' object has no attribute 'N)r   r   r!   r   type__name__)r   ra   rU   rU   rV   __getattr__\  s    zHDFStore.__getattr__c                 C  s4   |  |}|dk	r0|j}|||dd fkr0dS dS )zx
        check for existence of this key
        can match the exact pathname or the pathnm w/o the leading '/'
        Nrf   TF)get_noder   )r   r   nodera   rU   rU   rV   __contains__f  s    
zHDFStore.__contains__rc   c                 C  s   t |  S r\   )ro   r   r   rU   rU   rV   __len__r  s    zHDFStore.__len__c                 C  s   t | j}t|  d| dS )N
File path: 
)rJ   r   r   )r   pstrrU   rU   rV   __repr__u  s    
zHDFStore.__repr__c                 C  s   | S r\   rU   r   rU   rU   rV   	__enter__y  s    zHDFStore.__enter__ztype[BaseException] | NonezBaseException | NonezTracebackType | None)exc_type	exc_value	tracebackr[   c                 C  s   |    d S r\   )r   )r   r   r   r   rU   rU   rV   __exit__|  s    zHDFStore.__exit__pandas	list[str])includer[   c                 C  s^   |dkrdd |   D S |dkrJ| jdk	s0tdd | jjddd	D S td
| ddS )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  s   g | ]
}|j qS rU   r   rh   nrU   rU   rV   rl     s     z!HDFStore.keys.<locals>.<listcomp>nativeNc                 S  s   g | ]
}|j qS rU   r   r   rU   rU   rV   rl     s    /Table)	classnamez8`include` should be either 'pandas' or 'native' but is 'r   )r   r   r   Z
walk_nodesr   )r   r   rU   rU   rV   keys  s    
zHDFStore.keyszIterator[str]c                 C  s   t |  S r\   )iterr   r   rU   rU   rV   __iter__  s    zHDFStore.__iter__zIterator[tuple[str, list]]c                 c  s   |   D ]}|j|fV  qdS )z'
        iterate on key->group
        N)r   r   )r   grU   rU   rV   items  s    zHDFStore.items)r   r[   c                 K  s   t  }| j|krR| jdkr$|dkr$n(|dkrL| jrLtd| j d| j d|| _| jr`|   | jr| jdkrt  j| j| j| j	d| _
tr| jrd	}t||j| j| jf|| _d
S )a9  
        Open the file in the specified mode

        Parameters
        ----------
        mode : {'a', 'w', 'r', 'r+'}, default 'a'
            See HDFStore docstring or tables.open_file for info about modes
        **kwargs
            These parameters will be passed to the PyTables open_file method.
        )r   w)r   r   )r   zRe-opening the file [z] with mode [z] will delete the current file!r   )r   zGCannot open HDF5 file, which is already opened, even in read-only mode.N)r   r   r   r$   r   r   r   Filtersr   r   r   r   r   	open_filer   )r   r   r   r   msgrU   rU   rV   r     s.    
  
zHDFStore.openc                 C  s   | j dk	r| j   d| _ dS )z0
        Close the PyTables file handle
        N)r   r   r   rU   rU   rV   r     s    

zHDFStore.closec                 C  s   | j dkrdS t| j jS )zF
        return a boolean indicating whether the file is open
        NF)r   r   Zisopenr   rU   rU   rV   r     s    
zHDFStore.is_open)fsyncr[   c              	   C  s@   | j dk	r<| j   |r<tt t| j   W 5 Q R X 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  rU   rU   rV   r    s
    


zHDFStore.flushc              
   C  sJ   t  : | |}|dkr*td| d| |W  5 Q R  S Q R X 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   rU   rU   rV   r     s
    
zHDFStore.get)r   r   r   c	                   st   |  |}	|	dk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  rf   rd   c                   s   j | || dS )N)r   r   rp   r   read_start_stop_wherer   rT   rU   rV   funcQ  s    zHDFStore.select.<locals>.funcrp   nrowsr   r   r   r   r   )r   r   rq   _create_storer
infer_axesTableIteratorr  
get_result)r   r   rp   r   r   r   r   r   r   r   r  itrU   r  rV   r     s(    .

zHDFStore.selectr   r   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
        rf   rd   z&can only read_coordinates with a tablerp   r   r   )rq   
get_storerrP   r   r   read_coordinates)r   r   rp   r   r   tblrU   rU   rV   select_as_coordinatesd  s
    

zHDFStore.select_as_coordinates)r   columnr   r   c                 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r  r   r   )r  rP   r   r   read_column)r   r   r  r   r   r  rU   rU   rV   select_column  s    #

zHDFStore.select_column)r   r   c
                   sv  t |dd}t|ttfr.t|dkr.|d }t|trRj|||||||	dS t|ttfshtdt|sxtd|dkr|d }fdd	|D 	|}
d}t
|
|fgt|D ]\\}}|dkrtd
| d|jstd|j d|dkr
|j}q|j|krtdqdd	 D }dd |D    fdd}t|
||||||||	d
}|jddS )a  
        Retrieve pandas objects from multiple tables.

        .. warning::

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

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

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

        Raises
        ------
        raises KeyError if keys or selector is not found or keys is empty
        raises TypeError if keys is not a list or tuple
        raises ValueError if the tables are not ALL THE SAME DIMENSIONS
        rf   rd   r   )r   rp   r   r   r   r   r   r   zkeys must be a list/tuplez keys must have a non-zero lengthNc                   s   g | ]}  |qS rU   )r  rh   kr   rU   rV   rl     s     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 rU   )rP   r   rh   xrU   rU   rV   rl     s     
 c                 S  s   h | ]}|j d  d  qS r   )non_index_axesrh   rx   rU   rU   rV   	<setcomp>  s     z.HDFStore.select_as_multiple.<locals>.<setcomp>c                   s*    fddD }t |dd S )Nc                   s   g | ]}|j  d qS )rp   r   r   r   r  r(  )r  r  r  r   rU   rV   rl     s   z=HDFStore.select_as_multiple.<locals>.func.<locals>.<listcomp>F)axisverify_integrity)r=   _consolidate)r  r  r  Zobjs)r+  r   tblsr
  rV   r  
  s    z)HDFStore.select_as_multiple.<locals>.funcr  Tcoordinates)rq   rP   rm   rn   ro   rY   r   r   r   r  	itertoolschainzipr   is_tablepathnamer  popr  r  )r   r   rp   selectorr   r   r   r   r   r   rT   r  rx   r"  Z_tblsr  r  rU   )r+  r   r   r.  rV   select_as_multiple  sd    +

 


zHDFStore.select_as_multipleTr}   r   r   r   )r   r   r   r   r   r   r   r   track_timesr   r[   c                 C  sH   |dk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_formatru   )r   r   r   r   r   r   r   r   rZ   r   r9  r   )r   _validate_format_write_to_group)r   r   r   r   r   r   r   r   r   r   r   rZ   r   r9  r   rU   rU   rV   r   %  s&    4
zHDFStore.putc              
   C  s   t |dd}z| |}W n tk
r0    Y np tk
rD    Y n\ tk
r } z>|dk	rftd|| |}|dk	r|jdd W Y dS W 5 d}~X Y nX t	|||r|j
jdd n|jstd|j|||dS 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

        rf   rd   Nz5trying to remove a node with a non-None where clause!T	recursivez7can only remove with where on objects written as tablesr  )rq   r  r   r   	Exceptionr   r   Z	_f_removecomall_noner   r4  delete)r   r   rp   r   r   rT   errr   rU   rU   rV   r   m  s2    
zHDFStore.removezbool | list[str]r   )
r   r   r   r   r   r   r   r   r   r[   c                 C  sl   |	dk	rt d|dkr td}|dkr4tdp2d}| |}| 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_tabler:  rv   )r   axesr   r   r   r   r   r   r   expectedrowsr   r   rZ   r   )r   r   r;  r<  )r   r   r   r   rD  r   r   r   r   r   r   r   r   rE  r   r   rZ   r   rU   rU   rV   r     s6    ;
zHDFStore.appenddict)dr   r[   c                   s  |dk	rt dt|ts"td||kr2tdtttjttt	  d }d}	g }
|
 D ]0\}  dkr|	dk	rtd|}	qh|
  qh|	dk	rֈj| }|t|
}t||}||||	< |dkr|| }|r*fdd| D }t|}|D ]}||}qj| |d	d}|
 D ]h\} ||krT|nd}j |d
}|dk	r fdd|
 D nd}| j||f||d| q>dS )a  
        Append to multiple tables

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

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

        Nztaxes is currently not accepted as a parameter to append_to_multiple; you can create the tables independently insteadzQappend_to_multiple must have a dictionary specified as the way to split the valuez=append_to_multiple requires a selector that is in passed 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   )rh   cols)r   rU   rV   	<genexpr>I  s     z.HDFStore.append_to_multiple.<locals>.<genexpr>r   r+  c                   s   i | ]\}}| kr||qS rU   rU   rh   r   r   )vrU   rV   
<dictcomp>Y  s       z/HDFStore.append_to_multiple.<locals>.<dictcomp>)r   r   )r   rP   rF  r   rm   setrangendim	_AXES_MAPr   r   extendrD  
differencer7   sortedget_indexertakevaluesnextintersectionlocr6  reindexr   )r   rG  r   r7  r   rD  r   r   r+  Z
remain_keyZremain_valuesr"  orderedZorddZidxsZvalid_indexr   r   dcvalfilteredrU   )rN  r   rV   append_to_multiple  sZ    
&

zHDFStore.append_to_multiplerX   )r   optlevelkindr[   c                 C  sB   t   | |}|dk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   rc  rd  )r   r  rP   r   r   create_index)r   r   r   rc  rd  rT   rU   rU   rV   create_table_index_  s    

zHDFStore.create_table_indexrm   c                 C  s<   t   |   | jdk	sttdk	s(t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 | ]H}t |tjjst|jd dsHt|ddsHt |tjjr|jdkr|qS )pandas_typeNrv   )	rP   r~   linkLinkgetattr_v_attrsrv   r   r   )rh   r   rU   rU   rV   rl     s    
z#HDFStore.groups.<locals>.<listcomp>)r   r   r   r   r~   walk_groupsr   rU   rU   rV   r     s    zHDFStore.groupsr   z*Iterator[tuple[str, list[str], list[str]]])rp   r[   c                 c  s   t   |   | jdk	sttdk	s(t| j|D ]}t|jdddk	rLq4g }g }|j	 D ]B}t|jdd}|dkrt
|tjjr||j q^||j q^|jd||fV  q4d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`.
        Nrg  r   )r   r   r   r   r~   rl  rj  rk  Z_v_childrenrY  rP   r   Groupr   r   r   rstrip)r   rp   r   r   leaveschildrg  rU   rU   rV   walk  s     zHDFStore.walkzNode | Nonec                 C  s   |    |dsd| }| jdk	s(ttdk	s4tz| j| j|}W n tjjk
rb   Y dS X t	|tj
s|tt||S )z9return the node with the key or None if it does not existr   N)r   
startswithr   r   r~   r   r   
exceptionsZNoSuchNodeErrorrP   rM   r   )r   r   r   rU   rU   rV   r     s    
zHDFStore.get_nodeGenericFixed | Tablec                 C  s8   |  |}|dk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   rT   rU   rU   rV   r    s    

zHDFStore.get_storerr   )r   propindexesr   r   	overwriter[   c	              	   C  s   t |||||d}	|dkr&t|  }t|ttfs:|g}|D ]}
| |
}|dk	r>|
|	krj|rj|	|
 | |
}t|trd}|rd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  s   g | ]}|j r|jqS rU   )
is_indexedra   rh   r   rU   rU   rV   rl     s      z!HDFStore.copy.<locals>.<listcomp>r   )r   r   rZ   r^   )r   rm   r   rP   rn   r  r   r   r   rD  r   rj  rZ   r   )r   r   r   ru  r   r   r   r   rv  Z	new_storer"  rT   datar   rU   rU   rV   copy  s>        




zHDFStore.copyc           
      C  s
  t | j}t|  d| d}| jrt|  }t|rg }g }|D ]}z<| |}|dk	r|t |j	pj| |t |p|d W qD t
k
r    Y qD tk
r } z(|| t |}	|d|	 d W 5 d}~X Y qDX qD|td||7 }n|d7 }n|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)rJ   r   r   r   rV  r   ro   r  r   r5  r   r?  rI   )
r   r   outputZlkeysr   rY  r"  rT   detailZdstrrU   rU   rV   info(  s.    


&
zHDFStore.infoc                 C  s   | j st| j dd S )Nz file is not open!)r   r!   r   r   rU   rU   rV   r   R  s    zHDFStore._check_if_open)r   r[   c              
   C  sJ   zt |  }W n4 tk
rD } ztd| d|W 5 d}~X Y nX |S )zvalidate / deprecate formatsz#invalid HDFStore format specified [r#  N)_FORMAT_MAPlowerr   r   )r   r   rC  rU   rU   rV   r;  V  s
    $zHDFStore._validate_formatrO   zDataFrame | Series | None)r   rZ   r   r[   c              
   C  s:  |dk	rt |ttfstdtt|jdd}tt|jdd}|dkr|dkrt  tdk	sdt	t|dds~t |tj
jrd}d}qtdn$t |trd	}nd
}|dkr|d7 }d|kr,ttd}z|| }	W nD tk
r }
 z$td| dt| d| |
W 5 d}
~
X Y nX |	| |||dS |dkr|dk	r|dkrt|dd}|dk	r|jdkrrd}n|jdkrd}nB|dkrt|dd}|dk	r|jdkrd}n|jdkrd}ttttttd}z|| }	W nD tk
r( }
 z$td| dt| d| |
W 5 d}
~
X Y nX |	| |||dS )z"return a suitable class to operateNz(value must be None, Series, or DataFramerg  
table_typerv   frame_tablegeneric_tablezKcannot create a storer if the object is not existing nor a value are passedseriesframe_table)r  r  z=cannot properly create the storer for: [_STORER_MAP] [group->,value->z	,format->rZ   r   series_tabler   rf   appendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)r  r  r  r  r  wormz<cannot properly create the storer for: [_TABLE_MAP] [group->)rP   r;   r5   r   rW   rj  rk  r   r~   r   rv   r   SeriesFixed
FrameFixedr   r   nlevelsGenericTableAppendableSeriesTableAppendableMultiSeriesTableAppendableFrameTableAppendableMultiFrameTable	WORMTable)r   r   r   r   rZ   r   ptttZ_STORER_MAPclsrC  r   Z
_TABLE_MAPrU   rU   rV   r  `  s     








zHDFStore._create_storer)
r   r   r   r   r   r   r   r   r9  r[   c                 C  s   t |dd r|dks|rd S | ||}| j|||||d}|rr|jrZ|jrb|dkrb|jrbtd|jsz|  n|  |js|rtd|j||||||	|
||||||d t|t	r|r|j
|d d S )	Nemptyrv   r  ru   zCan only append to Tablesz0Compression not supported on Fixed format stores)objrD  r   r   r   r   r   r   rE  r   r   r   r9  )r   )rj  _identify_groupr  r4  	is_existsr   set_object_infowriterP   r   re  )r   r   r   r   rD  r   r   r   r   r   r   r   rE  r   r   r   rZ   r   r9  r   rT   rU   rU   rV   r<    s:    

zHDFStore._write_to_grouprM   r   c                 C  s   |  |}|  | S r\   )r  r  r	  )r   r   rT   rU   rU   rV   r    s    
zHDFStore._read_group)r   r   r[   c                 C  sN   |  |}| jdk	st|dk	r8|s8| jj|dd d}|dkrJ| |}|S )z@Identify HDF5 group based on key, delete/create group if needed.NTr=  )r   r   r   remove_node_create_nodes_and_group)r   r   r   r   rU   rU   rV   r    s    

zHDFStore._identify_groupc                 C  sv   | j dk	st|d}d}|D ]P}t|s.q |}|dsD|d7 }||7 }| |}|dkrl| j ||}|}q |S )z,Create nodes from key and return group name.Nr   )r   r   splitro   endswithr   Zcreate_group)r   r   pathsr   pnew_pathr   rU   rU   rV   r    s    


z HDFStore._create_nodes_and_group)r   NNF)r   )r   )F)NNNNFNF)NNN)NN)NNNNNFNF)NTFNNNNNNr}   TF)NNN)NNTTNNNNNNNNNNr}   )NNF)NNN)r   )r   TNNNFT)NNrO   r}   )NTFNNNNNNFNNNr}   T)1r   
__module____qualname____doc____annotations__r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r  r   r8  r   r   r   rb  rf  r   rq  r   r  rz  r  r   r;  r  r<  r  r  r  rU   rU   rU   rV   r     s  
A    !

"-       N   $  +        }            $H=               "]   d   (0       ;*    `               ">r   c                   @  sp   e Zd ZU dZded< ded< ded< dddd
dd
ddddZddddZddddZd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   rt  rT   NFr   r   )r   rT   r   r   r   r[   c                 C  s   || _ || _|| _|| _| jjrN|d kr,d}|d kr8d}|d krD|}t||}|| _|| _|| _d | _	|sr|	d k	r|	d kr~d}	t
|	| _nd | _|
| _d S )Nr   順 )r   rT   r  rp   r4  minr  r   r   r0  rc   r   r   )r   r   rT   r  rp   r  r   r   r   r   r   rU   rU   rV   r   >  s,    
zTableIterator.__init__r   r   c                 c  sv   | j }| jd krtd|| jk rjt|| j | j}| d d | j|| }|}|d kst|sbq|V  q|   d S )Nz*Cannot iterate until get_result is called.)	r   r0  r   r   r  r   r  ro   r   )r   r   r   r   rU   rU   rV   r   h  s    

zTableIterator.__iter__c                 C  s   | j r| j  d S r\   )r   r   r   r   rU   rU   rV   r   x  s    zTableIterator.closer/  c                 C  s   | j d k	r4t| jtstd| jj| jd| _| S |rft| jtsLtd| jj| j| j| j	d}n| j}| 
| j| j	|}|   |S )Nz0can only use an iterator or chunksize on a table)rp   z$can only read_coordinates on a tabler  )r   rP   rT   r   r   r  rp   r0  r   r   r  r   )r   r0  rp   resultsrU   rU   rV   r  |  s"    
  zTableIterator.get_result)NNFNF)F)	r   r  r  r  r  r   r   r   r  rU   rU   rU   rV   r  &  s   
	     *r  c                   @  s  e Zd ZU dZdZded< dZded< dddgZdMd
dddddZe	ddddZ
e	d
dddZdddddZd
dddZdddddZdddd Ze	ddd!d"Zd#d
d
d$d%d&d'Zd(d) Ze	d*d+ Ze	d,d- Ze	d.d/ Ze	d0d1 Zd2dd3d4ZdNddd5d6Zddd7d8Zd9ddd:d;d<ZdOd=d>Zddd?d@dAZdddBdCZdddDdEZdddFdGZd9ddHdIdJZ d9ddHdKdLZ!d	S )P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_nameNrY   rX   r   )ra   cnamer[   c                 C  s   t |tstd|| _|| _|| _|| _|p0|| _|| _|| _	|| _
|	| _|
| _|| _|| _|| _|| _|d k	r|| | t | jtstt | jtstd S )Nz`name` must be a str.)rP   rY   r   rY  rd  typra   r  r+  posr  r  r  r^  rv   r   metadataset_posr   )r   ra   rY  rd  r  r  r+  r  r  r  r  r^  rv   r   r  rU   rU   rV   r     s(    


zIndexCol.__init__rc   r   c                 C  s   | j jS r\   )r  itemsizer   rU   rU   rV   r    s    zIndexCol.itemsizec                 C  s   | j  dS )N_kindr`   r   rU   rU   rV   	kind_attr  s    zIndexCol.kind_attr)r  r[   c                 C  s$   || _ |dk	r | jdk	r || j_dS )z,set the position of this column in the TableN)r  r  Z_v_pos)r   r  rU   rU   rV   r    s    zIndexCol.set_posc              	   C  sF   t tt| j| j| j| j| jf}ddd t	dddddg|D S )	N,c                 S  s   g | ]\}}| d | qS z->rU   rM  rU   rU   rV   rl     s   z%IndexCol.__repr__.<locals>.<listcomp>ra   r  r+  r  rd  )
rn   maprJ   ra   r  r+  r  rd  joinr3  r   temprU   rU   rV   r     s    zIndexCol.__repr__r	   otherr[   c                   s   t  fdddD S )compare 2 col itemsc                 3  s&   | ]}t |d t  |d kV  qd S r\   rj  rx  r  r   rU   rV   rK    s   z"IndexCol.__eq__.<locals>.<genexpr>)ra   r  r+  r  rH  r   r  rU   r  rV   __eq__  s    zIndexCol.__eq__c                 C  s   |  | S r\   )r  r  rU   rU   rV   __ne__  s    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 columnrJ  F)hasattrrv   rj  rJ  r  rw  r   rU   rU   rV   rw    s    zIndexCol.is_indexed
np.ndarrayz3tuple[np.ndarray, np.ndarray] | tuple[Index, Index]rY  rZ   r   r[   c           
      C  s  t |tjstt||jjdk	r2|| j  }t	| j
}t||||}i }t	| j|d< | jdk	rtt	| j|d< t}t|jst|jrt}n|jdkrd|krdd }z||f|}W n0 tk
r   d|krd|d< ||f|}Y nX t|| j}	|	|	fS )zV
        Convert the data from this selection to the appropriate pandas type.
        Nra   r  i8c                 [  s   t f d| i|S )NZordinal)r9   )r%  kwdsrU   rU   rV   r     s   z"IndexCol.convert.<locals>.<lambda>)rP   rQ   ndarrayr   r   dtypefieldsr  rz  rW   rd  _maybe_convertr  r  r7   r+   r,   r6   r   _set_tzr  )
r   rY  r   rZ   r   val_kindr   factoryZnew_pd_indexZfinal_pd_indexrU   rU   rV   convert  s,    

zIndexCol.convertc                 C  s   | j S )zreturn the valuesrY  r   rU   rU   rV   	take_data.  s    zIndexCol.take_datac                 C  s   | j jS r\   )rv   rk  r   rU   rU   rV   attrs2  s    zIndexCol.attrsc                 C  s   | j jS r\   rv   descriptionr   rU   rU   rV   r  6  s    zIndexCol.descriptionc                 C  s   t | j| jdS )z!return my current col descriptionN)rj  r  r  r   rU   rU   rV   col:  s    zIndexCol.colc                 C  s   | j S zreturn my cython valuesr  r   rU   rU   rV   cvalues?  s    zIndexCol.cvaluesr   c                 C  s
   t | jS r\   )r   rY  r   rU   rU   rV   r   D  s    zIndexCol.__iter__c                 C  sP   t | jdkrLt|tr$|| j}|dk	rL| jj|k rLt j	|| j
d| _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  )rW   rd  rP   rF  r   ra   r  r  r   	StringColr  )r   r   rU   rU   rV   maybe_set_sizeG  s
    
zIndexCol.maybe_set_sizec                 C  s   d S r\   rU   r   rU   rU   rV   validate_namesT  s    zIndexCol.validate_namesAppendableTable)handlerr   r[   c                 C  s:   |j | _ |   | | | | | | |   d S r\   )rv   validate_colvalidate_attrvalidate_metadatawrite_metadataset_attr)r   r  r   rU   rU   rV   validate_and_setW  s    


zIndexCol.validate_and_setc                 C  s^   t | jdkrZ| j}|dk	rZ|dkr*| j}|j|k rTt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)rW   rd  r  r  r   r  )r   r  crU   rU   rV   r  _  s    
zIndexCol.validate_col)r   r[   c                 C  sB   |r>t | j| jd }|d k	r>|| jkr>td| d| j dd S )Nzincompatible kind in col [ - r#  )rj  r  r  rd  r   )r   r   Zexisting_kindrU   rU   rV   r  r  s    zIndexCol.validate_attrc                 C  s   | j D ]}t| |d}|| ji }||}||kr|dk	r||kr|dkrt|||f }tj|tt	 d d||< t
| |d qtd| j d| d| d| d	q|dk	s|dk	r|||< qdS )	z
        set/update the info for this indexable with the key/value
        if there is a conflict raise/warn as needed
        N)r  r  
stacklevelzinvalid info for [z] for [z], existing_value [z] conflicts with new value [r#  )_info_fieldsrj  
setdefaultra   r   rs   warningswarnr    r&   setattrr   )r   r  r   r   idxZexisting_valuewsrU   rU   rV   update_info{  s&    

  zIndexCol.update_infoc                 C  s$   | | j}|dk	r | j| dS )z!set my state from the passed infoN)r   ra   __dict__update)r   r  r  rU   rU   rV   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  rd  r   rU   rU   rV   r    s    zIndexCol.set_attr)r  r[   c                 C  sB   | j dkr>| j}|| j}|dk	r>|dk	r>t||s>td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  r4   r   )r   r  Znew_metadataZcur_metadatarU   rU   rV   r    s    
zIndexCol.validate_metadatac                 C  s   | j dk	r|| j| j  dS )zset the meta dataN)r  r  r  )r   r  rU   rU   rV   r    s    
zIndexCol.write_metadata)NNNNNNNNNNNNN)N)N)"r   r  r  r  r  r  r  r  r   r  r  r  r  r   r  r  rw  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  rU   rU   rU   rV   r    sb   

             +/




	 r  c                   @  sD   e Zd ZdZeddddZddddd	d
dZddddZdS )GenericIndexColz:an index which is not represented in the data of the tabler   r   c                 C  s   dS NFrU   r   rU   rU   rV   rw    s    zGenericIndexCol.is_indexedr  rY   ztuple[Index, Index]r  c                 C  s,   t |tjs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
        )rP   rQ   r  r   r   r:   ro   )r   rY  r   rZ   r   r   rU   rU   rV   r    s    zGenericIndexCol.convertr   c                 C  s   d S r\   rU   r   rU   rU   rV   r    s    zGenericIndexCol.set_attrN)r   r  r  r  r  rw  r  r  rU   rU   rU   rV   r    s
   r  c                      s>  e Zd ZdZdZdZddgZd;dddd	d
 fddZeddddZ	eddddZ
ddddZdddddZdd	dddZdd Zeddd d!d"Zed#d$ Zedd%d&d'd(Zeddd&d)d*Zed+d, Zed-d. Zed/d0 Zed1d2 Zd	dd3d4Zd5ddd6d7d8Zd	dd9d:Z  ZS )<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^  NrY   rX   zDtypeArg | Noner   )ra   r  r  r[   c                   s2   t  j|||||||||	|
|d || _|| _d S )N)ra   rY  rd  r  r  r  r  r^  rv   r   r  )superr   r  ry  )r   ra   rY  rd  r  r  r  r  r^  rv   r   r  r  ry  	__class__rU   rV   r     s    zDataCol.__init__r   c                 C  s   | j  dS )N_dtyper`   r   rU   rU   rV   
dtype_attr	  s    zDataCol.dtype_attrc                 C  s   | j  dS )N_metar`   r   rU   rU   rV   	meta_attr	  s    zDataCol.meta_attrc              	   C  sF   t tt| j| j| j| j| jf}ddd t	dddddg|D S )	Nr  c                 S  s   g | ]\}}| d | qS r  rU   rM  rU   rU   rV   rl   	  s   z$DataCol.__repr__.<locals>.<listcomp>ra   r  r  rd  shape)
rn   r  rJ   ra   r  r  rd  r  r  r3  r  rU   rU   rV   r   	  s     zDataCol.__repr__r	   r   r  c                   s   t  fdddD S )r  c                 3  s&   | ]}t |d t  |d kV  qd S r\   r  rx  r  rU   rV   rK  	  s   z!DataCol.__eq__.<locals>.<genexpr>)ra   r  r  r  r  r  rU   r  rV   r  	  s    zDataCol.__eq__r   )ry  r[   c                 C  s@   |d k	st | jd kst t|\}}|| _|| _t|| _d S r\   )r   r  _get_data_and_dtype_namery  _dtype_to_kindrd  )r   ry  
dtype_namerU   rU   rV   set_data$	  s    zDataCol.set_datac                 C  s   | j S )zreturn the datary  r   rU   rU   rV   r  .	  s    zDataCol.take_datarK   )rY  r[   c                 C  s   |j }|j}|j}|jdkr&d|jf}t|trJ|j}| j||j j	d}ntt
|sZt|rf| |}nXt|rz| |}nDt|rt j||d d}n&t|r| ||}n| j||j	d}|S )zW
        Get an appropriately typed and shaped pytables.Col object for values.
        rf   rd  r   r  r  )r  r  r  rR  sizerP   r?   codesget_atom_datara   r+   r,   get_atom_datetime64r2   get_atom_timedelta64r*   r   Z
ComplexColr1   get_atom_string)r  rY  r  r  r  r  atomrU   rU   rV   	_get_atom2	  s$    


zDataCol._get_atomc                 C  s   t  j||d dS )Nr   r  r   r  r  r  r  rU   rU   rV   r  R	  s    zDataCol.get_atom_stringz	type[Col]rd  r[   c                 C  sR   | dr$|dd }d| d}n"| dr4d}n| }| d}tt |S )z0return the PyTables column class for this columnuint   NZUIntrK   periodInt64Col)rr  
capitalizerj  r   )r  rd  Zk4Zcol_nameZkcaprU   rU   rV   get_atom_coltypeV	  s    


zDataCol.get_atom_coltypec                 C  s   | j |d|d dS )Nr  r   r  r#  r  r  rd  rU   rU   rV   r  e	  s    zDataCol.get_atom_datac                 C  s   t  j|d dS Nr   r$  r   r!  r  r  rU   rU   rV   r  i	  s    zDataCol.get_atom_datetime64c                 C  s   t  j|d dS r'  r(  r)  rU   rU   rV   r  m	  s    zDataCol.get_atom_timedelta64c                 C  s   t | jdd S )Nr  )rj  ry  r   rU   rU   rV   r  q	  s    zDataCol.shapec                 C  s   | j S r  r  r   rU   rU   rV   r  u	  s    zDataCol.cvaluesc                 C  s`   |r\t | j| jd}|dk	r2|t| jkr2tdt | j| jd}|dk	r\|| jkr\td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!)rj  r  r  rm   rY  r   r  r  )r   r   Zexisting_fieldsZexisting_dtyperU   rU   rV   r  z	  s    zDataCol.validate_attrr  )rY  rZ   r   c                 C  s  t |tjstt||jjdk	r.|| j }| jdk	s<t| jdkr\t	|\}}t
|}n|}| j}| j}t |tjs|tt| j}| j}	| j}
| j}|dk	stt|}|dkrt||dd}n(|dkrtj|dd}n|dkr8ztjd	d
 |D td}W n. tk
r4   tjdd
 |D td}Y nX n|dkr|	}| }|dkrhtg tjd}n<t|}| r||  }||dk  |t j8  < tj|||
d}n8z|j|dd}W n$ t k
r   |jddd}Y nX t|dkrt!||||d}| j"|fS )aR  
        Convert the data from this selection to the appropriate pandas type.

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

        Returns
        -------
        index : listlike to become an Index
        data : ndarraylike to become a column
        N
datetime64Tcoercetimedelta64m8[ns]r  r   c                 S  s   g | ]}t |qS rU   r   fromordinalrh   rN  rU   rU   rV   rl   	  s     z#DataCol.convert.<locals>.<listcomp>c                 S  s   g | ]}t |qS rU   r   fromtimestampr2  rU   rU   rV   rl   	  s     r  )
categoriesr^  Frz  Or  r   rZ   r   )#rP   rQ   r  r   r   r  r  r  r  r  r  rd  rW   r   r  r^  r  r  asarrayobjectr   ravelr7   Zfloat64r>   anyastyperc   Zcumsum_valuesr?   Z
from_codesr   _unconvert_string_arrayrY  )r   rY  r   rZ   r   	convertedr  rd  r   r  r^  r  r  r6  r  maskrU   rU   rV   r  	  st    




 
 



      zDataCol.convertc                 C  sH   t | j| j| j t | j| j| j | jdk	s2tt | j| j| j dS )zset the data for this columnN)	r  r  r  rY  r
  r   r  r   r  r   rU   rU   rV   r  	  s    zDataCol.set_attr)NNNNNNNNNNNN)r   r  r  r  r  r  r  r   r  r  r
  r   r  r  r  classmethodr  r  r#  r  r  r  r  r  r  r  r  __classcell__rU   rU   r  rV   r    sX                





dr  c                   @  sZ   e Zd ZdZdZddddZedd Zed	d
dddZedd Z	edd Z
dS )DataIndexableColz+represent a data column that can be indexedTr   r   c                 C  s   t t| jstdd S )N-cannot have non-object label DataIndexableCol)r0   r7   rY  r   r   rU   rU   rV   r  	  s    zDataIndexableCol.validate_namesc                 C  s   t  j|dS )N)r  r  r  rU   rU   rV   r  	  s    z DataIndexableCol.get_atom_stringrY   rK   r  c                 C  s   | j |d S )Nr  r%  r&  rU   rU   rV   r  
  s    zDataIndexableCol.get_atom_datac                 C  s
   t   S r\   r(  r)  rU   rU   rV   r  
  s    z$DataIndexableCol.get_atom_datetime64c                 C  s
   t   S r\   r(  r)  rU   rU   rV   r  	
  s    z%DataIndexableCol.get_atom_timedelta64N)r   r  r  r  r  r  rC  r  r  r  r  rU   rU   rU   rV   rE  	  s   

rE  c                   @  s   e Zd ZdZdS )GenericDataIndexableColz(represent a generic pytables data columnN)r   r  r  r  rU   rU   rU   rV   rG  
  s   rG  c                   @  s  e Zd ZU dZded< dZded< ded< ded	< d
ed< dZded< dNd
dddddddZeddddZ	eddddZ
edd Zdddd Zddd!d"Zd dd#d$Zed%d& Zed'd( Zed)d* Zed+d, Zeddd-d.Zeddd/d0Zed1d2 Zddd3d4Zddd5d6Zed7d8 Zeddd9d:Zed;d< Zd=dd>d?ZdOdddAdBZdddCdDZdPdEdEdFdGdHZdIdJ ZdQdEdEddKdLdMZ d@S )R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_kindru   format_typetype[DataFrame | Series]obj_typerc   rR  r   r   Fr   r4  rO   r}   rM   rX   r   )r   r   rZ   r   r[   c                 C  sZ   t |tstt|td k	s"tt |tjs:tt||| _|| _t|| _	|| _
d S r\   )rP   r   r   r   r~   rM   r   r   r_   rZ   r   )r   r   r   rZ   r   rU   rU   rV   r   &
  s    
zFixed.__init__r   c                 C  s*   | j d dko(| j d dko(| j d dk S )Nr   rf   
      )versionr   rU   rU   rV   is_old_version5
  s    zFixed.is_old_versionztuple[int, int, int]c                 C  sb   t t| jjdd}z0tdd |dD }t|dkrB|d }W n tk
r\   d}Y nX |S )	zcompute and set our versionpandas_versionNc                 s  s   | ]}t |V  qd S r\   rc   r$  rU   rU   rV   rK  >
  s     z Fixed.version.<locals>.<genexpr>.rN  r&  )r   r   r   )rW   rj  r   rk  rn   r  ro   r   )r   rO  rU   rU   rV   rO  9
  s    
zFixed.versionc                 C  s   t t| jjdd S )Nrg  )rW   rj  r   rk  r   rU   rU   rV   rg  E
  s    zFixed.pandas_typec                 C  s^   |    | j}|dk	rXt|ttfrDddd |D }d| d}| jdd| d	S | jS )
(return a pretty representation of myselfNr  c                 S  s   g | ]}t |qS rU   rJ   r$  rU   rU   rV   rl   O
  s     z"Fixed.__repr__.<locals>.<listcomp>[r#  12.12z	 (shape->))r  r  rP   rm   rn   r  rg  )r   rT   ZjshaperU   rU   rV   r   I
  s    zFixed.__repr__c                 C  s   t | j| j_t t| j_dS )zset my pandas type & versionN)rY   rI  r  rg  _versionrQ  r   rU   rU   rV   r  T
  s    zFixed.set_object_infoc                 C  s   t  | }|S r\   r7  )r   Znew_selfrU   rU   rV   rz  Y
  s    
z
Fixed.copyc                 C  s   | j S r\   )r  r   rU   rU   rV   r  ]
  s    zFixed.shapec                 C  s   | j jS r\   r   r   r   rU   rU   rV   r5  a
  s    zFixed.pathnamec                 C  s   | j jS r\   )r   r   r   rU   rU   rV   r   e
  s    zFixed._handlec                 C  s   | j jS r\   )r   r   r   rU   rU   rV   r   i
  s    zFixed._filtersc                 C  s   | j jS r\   )r   r   r   rU   rU   rV   r   m
  s    zFixed._complevelc                 C  s   | j jS r\   )r   r   r   rU   rU   rV   r   q
  s    zFixed._fletcher32c                 C  s   | j jS r\   )r   rk  r   rU   rU   rV   r  u
  s    zFixed.attrsc                 C  s   dS zset our object attributesNrU   r   rU   rU   rV   	set_attrsy
  s    zFixed.set_attrsc                 C  s   dS )zget our object attributesNrU   r   rU   rU   rV   	get_attrs|
  s    zFixed.get_attrsc                 C  s   | j S )zreturn my storabler  r   rU   rU   rV   storable
  s    zFixed.storablec                 C  s   dS r  rU   r   rU   rU   rV   r  
  s    zFixed.is_existsc                 C  s   t | jdd S )Nr  )rj  r^  r   rU   rU   rV   r  
  s    zFixed.nrowszLiteral[True] | Nonec                 C  s   |dkrdS dS )z%validate against an existing storableNTrU   r  rU   rU   rV   validate
  s    zFixed.validateNc                 C  s   dS )+are we trying to operate on an old version?NrU   )r   rp   rU   rU   rV   validate_version
  s    zFixed.validate_versionc                 C  s   | j }|dk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   rT   rU   rU   rV   r  
  s
    zFixed.infer_axesr   r   r   c                 C  s   t dd S )Nz>cannot read on an abstract storer: subclasses should implementr   r   rp   r   r   r   rU   rU   rV   r	  
  s    z
Fixed.readc                 K  s   t dd S )Nz?cannot write on an abstract storer: subclasses should implementrc  r   r   rU   rU   rV   r  
  s    zFixed.writer   r   r[   c                 C  s0   t |||r$| jj| jdd dS tddS )zs
        support fully deleting the node in its entirety (only) - where
        specification must be None
        Tr=  Nz#cannot delete on an abstract storer)r@  rA  r   r  r   r   )r   rp   r   r   rU   rU   rV   rB  
  s    zFixed.delete)rO   r}   )N)NNNN)NNN)!r   r  r  r  r  rJ  r4  r   r  rP  rO  rg  r   r  rz  r  r5  r   r   r   r   r  r\  r]  r^  r  r  r_  ra  r  r	  r  rB  rU   rU   rU   rV   rH  
  sl   
  







         rH  c                   @  sF  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
dZdd Zdd Zdd	ddZedd	ddZdd	ddZdd	ddZdd	ddZd:dddddd Zd;dddd!d"d#d$Zdd!dd%d&d'Zdd(dd%d)d*Zd<dddd(d"d+d,Zd=d-ddd!d.d/d0Zdd1dd2d3d4Zd>dd5d6dd7d8d9ZdS )?GenericFixedza generified fixed versiondatetimer   c                 C  s   i | ]\}}||qS rU   rU   )rh   r"  rN  rU   rU   rV   rO  
  s      zGenericFixed.<dictcomp>r   
attributesrY   r   c                 C  s   | j |dS )N )_index_type_mapr   )r   r  rU   rU   rV   _class_to_alias
  s    zGenericFixed._class_to_aliasc                 C  s   t |tr|S | j|tS r\   )rP   r   _reverse_index_mapr   r7   )r   aliasrU   rU   rV   _alias_to_class
  s    
zGenericFixed._alias_to_classc                 C  s   |  tt|dd}|tkr.d	dd}|}n|tkrFd
dd}|}n|}i }d|krn|d |d< |tkrnt}d|krt|d tr|d 	d|d< n|d |d< |tkst
||fS )Nindex_classrj  c                 S  s:   t j| j|d}tj|d d}|d k	r6|d|}|S )Nr  r`   UTC)r@   _simple_newrY  r6   tz_localize
tz_convert)rY  r  r  ZdtaresultrU   rU   rV   rw   
  s
    z*GenericFixed._get_index_factory.<locals>.fc                 S  s   t j| |d}tj|d dS )Nrq  r`   )rA   rs  r9   )rY  r  r  ZparrrU   rU   rV   rw   
  s    r  r  zutf-8)NN)NN)ro  rW   rj  r6   r9   r7   r<   rP   bytesrS   r   )r   r  rp  rw   r  r   rU   rU   rV   _get_index_factory
  s*    

zGenericFixed._get_index_factoryr   c                 C  s$   |dk	rt d|dk	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   rp   rU   rU   rV   validate_read
  s    zGenericFixed.validate_readr   c                 C  s   dS )NTrU   r   rU   rU   rV   r    s    zGenericFixed.is_existsc                 C  s   | j | j_ | j| j_dS r[  )rZ   r  r   r   rU   rU   rV   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 attributesrZ   Nr   r}   )r_   rj  r  rZ   rW   r   ri  r  )r   r   rU   rU   rV   r]    s    
zGenericFixed.get_attrsc                 K  s   |    d S r\   )r\  r   r  r   rU   rU   rV   r    s    zGenericFixed.writeNr   r  c                 C  s   ddl }t| j|}|j}t|dd}t||jrD|d || }nztt|dd}	t|dd}
|
dk	rxtj|
|	d}n||| }|	dkrt|d	d}t	||d
d}n|	dkrtj
|dd}|r|jS |S dS )z2read an array for the specified node (off of groupr   N
transposedF
value_typer  r/  r*  r  Tr+  r-  r.  )r   rj  r   rk  rP   ZVLArrayrW   rQ   r  r  r:  T)r   r   r   r   r   r   r  r|  retr  r  r  rU   rU   rV   
read_array   s&    zGenericFixed.read_arrayr7   )r   r   r   r[   c                 C  sh   t t| j| d}|dkr.| j|||dS |dkrVt| j|}| j|||d}|S td| d S )N_varietymultirb  regularzunrecognized index variety: )rW   rj  r  read_multi_indexr   read_index_noder   )r   r   r   r   Zvarietyr   r   rU   rU   rV   
read_indexB  s    zGenericFixed.read_index)r   r   r[   c                 C  s   t |tr,t| j| dd | || nt| j| dd td|| j| j}| ||j	 t
| j|}|j|j_|j|j_t |ttfr| t||j_t |tttfr|j|j_t |tr|jd k	rt|j|j_d S )Nr  r  r  r   )rP   r8   r  r  write_multi_index_convert_indexrZ   r   write_arrayrY  rj  r   rd  rk  ra   r6   r9   rl  r   rp  r<   r  r  _get_tz)r   r   r   rA  r   rU   rU   rV   write_indexP  s    



zGenericFixed.write_indexr8   c                 C  s   t | j| d|j tt|j|j|jD ]\}\}}}t|rJt	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  	enumerater3  levelsr  namesr-   r   r  rZ   r   r  rY  rj  r   rd  rk  ra   )r   r   r   ilevlevel_codesra   	level_keyZ
conv_levelr   	label_keyrU   rU   rV   r  g  s"    
zGenericFixed.write_multi_indexc                 C  s   t | j| d}g }g }g }t|D ]l}| d| }	t | j|	}
| j|
||d}|| ||j | d| }| j|||d}|| q&t|||ddS )Nr  r  rb  r  T)r  r  r  r,  )	rj  r  rQ  r   r  r   ra   r  r8   )r   r   r   r   r  r  r  r  r  r  r   r  r  r  rU   rU   rV   r    s&    
   zGenericFixed.read_multi_indexrM   )r   r   r   r[   c                 C  s   ||| }d|j kr>t|j jdkr>tj|j j|j jd}t|j j}d }d|j krlt|j j	}t|}|j }| 
|\}}	|dkr|t||| j| jdfdti|	}
n|t||| j| jdf|	}
||
_	|
S )Nr  r   r/  ra   )r   r;  r  r  )rk  rQ   prodr  r  r}  rW   rd  rb   ra   rx  _unconvert_indexrZ   r   r;  )r   r   r   r   ry  rd  ra   r  r  r   r   rU   rU   rV   r    sF    
      zGenericFixed.read_index_noder   )r   r   r[   c                 C  sJ   t d|j }| j| j|| t| j|}t|j|j	_
|j|j	_dS )zwrite a 0-len arrayrf   N)rQ   r  rR  r   create_arrayr   rj  rY   r  rk  r}  r  )r   r   r   Zarrr   rU   rU   rV   write_array_empty  s
    zGenericFixed.write_array_emptyr   zIndex | None)r   r  r   r[   c              	   C  s4  t |dd}|| jkr&| j| j| |jdk}d}t|jrFtd|s^t|dr^|j	}d}d }| j
d k	rtt t j|j}W 5 Q R X |d k	r|s| jj| j|||j| j
d}||d d < n| || nJ|jjtjkrJtj|dd}	|rn,|	d	krn t|	||f }
tj|
tt d
 | j| j|t  }|| nt |jr| j!| j||"d dt#| j|j$_%nt&|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)Zextract_numpyr   Fz]Cannot store a category dtype in a HDF5 dataset that uses format="fixed". Use format="table".r~  )r   Zskipnar  r  r  r*  r-  ),rD   r   r   r  r  r)   r  r   r  r~  r   r   r   r   ZAtomZ
from_dtypeZcreate_carrayr  r  r   rQ   Zobject_r   infer_dtypert   r  r  r#   r&   Zcreate_vlarray
ObjectAtomr   r+   r  viewrj  rk  r}  r,   asi8r  r  r2   r|  )r   r   r  r   r   Zempty_arrayr|  r  cainferred_typer  Zvlarrr   rU   rU   rV   r    sr    





    
  
zGenericFixed.write_array)NN)NN)NN)NN)N)r   r  r  r  r6   r9   rk  r   rm  ri  r  rl  ro  rx  ry  r  r  r\  r]  r  r  r  r  r  r  r  r  r  rU   rU   rU   rV   rg  
  s8   
.#         &
 rg  c                      sV   e Zd ZU dZdgZded< edd Zddddd	d
dZdd fddZ	  Z
S )r  r  ra   r   c              	   C  s0   zt | jjfW S  ttfk
r*   Y d S X d S r\   )ro   r   rY  r   r   r   rU   rU   rV   r  '  s    zSeriesFixed.shapeNr   r;   rf  c                 C  s>   |  || | jd||d}| jd||d}t||| jddS )Nr   rb  rY  F)r   ra   rz  )ry  r  r  r;   ra   )r   rp   r   r   r   r   rY  rU   rU   rV   r	  .  s    zSeriesFixed.readr   r   c                   s8   t  j|f| | d|j | d| |j| j_d S )Nr   rY  )r  r  r  r   r  ra   r  r{  r  rU   rV   r  ;  s    zSeriesFixed.write)NNNN)r   r  r  rI  ri  r  r  r  r	  r  rD  rU   rU   r  rV   r  !  s   

    r  c                      sZ   e Zd ZU ddgZded< eddddZdd	d	d
dddZdd fddZ  Z	S )BlockManagerFixedrR  nblocksrc   zShape | Noner   c                 C  s   z| j }d}t| jD ]8}t| jd| d}t|dd }|d k	r||d 7 }q| jj}t|dd }|d k	rt|d|d  }ng }|| |W S  tk
r   Y d S X d S )Nr   block_itemsr  rf   )	rR  rQ  r  rj  r   Zblock0_valuesrm   r   r   )r   rR  r   r  r   r  rU   rU   rV   r  G  s"    
zBlockManagerFixed.shapeNr   r5   rf  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	d
}|| q|t|dkrt|ddd}|j|d	d}|S t
|d |d dS )Nr   )NNr+  rb  r  r  r?  rf   Fr   r   rz  T)r+  rz  )r   rz  r   r   )ry  rL  Z_get_block_manager_axisrQ  rR  r  r   r  r  rW  r5   r~  ro   r=   r]  )r   rp   r   r   r   Zselect_axisrD  r  r  r  axr   dfs	blk_itemsrY  dfoutrU   rU   rV   r	  b  s(    zBlockManagerFixed.readr   c                   s   t  j|f| t|jtr&|d}|j}| s<| }|j| j	_t
|jD ]0\}}|dkrn|jsntd| d| | qPt|j| j	_t
|jD ]D\}}|j|j}| jd| d|j|d | d| d| qd S )Nr  r   z/Columns index has to be unique for fixed formatr+  r?  )r   r  )r  r  rP   _mgrrF   _as_managerZis_consolidatedZconsolidaterR  r  r  rD  Z	is_uniquer   r  ro   blocksr  r   rX  mgr_locsr  rY  )r   r  r   ry  r  r  blkr  r  rU   rV   r    s     

zBlockManagerFixed.write)NNNN)
r   r  r  ri  r  r  r  r	  r  rD  rU   rU   r  rV   r  B  s   
    $r  c                   @  s   e Zd ZdZeZdS )r  r  N)r   r  r  rI  r5   rL  rU   rU   rU   rV   r    s   r  c                      s  e Zd ZU dZdZdZded< ded< dZded	< d
Zded< dddddddddddd
 fddZ	e
ddddZddddZdd d!d"Zddd#d$Ze
d%dd&d'Zd(d)d*d+d,Ze
d-dd.d/Ze
d%dd0d1Ze
d2d3 Ze
d4d5 Ze
d6d7 Ze
d8d9 Ze
d:d; Ze
d-dd<d=Ze
d%dd>d?Ze
d@ddAdBZdCddDdEZdFdG ZdHddIdJZdddKdLdMZddNddOdPdQZddRdSdTZ dddUdVZ!dddWdXZ"ddddYdZZ#ddd[d\Z$e%d]d^ Z&dddd_d`daZ'ddbdbdcdddedfZ(e)d%dgdhdiZ*djdk Z+ddld%dmdndoZ,e-dld%dpdqdrZ.ddsdldtdudvZ/dbd%dbdCdwdxdyZ0ddbdbdzd{d|Z1dddbdbd}d~dZ2  Z3S )r   aa  
    represent a table:
        facilitate read/write of various types of tables

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

    index_axes    : a list of tuples of the (original indexing axis and
        index column)
    non_index_axes: a list of tuples of the (original index axis and
        columns on a non-indexing axis)
    values_axes   : a list of the columns which comprise the data of this
        table
    data_columns  : a list of the columns that we are allowing indexing
        (these become single columns in values_axes)
    nan_rep       : the string to use for nan representations for string
        objects
    levels        : the names of levels
    metadata      : the names of the metadata columns
    Z
wide_tablerv   rY   rJ  r  rf   zint | list[Hashable]r  Trm   r  Nr}   r   rM   rX   zlist[IndexCol] | Nonez list[tuple[AxisInt, Any]] | Nonezlist[DataCol] | Nonezlist | Nonezdict | Noner   )
r   r   rZ   r   
index_axesr'  values_axesr   r  r[   c                   sP   t  j||||d |pg | _|p$g | _|p.g | _|p8g | _|	pBi | _|
| _d S )Nr  )r  r   r  r'  r  r   r  r   )r   r   r   rZ   r   r  r'  r  r   r  r   r  rU   rV   r     s    




zTable.__init__r   c                 C  s   | j dd S )N_r   )r  r  r   rU   rU   rV   table_type_short  s    zTable.table_type_shortc                 C  s   |    t| jrd| jnd}d| d}d}| jrZddd | jD }d| d}dd	d | jD }| jd
| d| j d| j	 d| j
 d| d| dS )rT  r  rj  z,dc->[r#  rS  c                 S  s   g | ]}t |qS rU   rY   r$  rU   rU   rV   rl     s     z"Table.__repr__.<locals>.<listcomp>rV  c                 S  s   g | ]
}|j qS rU   r`   rx  rU   rU   rV   rl     s     rW  z (typ->z,nrows->z,ncols->z,indexers->[rX  )r  ro   r   r  rP  rO  r  rg  r  r  ncols)r   Zjdcr_  verZjverZjindex_axesrU   rU   rV   r     s    4zTable.__repr__)r  c                 C  s"   | j D ]}||jkr|  S qdS )zreturn the axis for cN)rD  ra   )r   r  r   rU   rU   rV   r     s    


zTable.__getitem__c              
   C  s   |dkrdS |j | j kr2td|j  d| j  ddD ]~}t| |d}t||d}||kr6t|D ]4\}}|| }||krbtd| d| d| dqbtd| d| d| dq6dS )	z"validate against an existing tableNz'incompatible table_type with existing [r  r#  )r  r'  r  zinvalid combination of [z] on appending data [z] vs current table [)r  r   rj  r  r   r?  )r   r  r  svovr  saxZoaxrU   rU   rV   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)rP   r  rm   r   rU   rU   rV   is_multi_index  s    zTable.is_multi_indexr   z tuple[DataFrame, list[Hashable]])r  r[   c              
   C  s^   t |jj}z| }W n, tk
rF } ztd|W 5 d}~X Y nX t|tsVt||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@  Zfill_missing_namesr   r  Zreset_indexr   rP   r5   r   )r   r  r  Z	reset_objrC  rU   rU   rV   validate_multiindex  s    zTable.validate_multiindexrc   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  rh   r  rU   rU   rV   rl   1  s     z(Table.nrows_expected.<locals>.<listcomp>)rQ   r  r  r   rU   rU   rV   nrows_expected.  s    zTable.nrows_expectedc                 C  s
   d| j kS )zhas this table been createdrv   r  r   rU   rU   rV   r  3  s    zTable.is_existsc                 C  s   t | jdd S Nrv   rj  r   r   rU   rU   rV   r^  8  s    zTable.storablec                 C  s   | j S )z,return the table group (this is my storable))r^  r   rU   rU   rV   rv   <  s    zTable.tablec                 C  s   | j jS r\   )rv   r  r   rU   rU   rV   r  A  s    zTable.dtypec                 C  s   | j jS r\   r  r   rU   rU   rV   r  E  s    zTable.descriptionc                 C  s   t | j| jS r\   )r1  r2  r  r  r   rU   rU   rV   rD  I  s    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 r\   )ro   rY  rx  rU   rU   rV   rK  P  s     zTable.ncols.<locals>.<genexpr>)sumr  r   rU   rU   rV   r  M  s    zTable.ncolsc                 C  s   dS r  rU   r   rU   rU   rV   is_transposedR  s    zTable.is_transposedz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&  rR  rx  rU   rU   rV   rl   [  s     z*Table.data_orientation.<locals>.<listcomp>c                 S  s   g | ]}t |jqS rU   )rc   r+  rx  rU   rU   rV   rl   \  s     )rn   r1  r2  r'  r  r   rU   rU   rV   data_orientationV  s    zTable.data_orientationz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   rf   c                 S  s   g | ]}|j |fqS rU   r  rx  rU   rU   rV   rl   f  s     z$Table.queryables.<locals>.<listcomp>c                   s   g | ]\}} | d fqS r\   rU   )rh   r+  rY  )
axis_namesrU   rV   rl   g  s     c                   s&   g | ]}|j t jkr|j|fqS rU   )ra   rP  r   r  r2  r   rU   rV   rl   h  s     )r  r'  r  rF  )r   Zd1Zd2Zd3rU   )r  r   rV   
queryables`  s    

zTable.queryablesc                 C  s   dd | j D S )zreturn a list of my index colsc                 S  s   g | ]}|j |jfqS rU   )r+  r  r  rU   rU   rV   rl   q  s     z$Table.index_cols.<locals>.<listcomp>r  r   rU   rU   rV   
index_colsn  s    zTable.index_colsr   c                 C  s   dd | j D S )zreturn a list of my values colsc                 S  s   g | ]
}|j qS rU   r  r  rU   rU   rV   rl   u  s     z%Table.values_cols.<locals>.<listcomp>)r  r   rU   rU   rV   values_colss  s    zTable.values_colsr   c                 C  s   | j j}| d| dS )z)return the metadata pathname for this keyz/meta/z/metarZ  r  rU   rU   rV   _get_metadata_pathw  s    zTable._get_metadata_pathr  )r   rY  r[   c                 C  s0   | j j| |t|ddd| j| j| jd dS )z
        Write out a metadata array to the key as a fixed-format Series.

        Parameters
        ----------
        key : str
        values : ndarray
        Fr7  rv   )r   rZ   r   r   N)r   r   r  r;   rZ   r   r   )r   r   rY  rU   rU   rV   r  |  s    	
zTable.write_metadatar   c                 C  s0   t t | jdd|ddk	r,| j| |S dS )z'return the meta data array for this keyr   N)rj  r   r   r   r  r   rU   rU   rV   r     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  r  r  r'  r   r   rZ   r   r  r  r   rU   rU   rV   r\    s    





zTable.set_attrsc                 C  s   t | jddpg | _t | jddp$g | _t | jddp8i | _t | jdd| _tt | jdd| _tt | jdd| _	t | jd	dpg | _
d
d | jD | _dd | jD | _dS )rz  r'  Nr   r  r   rZ   r   r}   r  c                 S  s   g | ]}|j r|qS rU   r  rx  rU   rU   rV   rl     s      z#Table.get_attrs.<locals>.<listcomp>c                 S  s   g | ]}|j s|qS rU   r  rx  rU   rU   rV   rl     s      )rj  r  r'  r   r  r   r_   rZ   rW   r   r  
indexablesr  r  r   rU   rU   rV   r]    s    zTable.get_attrsc                 C  s>   |dk	r:| j r:tddd | jD  }tj|tt d dS )r`  NrS  c                 S  s   g | ]}t |qS rU   r  r$  rU   rU   rV   rl     s     z*Table.validate_version.<locals>.<listcomp>r  )rP  rr   r  rO  r  r  r"   r&   )r   rp   r  rU   rU   rV   ra    s    zTable.validate_versionc                 C  sR   |dkrdS t |tsdS |  }|D ]&}|dkr4q&||k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
        NrY  zmin_itemsize has the key [z%] which is not an axis or data_column)rP   rF  r  r   )r   r   qr"  rU   rU   rV   validate_min_itemsize  s    

zTable.validate_min_itemsizec                   s   g }j jjtjjD ]j\}\}}t|}|}|dk	rJd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 existNr  r  )ra   r+  r  rd  r  rv   r   r  c                   s   t |tstt}|krt}t|}t|j}t| dd }t| dd }t|}	|}t| dd }	||||| |  |j
|	||d
}
|
S )Nr  r  r	  )
ra   r  rY  rd  r  r  rv   r   r  r  )rP   rY   r   r  rE  rj  _maybe_adjust_namerO  r  r   rv   )r  r  klassr  adj_namerY  r  rd  mdr   r  )base_posr_  descr   table_attrsrU   rV   rw     s0    

zTable.indexables.<locals>.fc                   s   g | ]\}} ||qS rU   rU   )rh   r  r  )rw   rU   rV   rl     s     z$Table.indexables.<locals>.<listcomp>)r  rv   r  r  r  rj  r   r  r   rP  r   ro   rT  r  )r   _indexablesr  r+  ra   r  r  r   r  rd  	index_colrU   )r  r_  r  rw   r   r  rV   r    s2    




% zTable.indexablesr  c              	   C  sR  |   sdS |dkrdS |dks(|dkr8dd | jD }t|ttfsL|g}i }|dk	r`||d< |dk	rp||d< | j}|D ]}t|j|d}|dk	r|jr|j	}|j
}	|j}
|dk	r|
|kr|  n|
|d< |dk	r|	|kr|  n|	|d< |jsL|jdrtd	|jf | qz|| jd
 d krztd| d| d| dqzd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  s   g | ]}|j r|jqS rU   )r  r  rx  rU   rU   rV   rl   >  s      z&Table.create_index.<locals>.<listcomp>rc  rd  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   rf   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.)r  rD  rP   rn   rm   rv   rj  rJ  rw  r   rc  rd  Zremove_indexr   rr  r   re  r'  r   )r   r   rc  rd  kwrv   r  rN  r   Zcur_optlevelZcur_kindrU   rU   rV   re    sJ    


zTable.create_indexr   z!list[tuple[ArrayLike, ArrayLike]]rf  c           	      C  sZ   t | |||d}| }g }| jD ]2}|| j |j|| j| j| jd}|	| q"|S )a  
        Create the axes sniffed from the table.

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

        Returns
        -------
        List[Tuple[index_values, column_values]]
        r  r9  )
	Selectionr   rD  r  r  r  r   rZ   r   r   )	r   rp   r   r   	selectionrY  r  r   resrU   rU   rV   
_read_axeso  s    
zTable._read_axesr|  c                 C  s   |S )zreturn the data for this objrU   r  r  r|  rU   rU   rV   
get_object  s    zTable.get_objectc                   s   t |sg S |d \} | j|i }|ddkrL|rLtd| d| |dkr^t }n|dkrjg }t|trt|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   r8   z"cannot use a multi-index on axis [z] with data_columns TNc                   s    g | ]}|d kr| kr|qS r  rU   r!  )existing_data_columnsrU   rV   rl     s    z/Table.validate_data_columns.<locals>.<listcomp>c                   s   g | ]}| kr|qS rU   rU   )rh   r  )axis_labelsrU   rV   rl     s      )
ro   r  r   r   rm   rP   rF  rP  rT  r   )r   r   r   r'  r+  r  rU   )r  r  rV   validate_data_columns  s*    


	zTable.validate_data_columnsr5   )r  r_  c           /        s  t ts,| jj}td| dt d dkr:dg fdd D  |  rzd}d	d | jD  t| j	}| j
}nd
}| j}	| jdkstt | jd krtdg }
|dkrd} fdddD d }j| }t|}|r<t|
}| j| d }tt|t|s<ttt|tt|r<|}|	|i }t|j|d< t|j|d< |
||f  d }j| }|}t||| j| j}||_|d | |	 |!| |g}t|}|dkstt|
dkst|
D ]}t"|d |d q|jdk}| #|||
}| $|% }| &|||
| j'|\}}g }t(t)||D ]\}\}}t*}d}|rt|dkr|d |krt+}|d }|dkst |t,std|r&|r&z| j'| }W nB t-t.fk
r" }  ztd| d| j' d| W 5 d} ~ X Y nX nd}|p8d| }!t/|!|j0|||| j| j|d}"t1|!| j2}#|3|"}$t4|"j5j6}%d}&t7|"dddk	rt8|"j9}&d }' }(})t:|"j5r|"j;})d}'tj|"j<d
d= }(t>|"\}*}+||#|!t||$||%|&|)|'|(|+|*d},|, |	 ||, |d7 }qddd |D }-t| | j?| j| j| j||
||-|	|d
}.t@| drj| jA|._A|.B| |r|r|.C|  |.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                   s   g | ]}  |qS rU   )_get_axis_numberrx  )r  rU   rV   rl     s     z&Table._create_axes.<locals>.<listcomp>Tc                 S  s   g | ]
}|j qS rU   rL  rx  rU   rU   rV   rl     s     FrN  rf   z<currently only support ndim-1 indexers in an AppendableTablenanc                   s   g | ]}| kr|qS rU   rU   r$  )rD  rU   rV   rl     s      r  r  r   rF  zIncompatible appended table [z]with existing table [Zvalues_block_)existing_colr   r   rZ   r   r   r  r  r7  )ra   r  rY  r  r  rd  r  r^  r   r  r  ry  c                 S  s   g | ]}|j r|jqS rU   )r  ra   )rh   r  rU   rU   rV   rl     s      )
r   r   rZ   r   r  r'  r  r   r  r   r  )DrP   r5   r   r   r   r   r  r  rm   r   r   r  rR  r   ro   r   rD  r'  r4   rQ   arrayrV  r  r  r   r   Z_get_axis_namer  rZ   r   r+  r  r  r  _reindex_axisr  r  r-  _get_blocks_and_itemsr  r  r3  r  rE  rY   
IndexErrorr   _maybe_convert_for_string_atomrY  r  rO  r  r  r  ra   rj  r  r  r)   r^  r6  r<  r  r   r  r  r  r_  )/r   rD  r  r_  r   r   r   r   table_existsZnew_infonew_non_index_axesr  r   Zappend_axisZindexerZ
exist_axisr  	axis_nameZ	new_indexZnew_index_axesjr|  r  r  r  Zvaxesr  r  b_itemsr  ra   r  rC  new_namedata_convertedr  r  rd  r  r   r  r^  ry  r  r  ZdcsZ	new_tablerU   )rD  r  rV   _create_axes  s"    


 





      "






zTable._create_axes)r  r  c                 C  s  t | jtr| d} dd }| j}tt|}t|j}||}t|r|d \}	}
t	|

t	|}| j||	dj}tt|}t|j}||}|D ]:}| j|g|	dj}tt|}||j ||| q|rdd t||D }g }g }|D ]}t|j}z&||\}}|| || W q ttfk
rz } z*dd	d
 |D }td| d|W 5 d }~X Y qX q|}|}||fS )Nr  c                   s    fdd j D S )Nc                   s   g | ]} j |jqS rU   )r   rX  r  )rh   r  mgrrU   rV   rl     s     zFTable._get_blocks_and_items.<locals>.get_blk_items.<locals>.<listcomp>)r  r  rU   r  rV   get_blk_items  s    z2Table._get_blocks_and_items.<locals>.get_blk_itemsr   rL  c                 S  s"   i | ]\}}t | ||fqS rU   )rn   tolist)rh   br  rU   rU   rV   rO    s   
 z/Table._get_blocks_and_items.<locals>.<dictcomp>r  c                 S  s   g | ]}t |qS rU   rU  )rh   itemrU   rU   rV   rl     s     z/Table._get_blocks_and_items.<locals>.<listcomp>z+cannot match existing table structure for [z] on appending data)rP   r  rF   r  r   rG   rm   r  ro   r7   rU  r]  rT  r3  rn   rY  r6  r   r  r   r  r   )r  r  r  r  r   r  r  r  r  r+  r  Z
new_labelsr  Zby_itemsZ
new_blocksZnew_blk_itemsZear   r  r  rC  ZjitemsrU   rU   rV   r    sR    








zTable._get_blocks_and_itemsr  )r  r[   c                   s   |dk	rt |}|dk	rNjrNtjt s.tjD ]}||kr4|d| q4jD ]$\}}t |||  fdd}qT|jdk	r|j	 D ]\}}	}
|||
|	 q S )zprocess axes filtersNr   c                   s    j D ]} |} |}|d k	s*t| |krfjrH|tj}|||} j|d|   S | |krt	t
 | j}t	|}t trd| }|||} j|d|   S qtd|  dd S )NrL  rf   zcannot find the field [z] for filtering!)Z_AXIS_ORDERSr  	_get_axisr   r  unionr7   r  r\  rE   rj  rY  rP   r5   r   )fieldfiltopr  Zaxis_numberZaxis_valuesZtakersrY  r  r   rU   rV   process_filter  s"    





z*Table.process_axes.<locals>.process_filter)
rm   r  rP   r  r   insertr'  r  filterr   )r   r  r  r   r   r+  labelsr  r   r  r  rU   r  rV   process_axes  s    
 
zTable.process_axes)r   r   rE  r[   c                 C  s   |dkrt | jd}d|d}dd | jD |d< |rj|dkrH| jpFd}t j|||pZ| jd	}||d
< n| jdk	r~| j|d
< |S )z:create the description of the table from the axes & valuesNi'  rv   )ra   rE  c                 S  s   i | ]}|j |jqS rU   )r  r  rx  rU   rU   rV   rO  .  s      z,Table.create_description.<locals>.<dictcomp>r  	   )r   r   r   r   )maxr  rD  r   r   r   r   r   )r   r   r   r   rE  rG  r   rU   rU   rV   create_description  s     	




zTable.create_descriptionrb  c           
      C  s   |  | |  sdS t| |||d}| }|jdk	r|j D ]D\}}}| j|| | d d}	|||	j	||   |j
 }qBt|S )zf
        select coordinates (row numbers) from a table; return the
        coordinates object
        Fr  Nrf   rb  )ra  r  r  select_coordsr  r   r  r  r
  ilocrY  r7   )
r   rp   r   r   r  Zcoordsr   r  r  ry  rU   rU   rV   r  >  s    

  
 zTable.read_coordinatesr  c                 C  s   |    |  sdS |dk	r$td| jD ]|}||jkr*|jsNtd| dt| jj	|}|
| j |j||| | j| j| jd}tt|d |j|dd  S q*td| d	dS )
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 indexabler9  rf   )ra   rz  z] not found in the table)ra  r  r   rD  ra   r  r   rj  rv   rJ  r  r  r  r   rZ   r   r;   r  r  r   )r   r  rp   r   r   r   r  Z
col_valuesrU   rU   rV   r  X  s*    



 zTable.read_column)Nr}   NNNNNN)N)NNN)NN)TNNN)N)NNN)NNN)4r   r  r  r  rI  rJ  r  r  r4  r   r  r  r   r   r_  r  r  r  r  r^  rv   r  r  rD  r  r  r  r  r  r  r  r  r   r\  r]  ra  r  r%   r  re  r  rC  r  r  r  staticmethodr  r  r  r  r  rD  rU   rU   r  rV   r     s   
        &!




	
L     W   "*     iC7         r   c                   @  s4   e Zd ZdZdZddddddZd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   rb  c                 C  s   t ddS )z[
        read the indices and the indexing array, calculate offset rows and return
        z!WORMTable needs to implement readNrc  rd  rU   rU   rV   r	    s    
zWORMTable.readr   r   c                 K  s   t ddS )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 writeNrc  re  rU   rU   rV   r    s    zWORMTable.write)NNNN)r   r  r  r  r  r	  r  rU   rU   rU   rV   r    s       r  c                   @  sf   e Zd ZdZdZddddddd	d
ZdddddddZddddddddZddddddZdS )r  (support the new appendable table formatsZ
appendableNFTr   r   )r   r   r9  r[   c                 C  s   |s| j r| j| jd | j||||||d}|jD ]}|  q6|j s~|j||||	d}|  ||d< |jj	|jf| |j
|j_
|jD ]}||| q|j||
d d S )Nrv   )rD  r  r_  r   r   r   )r   r   r   rE  r9  )r   )r  r   r  r   r  rD  r  r  r\  Zcreate_tabler  r  r  
write_data)r   r  rD  r   r   r   r   r   r   rE  r   r   r   r9  rv   r   optionsrU   rU   rV   r    s4    
	



zAppendableTable.writer   )r   r   r[   c                   s  | j j}| j}g }|rT| jD ]6}t|jjdd}t|tj	r|
|jddd qt|r|d }|dd D ]}||@ }qp| }nd}dd	 | jD }	t|	}
|
dkst|
d
d	 | jD }dd	 |D }g }t|D ]2\}}|f| j ||
|   j }|
|| q|dkr d}tjt||| j d}|| d }t|D ]x}|| t|d | |  krx q| j| fdd	|	D |dk	r|  nd fdd	|D d qJdS )z`
        we form the data into a 2-d including indexes,values,mask write chunk-by-chunk
        r   rL  u1Fr7  rf   Nc                 S  s   g | ]
}|j qS rU   )r  rx  rU   rU   rV   rl     s     z.AppendableTable.write_data.<locals>.<listcomp>c                 S  s   g | ]}|  qS rU   )r  rx  rU   rU   rV   rl     s     c              	   S  s,   g | ]$}| tt|j|jd  qS r  )Z	transposerQ   ZrollarangerR  r2  rU   rU   rV   rl     s     r  r/  c                   s   g | ]}|  qS rU   rU   rx  Zend_iZstart_irU   rV   rl     s     c                   s   g | ]}|  qS rU   rU   r2  r  rU   rV   rl     s     )indexesrB  rY  )r  r  r  r  r>   ry  rH  rP   rQ   r  r   r>  ro   r<  r  r   r  r  reshaper  r  rQ  write_data_chunk)r   r   r   r  r  masksr   rB  mr  nindexesrY  bvaluesr  rN  Z	new_shaperowschunksrU   r  rV   r    sL    




zAppendableTable.write_datar  zlist[np.ndarray]znpt.NDArray[np.bool_] | None)r  r  rB  rY  r[   c                 C  s   |D ]}t |js dS q|d jd }|t|krFt j|| jd}| jj}t|}t|D ]\}	}
|
|||	 < q^t|D ]\}	}||||	|  < q||dk	r| j	t
dd }| s|| }t|r| j| | j  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/  Fr7  )rQ   r  r  ro   r  r  r  r  r<  r>  r   rH  rv   r   r  )r   r  r  rB  rY  rN  r  r  r  r  r  r  rU   rU   rV   r    s&    z AppendableTable.write_data_chunkrb  c                 C  sf  |d kst |sf|d kr:|d kr:| j}| jj| jdd n(|d krH| j}| jj||d}| j  |S |  srd S | j}t	| |||d}|
 }t|dd }t |}	|	rb| }
t|
|
dk j}t |sdg}|d |	kr||	 |d dkr|dd | }t|D ]@}|t||}|j||jd  ||jd  d d |}q| j  |	S )	NTr=  rb  Fr7  rf   r   r5  )ro   r  r   r  r   rv   Zremove_rowsr  r  r  r  r;   Zsort_valuesdiffrm   r   r   r  r6  reversedrX  rQ  )r   rp   r   r   r  rv   r  rY  Zsorted_serieslnr  r   Zpgr   r  rU   rU   rV   rB  J  sF    

 
zAppendableTable.delete)NFNNNNNNFNNT)F)NNN)	r   r  r  r  r  r  r  r  rB  rU   rU   rU   rV   r    s$               ;;,r  c                   @  s`   e Zd ZU dZdZdZdZeZde	d< e
ddd	d
ZeddddZddddddZdS )r  r  r  r  rN  rK  rL  r   r   c                 C  s   | j d jdkS )Nr   rf   )r  r+  r   rU   rU   rV   r    s    z"AppendableFrameTable.is_transposedr  c                 C  s   |r
|j }|S )zthese are written transposed)r~  r  rU   rU   rV   r    s    zAppendableFrameTable.get_objectNr   rb  c                   s2    |   sd S  j|||d}t jrH j jd d i ni } fddt jD }t|dkstt	|d }|| d }	g }
t jD ]P\}}| j
krq|| \}}|ddkrt|}n
t|}|d}|d k	r|j|d	d
  jr |}|}t|	t|	dd d}n|j}t|	t|	dd d}|}|jdkrlt|tjrl|d|jd f}t|tjrt|j||dd}n.t|trt|||d}ntj|g||d}|j|jk st	|j|jf|
| qt|
dkr|
d }nt|
dd}t |||d} j |||d}|S )Nr  r   c                   s"   g | ]\}}| j d  kr|qS r&  r  )rh   r  r  r   rU   rV   rl     s      z-AppendableFrameTable.read.<locals>.<listcomp>rf   r   r8   r  TZinplacera   r`   Fr  r  rL  )r  r   )!ra  r  r  ro   r'  r  r   r  rD  r   r  r7   r8   from_tuples	set_namesr  rj  r~  rR  rP   rQ   r  r  r  r5   Z_from_arraysZdtypesr  rH  r   r=   r  r  )r   rp   r   r   r   rv  r  Zindsindr   framesr  r   Z
index_valsr  rJ  r  rY  Zindex_Zcols_r  r  rU   r   rV   r	    sZ    




"
zAppendableFrameTable.read)NNNN)r   r  r  r  rI  r  rR  r5   rL  r  r  r  rC  r  r	  rU   rU   rU   rV   r    s   
    r  c                      sn   e Zd ZdZdZdZdZeZe	ddddZ
edd	d
dZd fdd	Zddddd fddZ  ZS )r  r  r  r  rN  r   r   c                 C  s   dS r  rU   r   rU   rU   rV   r    s    z#AppendableSeriesTable.is_transposedr  c                 C  s   |S r\   rU   r  rU   rU   rV   r    s    z AppendableSeriesTable.get_objectNc                   s<   t |ts|jpd}||}t jf ||j d|S )+we are going to write this as a frame tablerY  r  r   )rP   r5   ra   Zto_framer  r  r   r  )r   r  r   r   ra   r  rU   rV   r    s    


zAppendableSeriesTable.writer   r;   rf  c                   s   | j }|d k	rB|rBt| jts"t| jD ]}||kr(|d| q(t j||||d}|rj|j| jdd |j	d d df }|j
dkrd |_
|S )Nr   r*  Tr!  rY  )r  rP   r  rm   r   r  r  r	  	set_indexr  ra   )r   rp   r   r   r   r  r   rT   r  rU   rV   r	    s    

zAppendableSeriesTable.read)N)NNNN)r   r  r  r  rI  r  rR  r;   rL  r  r  rC  r  r  r	  rD  rU   rU   r  rV   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*tt| j}|| t||_t	 j
f d|i|S )r&  rY  r  )ra   r  r  rP   rm   r   r   r7   r   r  r  )r   r  r   ra   ZnewobjrJ  r  rU   rV   r    s    



z AppendableMultiSeriesTable.write)r   r  r  r  rI  r  r  rD  rU   rU   r  rV   r    s   r  c                   @  sj   e Zd ZU dZdZdZdZeZde	d< e
ddd	d
Ze
dd Zd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  rN  zlist[Hashable]r  rY   r   c                 C  s   | j S r\   )rI  r   rU   rU   rV   rg  2  s    zGenericTable.pandas_typec                 C  s   t | jdd p| jS r  r  r   rU   rU   rV   r^  6  s    zGenericTable.storabler   c                 C  sL   g | _ d| _g | _dd | jD | _dd | jD | _dd | jD | _dS )rz  Nc                 S  s   g | ]}|j r|qS rU   r  rx  rU   rU   rV   rl   @  s      z*GenericTable.get_attrs.<locals>.<listcomp>c                 S  s   g | ]}|j s|qS rU   r  rx  rU   rU   rV   rl   A  s      c                 S  s   g | ]
}|j qS rU   r`   rx  rU   rU   rV   rl   B  s     )r'  r   r  r  r  r  r   r   rU   rU   rV   r]  :  s    zGenericTable.get_attrsc           
   
   C  s   | j }| d}|dk	rdnd}tdd| j||d}|g}t|jD ]^\}}t|tsZtt	||}| |}|dk	rzdnd}t
|||g|| j||d}	||	 qD|S )z0create the indexables from the table descriptionr   Nr  r   )ra   r+  rv   r   r  )ra   r  rY  r  rv   r   r  )r  r   r  rv   r  Z_v_namesrP   rY   r   rj  rG  r   )
r   rG  r  r   r  r  r  r   r  r_  rU   rU   rV   r  D  s6    
    

	zGenericTable.indexablesc                 K  s   t dd S )Nz cannot write on an generic tablerc  re  rU   rU   rV   r  g  s    zGenericTable.writeN)r   r  r  r  rI  r  rR  r5   rL  r  r  rg  r^  r]  r%   r  r  rU   rU   rU   rV   r  )  s   



"r  c                      s`   e Zd ZdZdZeZdZe	dZ
eddddZd fd
d	Zdddd fddZ  ZS )r  za frame with a multi-indexr  rN  z^level_\d+$rY   r   c                 C  s   dS )NZappendable_multirU   r   rU   rU   rV   r  s  s    z*AppendableMultiFrameTable.table_type_shortNc                   sx   |d krg }n|dkr |j  }| |\}| _t| jts@t| jD ]}||krF|d| qFt j	f ||d|S )NTr   r'  )
r   r  r  r  rP   rm   r   r  r  r  )r   r  r   r   r   r  rU   rV   r  w  s    

zAppendableMultiFrameTable.writer   rb  c                   sD   t  j||||d}| j}|j fdd|jjD |_|S )Nr*  c                   s    g | ]} j |rd n|qS r\   )
_re_levelssearch)rh   ra   r   rU   rV   rl     s     z2AppendableMultiFrameTable.read.<locals>.<listcomp>)r  r	  r(  r  r   r#  r  )r   rp   r   r   r   r  r  r   rV   r	    s    zAppendableMultiFrameTable.read)N)NNNN)r   r  r  r  r  r5   rL  rR  recompiler)  r  r  r  r	  rD  rU   rU   r  rV   r  k  s   
    r  r5   r   r7   )r  r+  r  r[   c                 C  s   |  |}t|}|d k	r"t|}|d ks4||rB||rB| S t| }|d k	rlt| j|dd}||std d g| j }|||< | jt| } | S )NF)sort)	r  rE   equalsuniquer[  slicerR  r\  rn   )r  r+  r  r  r  ZslicerrU   rU   rV   r    s    

r  r   zstr | tzinfo)r  r[   c                 C  s   t | }|S )z+for a tz-aware type, return an encoded zone)r   Zget_timezone)r  zonerU   rU   rV   r    s    
r  znp.ndarray | Indexr6   )rY  r  r,  r[   c                 C  s   d S r\   rU   rY  r  r,  rU   rU   rV   r    s    r  r  c                 C  s   d S r\   rU   r2  rU   rU   rV   r    s    zstr | tzinfo | Noneznp.ndarray | DatetimeIndexc                 C  s   t | tr"| jdks"| j|ks"t|dk	rtt | trB| j}| j} nd}|  } t|}t| |d} | d	|} n|rt
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
    Nr`   rr  M8[ns]r/  )rP   r6   r  r   ra   r  r<  rW   rt  ru  rQ   r:  )rY  r  r,  ra   rU   rU   rV   r    s    

)ra   r   rZ   r   r[   c              
   C  s  t | tst|j}t|\}}t|}t|}t |jt	jrHt
|s\t|js\t|jrt| |||t|dd t|dd |dS t |trtdtj|dd}	t	|}
|	dkrt	jdd	 |
D t	jd
}t| |dt  |dS |	dkrt|
||}|jj}t| |dt ||dS |	dkr:t| ||||dS t |t	jrT|jtksXt|dksjt|t  }t| ||||dS d S )Nr  r  )rY  rd  r  r  r  r  zMultiIndex not supported here!Fr  r   c                 S  s   g | ]}|  qS rU   )	toordinalr2  rU   rU   rV   rl     s     z"_convert_index.<locals>.<listcomp>r/  )r  r  )integerZfloating)rY  rd  r  r  r;  )rP   rY   r   ra   r  r  rE  r  r  rQ   r.   r3   r(   r  rj  r8   r   r   r  r:  Zint32r   Z	Time32Col_convert_string_arrayr  r  r  r;  r  )ra   r   rZ   r   r  rA  r  rd  r  r  rY  r  rU   rU   rV   r    sr    





    


    
r  )rd  rZ   r   r[   c                 C  s   |dkrt | }n|dkr$t| }n|dkrxztjdd | D td}W q tk
rt   tjdd | D td}Y qX nT|dkrt| }n@|d	krt| d ||d
}n&|dkrt| d }ntd| |S )Nr*  r-  r   c                 S  s   g | ]}t |qS rU   r0  r2  rU   rU   rV   rl   0  s     z$_unconvert_index.<locals>.<listcomp>r/  c                 S  s   g | ]}t |qS rU   r3  r2  rU   rU   rV   rl   2  s     )r5  floatr   r  r9  r;  r   zunrecognized index type )r6   r<   rQ   r:  r;  r   r@  )ry  rd  rZ   r   r   rU   rU   rV   r  '  s,    

    r  r   r   )ra   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rPtd|	dksd|dksd|S t	|}
|
 }|||
< tj|dd}	|	dkrt|jd	 D ]V}|| }tj|dd}	|	dkrt||kr|| nd
| }td| d|	 dqt||||j}|j}t|tr>t|| p:|dp:d	}t|pHd	|}|d k	rz||}|d k	rz||krz|}|jd| dd}|S )NFr  r   z+[date] is not implemented as a table columnrh  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 dtyperY  z|Sr7  )r  r;  r   rQ   r  ra   r   r  r   r>   rz  rQ  r  ro   r6  r  r  rP   rF  rc   r   r
  r  r>  )ra   r  r  r   r   rZ   r   r   r  r  rB  ry  r  r  Zerror_column_labelr  r  ZecirU   rU   rV   r  @  sJ    

 

r  )ry  rZ   r   r[   c                 C  s`   t | r,t|  ddj||j| j} t|  }t	dt
|}tj| d| d} | S )a  
    Take a string-like that is object dtype and coerce to a fixed size string type.

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

    Returns
    -------
    np.ndarray[fixed-length-string]
    Fr7  rf   Sr/  )ro   r;   r<  rY   encoder?  r  r  r'   r
  
libwritersmax_len_string_arrayrQ   r:  )ry  rZ   r   ensuredr  rU   rU   rV   r6    s     r6  c                 C  s   | j }tj|  td} t| rztt| }d| }t	| d t
rbt| ddjj||dj} n| j|ddjtdd} |dkrd}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   Fr7  )r   Nr  )r  rQ   r:  r<  r;  ro   r:  r;  r'   rP   rw  r;   rY   rS   r?  r>  Z!string_array_replace_from_nan_repr  )ry  r   rZ   r   r  r  r  rU   rU   rV   r@    s    
r@  )rY  r  rZ   r   c                 C  s6   t |tstt|t|r2t|||}|| } | S r\   )rP   rY   r   r   _need_convert_get_converter)rY  r  rZ   r   convrU   rU   rV   r    s
    r  rd  rZ   r   c                   s8   | dkrdd S | dkr& fddS t d|  d S )Nr*  c                 S  s   t j| ddS )Nr3  r/  )rQ   r:  r%  rU   rU   rV   r         z _get_converter.<locals>.<lambda>r  c                   s   t | d  dS )Nr9  )r@  rB  r  rU   rV   r     s
      zinvalid kind )r   rA  rU   r  rV   r?    s
    r?  r  c                 C  s   | dkrdS dS )N)r*  r  TFrU   r  rU   rU   rV   r>    s    r>  zSequence[int])ra   rO  r[   c                 C  sl   t |tst|dk rtd|d dkrh|d dkrh|d dkrhtd| }|rh| 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   rf   rM  rN  zvalues_block_(\d+)Zvalues_)rP   rY   ro   r   r+  r*  r   )ra   rO  r  grprU   rU   rV   r    s    $
r  )	dtype_strr[   c                 C  s   t | } | ds| dr"d}n| dr2d}n| drBd}n| dsV| dr\d}nn| drld}n^| d	r|d
}nN| drd}n>| drd}n.| drd}n| dkrd}ntd|  d|S )zA
    Find the "kind" string describing the given dtype name.
    r  rw  r7  r  rc   r  r5  r*  	timedeltar-  r   r  r   r;  zcannot interpret dtype of [r#  )rW   rr  r   )rF  rd  rU   rU   rV   r     s.    






r  r  c                 C  sb   t | tr| j} | jjdd }| jjdkr@t| 	d} nt | t
rP| j} t| } | |fS )zJ
    Convert the passed data into a storable form and a dtype string.
    rV  r   )r  Mr  )rP   r?   r  r  ra   r  rd  rQ   r:  r  r9   r  )ry  r  rU   rU   rV   r  !  s    


r  c                   @  s>   e Zd ZdZddddddddZd	d
 Zdd Zdd ZdS )r  z
    Carries out a selection operation on a tables.Table object.

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

    Nr   r   r   )rv   r   r   r[   c              	   C  s@  || _ || _|| _|| _d | _d | _d | _d | _t|rt	t
 tj|dd}|dkrt|}|jtjkr| j| j }}|d krd}|d kr| j j}t||| | _nNt|jjtjr| jd k	r|| jk  s| jd k	r|| jk rt
d|| _W 5 Q R X | jd kr<| || _| jd k	r<| j \| _| _d S )NFr  )r5  booleanr   z3where must have index locations >= start and < stop)rv   rp   r   r   	conditionr  Ztermsr0  r/   r   r   r   r  rQ   r:  r  Zbool_r  r  
issubclassr   r5  r=  generateevaluate)r   rv   rp   r   r   inferredrU   rU   rV   r   C  sD    


zSelection.__init__c              
   C  s   |dkrdS | j  }zt||| j jdW S  tk
rz } z2d| }td| d| d}t||W 5 d}~X Y nX dS )z'where can be a : dict,list,tuple,stringN)r  rZ   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
                )	rv   r  rB   rZ   	NameErrorr  r   r   r   )r   rp   r  rC  Zqkeysr   rU   rU   rV   rL  p  s    
	zSelection.generatec                 C  sX   | j dk	r(| jjj| j  | j| jdS | jdk	rB| jj| jS | jjj| j| jdS )(
        generate the selection
        Nrb  )	rJ  rv   Z
read_wherer   r   r   r0  r  r	  r   rU   rU   rV   r     s    
  
zSelection.selectc                 C  s   | j | j }}| jj}|dkr$d}n|dk r4||7 }|dkrB|}n|dk rR||7 }| jdk	rx| jjj| j ||ddS | jdk	r| jS t	||S )rP  Nr   T)r   r   r-  )
r   r   rv   r  rJ  Zget_where_listr   r0  rQ   r  )r   r   r   r  rU   rU   rV   r    s(    
   
zSelection.select_coords)NNN)r   r  r  r  r   rL  r   r  rU   rU   rU   rV   r  7  s      -r  )r   NNFNTNNNNr}   rO   )	Nr   r}   NNNNFN)N)F)F)F)r  
__future__r   
contextlibr   rz  rh  r   r   r1  r   r+  textwrapr   typesr   typingr   r	   r
   r   r   r   r   r   r   r   r  numpyrQ   Zpandas._configr   r   Zpandas._libsr   r   r:  Zpandas._libs.tslibsr   Zpandas._typingr   r   r   r   r   r   r   Zpandas.compat._optionalr   Zpandas.compat.pickle_compatr   Zpandas.errorsr    r!   r"   r#   r$   Zpandas.util._decoratorsr%   Zpandas.util._exceptionsr&   Zpandas.core.dtypes.commonr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   Zpandas.core.dtypes.missingr4   r   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   Zpandas.core.arraysr?   r@   rA   Zpandas.core.commoncorecommonr@  Z pandas.core.computation.pytablesrB   rC   Zpandas.core.constructionrD   Zpandas.core.indexes.apirE   Zpandas.core.internalsrF   rG   Zpandas.io.commonrH   Zpandas.io.formats.printingrI   rJ   r   rK   rL   rM   rN   rY  r]   rW   r_   rb   rg   rq   rr   r  rs   rt   r  rS  ry   rz   Zconfig_prefixZregister_optionZis_boolZis_one_of_factoryr~   r   r   r   r   r   r   r  r  r  r  rE  rG  rH  rg  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r6  r@  r  r?  r>  r  r  r  r  rU   rU   rU   rV   <module>   s0  0$	<0
            ,:                     Qp  &   -  e!^       f dc0B+   &@I&!