Файловый менеджер - Редактировать - /home/digitalm/venv/lib/python3.7/site-packages/pandas/io/__pycache__/stata.cpython-37.pyc
Назад
B �5�g�� � @ s� d Z ddlmZ ddlmZ ddlZddlmZ ddlZddl Z ddl Z ddlmZm Z mZmZmZ ddlZddlmZ ddlZddlmZ dd lmZ dd lmZmZmZmZ ddlm Z m!Z! ddl"m#Z#m$Z$m%Z% dd l&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 dZ9dZ:dZ;dZ<de0j=d � �Z>dZ?dZ@de:� de;� de<� de?� de>� de@� d� ZAde:� de;� d �ZBd!e:� de;� de<� de>� d"e@� d�ZCd#d$d%d&d'd(d)d*d+g ZDe�d,d-d-�ZEd.d/�d0d1�ZFd.d2d.d3�d4d5�ZGd6ZHG d7d8� d8eI�ZJd9ZKG d:d;� d;eI�ZLd<ZMG d=d>� d>eI�ZNd?ZOG d@dA� dAeI�ZPdBZQdCdCdD�dEdF�ZRG dGdH� dH�ZSG dIdJ� dJ�ZTG dKdL� dL�ZUG dMdN� dNeUejV�ZWe eA�d�dRdSdSdTdSdSdUdSdVdSdWdXdYdZ� d[d\��ZXd2d2d]�d^d_�ZYd`dad`db�dcdd�ZZd2dedf�dgdh�Z[didjdidk�dldm�Z\ded.dadn�dodp�Z]d�d.dadSd2dr�dsdt�Z^e!e0j=d du�G dvdw� dweU��Z_ded.dSdadx�dydz�Z`d{dad|db�d}d~�ZaG dd�� d��ZbG d�d�� d�e_�ZcG d�d�� d�ec�ZddS )�a� Module contains tools for processing Stata files into DataFrames The StataReader below was originally written by Joe Presbrey as part of PyDTA. It has been extended and improved by Skipper Seabold from the Statsmodels project who also developed the StataWriter and was finally added to pandas in a once again improved version. You can find more information on http://presbrey.mit.edu/PyDTA and https://www.statsmodels.org/devel/ � )�annotations)�abcN)�BytesIO)�Any�AnyStr�Hashable�Sequence�cast)� relativedelta)�infer_dtype)�max_len_string_array)�Buffer�CompressionOptions�FilePathOrBuffer�StorageOptions)�Appender�doc)� ensure_object�is_categorical_dtype�is_datetime64_dtype)�Categorical� DatetimeIndex�NaT� Timestamp�concat�isna�to_datetime�to_timedelta)�generic)� DataFrame)�Index)�Series)� get_handlez�Version of given Stata file is {version}. pandas supports importing versions 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), 114 (Stata 10/11), 115 (Stata 12), 117 (Stata 13), 118 (Stata 14/15/16),and 119 (Stata 15/16, over 32,767 variables).z�convert_dates : bool, default True Convert date variables to DataFrame time values. convert_categoricals : bool, default True Read value labels and convert columns to Categorical/Factor variables.a index_col : str, optional Column to set as index. convert_missing : bool, default False Flag indicating whether to convert missing values to their Stata representations. If False, missing values are replaced with nan. If True, columns containing missing values are returned with object data types and missing values are represented by StataMissingValue objects. preserve_dtypes : bool, default True Preserve Stata datatypes. If False, numeric data are upcast to pandas default types for foreign data (float64 or int64). columns : list or None Columns to retain. Columns will be returned in the given order. None returns all columns. order_categoricals : bool, default True Flag indicating whether converted categorical data are ordered.zzchunksize : int, default None Return StataReader object for iterations, returns chunks with given number of lines.aH compression : str or dict, default None If string, specifies compression mode. If dict, value at key 'method' specifies compression mode. Compression mode must be one of {'infer', 'gzip', 'bz2', 'zip', 'xz', None}. If compression mode is 'infer' and `filepath_or_buffer` is path-like, then detect compression from the following extensions: '.gz', '.bz2', '.zip', or '.xz' (otherwise no compression). If dict and compression mode is one of {'zip', 'gzip', 'bz2'}, or inferred as one of the above, other entries passed as additional compression options. �storage_optionsz=iterator : bool, default False Return StataReader object.z�Notes ----- Categorical variables read through an iterator may not have the same categories and dtype. This occurs when a variable stored in a DTA file is associated to an incomplete set of value labels that only label a strict subset of the values.a> Read Stata file into DataFrame. Parameters ---------- filepath_or_buffer : str, path object or file-like object Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is expected. A local file could be: ``file://localhost/path/to/table.dta``. If you want to pass in a path object, pandas accepts any ``os.PathLike``. By file-like object, we refer to objects with a ``read()`` method, such as a file handle (e.g. via builtin ``open`` function) or ``StringIO``. � z� Returns ------- DataFrame or StataReader See Also -------- io.stata.StataReader : Low-level reader for Stata data files. DataFrame.to_stata: Export Stata data files. z� Examples -------- Read a Stata dta file: >>> df = pd.read_stata('filename.dta') Read a Stata dta file in 10,000 line chunks: >>> itr = pd.read_stata('filename.dta', chunksize=10000) >>> for chunk in itr: ... do_something(chunk) z�Reads observations from Stata file, converting them into a dataframe Parameters ---------- nrows : int Number of lines to read from data file, if None read whole file. z Returns ------- DataFrame z�Class for reading Stata dta files. Parameters ---------- path_or_buf : path (string), buffer or path object string, path object (pathlib.Path or py._path.local.LocalPath) or object implementing a binary read() functions. z z%tcz%tCz%tdz%dz%twz%tmz%tqz%thz%tyi� � r! )�returnc sf t jjt jj ��t jt�ddd� j� t jt�ddd� j��d d d �� d d d �dd���fdd �}dd���fd d�}dd�� ���fdd �}t�| �}d}|�� r�d}t | �}d||<