gL i dUdZddlmZddlmZddlZddlmZmZddl Z ddl Z ddl Z ddl m Z ddlmZmZmZmZmZmZmZddlZddlZddlmZmZmZmZdd lmZm Z!dd l"m#Z#dd l$m%Z%dd l&m'Z'dd l(m)Z)ddl*m+Z+ddl,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAddlBmCZCddlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOddlPmQZQmRZRmSZSddlTmUZUddlVmWcmXZYddlZm[Z[m\Z\ddl]m^Z_m`Z`ddlambZbddlcmdZdmeZeddlfmgZgddlhmiZimjZjer4ddlkmlZlmmZmmnZnddlompZpdd lqmrZrmsZsmtZtdd!lumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}dd"lcm~Z~d#Zd$Zd%Zd{d&Zd'Ze[Zd|d(Zd)Zd*ed+<d,Zd*ed-<d.Zd*ed/<d0d0d1d1d2ZeEdgiZd3Zd*ed4<d5Zd*ed6<ejd75ejd8d9eej :ejd;deej"gd<:ddddad9ad=Z d} d~d>Z d dd?Zdd@ZGdAdBZGdCdDZGdEdFZGdGdHeZGdIdJeZGdKdLeZGdMdNeZGdOdPZGdQdReZGdSdTeZGdUdVeZGdWdXeZGdYdZeZGd[d\eZGd]d^eZGd_d`eZGdadbeZGdcddeZGdedfeZGdgdheZ d ddiZddjZe d ddkZedddlZ d ddmZddnZddoZ ddpZddqZ ddrZddsZddtZdduZddvZddwZddxZGdydzZy#1swYxYw)zY High level interface to PyTables for reading and writing pandas data structures to disk ) annotations)suppressN)datetzinfo)dedent) TYPE_CHECKINGAnyCallableFinalLiteralcastoverload)config get_optionusing_copy_on_writeusing_string_dtype)libwriters)is_string_array) timezones) HAS_PYARROW)import_optional_dependency) patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly)find_stack_level) ensure_object is_bool_dtypeis_complex_dtype is_list_likeis_string_dtypeneeds_i8_conversion)CategoricalDtypeDatetimeTZDtypeExtensionDtype PeriodDtype)array_equivalent) DataFrame DatetimeIndexIndex MultiIndex PeriodIndex RangeIndexSeries StringDtypeTimedeltaIndexconcatisna) Categorical DatetimeArray PeriodArray)BaseStringArray) PyTablesExprmaybe_expression)array extract_array) ensure_index) ArrayManager BlockManager)stringify_path)adjoin pprint_thing)HashableIteratorSequence) TracebackType)ColFileNode) AnyArrayLike ArrayLikeAxisIntDtypeArgFilePathSelfShapenpt)Blockz0.15.2UTF-8c\t|tjr|jd}|S)z(if we have bytes, decode them to unicoderU) isinstancenpbytes_decode)ss X/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pandas/io/pytables.py_ensure_decodedr]s#!RYY HHW  Hc|t}|SN)_default_encodingencodings r\_ensure_encodingrds$ Or^c<t|tr 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 )rWstrnames r\ _ensure_strris$4y Kr^c|dz}t|ttfr-|Dcgc]!}|t|rt ||dzn|#}}nt|r t ||}| t |r|SdScc}w)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) N scope_level)rWlisttupler<Termlen)wherermlevelterms r\ _ensure_termrus !OE%$' 2B$1GD519 -T Q  % U.MSZ59T9 s&A2z 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_docfixedtable)frytrzz; : 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_doczio.hdf dropna_tableF) validatordefault_format)ryrzNct=ddl}|att5|jj dk(adddtStS#1swYtSxYw)Nrstrict) _table_modtablesrAttributeErrorfile_FILE_OPEN_POLICY!_table_file_open_policy_is_strict)rs r\_tablesrsX n %  --9 .  :   s A  Ac  |r   f d}n   f d}t|}t|tr!t||||5}||dddy||y#1swYyxYw)z+store this object, close it if we opened itc : |j   S)N)formatindex min_itemsizenan_repdropna data_columnserrorsrc)append storerrrcrrrkeyrrvalues r\zto_hdf..s3%,,  %%'  r^c : |j   S)N)rrrrrrrcrputrs r\rzto_hdf..+s3%))  %%$  r^)mode complevelcomplibN)rBrWrfHDFStore) path_or_bufrrrrrrrrrrrrrrcr{rs `` ```````` r\to_hdfr su$  !-K+s#  di    eH   +   s  A//A8c F|dvrtd|d| t|d}t|tr|js t d|} d} nht |}t|ts td  tjj|} | std |d t|f||d | } d } |[| j}t|dk(r td|d}|ddD]}t!||rtd|j"}| j%||||||| | S#ttf$rd} YwxYw#ttt&f$rGt|ts5t)t*5| j-ddd#1swYxYwwxYw)a> Read from the store, close it if we opened it. Retrieve pandas object stored in file, optionally based on where criteria. .. warning:: Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the "fixed" format. Loading pickled data received from untrusted sources can be unsafe. See: https://docs.python.org/3/library/pickle.html for more. Parameters ---------- path_or_buf : str, path object, pandas.HDFStore Any valid string path is acceptable. Only supports the local file system, remote URLs and file-like objects are not supported. If you want to pass in a path object, pandas accepts any ``os.PathLike``. Alternatively, pandas accepts an open :class:`pandas.HDFStore` object. key : object, optional The group identifier in the store. Can be omitted if the HDF file contains a single pandas object. mode : {'r', 'r+', 'a'}, default 'r' Mode to use when opening the file. Ignored if path_or_buf is a :class:`pandas.HDFStore`. Default is 'r'. errors : str, default 'strict' Specifies how encoding and decoding errors are to be handled. See the errors argument for :func:`open` for a full list of options. where : list, optional A list of Term (or convertible) objects. start : int, optional Row number to start selection. stop : int, optional Row number to stop selection. columns : list, optional A list of columns names to return. iterator : bool, optional Return an iterator object. chunksize : int, optional Number of rows to include in an iteration when using an iterator. **kwargs Additional keyword arguments passed to HDFStore. Returns ------- object The selected object. Return type depends on the object stored. See Also -------- DataFrame.to_hdf : Write a HDF file from a DataFrame. HDFStore : Low-level access to HDF files. Notes ----- When ``errors="surrogatepass"``, ``pd.options.future.infer_string`` is true, and PyArrow is installed, if a UTF-16 surrogate is encountered when decoding to UTF-8, the resulting dtype will be ``pd.StringDtype(storage="python", na_value=np.nan)``. Examples -------- >>> df = pd.DataFrame([[1, 1.0, 'a']], columns=['x', 'y', 'z']) # doctest: +SKIP >>> df.to_hdf('./store.h5', 'data') # doctest: +SKIP >>> reread = pd.read_hdf('./store.h5') # doctest: +SKIP )rr+azmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.Nrkrlz&The HDFStore must be open for reading.Fz5Support for generic buffers has not been implemented.zFile z does not exist)rrTrz]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.)rrstartstopcolumnsiterator chunksize auto_close) ValueErrorrurWris_openOSErrorrBrfNotImplementedErrorospathexists TypeErrorFileNotFoundErrorgroupsrq_is_metadata_of _v_pathnameselect LookupErrorrrclose)rrrrrrrrrrrkwargsrrrrcandidate_only_groupgroup_to_checks r\read_hdfrBsl ##D6- .   U2+x(""BC C $[1 +s+%G  WW^^K0F #eK=$HI II4I&I % ;\\^F6{a D$*!9 #)* &~7KL$;  '22C|| !  A:& F T  ; /+x0.)       s=6D.8AE=0E.EE3F 8F F F  F c|j|jkry|}|jdkDr=|j}||k(r|jdk(ry|j}|jdkDr=y)zDCheck if a given group is a metadata group for a given parent_group.FrkmetaT)_v_depth _v_parent_v_name)group parent_groupcurrentparents r\rrsk ~~...G   Q "" \ !goo&?##   Q  r^cjeZdZUdZded<ded< d2 d3dZd4dZed Zed4d Z d5d Z d6d Z d6d Z d7dZ d8dZd9dZd4dZd:dZ d;dZddZd?dZd@dAdZdBdZedCdZdDdEdZd5dZ dF dGdZ dH dIdZ dJ dKdZ dL dMdZ dN dOd ZdHd6d!Z dP dQd"Z! dR dSd#Z" dH dTd$Z#dUd%Z$dVdWd&Z%dXd'Z&dYd(Z' dZ d[d)Z(d4d*Z)dBd+Z*d\d,Z+ d] d^d-Z, d_ d`d.Z-dad/Z.dbd0Z/dcd1Z0y)draS Dict-like IO interface for storing pandas objects in PyTables. Either Fixed or Table format. .. warning:: Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the "fixed" format. Loading pickled data received from untrusted sources can be unsafe. See: https://docs.python.org/3/library/pickle.html for more. Parameters ---------- path : str File path to HDF5 file. mode : {'a', 'w', 'r', 'r+'}, default 'a' ``'r'`` Read-only; no data can be modified. ``'w'`` Write; a new file is created (an existing file with the same name would be deleted). ``'a'`` Append; an existing file is opened for reading and writing, and if the file does not exist it is created. ``'r+'`` It is similar to ``'a'``, but the file must already exist. complevel : int, 0-9, default None Specifies a compression level for data. A value of 0 or None disables compression. complib : {'zlib', 'lzo', 'bzip2', 'blosc'}, default 'zlib' Specifies the compression library to be used. These additional compressors for Blosc are supported (default if no compressor specified: 'blosc:blosclz'): {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy', 'blosc:zlib', 'blosc:zstd'}. Specifying a compression library which is not available issues a ValueError. fletcher32 : bool, default False If applying compression use the fletcher32 checksum. **kwargs These parameters will be passed to the PyTables open_file method. Examples -------- >>> bar = pd.DataFrame(np.random.randn(10, 4)) >>> store = pd.HDFStore('test.h5') >>> store['foo'] = bar # write to HDF5 >>> bar = store['foo'] # retrieve >>> store.close() **Create or load HDF5 file in-memory** When passing the `driver` option to the PyTables open_file method through **kwargs, the HDF5 file is loaded or created in-memory and will only be written when closed: >>> bar = pd.DataFrame(np.random.randn(10, 4)) >>> store = pd.HDFStore('test.h5', driver='H5FD_CORE') >>> store['foo'] = bar >>> store.close() # only now, data is written to disk z File | None_handlerf_modeNc d|vr tdtd}|;||jjvr#td|jjd|||jj}t ||_|d}||_d|_|r|nd|_ ||_ ||_ d|_ |jd d|i|y) Nrz-format is not a defined argument for HDFStorerzcomplib only supports z compression.rrr)rrfilters all_complibsdefault_complibrB_pathrr _complevel_complib _fletcher32_filtersopen)selfrrrr fletcher32rrs r\__init__zHDFStore.__init__7s v LM M+H5  7&..2M2M#M()D)D(E]S  ?y4nn44G#D) <D  '0)a %  &t&v&r^c|jSr`rrs r\ __fspath__zHDFStore.__fspath__Xs zzr^cj|j|jJ|jjS)zreturn the root node)_check_if_openrrootrs r\rz HDFStore.root[s0 ||'''||   r^c|jSr`rrs r\filenamezHDFStore.filenameb zzr^c$|j|Sr`)getrrs r\ __getitem__zHDFStore.__getitem__fsxx}r^c(|j||yr`r)rrrs r\ __setitem__zHDFStore.__setitem__is er^c$|j|Sr`)removers r\ __delitem__zHDFStore.__delitem__ls{{3r^c |j|S#ttf$rYnwxYwtdt |j d|d)z$allow attribute access to get stores'z' object has no attribute ')rKeyErrorrrtype__name__)rrhs r\ __getattr__zHDFStore.__getattr__osW 88D> !/*   T ##$$?vQ G  s %%cV|j|}||j}|||ddfvryy)zx check for existence of this key can match the exact pathname or the pathnm w/o the leading '/' NrkTF)get_noder)rrnoderhs r\ __contains__zHDFStore.__contains__ys< }}S!  ##DtT!"X&&r^c4t|jSr`)rqrrs r\__len__zHDFStore.__len__s4;;=!!r^cNt|j}t|d|dS)N File path:  )rDrr)rpstrs r\__repr__zHDFStore.__repr__s'DJJ't*]4&33r^c|Sr`rrs r\ __enter__zHDFStore.__enter__s r^c$|jyr`)r)rexc_type exc_value tracebacks r\__exit__zHDFStore.__exit__s r^c|dk(r(|jDcgc]}|jc}S|dk(rC|jJ|jjddDcgc]}|jc}St d|dcc}wcc}w)a Return a list of keys corresponding to objects stored in HDFStore. Parameters ---------- include : str, default 'pandas' When kind equals 'pandas' return pandas objects. When kind equals 'native' return native HDF5 Table objects. Returns ------- list List of ABSOLUTE path-names (e.g. have the leading '/'). Raises ------ raises ValueError if kind has an illegal value Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> store.get('data') # doctest: +SKIP >>> print(store.keys()) # doctest: +SKIP ['/data1', '/data2'] >>> store.close() # doctest: +SKIP pandasnative/Table) classnamez8`include` should be either 'pandas' or 'native' but is 'r)rrr walk_nodesr)rincludens r\keysz HDFStore.keyss< h +/;;=9aAMM9 9  <<+ ++'+||'>'>sg'>'V"#  Fwiq Q  :s B B c4t|jSr`)iterrrs r\__iter__zHDFStore.__iter__sDIIK  r^c#VK|jD]}|j|fyw)z' iterate on key->group N)rrrgs r\itemszHDFStore.itemss, #A--" " #s')c Zt}|j|k7rP|jdvr|dvrn6|dvr2|jr&td|jd|jd||_|jr|j |j rN|j dkDr?tj|j |j|j|_ tr|jr d }t||j|j|jfi||_y ) 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. )rw)rr)rzRe-opening the file [z ] with mode [z] will delete the current file!r)rzGCannot open HDF5 file, which is already opened, even in read-only mode.N)rrrrrrrFiltersrrrrr open_filer)rrrrmsgs r\rz HDFStore.opens :: zzZ'DK,?<<// |= U88 DJ << JJL ??t2#I--4;K;K.DM -* S/ !'v'' DJJI&I r^c^|j|jjd|_y)z0 Close the PyTables file handle N)rrrs r\rzHDFStore.closes% << # LL    r^cZ|jyt|jjS)zF return a boolean indicating whether the file is open F)rboolisopenrs r\rzHDFStore.is_opens& << DLL''((r^c|jc|jj|rFtt5t j |jj dddyyy#1swYyxYw)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)rflushrrrfsyncfileno)rr!s r\r zHDFStore.flush sf << # LL   g&4HHT\\002344 $44s .A11A:ct5|j|}|td|d|j|cdddS#1swYyxYw)a  Retrieve pandas object stored in file. Parameters ---------- key : str Returns ------- object Same type as object stored in file. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> store.get('data') # doctest: +SKIP >>> store.close() # doctest: +SKIP NNo object named in the file)rrr _read_grouprrrs r\rz HDFStore.getsV*^ +MM#&E}!1#lCDD##E*  + + +s 3AAc  |j|} | td|dt|d}|j|  j  fd} t | | | j ||||| } | jS)a6 Retrieve pandas object stored in file, optionally based on where criteria. .. warning:: Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the "fixed" format. Loading pickled data received from untrusted sources can be unsafe. See: https://docs.python.org/3/library/pickle.html for more. Parameters ---------- key : str Object being retrieved from file. where : list or None List of Term (or convertible) objects, optional. start : int or None Row number to start selection. stop : int, default None Row number to stop selection. columns : list or None A list of columns that if not None, will limit the return columns. iterator : bool or False Returns an iterator. chunksize : int or None Number or rows to include in iteration, return an iterator. auto_close : bool or False Should automatically close the store when finished. Returns ------- object Retrieved object from file. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> store.get('data') # doctest: +SKIP >>> print(store.keys()) # doctest: +SKIP ['/data1', '/data2'] >>> store.select('/data1') # doctest: +SKIP A B 0 1 2 1 3 4 >>> store.select('/data1', where='columns == A') # doctest: +SKIP A 0 1 1 3 >>> store.close() # doctest: +SKIP r$r%rkrlc.j|||S)N)rrrrr)read)_start_stop_whererr[s r\funczHDFStore.select..funcs66U&'6R Rr^rrnrowsrrrrr)rrru_create_storer infer_axes TableIteratorr0 get_result) rrrrrrrrrrrr.itr[s ` @r\rzHDFStore.select<s@ c" =-cU,?@ @U2    &  S  ''!  }}r^ct|d}|j|}t|ts t d|j |||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 rkrlz&can only read_coordinates with a tablerrrr)ru get_storerrWr rread_coordinates)rrrrrrtbls r\select_as_coordinateszHDFStore.select_as_coordinatessL4U2ooc"#u%DE E##%u4#HHr^c|j|}t|ts td|j |||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)columnrr)r8rWr r read_column)rrr=rrr:s r\ select_columnzHDFStore.select_columns>Fooc"#u%?@ @fEEEr^c t|d}t|ttfrt |dk(r|d}t|t r|j ||||||| St|ttfs tdt |s td||d}|D cgc]} |j| c} |j|} d} tj| |fgt|D]d\} } | td| d | jstd | jd | | j } K| j | k7s[td Dcgc]}t|t"s|}}|D chc]} | j$ddc} j'fd }t)|| ||| |||||  }|j+dScc} wcc}wcc} w)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 rkrlr)rrrrrrrrrzkeys must be a list/tuplez keys must have a non-zero lengthNzInvalid table []zobject [z>] is not a table, and cannot be used in all select as multiplez,all tables must have exactly the same nrows!c Dcgc]}|j|||}}t|djScc}w)NrrrrrF)axisverify_integrity)r*r5 _consolidate)r+r,r-r|objsrDrtblss r\r.z)HDFStore.select_as_multiple..func?sR VWFOD $TEBOOQ Q sAr/T) coordinates)rurWrnrorqrfrrrr8 itertoolschainzipris_tablepathnamer0r non_index_axespopr3r4)rrrrselectorrrrrrrkr[r0r|x_tblsr.r5rDrHs ` @@r\select_as_multiplezHDFStore.select_as_multiples VU2 dT5M *s4yA~7D dC ;;!#%  $u .78 84y?@ @  AwH-11q"1 OOH %OOa]OSt_E QDAqy1566::qzzl+)) }E! !OPP Q !9qJq%$8991661  #A&6::< R  !  }}}..g2*:7s%G!G7GG#c|tdxsd}|j|}|j||||||||| | | | | |y)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 `__. encoding : str, default None Provide an encoding for strings. track_times : bool, default True Parameter is propagated to 'create_table' method of 'PyTables'. If set to False it enables to have the same h5 files (same hashes) independent on creation time. dropna : bool, default False, optional Remove missing values. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP Nio.hdf.default_formatry) rrrrrrrrrcr track_timesr)r_validate_format_write_to_group)rrrrrrrrrrrrcrrXrs r\rz HDFStore.putZsgp > 78CGF&&v.   %%#  r^ct|d} |j|}tj|||rjjdyjs t d|j|||S#t$rt$rt$rB}| t d||j |}||jdYd}~yYd}~d}~wwxYw) 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 rkrlNz5trying to remove a node with a non-None where clause!T recursivez7can only remove with where on objects written as tablesr7) rur8rAssertionError Exceptionrr _f_removecomall_nonerrMdelete)rrrrrrr[errrs r\rzHDFStore.removes*U2 $A. <<ud + GG    -:: M88%u48@ @?       K ==%D.  sA??C3CCc| td| td}|tdxsd}|j|}|j||||||||| | | | ||||y)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 `__. min_itemsize : dict of columns that specify minimum str sizes nan_rep : str to use as str nan representation chunksize : size to chunk the writing expectedrows : expected TOTAL row size of this table encoding : default None, provide an encoding for str dropna : bool, default False, optional Do not write an ALL nan row to the store settable by the option 'io.hdf.dropna_table'. Notes ----- Does *not* check if data being appended overlaps with existing data in the table, so be careful Examples -------- >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df1, format='table') # doctest: +SKIP >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B']) >>> store.append('data', df2) # doctest: +SKIP >>> store.close() # doctest: +SKIP A B 0 1 2 1 3 4 0 5 6 1 7 8 Nz>columns is not a supported keyword in append, try data_columnszio.hdf.dropna_tablerWrz)raxesrrrrrrr expectedrowsrrrcr)rrrYrZ)rrrrrfrrrrrrrrrgrrrcrs r\rzHDFStore.appendsR  P  > 56F > 78CGF&&v.   %%%!  r^c | tdt|ts td||vr tdt t t tjt ttz }d} g} |jD](\} } | | td| } | j| *| Wj|} | jt| }t!| j#|}| j%||| <|||}|rKfd|j'D}t |}|D]}|j)|}j*||j-dd}|jD]e\} } | |k(r|nd}j/| |}|)|jDcic] \}}|| vs ||c}}nd}|j0| |f||d |gycc}}w) 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 dictzz.HDFStore.append_to_multiple..s)ODE$K&&5&177Os),rrD)rr)rrWdictrnextrsetrangendim _AXES_MAPrrextendrf differencer.sorted get_indexertakevalues intersectionlocrPreindexr)rdrrQrrfrrrD remain_key remain_valuesrRvorderedorddidxs valid_indexrrdcvalrfiltereds ` r\append_to_multiplezHDFStore.append_to_multipleEs4>  B  !T")  1 O  DU5::./#iU 6L2MMNO  GGI (DAqy)$V $$Q' (  !jj&G%%eM&:;D'--d34D#LL.AjM  X;L OAHHJODt*K >)66u=  >IIk*Ezz.$7 GGI RDAq!"hDB----C +1=0B0B0DQ eqeQ  DKK3 QRh Q& Q RRs G<G<ct|j|}|yt|ts t d|j |||y)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)roptlevelkind)rr8rWr r create_index)rrrrrr[s r\create_table_indexzHDFStore.create_table_indexsG>  OOC  9 !U#OP P wEr^ct|j|jJtJ|jj Dcgc]}t |tj jsYt|jdds@t|dds3t |tjjr|jdk7r|c}Scc}w)a Return a list of all the top-level nodes. Each node returned is not a pandas storage object. Returns ------- list List of objects. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> print(store.groups()) # doctest: +SKIP >>> store.close() # doctest: +SKIP [/data (Group) '' children := ['axis0' (Array), 'axis1' (Array), 'block0_values' (Array), 'block0_items' (Array)]] N pandas_typerz) rrrr walk_groupsrWlinkLinkgetattr_v_attrsrzr rrs r\rzHDFStore.groupss,   ||'''%%%\\--/  q*//"6"67AJJ t<q'40"1j&6&6&<&<=!))wBV    s BCc#LKt|j|jJtJ|jj |D]}t |j ddg}g}|jjD]w}t |j dd}|At|tjjsA|j|j]|j|jy|jjd||fyw)a Walk the pytables group hierarchy for pandas objects. This generator will yield the group path, subgroups and pandas object names for each group. Any non-pandas PyTables objects that are not a group will be ignored. The `where` group itself is listed first (preorder), then each of its child groups (following an alphanumerical order) is also traversed, following the same procedure. Parameters ---------- where : str, default "/" Group where to start walking. Yields ------ path : str Full path to a group (without trailing '/'). groups : list Names (strings) of the groups contained in `path`. leaves : list Names (strings) of the pandas objects contained in `path`. Examples -------- >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df1, format='table') # doctest: +SKIP >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B']) >>> store.append('data', df2) # doctest: +SKIP >>> store.close() # doctest: +SKIP >>> for group in store.walk(): # doctest: +SKIP ... print(group) # doctest: +SKIP >>> store.close() # doctest: +SKIP Nrr)rrrrrrr _v_childrenr{rWrGrouprrrrstrip)rrrrrleaveschildrs r\walkz HDFStore.walksN   ||'''%%%))%0 >Aqzz=$7CFF--/ 1%ennmTJ &!%)9)9)?)?@ emm4MM%--0  1=='',ff= = >s CD$AD$cf|j|jdsd|z}|jJtJ |jj |j |}t|tjsJt||S#tj j$rYywxYw)z9return the node with the key or None if it does not existrN) r startswithrrrr exceptionsNoSuchNodeErrorrWrKr)rrrs r\rzHDFStore.get_node1s ~~c")C||'''%%% <<((C8D$ 0<$t*<0 $$44  s&BB0/B0c|j|}|td|d|j|}|j|S)z !((+{{1~a'.3E"12 HA1<< H H$$#%,Q%E!" %MM!TAJJM?) @,!Is (D:DcXt|j}t|d|d}|jrt |j }t |rwg}g}|D]\} |j|}|F|jt|jxs||jt|xsd^|td||z }|S|dz }|S|d z }|S#t$rt$r;}|j|t|} |jd| dYd}~d}~wwxYw) a Print detailed information on the store. Returns ------- str Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> print(store.info()) # doctest: +SKIP >>> store.close() # doctest: +SKIP File path: store.h5 /data frame (shape->[2,2]) rrNzinvalid_HDFStore nodez[invalid_HDFStore node: rA EmptyzFile is CLOSED) rDrrrrxrrqr8rrNr^r_rC) rroutputlkeysrr{rRr[detaildstrs r\infoz HDFStore.infos9&DJJ'J<}TF"5 <<499;'E5z JA J OOA.= KK QZZ_1(EF"MM,q7S,value->z ,format->rcr series_tablerrkappendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)rrrrrwormz)rWr2r,rr]rrrrrzr  SeriesFixed FrameFixedrrnlevels GenericTableAppendableSeriesTableAppendableMultiSeriesTableAppendableFrameTableAppendableMultiFrameTable WORMTable) rrrrrcrpttt _STORER_MAPclsrdr _TABLE_MAPs r\r1zHDFStore._create_storersY  Z 7J%KFG G WU^^]DI J WU^^\4H I :} !---5'40J:++115'B(B#1 eV,!B BW$(NB " %0:FK !"o tUXfE E : '#E7D9E( ==A-!4B"]]Q.!9B=(#E7D9E( ==A-!3B"]]Q.!8B*!6&@ 4%>   R.C4&AAU SgXd5k])F8E H N'$u+ixA  s0,F#G# G,G  G G>G99G>ct|ddr|dk(s|ry|j||}|j|||||}|rQ|jr|jr|dk(r|jr t d|js!|j n|j |js |r t d|j|||||| | | | | ||| t|tr|r|j|yyy) NemptyrzrryzCan only append to Tablesz0Compression not supported on Fixed format stores) objrfrrrrrrrgrrrrX)r) r_identify_groupr1rM is_existsrset_object_infowriterWr r)rrrrrfrrrrrrrrgrrrrcrrXrr[s r\rZzHDFStore._write_to_group$s. 5'4 (f.?6 $$S&1   vuxPV  W ::!**71Bq{{ !<==;;!!#   zzgOP P !%%%#  a E NN5N )%* r^cd|j|}|j|jSr`)r1r2r*)rrr[s r\r&zHDFStore._read_groupbs&    & vvxr^c|j|}|jJ|!|s|jj|dd}||j|}|S)z@Identify HDF5 group based on key, delete/create group if needed.NTr\)rr remove_node_create_nodes_and_group)rrrrs r\rzHDFStore._identify_groupgsb c"||'''  V LL $ $Ud $ ;E =005E r^c |jJ|jd}d}|D]\}t|s|}|jds|dz }||z }|j |}||jj ||}|}^S)z,Create nodes from key and return group name.r)rsplitrqendswithr create_group)rrpathsrpnew_pathrs r\rz HDFStore._create_nodes_and_groupys||''' # Aq6H==%C MHMM(+E} 11$:D  r^)rNNF)rrfr int | NonerrreturnNonerrfrrf)rrfrr)rhrf)rrfrrrint)rrQ)rztype[BaseException] | NonerzBaseException | NonerzTracebackType | Nonerr)r)r rfr list[str])rz Iterator[str])rzIterator[tuple[str, list]])r)rrfrrrrrrF)r!rrr)NNNNFNF)rrfrrrrrrNNNrrfrrrrNN)rrfr=rfrrrr)NNNNNFNF)rrrrrr) NTFNNNNNNrTF)rrfrDataFrame | Seriesrrrrrrrint | dict[str, int] | Noner Literal[True] | list[str] | NonerrfrXrrrrr)NNTTNNNNNNNNNNr)rrfrrrbool | list[str]rrrrrrrrr bool | Nonerrrrfrr)NNF)rrprrrr)rrfrrr str | Nonerr)rrn)r)rrrfrz*Iterator[tuple[str, list[str], list[str]]])rrfrz Node | None)rrfrGenericFixed | Table)rTNNNFT) rrfrrrrrrrrrr)rrfrrf)NNrUr)rzDataFrame | Series | Nonercrfrrfrr)NTFNNNNNNFNNNrT)rrfrrrrrrrrrrrrrrrrfrXrrr)rrK)rrfrrrrK)rrfrrK)1r __module__ __qualname____doc____annotations__rrpropertyrrrrrrrrrrrrrrrrrr rrr;r?rUrrrrrrrrr8rrrrYr1rZr&rrrr^r\rrs??B J  $ '' '  ' 'B!!    "4,((   ( T!#+JZ))4,+@  $ [ [[[[@  I I I  IH! &F &F&F &F  &FV  $ w/w/w/w/z $489= J J "J  J  J J 2J 7J J J J !J X7Az "& $48 $"9=%d d "d  d d d 2d d d 7!d $%d & 'd V _R _R_R _RH# &F &F &F  &F  &FP% N:>x   $ 99 9999 9v0jE+/ YB) YB  YB  YB YB@"& $48 $ '<* <*"<*  <*<*<*2<*<*<*$%<*&'<*( )<*| $r^rcteZdZUdZded<ded<ded< d dd Zdd Zdd Zddd Zy)r3aa 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. rrrrrr[Nc ,||_||_||_||_|jjr|d}|d}||}t ||}||_||_||_d|_ |s| | d} t| |_ | |_ yd|_ | |_ y)Nr順) rr[r.rrrMminr0rrrIrrr) rrr[r.rrr0rrrrrs r\rzTableIterator.__init__s    66??}}|ud#D    y, "  ^DN%"DN$r^c#^K|j}|j td||jkrgt ||j z|j}|j dd|j||}|}| t|sb|||jkrg|jyw)Nz*Cannot iterate until get_result is called.) rrIrrrrr.rqr)rrrrs r\rzTableIterator.__iter__s**    #IJ J !w/;DIIdD$*:*:74*HIEG}CJK ! s BB-B-cR|jr|jjyyr`)rrrrs r\rzTableIterator.closes ?? JJ    r^c|jRt|jts t d|jj |j |_|S|rbt|jts t d|jj |j |j|j}n |j }|j|j|j|}|j|S)Nz0can only use an iterator or chunksize on a table)rrz$can only read_coordinates on a tabler7) rrWr[r rr9rrrIrrr.r)rrIrrresultss r\r4zTableIterator.get_results >> %dffe, RSS#vv66TZZ6HD K dffe, FGGFF++jj ,EJJE))DJJ 59 r^)NNFNF) rrr[rrrrrrrrrrrFrr)rIr) rrrrrrrrr4rr^r\r3r3sz& O  $ (%(% (%(%(%(% (%T r^r3creZdZUdZdZded<dZded<gdZ d! d"dZe d#d Z e d$d Z d%d Z d$d Z d&d Zd'dZe d'dZ d(dZdZe dZe dZe dZe dZd)dZd*d+dZd+dZd,dZd*dZd-dZd+dZd+dZd+dZd.dZ d.d Z!y)/IndexCola an index column description class Parameters ---------- axis : axis which I reference values : the ndarray like converted values kind : a string description of this type typ : the pytables type pos : the position in the pytables Tris_an_indexableis_data_indexable)freqtz index_nameNct|ts td||_||_||_||_|xs||_||_||_ ||_ | |_ | |_ | |_ | |_| |_||_||j#|t|j tsJt|jtsJy)Nz`name` must be a str.)rWrfrr{rtyprhcnamerDposr r rrrzrmetadataset_pos)rrhr{rrrrDrr r rrrzrrs r\rzIndexCol.__init__s"$$45 5   ]d   $     ? LL $))S)))$**c***r^c.|jjSr`)ritemsizers r\rzIndexCol.itemsize<sxx   r^c |jdS)N_kindrgrs r\ kind_attrzIndexCol.kind_attrA))E""r^cT||_||j||j_yyy)z,set the position of this column in the TableN)rr_v_pos)rrs r\rzIndexCol.set_posEs) ?txx3!DHHO 4?r^c ttt|j|j|j |j |jf}djtgd|Dcgc] \}}|d|c}}Scc}}w)N,)rhrrDrr->) romaprDrhrrDrrjoinrLrtemprrs r\rzIndexCol.__repr__Ks}  tyy$**dii499U V xx#&&NPT"U C%r%!    -B c0tfddDS)compare 2 col itemsc3TK|]}t|dt|dk(!ywr`rrlrotherrs r\rnz"IndexCol.__eq__..X0  D!T "geQ&= = %()rhrrDrrjrr*s``r\__eq__zIndexCol.__eq__Vs 5   r^c&|j| Sr`)r/r.s r\__ne__zIndexCol.__ne__]s;;u%%%r^ct|jdsyt|jj|jj S)z%return whether I am an indexed columnrmF)hasattrrzrrmrrrs r\rzIndexCol.is_indexed`s4tzz6*tzz 3>>>r^c t|tjsJt||jj ||j j}t|j}t||||}i}t|j|d<|jt|j|d<t}tj|jdst|jt rt"}n|jdk(rd|vrd} ||fi|}t5||j6} | | fS#t$$r`} |dk(rPt'drEt)| j+d r+t,r%||fd t/d tj0 i|}nYd} ~ ~d} ~ wt2$rd|vrd|d<||fi|}YwxYw) zV Convert the data from this selection to the appropriate pandas type. Nrhr Mi8cttj||jddj|dS)Nr )r rh)r0 from_ordinalsr_rename)rSkwdss r\rz"IndexCol.convert..s5 (A(A.)gV r^ surrogatepassfuture.infer_stringsurrogates not alloweddtypepythonstoragena_value)rWrXndarrayrr>fieldsrrr]r_maybe_convertrr r.r is_np_dtyper(r-UnicodeEncodeErrorrrfrrr3nanr_set_tzr ) rr{rrcrval_kindrfactory new_pd_indexrdfinal_pd_indexs r\convertzIndexCol.converths &"**-;tF|;- <<   *DJJ',,.F"499-(FC(9v 99 ,TYY7F6N/4 ??6<< - LL/2 $G \\T !f&6 G 5"64V4L*!tww7~--+" /)45H%%&>?& %hH     5!%v"64V4L  5s E G AF$$GGc|jS)zreturn the valuesr{rs r\ take_datazIndexCol.take_datas {{r^c.|jjSr`)rzrrs r\attrszIndexCol.attrszz"""r^c.|jjSr`rz descriptionrs r\rWzIndexCol.descriptionzz%%%r^cDt|j|jdS)z!return my current col descriptionN)rrWrrs r\colz IndexCol.colst''T::r^c|jSzreturn my cython valuesrPrs r\cvalueszIndexCol.cvaluess{{r^c,t|jSr`)rr{rs r\rzIndexCol.__iter__sDKK  r^ct|jdk(rst|tr|j |j }|E|j j|kr+tj||j|_yyyy)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)rr) r]rrWrprrhrrr StringColr)rrs r\maybe_set_sizezIndexCol.maybe_set_sizesu 499 % 1,-+// : 'DHH,=,= ,L"9.. $((.S-M' 2r^cyr`rrs r\validate_nameszIndexCol.validate_names r^c|j|_|j|j||j||j ||j yr`)rz validate_col validate_attrvalidate_metadatawrite_metadataset_attr)rhandlerrs r\validate_and_setzIndexCol.validate_and_setsL]]   6" w' G$ r^c t|jdk(r`|j}|R| |j}|j|kr)t d|d|j d|jd|jSy)z:validate this column: return the compared against itemsizer`Nz#Trying to store a string with len [z] in [z)] column but this column has a limit of [zC]! Consider using min_itemsize to preset the sizes on these columns)r]rrZrrr)rrcs r\rgzIndexCol.validate_cols 499 % 1A}##}}H::($=hZH JJ<(JJ<(<< zz!r^c|rPt|j|jd}|,||jk7rt d|d|jdyyy)Nzincompatible kind in col [ - rA)rrSrrr)rr existing_kinds r\rhzIndexCol.validate_attrs] #DJJEM(]dii-G0s499+QO.H( r^c |jD]}t||d}|j|ji}|j |}||vrp|n||k7ri|dvrCt |||fz}t j|ttd||<t||dtd|jd|d|d|d |||||<y) z set/update the info for this indexable with the key/value if there is a conflict raise/warn as needed N)r r stacklevelzinvalid info for [z] for [z], existing_value [z] conflicts with new value [rA) _info_fieldsr setdefaultrhrrwwarningswarnrr setattrr)rrrridxexisting_valuewss r\ update_infozIndexCol.update_infos $$ !CD#t,E//$))R0C WWS\Ncze/Ne4K00/32NNBMM4AQAS $CHD#t,%,TYYKwseD++9*:;&&+WA/ "n&@ C1 !r^cv|j|j}||jj|yy)z!set my state from the passed infoN)rrh__dict__update)rrr{s r\set_infozIndexCol.set_info s0hhtyy! ? MM  % r^cZt|j|j|jy)zset the kind for this columnN)rzrSrrrs r\rkzIndexCol.set_attr s DNNDII6r^c|jdk(rH|j}|j|j}||t ||dds t dyyyy)z:validate that kind=category does not change the categoriescategoryNT strict_nan dtype_equalzEcannot append a categorical with different categories to the existing)rr read_metadatarr+r)rrl new_metadata cur_metadatas r\rizIndexCol.validate_metadata sp 99 "==L"00. >.58>.BE>. <>.@##&&;;! T &!>& 7">r^r cBeZdZdZeddZ ddZddZy) GenericIndexColz:an index which is not represented in the data of the tablecyNFrrs r\rzGenericIndexCol.is_indexed8 r^ct|tjsJt|t t |}||fS)z Convert the data from this selection to the appropriate pandas type. Parameters ---------- values : np.ndarray nan_rep : str encoding : str errors : str )rWrXrCrr1rq)rr{rrcrrs r\rNzGenericIndexCol.convert< s9&"**-;tF|;-3v;'e|r^cyr`rrs r\rkzGenericIndexCol.set_attrN rer^Nr)r{rrcrfrrfrztuple[Index, Index]r)rrrrrrrNrkrr^r\rr5 sAD  58BE $ r^rc<eZdZdZdZdZddgZ d dfd ZeddZ eddZ ddZ dd Z dd Z d Zedd Zed ZeddZeddZedZedZedZedZddZd dZddZxZS)!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 rc Vt|||||||||| | |  | |_| |_y)N) rhr{rrrrr rrzrr)superrr>r)rrhr{rrrrr rrzrrr>r __class__s r\rzDataCol.__init__c sH     r^c |jdS)N_dtypergrs r\ dtype_attrzDataCol.dtype_attr s))F##r^c |jdS)N_metargrs r\ meta_attrzDataCol.meta_attr rr^c ttt|j|j|j |j |jf}djtgd|Dcgc] \}}|d|c}}Scc}}w)Nr)rhrr>rshaper) ror rDrhrr>rrr!rLr"s r\rzDataCol.__repr__ s tyy$**djj$))TZZX   xx#&&QSW"X C%r%!    r$c0tfddDS)r&c3TK|]}t|dt|dk(!ywr`r(r)s r\rnz!DataCol.__eq__.. r+r,)rhrr>rr-r.s``r\r/zDataCol.__eq__ s 6   r^c|J|jJt|\}}||_||_t||_yr`)r>_get_data_and_dtype_namer_dtype_to_kindr)rr dtype_names r\set_datazDataCol.set_data sGzz!!!3D9j  ":. r^c|jS)zreturn the datarrs r\rQzDataCol.take_data s yyr^c|j}|j}|j}|jdk(rd|jf}t |t r5|j}|j||jj}|Stj|dst |tr|j|}|Stj|dr|j|}|St|r t!j#||d}|St%|r|j'||}|S|j||j}|S)zW Get an appropriately typed and shaped pytables.Col object for values. rkrr5mrrr)r>rrrtsizerWr7codes get_atom_datarhrrFr(get_atom_datetime64get_atom_timedelta64r#r ComplexColr%get_atom_string)rr{r>rrratoms r\ _get_atomzDataCol._get_atom s<  >>  ;;!  $E fk *LLE$$U1A1A$BD __UC (Juo,N**51D __UC (++E2D e $9''q'JD  U #&&uh7D $$U$tj||dS)Nrrrrarrrs r\rzDataCol.get_atom_string sy""HE!H"EEr^c|jdr |dd}d|d}n)|jdrd}n|j}|d}tt|S)z0return the PyTables column class for this columnuintNUIntrIperiodInt64Col)r capitalizerr)rrk4col_namekcaps r\get_atom_coltypezDataCol.get_atom_coltype s_ ??6 "abBbT~H __X &!H??$Ds|Hwy(++r^c:|j||dS)Nrrrrrrrs r\rzDataCol.get_atom_data s!.s###.U1X>>r^c<tj|dSNrrrrrrs r\rzDataCol.get_atom_datetime64 y!!a!11r^c<tj|dSrrrs r\rzDataCol.get_atom_timedelta64 rr^c0t|jddS)Nr)rrrs r\rz DataCol.shape styy'400r^c|jSr\rrs r\r]zDataCol.cvalues syyr^c|rt|j|jd}|#|t|jk7r t dt|j|j d}|||jk7r t dyyy)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!)rrSrrnr{rrr>)rrexisting_fieldsexisting_dtypes r\rhzDataCol.validate_attr s %djj$..$GO*$t{{BS/S !WXX$TZZ$GN)n .J V/K) r^c t|tjsJt||jj ||j }|jJ|jt|\}}t|}n|}|j}|j}t|tjsJt|j}|j} |j} |j} |Jt|} | j!drt#|| d}n | dk(rtj$|d}n| dk(r> tj$|D cgc]} t'j(| c} t*}n|dk(r| }|j1}|t3gtj4}n\t7|}|j9rA||}||d k7xx|j;t<j?j@zcc<tCjD||| d }n |j;| d }t|dk(rtI||||}|jJ|fScc} w#t,$rEtj$|D cgc]} t'j.| ncc} wc} t*}Y}wxYw#tF$r|j;d d }YwxYw)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 datetime64Tcoerce timedelta64m8[ns]r>rrF) categoriesrvalidaterOr`rrcr)&rWrXrCrr>rDrrrrrr]rrrr rrIasarrayr fromordinalrr fromtimestampravelr.float64r6anyastypercumsum_valuesr7 from_codesr_unconvert_string_arrayr{)rr{rrcr convertedrrrrrr r>rrrmasks r\rNzDataCol.convert s &"**-;tF|;- <<   *DJJ'Fxx### :: %=V$D !Iz!*-DIJ99D)RZZ000tyy)==,, WW%%% +   L ) 2d;I m # 9H=I f_ JJ2;%,,U,? 4 H ,/7XfI{{I%%W= JJ4=>qT''*>>f  @ >%,,Su,=  >sBI3I.6 I30K.I33KJ, +KKK#"K#c"t|j|j|jt|j|j|j |j Jt|j|j|j y)zset the data for this columnN)rzrSrr{rrr>rrs r\rkzDataCol.set_attrf sZ DNNDKK8 DNNDII6zz%%% DOOTZZ8r^) NNNNNNNNNNNN)rhrfrrr>zDtypeArg | Nonerrrr)rrMrr)r{rMrrI)rrfrz type[Col]rrfrrIr)r{rrcrfrrf)rrrrr r rvrrrrrr/rrQ classmethodrrrrrrrr]rhrNrk __classcell__rs@r\rrR s` O)$L      !%    @$$##   />FF , ,??222211 b&H9r^rc^eZdZdZdZd dZedZed dZedZ edZ y) DataIndexableColz+represent a data column that can be indexedTcjtt|jjs t dy)N-cannot have non-object label DataIndexableCol)r%r.r{r>rrs r\rdzDataIndexableCol.validate_namess s*uT[[1778LM M9r^c6tj|S)N)rrrs r\rz DataIndexableCol.get_atom_stringx sy""H"55r^c0|j|S)Nrrrs r\rzDataIndexableCol.get_atom_data| s.s###.00r^c2tjSr`rrs r\rz$DataIndexableCol.get_atom_datetime64 y!!##r^c2tjSr`rrs r\rz%DataIndexableCol.get_atom_timedelta64 rr^Nrr) rrrrr rdrrrrrrr^r\rrn sa5N 6611$$$$r^rceZdZdZy)GenericDataIndexableColz(represent a generic pytables data columnN)rrrrrr^r\rr s2r^rceZdZUdZded<dZded<ded<ded <d ed <d Zd ed< d) d*dZed+dZ ed,dZ edZ d-dZ d.dZ d/dZedZedZedZedZed0dZed+dZedZd.dZd.dZedZed+d Zed!Zd1d"Zd2d.d$Zd+d%Z d3 d4d&Zd.d'Z d5 d6d(Z y#)7Fixedz 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. rf pandas_kindry format_typetype[DataFrame | Series]obj_typerrtrrFrrMct|tsJt|tJt|tjsJt|||_||_t||_||_ yr`) rWrrrrKrrrdrcr)rrrrcrs r\rzFixed.__init__ sg&(+9T&\9+%%%%1>4;>1  (2  r^cv|jddkxr&|jddkxr|jddkS)Nrrk )versionrs r\is_old_versionzFixed.is_old_version s:||A!#U Q2(=U$,,q/TUBUUr^ctt|jjdd} t d|j dD}t |dk(r|dz}|S#t$rd}Y|SwxYw)zcompute and set our versionpandas_versionNc32K|]}t|ywr`)r)rlrSs r\rnz Fixed.version.. s?qCF?s.r )r)rrr)r]rrrrorrqr)rr s r\r z Fixed.version sx"'$***=*=?OQU"VW ?GMM#,>??G7|q !D. G s4A"" A10A1cVtt|jjddS)Nr)r]rrrrs r\rzFixed.pandas_type s wtzz':':M4PQQr^c|j|j}|Wt|ttfr.dj |Dcgc] }t |c}}d|d}|jdd|dS|jScc}w)(return a pretty representation of myselfr[rA12.12z (shape->))r2rrWrnror!rDr)rr[rSjshapes r\rzFixed.__repr__ s  JJ =!dE]+A">q<?">?xqM&&u-Yqc; ;#?sBct|j|j_tt|j_y)zset my pandas type & versionN)rfrrSr_versionrrs r\rzFixed.set_object_info s)!$T%5%5!6 $'M !r^c0tj|}|Sr`r)rnew_selfs r\rz Fixed.copy s99T?r^c|jSr`)r0rs r\rz Fixed.shape rr^c.|jjSr`rrrs r\rNzFixed.pathname rXr^c.|jjSr`)rrrs r\rz Fixed._handle s{{"""r^c.|jjSr`)rrrs r\rzFixed._filters s{{###r^c.|jjSr`)rrrs r\rzFixed._complevel s{{%%%r^c.|jjSr`)rrrs r\rzFixed._fletcher32 s{{&&&r^c.|jjSr`)rrrs r\rSz Fixed.attrs rTr^cyzset our object attributesNrrs r\ set_attrszFixed.set_attrs r^cy)zget our object attributesNrrs r\ get_attrszFixed.get_attrs r(r^c|jS)zreturn my storablerrs r\storablezFixed.storable szzr^cyrrrs r\rzFixed.is_exists rr^c0t|jddS)Nr0)rr-rs r\r0z Fixed.nrows st}}gt44r^c |yy)z%validate against an existing storableNTrr.s r\rzFixed.validate s =r^Ncy)+are we trying to operate on an old version?Nr)rrrs r\validate_versionzFixed.validate_version r(r^cB|j}|y|jy)zr infer the axes of my storer return a boolean indicating if we have a valid storer or not FT)r-r*)rr[s r\r2zFixed.infer_axes s" MM 9 r^ctd)Nz>cannot read on an abstract storer: subclasses should implementrrrrrrrs r\r*z Fixed.read s" L  r^c td)Nz?cannot write on an abstract storer: subclasses should implementr6rrrs r\rz Fixed.write& s! M  r^ctj|||r(|jj|jdyt d)zs support fully deleting the node in its entirety (only) - where specification must be None Tr\Nz#cannot delete on an abstract storer)rarbrrrr)rrrrrs r\rcz Fixed.delete+ s> <<ud + LL $ $TZZ4 $ @=>>r^)rUr) rrrrKrcrrrfrrr)rztuple[int, int, int]rr)rrr)rzLiteral[True] | Noner`NNNNrrrrr)rrrrrr)!rrrrrrrMrrr r rrrrrrNrrrrrSr'r*r-rr0rr3r2r*rrcrr^r\rr s K&& I Hd '        VV  RR  2 &&##$$&&''##((55 :         HL ?!+ ?:D ?  ?r^rcVeZdZUdZedediZejDcic]\}}|| c}}}ZgZ de d<ddZ dZ dZ dd Zedd Zdd Zdd Zdd ZdddZ d ddZddZddZ d ddZ d d dZd!dZ d" d#dZycc}}}w)$ GenericFixedza generified fixed versiondatetimerr attributesc:|jj|dS)N)_index_type_mapr)rrs r\_class_to_aliaszGenericFixed._class_to_aliasA s##''R00r^cft|tr|S|jj|tSr`)rWr_reverse_index_maprr.)raliass r\_alias_to_classzGenericFixed._alias_to_classD s* eT "L&&**5%88r^c R|jtt|dd}|tk(rdd}|}n|tk(rdd}|}n|}i}d|vr|d|d<|t urt }d|vr=t|dtr|djd|d<n|d|d<|tusJ||fS) N index_classrBctj|j|j|}t j|d}| |j dj |}|S)N)r>r rgUTC)r8 _simple_newr{r>r- tz_localize tz_convert)r{r r dtaresults r\r{z*GenericFixed._get_index_factory..fS sZ#//MMD'223TB>#//6AA"EF r^ctt|}tj||}tj|dS)Nrrg)r*r9rMr0)r{r r r>parrs r\r{z*GenericFixed._get_index_factory..f` s1#D)"..vUC"..t$??r^r r zutf-8r) rHr]rr-r0r.r4rWbytesrZ)rrSrJr{rKrs r\_get_index_factoryzGenericFixed._get_index_factoryJ s** GE="= > - ' G K ' @ G!G U?"6]F6Ne#( 5=%+u-$T{11':t  %T{t -/ //r^c8| td| tdy)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)rrrrs r\ validate_readzGenericFixed.validate_read{ s=  T   Y  r^cy)NTrrs r\rzGenericFixed.is_exists sr^cp|j|j_|j|j_yr&)rcrSrrs r\r'zGenericFixed.set_attrs s""mm  KK r^c tt|jdd|_t t|jdd|_|j D]-}t||t t|j|d/y)retrieve our attributesrcNrr)rdrrSrcr]rr@rz)rr s r\r*zGenericFixed.get_attrs sg(Z)NO %gdjj(H&MN  LA D!_WTZZD-IJ K Lr^c $|jyr`)r'r9s r\rzGenericFixed.write s  r^Ncddl}t|j|}|j}t|dd}t ||j r%|d||}t|dd} | t || }ntt|dd} t|dd} | tj| | }n|||}| r-| jdrt|d d} t|| d }n| d k(rtj|d }|r |jS|S)z2read an array for the specified node (off of grouprN transposedF value_typerrrr Trrr)rrrrrWVLArraypd_arrayr]rXrrrIrT) rrrrrrrSr^retr>rr s r\ read_arrayzGenericFixed.read_array stzz3' UL%8 dFNN +q'%%CE<6E s%0#GE<$FGEE7D1E hhuE25&)),7UD$/c2d3-'jjH5 55LJr^ctt|j|d}|dk(r|j|||S|dk(r,t|j|}|j |||}|St d|)N_varietymultirrregularzunrecognized index variety: )r]rrSread_multi_indexrread_index_noder)rrrrvarietyrrs r\ read_indexzGenericFixed.read_index s"'$**X6F"GH g ((E(E E  !4::s+D((U(FEL:7)DE Er^c4t|tr-t|j|dd|j ||yt|j|ddt d||j |j}|j||jt|j|}|j|j_ |j|j_t|tt fr)|j#t%||j_t|tt t(fr|j*|j_t|tr2|j,%t/|j,|j_yyy)Nrfrgrir)rWr/rzrSwrite_multi_index_convert_indexrcr write_arrayr{rrrrrhr-r0rDrrJr4r r _get_tz)rrrrrs r\ write_indexzGenericFixed.write_index s$ eZ ( DJJ3%x 0' :  " "3 . DJJ3%x 0) <&wt}}dkkRI   S)"2"2 34::s+D!*DMM !&DMM %-!=>,0,@,@e,M )%-n!MN%*ZZ "%/EHH4H#*588#4  5I/r^ct|j|d|jtt |j |j |jD]\}\}}}t|jtr td|d|}t|||j|j}|j||j t#|j$|} |j&| j(_|| j(_t| j(|d|||d|} |j| |y)N_nlevelsz=Saving a MultiIndex with an extension dtype is not supported._level_name_label)rzrSr enumeraterLlevelsrnamesrWr>r)rrprcrrqr{rrrrrh) rrrilev level_codesrh level_key conv_levelr label_keys r\rozGenericFixed.write_multi_index s  se8,emm<+4  ekk5;; 7,  5 'A'[$#))^4)S%vaS)I' 3 t{{SJ   Y (9(9 :4::y1D!+DMM !%DMM  DMMcU%v#6 =%vaS)I   Y 4) 5r^ct|j|d}g}g}g}t|D]}|d|} t|j| } |j | ||} |j | |j | j |d|} |j| ||} |j | t|||dS)NrurvrhrxT)rzrr{rE) rrSrsrrkrrhrdr/)rrrrrrzrr{r|rrr}rr~s r\rjzGenericFixed.read_multi_index s$**X&67 "w &A%vaS)I4::y1D&&t5t&DC MM#  LL "%vaS)I//)5t/LK LL % &ed  r^c |||}d|jvrktj|jjdk(r?tj|jj|jj }t |jj}d}d|jvr*t|jj}t |}|j}|j|\}} |dvr1|t|||j|jfdti| } n+ |t|||j|jfi| } || _ | S#t$r} |jdk(rqt!d rft#| j%d rLt&rF|t|||j|jfdt)d tj* i| } nYd} ~ d} ~ wwxYw) Nrrrrh)rrrr>r;r<r=r?r@)rrXprodrrr_r]rrirhrU_unconvert_indexrcrrrGrrfrrr3rH) rrrrrrrhrSrKrrrds r\rkzGenericFixed.read_index_node sE$ dmm # 0C0C(D(I88DMM//t}}7O7OPDt}}112 T]] "t}}112D"4(D 11%8 % % $t{{   E $dT]]4;; .  '& KK?2"#89C))*BC##( $t{{*(RVVL  ! E s.*E!! G5*BG00G5c@tjd|jz}|jj |j ||t |j |}t|j|j_ |j|j_ y)zwrite a 0-len array)rkN) rXrrtr create_arrayrrrfr>rr_r)rrrarrrs r\write_array_emptyzGenericFixed.write_array_emptyN sjhhtejj() !!$**c37tzz3'#&u{{#3  #kk r^c t|d}||jvr&|jj|j||jdk(}d}t |j tr td|st|dr|j}d}d}|jEtt5tjj!|j }ddd|[|sE|jj#|j|||j$|j}||ddnz|j'||nf|j j(t*j,k(rt/j0|d} |rn6| d k(rn0t2| ||fz} t5j6| t8t; |jj=|j|tj?} | jA|nt/jB|j d rp|jjE|j||jGd tI|j tK|j|jL_'nt |j tPr|jjE|j||jRtK|j|} tU|jV| jL_+d |j jXd| jL_'n_t/jB|j dr\|jjE|j||jGd dtK|j|jL_'nt |tZr|jj=|j|tj?} | jA|j]tK|j|} tI|j | jL_'n<|r|j'||n'|jjE|j|||tK|j|jL_/y#1swYxYw)NT) extract_numpyrFz]Cannot store a category dtype in a HDF5 dataset that uses format="fixed". Use format="table".rb)rskipnar`rtr5r6 datetime64[rArr)0r>rrrrrWr>r'rr3rbrrrrAtom from_dtype create_carrayrrrrXobject_r infer_dtyperxrxryrr create_vlarray ObjectAtomrrFrviewrfrrr_r(asi8rrr unitr:to_numpyr^) rrrrr empty_arrayr^rca inferred_typer}vlarrrs r\rqzGenericFixed.write_arrayW sc6 $**  LL $ $TZZ 5jjAo  ekk#3 4%/ uc"!  == $*% >y~~00= >   \\//JJT5;; 01&&sE2 [[   + OOE%@M(*$ sE'BB b"4AQASTLL// CAUAUAWXE LL  __U[[# . LL % %djj#uzz$7G H;>u{{;KGDJJ $ - - 8  _ 5 LL % % C 4::s+D 'uxx0DMM )4U[[5E5E4Fa'HDMM $ __U[[# . LL % %djj#uzz$7G H;HGDJJ $ - - 8  /LL// CAUAUAWXE LL) *4::s+D'*5;;'7DMM $   " "3 . LL % %djj#u =7A C ))4A > >s 1.SSrrrrr)rrfrrrrrr.)rrfrr.rr)rrfrr/rr)rrfrrrrrr/)rrKrrrrrr.)rrfrrMrrr`)rrfrrLrz Index | Nonerr)rrrrr-r0rCrrFr@rrDrHrUrWrrr'r*rrdrmrsrorjrkrrq)rlrRrs000r\r>r>9 sW$$j+xHO+:+@+@+BCC41a!Q$CJ 19 /b ( L#LFJ F F) F8B F  F5.54FJ  ) 8B  0HL55!+5:D5 5n*BF]B]B)]B2>]B ]BuDs B$r>cbeZdZUdZdgZded<edZ d ddZd fd Z xZ S) rrrhrEcn t|jjfS#ttf$rYywxYwr`)rqrr{rrrs r\rzSeriesFixed.shape s6  ))*, ,>*  s "44c |j|||jd||}|jd||} t|||jd}|S#t $rz}|j dk(r_tdrTt|jdr:tr4t|||jdtd tj  }nYd}~|Sd}~wwxYw) Nrrhr{F)rrhrr;r<r=r?r@)rrhrr>)rWrmrdr2rhrGrrrfrrr3rXrH) rrrrrrrr{rQrds r\r*zSeriesFixed.read s 7E*u4@TB F%diieLF" !"  .45H%%&>?%hH  ! sA C A/CCc t||fi||jd|j|j d||j |j _y)Nrr{)rrrsrrqrhrS)rrrrs r\rzSeriesFixed.write sG  c$V$ #)), 3'(( r^r;rrrrrr2r) rrrrr@rrrr*rrrs@r\rr saKJ N        <##r^rcbeZdZUddgZded<eddZ d d dZd fd ZxZ S) BlockManagerFixedrtnblocksrcn |j}d}t|jD]4}t|jd|d}t|dd}|-||dz }6|jj }t|dd}|t |d|dz }ng}|j||S#t$rYywxYw)Nrblock_itemsrrk) rtrsrrr block0_valuesrnrr)rrtrr|rrs r\rzBlockManagerFixed.shape s 99DE4<<( &tzzU1#V+<=gt4$U1X%E  &::++DD'40E U1q23 LL L  sAB(AB(( B43B4c|j|||jjd}g}t|jD]8}||k(r||fnd\}} |j d||| } |j | :|d} g} t|jD]}|j d|d} |jd|d }| | j| }t|j||dd }trPt|tjr6t!|d r)|j#t%tj& }| j |t)| dkDr=t+| dd }t-r|j/}|j1| d }|St|d|dS)NrrrDrhrrrrkFrrrTr)rB)rDr)rrrr)rWr_get_block_manager_axisrsrtrmrrrdryr,rbrrWrXrCrrr3rHrqr5rrr~)rrrrrr select_axisrfr|r+r,axrdfs blk_itemsr{dfouts r\r*zBlockManagerFixed.read s 7E*mmo==a@ tyy! A-.+-=UDMd Zd?d!Zd@d"ZdAd#Z d7d$Z!d7d%Z"dBd7d&Z#d7d'Z$e%d(Z& dC dDd)Z' dE dFd*Z(e)dGd+Z*d,Z+ dH dId-Z,e- dJd.Z.dBdKd/Z/ dLd0Z0 dC dMd1Z1 dC dNd2Z2xZ3S)Or aa represent a table: facilitate read/write of various types of tables Attrs in Table Node ------------------- These are attributes that are store in the main table node, they are necessary to recreate these tables when read back in. index_axes : a list of tuples of the (original indexing axis and index column) non_index_axes: a list of tuples of the (original index axis and columns on a non-indexing axis) values_axes : a list of the columns which comprise the data of this table data_columns : a list of the columns that we are allowing indexing (these become single columns in values_axes) nan_rep : the string to use for nan representations for string objects levels : the names of levels metadata : the names of the metadata columns wide_tablerzrfrrrkzint | list[Hashable]rzTrnrc t ||||||xsg|_|xsg|_|xsg|_|xsg|_| xsi|_| |_y)Nr)rr index_axesrO values_axesrrr) rrrrcrrrOrrrrrs r\rzTable.__init__u s` &I$*,2&,"(.BJB  r^c>|jjddS)N_r)rrrs r\table_type_shortzTable.table_type_short s$$S)!,,r^c |jt|jrdj|jnd}d|d}d}|jr8dj|j Dcgc] }t |c}}d|d}dj|jDcgc]}|jc}}|jd|d|jd |jd |jd |d|d Scc}wcc}w) rrrBz,dc->[rArrrz (typ->z,nrows->z,ncols->z ,indexers->[r) r2rqrr!r r rfrrhrrr0ncols)rjdcrverrSjverr jindex_axess r\rzTable.__repr__ s -01B1B-Cchht(()cU!_   88T\\:SV:;DdV1+Chh@1@A &se,**+8DJJ<@jj\k]!B4q B ; As 0D(DcL|jD]}||jk(s|cSy)zreturn the axis for cN)rfrh)rrors r\rzTable.__getitem__ s* AAFF{ r^c  |y|j|jk7r&td|jd|jddD]}t||d}t||d}||k7s#t|D]x\}}||}||k7s|dk(rO|j|jk7r6t d|j dd |jd |jd t d |d |d|dtd |d |d|dy)z"validate against an existing tableNz'incompatible table_type with existing [rqrA)rrOrrCannot serialize the column [rz%] because its data contents are not [z] but [] object dtypezinvalid combination of [z] on appending data [z] vs current table [)rrrryrrr{r_)rr*rosvovr|saxoaxs r\rzTable.validate sb =    t .$$%S(9<  A Aq$'B4(BRx(m FAsQ%Ccz -#((chh2F","? 1 OFFIhhZP((+z!A# )6qc: #u$8Q@   .qc1FrdK&&(T,/ r^c6t|jtS)z@the levels attribute is 1 or a list in the case of a multi-index)rWrzrnrs r\is_multi_indexzTable.is_multi_index s$++t,,r^ctj|jj} |j }t |tsJ||fS#t $r}t d|d}~wwxYw)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)rafill_missing_namesrr{ reset_indexrrWr,)rrrz reset_objrds r\validate_multiindexzTable.validate_multiindex so'' 8 )I )Y///&   T  sA A+ A&&A+ctj|jDcgc]}|jjdc}Scc}w)z-based on our axes, compute the expected nrowsr)rXrrr]rrr|s r\nrows_expectedzTable.nrows_expected s2wwDOODq *DEEDs Acd|jvS)zhas this table been createdrzr,rs r\rzTable.is_exists s$**$$r^c0t|jddSNrzrrrs r\r-zTable.storable stzz7D11r^c|jS)z,return the table group (this is my storable))r-rs r\rzz Table.table s}}r^c.|jjSr`)rzr>rs r\r>z Table.dtype szzr^c.|jjSr`rVrs r\rWzTable.description rXr^cVtj|j|jSr`)rJrKrrrs r\rfz Table.axes st0@0@AAr^c:td|jDS)z.the number of total columns in the values axesc3FK|]}t|jywr`)rqr{)rlrs r\rnzTable.ncols..s;Q3qxx=;s!)sumrrs r\rz Table.ncolss;$*:*:;;;r^cyrrrs r\ is_transposedzTable.is_transposedrr^c ttj|jDcgc]}t |dc}|j Dcgc]}t |j c}Scc}wcc}w)z@return a tuple of my permutated axes, non_indexable at the frontr)rorJrKrOrrrDrrs r\data_orientationzTable.data_orientation sY OO$($7$78qQqT8&*oo6QVV6   86s A/ A4clddd}|jDcgc]}|j|f}}|jDcgc] \}}||df}}}|jDcgc]2}|jt |j vs%|j|f4}}t||z|zScc}wcc}}wcc}w)z|jj}|d|dS)z)return the metadata pathname for this keyz/meta/z/metarr's r\_get_metadata_pathzTable._get_metadata_path-s$ &&se5))r^c|jj|j|t|dd|j|j |j y)z Write out a metadata array to the key as a fixed-format Series. Parameters ---------- key : str values : ndarray Frrz)rrcrrN)rrrr2rcrr)rrr{s r\rjzTable.write_metadata2sI   # #C ( 6 &]];;LL  r^ctt|jdd|d*|jj|j |Sy)z'return the meta data array for this keyrN)rrrrrrs r\rzTable.read_metadataDsA 74::vt4c4 @ L;;%%d&=&=c&BC Cr^cBt|j|j_|j|j_|j |j_|j |j_|j |j_|j|j_|j|j_|j|j_ |j|j_ |j|j_ y)zset our table type & indexablesN) rfrrSrrrOrrrcrrzrrs r\r'zTable.set_attrsJs #DOO 4  $ 1 !%!1!1!3 $($7$7 !"&"3"3 !\\ "mm  KK  KK )) r^ct|jddxsg|_t|jddxsg|_t|jddxsi|_t|jdd|_t t|jdd|_tt|jdd|_ t|jd dxsg|_ |jDcgc]}|js|c}|_ |jDcgc]}|jr|c}|_ycc}wcc}w) r[rONrrrrcrrrz)rrSrOrrrrdrcr]rrz indexablesr rrrs r\r*zTable.get_attrsWs%djj2BDIOR#DJJEKDJJ5; tzz9d; (Z)NO %gdjj(H&MN &-djj(D&I&OR &*ooK9J9J1K'+P!a>O>OAPLPs5EE!E3Ec |k|jr^tdj|jDcgc] }t |c}z}t j |ttyyycc}w)r2Nrrt) r rvr!r rfrxryrr )rrrrSr}s r\r3zTable.validate_versioncs\  ""(388T\\4RSV4R+SS */1# 4RsA/ c|yt|tsy|j}|D]}|dk(r ||vstd|dy)z validate the min_itemsize doesn't contain items that are not in the axes this needs data_columns to be defined Nr{zmin_itemsize has the key [z%] which is not an axis or data_column)rWrprr)rrqrRs r\validate_min_itemsizezTable.validate_min_itemsizensd   ,-  OO  AH}z 04""  r^c ` g}jjjtjjD]k\}\}}t |}j |}|dnd}|d}t |d} t|||| |j||} |j| mtjt| fd} |jtjjD cgc]\}} | || c} }|Scc} }w)z/create/cache the indexables if they don't existNrr)rhrDrrrrzrrc ft|tsJt}| vrt}t |}t |j }t |dd}t |dd}t|}j|}t |dd} ||||| |z|j| || } | S)Nrrr) rhrr{rrrrzrrr>) rWrfrrr_maybe_adjust_namer rrrz)r|roklassradj_namer{r>rmdrrbase_posrdescr table_attrss r\r{zTable.indexables..fsa% %%EBw(4#D)!T\\:H[XJe*)>? *OA|d4&D##D)B!#:TD&I; 48D jj I   y )% **"" #{#! ! J  $**:P:P0QR1AaGRSSs D* c |jsy|dury||dur0|jDcgc]}|js|j}}t |t t fs|g}i}|||d<|||d<|j}|D]}t|j|d}||jr^|j} | j} | j} || |k7r|jn| |d<|| |k7r|jn| |d<|jr|jj!dr t#d|j$di|||j&dd vst)d |d |d |d ycc}w)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. NFTrrcomplexzColumns 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.rrkzcolumn 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)r2rfr rrWrornrzrrmrrrr remove_indexrrrrrOr) rrrrrkwrzrorr cur_optlevelcur_kinds r\rzTable.create_indexs<  e   ?go(, I1Q5H5HqwwIGI'E4=1iG   %BzN  BvJ $ A At,A}<<GGE#(>>L$zzH'H,<(%-6 + 0H()5:||vv((3'H#ANN(R(d))!,Q//$aS!//0c21123SUA$ Js E<E<c(t||||}|j}g}|jD]a}|j|j|j ||j |j|j}|j|c|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]] r7r) SelectionrrfrrrNrrcrr) rrrrr selectionr{rrress r\ _read_axeszTable._read_axes%s"d%u4H !!# A JJtyy !)) {{ C NN3  r^c|S)zreturn the data for this objrrrr^s r\ get_objectzTable.get_objectGs  r^ct|sgS|d\}}|jj|i}|jddk(r|rtd|d||dur t |}n|g}t |t rLt|}t |}|j|jDcgc] }|dk7r||vr|c}|D cgc] } | |vs|  c} Scc}wcc} w)zd take the input data_columns and min_itemize and create a data columns spec rrr/z"cannot use a multi-index on axis [z] with data_columns Tr{) rqrrrrnrWrprrrvr) rrrrOrD axis_labelsrexisting_data_columnsrRros r\validate_data_columnszTable.validate_data_columnsLs  >"I*1-kyy}}T2& 88F | + 4TF; ,~/  4  ,L  !L lD )$' $5 ! -L   *..0H}2G)G (}| |_ |jAd|jC| |jE||g}t|}|d k(sJt| d k(sJ| D]}tG||d|d }|jd k(}|jI||| }|jK||jM}|jO|| | |jP|\}}g}tStU||D]\}\}}tV}d}|r=t|d k(r/|d|vr(tX}|d}|t|tZs t!d| r|r |jP|}nd}|xsd|}!ta|!|jb||||j<|j>|}"te|!|jf}#|ji|"}$tk|"jljn}%d}&tq|"ddts|"jt}&dx}'x}(})t|"jltvr<|"jx})d}'t+jz|"j|j}(n/t|jltrt[|jl}'t|"\}*}+||#|!t||$||%|&|)|'|(|+|* },|,jC| |j7|,|d z }|D,cgc]},|,js|,jn}-},t ||j|j|j<|j>|| ||-| | }.t|dr|j|._E|.j||r| r|.j||.Scc}wcc}w#t\t^f$r"} t!d|d|jPd| d} ~ wwxYwcc},w)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->rrANrTFr rkz.s6 16s rrr{rrzIncompatible appended table [z]with existing table [ values_block_) existing_colrrrcrrr r) rhrr{rrrr rrrr>r) rrrcrrrOrrrrrz)HrWr,rrrr_get_axis_numberr2rrDrnrrrrtrqrrqrfrOr+rXr=rxrwr{rr_get_axis_namerprcrrr~rb _reindex_axisr rrF_get_blocks_and_itemsrryrLrrrf IndexErrorr_maybe_convert_for_string_atomr{rr rrr>rhrrrr r'rrrrr3rr rr3rzrr)/rrfrrrrrrr table_existsnew_infonew_non_index_axesr{ append_axisindexer exist_axisr axis_name new_indexnew_index_axesjr^rrrvaxesr|rb_itemsrrhr$rdnew_namedata_convertedrrrr rrrrrrZdcs new_tables/ ` r\ _create_axeszTable._create_axesrs7@#y)JJ&&EA%Is)A'  <3D266A$$Q'6 ?? L$(OO4qAFF4D 1 12LllG!L99yyA~~ t9 A %N  $& ?G6f66 HHSM1g ,-G,,W5a8J#%$ $HHVK01HHVJ/0# $  #-K""3+QWW W Aw''V !!3 "451g HHSM&&s+ "9a L   !h'  .#  Av v%&!+++# 1AQqT1Q40C 1^^q( 11 ,(: Z0==? 66 ^../(, ,D ,8g...0@A(00!::n&?&?@FFHCII{3399~7G D*G}!  C OOH % LL  FAWK Z$)BCC,A,AsxxBBDJ;;**]];;%-   4 "#{{I '' 5    t $I7 5^#H-$7x@0040@0@/ADrCs0 W?X;X X='X= X:X55X:c t|jtr|jd}d}|j}t t |}t |j}||}t|r|d\} } t| jt|} |j| | j}t t |}t |j}||}|D]b} |j| g| j}t t |}|j|j|j||d|rt||D cic]!\} }t|j| |f#}} }g}g}|D]N}t|j } |j#|\} }|j%| |j%|P|}|}||fScc}} w#t&t(f$rC}dj+|Dcgc] }t-|ncc}wc}}t/d|d|d}~wwxYw)Nrc|jDcgc]'}|jj|j)c}Scc}wr`)rrrzr)mgrrs r\ get_blk_itemsz2Table._get_blocks_and_items..get_blk_itemsrs+rrorz+cannot match existing table structure for [z] on appending data)rWrr@rr rArnrrqr.rwr~rvrLrotolistr{rPrr)rr!rDr)rr+r-rrr?r>rrrDr new_labelsrobr6by_items new_blocks new_blk_itemsearrditemjitemss r\r(zTable._get_blocks_and_itemsds8 ejj, /%%g.E Hjj<%"3::.!.s!3 |  !31 5 D+{+66u\7JKJ-- -6;;C|S)C#**%F%c*I! 5mmQCdm388<- cjj)  s!34 5 #&fi"8Awgnn&'!W5H')JM! bii( !)e!4JAw%%a(!((1  F%Iy  +#H- XXe&Ld|D'9&L&LMF$EfXN,,s* &G((6G..I=H; H H;;Ic| t|}|PjrDtjtsJjD]}||vs|j d|j D]\}}t |||fd}|j-|jjD]\}} } || | S)zprocess axes filtersrcjD]}j|}j|}|J||k(rP jr$|j t j }|||}j||cS||vstt|j}t|}ttrd|z }|||}j||cStd|d)Nrorkzcannot find the field [z] for filtering!) _AXIS_ORDERSr% _get_axisrunionr.rzr}r?rr{rWr,r) fieldfiltopr1 axis_number axis_valuestakersr{rrs r\process_filterz*Table.process_axes..process_filters !$!1!1AI"%"6"6y"AK"%-- ":K&222 ) ..#'::eDKK.@#AD!#K!6"wwKw8@@+-!-gc5.A.H.H!I+D1&c95*+k/K!#FD!1"wwKw8@@5A8!#:5'AQ!RSSr^) rnrrWrzinsertrOr'filterr) rrrrr rDlabelsrTrNrPrOs `` r\ process_axeszTable.process_axess  7mG  4#6#6dkk40 00[[ )G#NN1a( ) !// TLD&T67;C T TF    '#,#3#3#:#:#< 6r4$UD"5 6 r^cn|t|jd}d|d}|jDcic]}|j|jc}|d<|rC||j xsd}t j|||xs |j}||d<|S|j|j|d<|Scc}w)z:create the description of the table from the axes & valuesi'rz)rhrgrW )rrrr) maxrrfrrrrrrr)rrrrrgrrrs r\create_descriptionzTable.create_descriptions  t22E:Ll ;59II>qAGGQUUN>-   OO0q i''#%9)9)9(G #AiL]] &==AiL?sB2c|j||jsyt||||}|j}|j|jj D]m\}}}|j ||j|jdz} ||| j||jz |j}ot|S)zf select coordinates (row numbers) from a table; return the coordinates object Fr7rkrh) r3r2r select_coordsrVrr>rr[ilocr{r.) rrrrrrcoordsrNrPrOrs r\r9zTable.read_coordinatess e$ d%u4H ((*    '#,#3#3#:#:#< Sr4''FJJL14D( 499Vfjjl-B#CT J Q QR  S V}r^cp|j|jsy| td|jD]}||jk(s|j st d|dt|jj|}|j|j|j||||j|j|j}t!|d|j"}t|jj$|dd} t'||d| cSt)d|d ) zj return a single column from the table, generally only indexables are interesting FNz4read_column does not currently accept a where clausezcolumn [z=] can not be extracted individually; it is not data indexablerrkr)rhrr>z] not found in the table)r3r2rrfrhr rrrzrmrrrNrrcrrIr rSr2r) rr=rrrrrro col_valuescvsr>s r\r>zTable.read_columns/    RS S IA**$"6(+33 DJJOOV4 499%YYeDM LL!]];; ' jmQTT2 0 0VHE2BDIcU%HH' I*&)ABCCr^)NrNNNNNN)rrrrKrcrrrfrzlist[IndexCol] | NonerOz list[tuple[AxisInt, Any]] | Nonerzlist[DataCol] | Nonerz list | Nonerz dict | Nonerrr)rorfrr)rrrz tuple[DataFrame, list[Hashable]]r)rzitertools.chain[IndexCol])rztuple[int, ...])rdict[str, Any])rr)rrfrrf)rrfr{rrrrr`r)rrrrr)rrrrrz9list[tuple[np.ndarray, np.ndarray] | tuple[Index, Index]]r^r)TNNN)rr,rr)rr,r+r)rrrr,)rrrrrgrrrdr<)r=rfrrrr)4rrrrrrrrzrMrrrrrrrrrrr-rzr>rWrfrrrrrrrrjrr'r*r3rrrrrrrr r; staticmethodr(rXr\r9r>rrs@r\r r U sI.KKO#$F $HN $,0;?,0$(     * 9*" *-- $%N--!%! )!"FF%%22  &&BB<<   "< 3*  $ $ Q *IIX?CT1;T TnCG & 5?  B D$=Tpp pdA!A!A!A!F5n  !   @HL!+:D:  +D+D +D  +Dr^r c4eZdZdZdZ d ddZddZy) rz 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 rNctd)z[ read the indices and the indexing array, calculate offset rows and return z!WORMTable needs to implement readr6r7s r\r*zWORMTable.readOs""EFFr^c td)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 writer6r9s r\rzWORMTable.write[s ""FGGr^r;r<r)rrrrrr*rrr^r\rrFs> J  G G  GHr^rcxeZdZdZdZ d d dZd d dZ d dZd ddZy)r(support the new appendable table formats appendableNc8|s2|jr&|jj|jd|j ||||| | }|j D]}|j |jsQ|j|||| }|j| |d<|jj|jfi||j|j_ |j D]}|j|||j|| y)Nrz)rfrrrrr)rrrrgrX)r)rrrrr;rfrdr\r' create_tablerrSrm write_data)rrrfrrrrrrrgrrrrXrzroptionss r\rzAppendableTable.writejs $.. LL $ $TZZ 9!!%% "  A    ..#%) /G OO %0GM " 'EMM & &u{{ >g >!::  .A  uf - . 62r^c <|jj}|j}g}|rs|jD]d}t |j j d}t|tjsC|j|jddft|r%|d}|ddD]}||z} |j}nd}|jDcgc]}|j} }t| } | dk(sJ| |jDcgc]}|j!} }| D cgc]Q} | j#tj$tj&| j(| j(dz S} } g} t+| D]H\}} |f|j|| |zj,z}| j| j/|J|d}tj0t3|||j }||zdz}t5|D]^}||z}t3|dz|z|}||k\ry|j7|| Dcgc]}||| c}||||nd| D cgc]} | || c} `ycc}wcc}wcc} wcc}wcc} w) z` we form the data into a 2-d including indexes,values,mask write chunk-by-chunk rrou1FrrkNrr)indexesrr{)r>r{rrr6rrjrWrXrCrrrqrrr]rQ transposerollarangertryrreshaperrrswrite_data_chunk)rrrr{r0masksrrrrsnindexesr{rbvaluesr| new_shaperowschunksstart_iend_is r\rozAppendableTable.write_datas   ## %% @AFF|''Q'/dBJJ/LLT!>?  @ u:8D12Y ax ::r{ryrrrrjrzrr ) rr}rsrr{rr0r{rzr|r{rs r\rxz AppendableTable.write_data_chunks.  A77177#    # CI 88E4D   w< ( !FAs DqN !f% *DAq()Dq8|$ % *  $$T$66A557Aw t9 JJ  d # JJ    r^c| t|s|7|5|j}|jj|jd|S| |j}|j j ||}|j j|S|jsy|j }t||||}|j}t|dj}t|} | r|j} t| | dkDj} t| sdg} | d| k7r| j!| | ddk7r| j#dd| j%} t'| D]U} |j)t+| | }|j ||jd||jddz| } W|j j| S) NTr\rhFrrkrr)rqr0rrrrz remove_rowsr r2rr^r2 sort_valuesdiffrnrrrUrPreversedrzrs)rrrrrr0rzrr{ sorted_serieslnrrpgrr}s r\rczAppendableTable.delete s =E }  ((t(DL <::D ..U.F   "L  dETB ((*vE2>>@    %%'D$tax.../Fv;bzR b!ayA~ a#Bf% $))%2,7!!tzz!}-DB4H14L"   JJ    r^) NFNNNNNNFNNT) rrrrrrrXrrrr)rrrrrr) r}rrslist[np.ndarray]rznpt.NDArray[np.bool_] | Noner{rrrrr<) rrrrrrrorxrcrr^r\rrds2J  $ 93 93939393 93v9v**"*+ * ! *  *X8r^rcheZdZUdZdZdZdZeZde d<e d dZ e d dZ d dd Zy )rrkrrr rrc:|jdjdk(S)Nrrk)rrDrs r\rz"AppendableFrameTable.is_transposedOsq!&&!++r^c"|r |j}|S)zthese are written transposed)rbrs r\rzAppendableFrameTable.get_objectSs %%C r^Nc |j||jsy|j|||}t|jr,|j j |jddini}t|jDcgc]\}}||jdus|} }}t| dk(sJ| d} || d} g} t|jD]<\}} | |jvr||\}}|j ddk7r t|}ntj|}|j d}||j|d|jr|}|}t| t!| d d }n&|j"}t| t!| d d }|}|j$dk(r:t'|t(j*r |j-d|j.df}t'|t(j*r t1|j"||d }n8t'|trt1|||}nt1jB|g||}tEr|jFjHdk(sD|jJ|jFk(jMsJ|jJ|jFf|D]B}t!|jNjP|dd}|dvs,||jS|||<D| jU|?t| dk(r| d}n tW| d}tY||||}|j[|||}|Scc}}w#t2$rz}|j4d k(r_t7drTt9|j;dr:t<r4t1|j"||d t?dt(j@}nYd}~d}~wwxYw)Nr7rrkrr/r{TinplacerhrgFrr;r<r=r?r@)rrrr>rrr)rfr`ro)rr).r3r2rrqrOrrryrfrrr.r/ from_tuples set_namesrrrbrtrWrXrCrwrr,rGrrrfrrr3rH _from_arraysrr>rdtypesrjrzrSrrr5rrX)rrrrrrrQrr|rindsindrframesr index_valsr]rmr{r{index_cols_rrdr=r>rs r\r*zAppendableFrameTable.readZs e$ uEE4&&' IIMM$--a03R 8 )3PearT__Q=O7OPP4yA~~1gs Adii(= DAq((("() Jxx</Z(!--j9HHW%E ud3!! e'%*FG u75&$+GH{{aJvrzz$BFLLO(<=&"**-"688U&uUB"FE*vuFC++VHe6R&(V\\->->#-E V\\1668S299fll:SS8  : 0 0VHE2BDI--!#F!2!25!9BvJ : MM" {= ~ v;! BQ'Bd%u4H   rY  H ]QN* 6&'<=H--.FG'&"HH$)"(!&"-h"P s%M-,M-M33 O6,>,@KFKr^cf|j}|F|rDt|jtsJ|jD]}||vs|j d|t |||||}|r|j|jd|jdddf}|jdk(rd|_ |S)NrrCTrr{) rrWrzrnrUrr* set_indexr_rh) rrrrrrrr r[rs r\r*zAppendableSeriesTable.reads,,  >dkk40 00[[ )G#NN1a( ) GLugUL N  KK TK 2 FF1a4L 66X AFr^rrer`rr;r)rrrrrrrtr2rrrrrrr*rrs@r\rrs|2 K$J DH L       r^rc,eZdZdZdZdZdfd ZxZS)rrkrrc |jxsd}|j|\}|_t|jtsJt |j}|j |t ||_t|$dd|i|y)rr{rNr) rhrrzrWrnrr.rrr)rrrrhnewobjrmrs r\rz AppendableMultiSeriesTable.writesuxx#8"66s; $++t,,,DKK  Dt  +&+F+r^r)rrrrrrrrrs@r\rrs2 K)J,,r^rcneZdZUdZdZdZdZeZde d<e d dZ e dZ dd Z ed Zdd Zy )rz:a table that read/writes the generic pytables table formatrrr zlist[Hashable]rzc|jSr`)rrs r\rzGenericTable.pandas_type sr^cLt|jddxs |jSrrrs r\r-zGenericTable.storablestzz7D1?TZZ?r^cNg|_d|_g|_|jDcgc]}|js|c}|_|jDcgc]}|jr|c}|_|j Dcgc]}|jc}|_ycc}wcc}wcc}w)r[N) rOrrzrr rrrhrrs r\r*zGenericTable.get_attrss~   &*ooK9J9J1K'+P!a>O>OAP-1-=-=>QVV>LP>sBBB"B<B"c |j}|jd}|dnd}tdd|j||}|g}t |j D]h\}}t |tsJt||}|j|}|dnd}t|||g||j||} |j| j|S)z0create the indexables from the table descriptionrNrr)rhrDrzrr)rhrr{rrzrr) rWrrrzry_v_namesrWrfrrr) rrr rrr r|r rrs r\rzGenericTable.indexabless       (^z#q  IR{ ajj) #DAqa% %%1a=D##A&B!#:TD(sjjB   r " #"r^c td)Nz cannot write on an generic tabler6)rrs r\rzGenericTable.writeCs!"DEEr^Nrr)rrrrrrrtr,rrrrr-r*rrrrr^r\rrsgDK J DH    @@?  FFr^rceZdZdZdZeZdZejdZ e ddZ d d fd Z d d fd ZxZS) rza frame with a multi-indexrr z ^level_\d+$cy)Nappendable_multirrs r\rz*AppendableMultiFrameTable.table_type_shortOs!r^c *|g}n|dur|jj}|j|\}|_t |jt sJ|jD]}||vs|j d|t| d||d|y)NTrrr) rr@rrzrWrnrUrr)rrrrr rs r\rzAppendableMultiFrameTable.writeTs  L T !;;--/L33C8T[$++t,,, *A $##Aq) *  C#LCFCr^c,t|||||}|j|j}|jj |jj Dcgc]!}|jj|rdn|#c}|_|Scc}w)NrC) rr*rrzrrr{ _re_levelssearch)rrrrrrrrhrs r\r*zAppendableMultiFrameTable.read`s~W\we$\ O \\$++ &88%%HJ WT__++D1Tt ; W   Xs&Brr`rr;r<)rrrrrr,rrtrecompilerrrrr*rrs@r\rrGsi$(JH DN+J "" D     r^rc|j|}t|}| t|}||j|r|j|r|St|j}|*t|jj |d}|j|s7t ddg|j z}|||<|jt|}|S)NF)sort) rLr?equalsuniquer|slicertr}ro)rrDrWr*rslicers r\r'r'rs t B & !F U# u-6==3D &--/ *F elln-::6:N == ',T4'8&9CHH&Dt ggeFm$ Jr^c0tj|}|S)z+for a tz-aware type, return an encoded zone)r get_timezone)r zones r\rrrrs  ! !" %D Kr^cyr`rr{r rs r\rIrIsr^cyr`rrs r\rIrIsr^ct|tr+|j|j|k(sJ|j|S|it|tr |j}nd}|j }t |}t||}|j dj|}|S|rtj|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 NrgrLM8[ns]r) rWr-r rhrr]rNrOrXr)r{r rrhs r\rIrIs&-(yy FIIO33 99 M ~ fm ,;;DD\\^F R vD1##E*55b9 M F(3 Mr^c zt|tsJ|j}t|\}}t |}t j |}tj|jds*t|jst|jr(t||||t|ddt|dd|St|tr tdtj |d} t#j$|} | dk(rgt#j$| D cgc]} | j'c} t"j( }t||dt+j-| S| d k(rJt/| ||}|jj0} t||d t+j3| | S| d vrt||||| St|t"j4r|jt6k(sJ|dk(sJ|t+j9}t||||| Scc} w)Niur r )r{rrr r rzMultiIndex not supported here!Frrr)rr`)integerfloating)r{rrrr)rWrfrhrrrrrrFr>r&r"r rr/rrrXr toordinalint32r Time32Col_convert_string_arrayrrarCrr) rhrrcrrrrrrrr{rrs r\rprps dC  J5U;Iz * %D  % %i 0D  T* u{{ +  %  -udD)!  %$899OOE%8MZZ FJJv>! >bhhO  )VWY%8%8%:z   ( ")&(FC ??++    I   )!    1 1 4J  )RZZ0Y__5NNNx%%y##%it KK/ ?sH8c |jdr.|dk(r t|}|St|j|}|S|dk(r t|}|S|dk(r? t j |Dcgc]}t j|c}t}|S|dvrt j |}|S|dvrt|d||}|S|dk(rt j |d }|Std |cc}w#t$rFt j |Dcgc]}t j|ncc}wc}t}Y|SwxYw) Nrrrr)rfloatrr`rrrzunrecognized index type ) rr-rr4rXrrrrrrr)rrrcrrrs r\rrs^ |$ < !$'E( L%"$))D/2E$ L#  t$ L  TJJTB 0 0 3B&QE L - - 4  L ( ' $&  L   47# L3D6:;; C TJJtD! 2 21 5DDFSE L Ts0C8+C3 C83C88ED1 0EEct|jtr|j}|jtk7r|St t j|}|jj}tj|d} | dk(r td| dk(r td| dk(s|dk(s|St|} |j} || | <|r3| jr#t||j kDr t#d tj| d} | dk7rht%| j&d D]M} | | } tj| d} | dk7s%t|| kDr|| nd | }td |d | dt)| ||j+| j&}|j }t|t,r1t/|j1|xs|j1dxsd }t3|xsd |}||j5|}|||kDr|}|j7d|d}|S)NFrrz+[date] is not implemented as a table columnr?z>too many timezones in this block, create separate data columnsr`rz8NaN representation is too large for existing column sizerzNo.rz2] because its data contents are not [string] but [rr{z|Sr)rWr>r3rrr rXrCrhrrrr6rrrqrrrsrrrwrprrr[rgr)rhr{r$rrrcrrrrrrr|rZerror_column_labelr8recis r\r*r*"sB'---""$}}2::w'G##JOOGE:MEFF " L   X %x)? =D <<>DDJ s7|l6K6K'KSTTOOD7M tzz!}% Aq'COOC>M(36wrkSr)rqr2rrfencoderrwrr!r[ libwritersmax_len_string_arrayrXr)rrcrensuredrs r\rrqs  4y 4::?H ::dAhZ. 1D Kr^c*|j}tj|jt}t |rt jt|}d|}t|dtrKt|djj||d}|j}d|j_n(|j#|dj#td}|d }t j$|||j'|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. rUrFrr)rr>TrH)rrXrrrrqrrr!rWrTr2rfrZrflags writeabler!string_array_replace_from_nan_reprw)rrrcrrrr>sers r\rrs& JJE ::djjl& 1D 4y22=3FGH: d1gu %E*..55x6C<<>D#'DJJ ;;u5;188e8LD00w? << r^ct|tsJt|t|rt |||}||}|Sr`)rWrfr _need_convert_get_converter)r{rJrcrconvs r\rErEs? h $4d8n4 $Xh&9f Mr^c\dk(rdSdvrfdSdk(rfdStd)Nrc0tj|dS)NrrrXr)rSs r\rz _get_converter..sAX6r^c2tj|S)Nrr)rSrs r\rz _get_converter..sAT2r^r`c"t|dS)Nr)r)rSrcrs r\rz _get_converter..s0 thv r^z invalid kind )r)rrcrs```r\rrsE |66  22    =/00r^c|dvsd|vryy)N)rr`rTFrrs r\rrs ''<4+? r^ct|tst|dkr td|ddk(r@|ddkr8|ddk(r0t j d|}|r|j 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.rrkr r zvalues_block_(\d+)values_)rWrfrqrrrr)rhr rgrps r\rrsx'33wr(rrhrrXrrr0r)rrs r\rrs$ $zz$**o."4::??"315 ZZ__  zz$zz$))D/* D+ &yy ::d D  r^c@eZdZdZ d ddZdZdZdZy) rz 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 Nc||_||_||_||_d|_d|_d|_d|_t|rKtt5tj|d}|dvrtj|}|jtj k(rS|j|j}}|d}||jj"}tj$||||_nt'|jj(tj*rd|j||jkj-s)|j(||jk\j-r td||_ddd|jK|j/||_|j (|j j1\|_|_yyy#1swYaxYw)NFr)rbooleanrz3where must have index locations >= start and < stop)rzrrrr conditionrVtermsrIr$rrrrrXrr>bool_r0rv issubclassrrrgenerateevaluate)rrzrrrrinferreds r\rzSelection.__init__6s        *% 1??5?55JJu-E{{bhh.&*jj$))t =$%E<#'::#3#3D+-99UD+A%+H(#EKK$4$4bjjA JJ2 8J7O7O7Q II1u 7I6N6N6P", U#,1(% 1(    #u-DJzz%.2jj.A.A.C+ & $) 1 1s D4G((G1c|y|jj} t|||jjS#t$rB}dj |j }td|d|d}t||d}~wwxYw)z'where can be a : dict,list,tuple,stringN)rrcrz- 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 ) rzrr;rc NameErrorr!rrr)rrrrrdqkeysrs r\rzSelection.generatecs = JJ ! ! # +!djj>Q>QR R +HHQVVX&E..3W5CDI'J CS/s * +s!A B  =BB c|jT|jjj|jj|j|j S|j /|jjj|j S|jjj|j|j S)( generate the selection rh) rrz read_whererrrrIr9r*rs r\rzSelection.selectzs >> %::##..%%'tzz /    )::##44T5E5EF Fzz$$4::DII$FFr^c|j|j}}|jj}|d}n |dkr||z }||}n |dkr||z }|jA|jjj |jj ||dS|j |jStj||S)rrT)rrr) rrrzr0rget_where_listrrIrXrv)rrrr0s r\r^zSelection.select_coordssjj$))t    =E QY UNE <D AX EMD >> %::##22%%'u4d3    )## #yy%%r^r)rzr rrrrrr)rrrrrrrr^rr^r\rr*sS   +D+D +D  +D  +DZ+. G&r^r)rcrrrf)rmr) rNNFNTNNNNrrU)rFilePath | HDFStorerrfrrrrfrrrrrrrrrrrrrrrrrrfrcrfrr) NrrNNNNFN)rrrrfrrfrrzstr | list | Nonerrrrrzlist[str] | Nonerrrr)rrKrrKrrr`)rr,rDrNrWr.rr,)r rr str | tzinfor)r{np.ndarray | Indexr rrrrr-)r{rr rrrrr)r{rr zstr | tzinfo | Nonerrrznp.ndarray | DatetimeIndex) rhrfrr.rcrfrrfrr )rrfrcrfrrfrr)rhrfr{rMrr)rrrcrfrrfrr)r{rrJrfrcrfrrf)rrfrcrfrrf)rrfrr)rhrfr z Sequence[int]rrf)rrfrrf)rrM)r __future__r contextlibrrr?rrrJrrtextwraprtypingrr r r r r rrxnumpyrXpandas._configrrrr pandas._libsrrrpandas._libs.librpandas._libs.tslibsr pandas.compatrpandas.compat._optionalrpandas.compat.pickle_compatr pandas.errorsrrrrrpandas.util._decoratorsrpandas.util._exceptionsr pandas.core.dtypes.commonr!r"r#r$r%r&pandas.core.dtypes.dtypesr'r(r)r*pandas.core.dtypes.missingr+rr,r-r.r/r0r1r2r3r4r5r6pandas.core.arraysr7r8r9pandas.core.arrays.string_r:pandas.core.commoncorecommonra pandas.core.computation.pytablesr;r<pandas.core.constructionr=rar>pandas.core.indexes.apir?pandas.core.internalsr@rApandas.io.commonrBpandas.io.formats.printingrCrDcollections.abcrErFrGtypesrHrrIrJrKpandas._typingrLrMrNrOrPrQrRrSrTrrar]rdrirprurvrrwrxrrur}r~ config_prefixregister_optionis_boolis_one_of_factoryrrrrrrrr3r rrrrrr>rrrr rrrrrrrr'rrrIrprr*rrrErrrrrrrr^r\r*s#  -)%>434 8     7 1 ,  $   ,   :*U !  gGgN    E E V(#F>5*WF *&**+CD  $)!4 04 595$5 5 5  5  5  5 5 5 5.5 535 55  !5t # $ _$_ _  _  _  _ ____D ZZz,mm`s>s>l  h :Y9hY9x$w$63.3i?i?X{B5{B| /#,/#dd; d;N" nDEnDbHH<`e`Fw?wt.0.b,!6,$@F'@FF( 4(X9= !+04  AF $0:>     IN$ $$7$AE$$N=L@:L L LL^>' '),'69''T 1 2 F2r&r&Ibs !A N%%N/