B
    T\	              	   @   sh   d dl mZmZmZ d dlZddlmZ ddddeee	e	d	dfd
dZ
dd ZdddZdddZdS )    )absolute_importprint_functiondivisionN   )import_requiredz
2000-01-01z
2000-01-31Z1sZ1d)nameidxyc          	   K   s(   ddl m} |f | |||||d|S )a   Create timeseries dataframe with random data

    Parameters
    ----------
    start : datetime (or datetime-like string)
        Start of time series
    end : datetime (or datetime-like string)
        End of time series
    dtypes : dict
        Mapping of column names to types.
        Valid types include {float, int, str, 'category'}
    freq : string
        String like '2s' or '1H' or '12W' for the time series frequency
    partition_freq : string
        String like '1M' or '2Y' to divide the dataframe into partitions
    seed : int (optional)
        Randomstate seed
    kwargs:
        Keywords to pass down to individual column creation functions.
        Keywords should be prefixed by the column name and then an underscore.

    Examples
    --------
    >>> import dask
    >>> df = dask.datasets.timeseries()
    >>> df.head()  # doctest: +SKIP
              timestamp    id     name         x         y
    2000-01-01 00:00:00   967    Jerry -0.031348 -0.040633
    2000-01-01 00:00:01  1066  Michael -0.262136  0.307107
    2000-01-01 00:00:02   988    Wendy -0.526331  0.128641
    2000-01-01 00:00:03  1016   Yvonne  0.620456  0.767270
    2000-01-01 00:00:04   998   Ursula  0.684902 -0.463278
    >>> df = dask.datasets.timeseries(
    ...     '2000', '2010',
    ...     freq='2H', partition_freq='1D', seed=1,  # data frequency
    ...     dtypes={'value': float, 'name': str, 'id': int},  # data types
    ...     id_lam=1000  # control number of items in id column
    ... )
    r   )make_timeseries)startendfreqpartition_freqseeddtypes)Zdask.dataframe.io.demor   )r   r   r   r   r   r   kwargsr    r   ,lib/python3.7/site-packages/dask/datasets.py
timeseries   s    0
r   c             #   s^   ddl m}m} |f d|i  | fddd}x"t|D ]}|jddd V  q@W d	S )
ze Generate data for a single partition of a dask bag

    See Also
    --------
    _make_mimesis
    r   )SchemaFieldr   c                  s    S )Nr   r   )fieldschema_descriptionr   r   <lambda>G   s    z#_generate_mimesis.<locals>.<lambda>)schemar   )Z
iterationsN)Zmimesis.schemar   r   rangeZcreate)r   r   records_per_partitionr   r   r   r   ir   )r   r   r   _generate_mimesis>   s
    r   c       	         s|   ddl m} ddlm}  pi  |dkr0t }|j||}d| ||  fddt|D }|||S )a  
    Make a Dask Bag filled with data randomly generated by the mimesis projet

    Parameters
    ----------
    field: dict
        keyword arguments to pass to ``mimesis.Field``
    schema: Callable[Field] -> dict
        The schema to use to generate the data
    npartitions: int
    records_per_partition: int
    seed: int, None
        Seed for random data

    Returns
    -------
    Dask Bag

    See Also
    --------
    make_people
    r   N)tokenizezmimesis-c                s$   i | ]\}}t  |f|fqS r   )r   ).0r   r   )r   r   r   r   r   r   
<dictcomp>n   s   z!_make_mimesis.<locals>.<dictcomp>)	Zdask.bagZbagZ	dask.baser    randomZcoreZrandom_state_data_python	enumerateZBag)	r   r   npartitionsr   r   Zdbr    ZseedsZdskr   )r   r   r   r   r   _make_mimesisL   s    r&   
     enc             C   s&   t dd dd }td|i|| ||S )a   Make a dataset of random people

    This makes a Dask Bag with dictionary records of randomly generated people.
    This requires the optional library ``mimesis`` to generate records.

    Paramters
    ---------
    npartitions : int
        Number of partitions
    records_per_partition : int
        Number of records in each partition
    seed : int, (optional)
        Random seed
    locale : str
        Language locale, like 'en', 'fr', 'zh', or 'ru'

    Returns
    -------
    b: Dask Bag
    ZmimesiszMThe mimesis module is required for this function.  Try:
  pip install mimesisc             S   sF   | d| d| df| d| d| d| dd| d	| d
ddS )Nz
person.agezperson.namezperson.surnamezperson.occupationzperson.telephonezaddress.addresszaddress.city)addressZcityzpayment.credit_card_numberz#payment.credit_card_expiration_date)Znumberzexpiration-date)Zager   Z
occupationZ	telephoner*   zcredit-cardr   )r   r   r   r   r      s    
zmake_people.<locals>.<lambda>locale)r   r&   )r%   r   r   r+   r   r   r   r   make_peoplet   s    r,   )N)r'   r(   Nr)   )Z
__future__r   r   r   r#   Zutilsr   strintfloatr   r   r&   r,   r   r   r   r   <module>   s   0
(