Файловый менеджер - Редактировать - /home/digitalm/venv/lib/python3.7/site-packages/pandas/io/__pycache__/pytables.cpython-37.pyc
Назад
B �5�g�� � @ s� d Z ddlmZ ddlmZ ddlZddlmZmZ ddl Z ddl Z ddlZddlm Z ddlmZmZmZmZmZmZ ddlZddlZddlmZmZ dd lmZmZ dd lm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z& ddl'm(Z( dd l)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 ddl:m;Z; ddl<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZF ddlGmHZHmIZImJZJ ddlKmL mMZN ddlOmPZPmQZQ ddlRmSZS ddlTmUZU ddlVmWZWmXZX ddlYmZZZ ddl[m\Z\m]Z] e�rddl^m_Z_m`Z`maZa ddlVmbZb dZcdZddd� Zed d!� Zfd"d#� ZgePZhd$d%�d&d'�ZiG d(d)� d)ej�ZkG d*d+� d+ej�ZlG d,d-� d-em�Znd.ZoG d/d0� d0em�Zpd1ZqG d2d3� d3em�Zrd4Zsd5Ztd6d6d7d7d8�Zue=dgiZvd9Zwd:Zxe�yd;��8 ejzd<d=ewej{d>� ejzd?dexe�|d6d7dg�d>� W dQ R X da}d=a~d@dA� Zd�dEdFdEdGdHdIdHdIdJdKdLdEdEdM� dNdO�Z�d�dEdEdGdGdGdQ�dRdS�Z�dTdTdIdU�dVdW�Z�G dXdY� dY�Z�G dZd[� d[�Z�G d\d]� d]�Z�G d^d_� d_e��Z�G d`da� dae��Z�G dbdc� dce��Z�G ddde� dee��Z�G dfdg� dg�Z�G dhdi� die��Z�G djdk� dke��Z�G dldm� dme��Z�G dndo� doe��Z�G dpdq� dqe��Z�G drds� dse��Z�G dtdu� due��Z�G dvdw� dwe��Z�G dxdy� dye��Z�G dzd{� d{e��Z�G d|d}� d}e��Z�G d~d� de��Z�d�d�d$d�d�d��d�d��Z�d�d�d��d�d��Z�d�d�d�dId�d��d�d��Z�dEd�dEdEd]d��d�d��Z�dEdEdEd�d��d�d��Z�dEd�d�d��d�d��Z�d�dEdEd�d��d�d��Z�d�dEdEd�d��d�d��Z�d�dEdEdEd��d�d��Z�dEdEdEd��d�d��Z�dEdId��d�d��Z�dEd�dEd��d�d��Z�dEdEd��d�d��Z�d�d��d�d��Z�G d�d�� d��Z�dS )�zY High level interface to PyTables for reading and writing pandas data structures to disk � )�annotations)�suppressN)�date�tzinfo)�dedent)� TYPE_CHECKING�Any�Callable�Hashable�Sequence�cast)�config� get_option)�lib�writers)� timezones)� ArrayLike�DtypeArg� FrameOrSeries�FrameOrSeriesUnion�Shape)�import_optional_dependency)�patch_pickle)�PerformanceWarning)�cache_readonly) � ensure_object�is_categorical_dtype�is_complex_dtype�is_datetime64_dtype�is_datetime64tz_dtype�is_extension_array_dtype�is_list_like�is_string_dtype�is_timedelta64_dtype�needs_i8_conversion)�array_equivalent) � DataFrame� DatetimeIndex�Index� Int64Index� MultiIndex�PeriodIndex�Series�TimedeltaIndex�concat�isna)�Categorical� DatetimeArray�PeriodArray)�PyTablesExpr�maybe_expression)� extract_array)�ensure_index)�ArrayManager�BlockManager)�stringify_path)�adjoin�pprint_thing)�Col�File�Node)�Blockz0.15.2�UTF-8c C s t | tj�r| �d�} | S )z(if we have bytes, decode them to unicodezUTF-8)� isinstance�np�bytes_�decode)�s� rF �H/home/digitalm-up/venv/lib/python3.7/site-packages/pandas/io/pytables.py�_ensure_decodedu s rH c C s | d krt } | S )N)�_default_encoding)�encodingrF rF rG �_ensure_encoding| s rK c C s t | t�rt| �} | 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 )rA �str)�namerF rF rG �_ensure_str� s rN �int)�scope_levelc sV |d � t | ttf�r*� fdd�| D �} nt| �r>t| � d�} | dksNt| �rR| S dS )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 rt |�r(t|� d d�n|�qS )NrQ )rP )r4 �Term)�.0�term)�levelrF rG � <listcomp>� s z _ensure_term.<locals>.<listcomp>)rP N)rA �list�tupler4 rR �len)�whererP rF )rU rG �_ensure_term� s r[ c @ s e Zd ZdS )�PossibleDataLossErrorN)�__name__� __module__�__qualname__rF rF rF rG r\ � s r\ c @ s e Zd ZdS )�ClosedFileErrorN)r] r^ r_ rF rF rF rG r` � s r` c @ s e Zd ZdS )�IncompatibilityWarningN)r] r^ r_ rF rF rF rG ra � s ra 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) c @ s e Zd ZdS )�AttributeConflictWarningN)r] r^ r_ rF rF rF rG rb � s rb zu the [%s] attribute of the existing index is [%s] which conflicts with the new [%s], resetting the attribute to None c @ s e Zd ZdS )�DuplicateWarningN)r] r^ r_ rF rF rF rG rc � s rc z; duplicate entries in table, taking most recently appended z� 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] �fixed�table)�frd �tre z; : boolean drop ALL nan rows when appending to a table z~ : format default format writing format, if None, then put will default to 'fixed' and append will default to 'table' zio.hdfZdropna_tableF)� validator�default_formatc C s8 t d kr4dd l} | a tt�� | jjdkaW d Q R X t S )Nr �strict)� _table_mod�tablesr �AttributeError�fileZ_FILE_OPEN_POLICY�!_table_file_open_policy_is_strict)rl rF rF rG �_tables� s rp �aTrj rL r z int | Nonez str | None�boolzint | dict[str, int] | Nonezbool | Nonezbool | list[str] | None) �key�value�mode� complevel�complib�append�format�index�min_itemsize�dropna�data_columns�errorsrJ c s� |r$� ��������� f dd�}n� ��������� f dd�}t | �} t| t�rzt| |||d��}||� W dQ R X n|| � dS )z+store this object, close it if we opened itc s | j �� ������ ��d� S )N)ry rz r{ �nan_repr| r} r~ rJ )rx )�store) r} r| rJ r~ ry rz rs r{ r rt rF rG �<lambda> s zto_hdf.<locals>.<lambda>c s | j �� ����� ���d� S )N)ry rz r{ r r} r~ rJ r| )�put)r� ) r} r| rJ r~ ry rz rs r{ r rt rF rG r� ( s )ru rv rw N)r9 rA rL �HDFStore)�path_or_bufrs rt ru rv rw rx ry rz r{ r r| r} r~ rJ rf r� rF ) r} r| rJ r~ ry rz rs r{ r rt rG �to_hdf s r� �r)ru r~ �start�stop� chunksizec K s� |dkrt d|� d���|dk r,t|dd�}t| t�rN| jsDtd��| }d}nvt| �} t| t�shtd ��yt j �| �} W n tt fk r� d} Y nX | s�t d | � d���t| f||d�| ��}d }yz|dk�r&|�� }t|�dkr�t d��|d }x*|dd� D ]}t||��st d���qW |j}|j||||||| |d�S t ttfk �r� t| t��s~tt�� |�� W dQ R X � Y nX dS )a� Read from the store, close it if we opened it. Retrieve pandas object stored in file, optionally based on where criteria. .. warning:: Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the "fixed" format. Loading pickled data received from untrusted sources can be unsafe. See: https://docs.python.org/3/library/pickle.html for more. Parameters ---------- path_or_buf : str, path object, pandas.HDFStore Any valid string path is acceptable. Only supports the local file system, remote URLs and file-like objects are not supported. If you want to pass in a path object, pandas accepts any ``os.PathLike``. Alternatively, pandas accepts an open :class:`pandas.HDFStore` object. key : object, optional The group identifier in the store. Can be omitted if the HDF file contains a single pandas object. mode : {'r', 'r+', 'a'}, default 'r' Mode to use when opening the file. Ignored if path_or_buf is a :class:`pandas.HDFStore`. Default is 'r'. errors : str, default 'strict' Specifies how encoding and decoding errors are to be handled. See the errors argument for :func:`open` for a full list of options. where : list, optional A list of Term (or convertible) objects. start : int, optional Row number to start selection. stop : int, optional Row number to stop selection. columns : list, optional A list of columns names to return. iterator : bool, optional Return an iterator object. chunksize : int, optional Number of rows to include in an iteration when using an iterator. **kwargs Additional keyword arguments passed to HDFStore. Returns ------- item : object The selected object. Return type depends on the object stored. See Also -------- DataFrame.to_hdf : Write a HDF file from a DataFrame. HDFStore : Low-level access to HDF files. Examples -------- >>> df = pd.DataFrame([[1, 1.0, 'a']], columns=['x', 'y', 'z']) >>> df.to_hdf('./store.h5', 'data') >>> reread = pd.read_hdf('./store.h5') )r� zr+rq zmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.NrQ )rP z&The HDFStore must be open for reading.Fz5Support for generic buffers has not been implemented.zFile z does not exist)ru 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.)rZ r� r� �columns�iteratorr� � auto_close)� ValueErrorr[ rA r� �is_open�OSErrorr9 rL �NotImplementedError�os�path�exists� TypeError�FileNotFoundError�groupsrY �_is_metadata_of�_v_pathname�select�KeyErrorr rm �close)r� rs ru r~ rZ r� r� r� r� r� �kwargsr� r� r� r� Zcandidate_only_groupZgroup_to_checkrF rF rG �read_hdf? s` O r� r>