code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"]: rendered +=...
TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix)
render_git_describe
python
mars-project/mars
mars/_version.py
https://github.com/mars-project/mars/blob/master/mars/_version.py
Apache-2.0
def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. The distance/hash is unconditional. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] ...
TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. The distance/hash is unconditional. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix)
render_git_describe_long
python
mars-project/mars
mars/_version.py
https://github.com/mars-project/mars/blob/master/mars/_version.py
Apache-2.0
def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", "full-revisionid": pieces.get("long"), "dirty": None, "error": pieces["error"], "date": None} ...
Render the given version pieces into the requested style.
render
python
mars-project/mars
mars/_version.py
https://github.com/mars-project/mars/blob/master/mars/_version.py
Apache-2.0
def get_versions(): """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which #...
Get version information or return default if unable to do so.
get_versions
python
mars-project/mars
mars/_version.py
https://github.com/mars-project/mars/blob/master/mars/_version.py
Apache-2.0
def convert_dask_collection(dc): """ Convert dask collection object into mars.core.Object via remote API Parameters ---------- dc: dask collection Dask collection object to be converted. Returns ------- Object Mars Object. """ if not is_dask_collection(dc): ...
Convert dask collection object into mars.core.Object via remote API Parameters ---------- dc: dask collection Dask collection object to be converted. Returns ------- Object Mars Object.
convert_dask_collection
python
mars-project/mars
mars/contrib/dask/converter.py
https://github.com/mars-project/mars/blob/master/mars/contrib/dask/converter.py
Apache-2.0
def mars_scheduler(dsk: dict, keys: Union[List[List[str]], List[str]]): """ A Dask-Mars scheduler This scheduler is intended to be compatible with existing dask user interface, no callbacks are implemented. Parameters ---------- dsk: Dict Dask graph, represented as a task DAG dicti...
A Dask-Mars scheduler This scheduler is intended to be compatible with existing dask user interface, no callbacks are implemented. Parameters ---------- dsk: Dict Dask graph, represented as a task DAG dictionary. keys: Union[List[List[str]], List[str]] 1d or 2d list of Das...
mars_scheduler
python
mars-project/mars
mars/contrib/dask/scheduler.py
https://github.com/mars-project/mars/blob/master/mars/contrib/dask/scheduler.py
Apache-2.0
def mars_dask_get(dsk: dict, keys: Union[List[List[str]], List[str]]): """ A Dask-Mars convert function. This function will send the dask graph layers to Mars Remote API, generating mars objects correspond to the provided keys. Parameters ---------- dsk: Dict Dask graph, represented...
A Dask-Mars convert function. This function will send the dask graph layers to Mars Remote API, generating mars objects correspond to the provided keys. Parameters ---------- dsk: Dict Dask graph, represented as a task DAG dictionary. keys: Union[List[List[str]], List[str]] ...
mars_dask_get
python
mars-project/mars
mars/contrib/dask/scheduler.py
https://github.com/mars-project/mars/blob/master/mars/contrib/dask/scheduler.py
Apache-2.0
def concat(objs: List): """ Concat the results of partitioned dask task executions. This function guess the types of resulting list, then calls the corresponding native dask concat functions. Parameters ---------- objs: List List of the partitioned dask task execution results, which...
Concat the results of partitioned dask task executions. This function guess the types of resulting list, then calls the corresponding native dask concat functions. Parameters ---------- objs: List List of the partitioned dask task execution results, which will be concat. Returns ...
concat
python
mars-project/mars
mars/contrib/dask/utils.py
https://github.com/mars-project/mars/blob/master/mars/contrib/dask/utils.py
Apache-2.0
def get_local_host_ip(self) -> str: """ Get local worker's host ip Returns ------- host_ip : str """
Get local worker's host ip Returns ------- host_ip : str
get_local_host_ip
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def get_total_n_cpu(self) -> int: """ Get number of cpus. Returns ------- number_of_cpu: int """
Get number of cpus. Returns ------- number_of_cpu: int
get_total_n_cpu
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def get_slots(self) -> int: """ Get num of slots of current band Returns ------- number_of_bands: int """
Get num of slots of current band Returns ------- number_of_bands: int
get_slots
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def get_chunks_result(self, data_keys: List[str], fetch_only: bool = False) -> List: """ Get result of chunks. Parameters ---------- data_keys : list Data keys. fetch_only : bool If fetch_only, only fetch data but not return. Returns ...
Get result of chunks. Parameters ---------- data_keys : list Data keys. fetch_only : bool If fetch_only, only fetch data but not return. Returns ------- results : list Result of chunks if not fetch_only, else return N...
get_chunks_result
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def get_chunks_meta( self, data_keys: List[str], fields: List[str] = None, error="raise" ) -> List[Dict]: """ Get meta of chunks. Parameters ---------- data_keys : list Data keys. fields : list Fields to filter. error : str ...
Get meta of chunks. Parameters ---------- data_keys : list Data keys. fields : list Fields to filter. error : str raise, ignore Returns ------- meta_list : list Meta list.
get_chunks_meta
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def get_storage_info(self, address: str, level: StorageLevel): """ Get the customized storage backend info of requested storage backend level at given worker. Parameters ---------- address: str The worker address. level: StorageLevel The storage l...
Get the customized storage backend info of requested storage backend level at given worker. Parameters ---------- address: str The worker address. level: StorageLevel The storage level to fetch the backend info. Returns ------- i...
get_storage_info
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def create_remote_object(self, name: str, object_cls, *args, **kwargs): """ Create remote object. Parameters ---------- name : str Object name. object_cls Object class. args kwargs Returns ------- ref ...
Create remote object. Parameters ---------- name : str Object name. object_cls Object class. args kwargs Returns ------- ref
create_remote_object
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def get_remote_object(self, name: str): """ Get remote object Parameters ---------- name : str Object name. Returns ------- ref """
Get remote object Parameters ---------- name : str Object name. Returns ------- ref
get_remote_object
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def destroy_remote_object(self, name: str): """ Destroy remote object. Parameters ---------- name : str Object name. """
Destroy remote object. Parameters ---------- name : str Object name.
destroy_remote_object
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def register_custom_log_path( self, session_id: str, tileable_op_key: str, chunk_op_key: str, worker_address: str, log_path: str, ): """ Register custom log path. Parameters ---------- session_id : str Session ID. ...
Register custom log path. Parameters ---------- session_id : str Session ID. tileable_op_key : str Key of tileable's op. chunk_op_key : str Kye of chunk's op. worker_address : str Worker address. log_path :...
register_custom_log_path
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def new_custom_log_dir(self) -> str: """ New custom log dir. Returns ------- custom_log_dir : str Custom log dir. """
New custom log dir. Returns ------- custom_log_dir : str Custom log dir.
new_custom_log_dir
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def set_running_operand_key(self, session_id: str, op_key: str): """ Set key of running operand. Parameters ---------- session_id : str op_key : str """
Set key of running operand. Parameters ---------- session_id : str op_key : str
set_running_operand_key
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def set_progress(self, progress: float): """ Set progress of running operand. Parameters ---------- progress : float """
Set progress of running operand. Parameters ---------- progress : float
set_progress
python
mars-project/mars
mars/core/context.py
https://github.com/mars-project/mars/blob/master/mars/core/context.py
Apache-2.0
def redirect_custom_log(func: Callable[[Type, Context, OperandType], None]): """ Redirect stdout to a file by wrapping ``Operand.execute(ctx, op)`` """ @functools.wraps(func) def wrap(cls, ctx: Context, op: OperandType): custom_log_dir = ctx.new_custom_log_dir() if custom_log_dir i...
Redirect stdout to a file by wrapping ``Operand.execute(ctx, op)``
redirect_custom_log
python
mars-project/mars
mars/core/custom_log.py
https://github.com/mars-project/mars/blob/master/mars/core/custom_log.py
Apache-2.0
def init_extension_entrypoints(): """Execute all `mars_extensions` entry points with the name `init` If extensions have already been initialized, this function does nothing. """ from pkg_resources import iter_entry_points for entry_point in iter_entry_points("mars_extensions", "init"): logg...
Execute all `mars_extensions` entry points with the name `init` If extensions have already been initialized, this function does nothing.
init_extension_entrypoints
python
mars-project/mars
mars/core/entrypoints.py
https://github.com/mars-project/mars/blob/master/mars/core/entrypoints.py
Apache-2.0
def __getitem__(self, item): """ The indices for `cix` can be [x, y] or [x, :]. For the former the result will be a single chunk, and for the later the result will be a list of chunks (flattened). The length of indices must be the same with `chunk_shape` of tileable. """...
The indices for `cix` can be [x, y] or [x, :]. For the former the result will be a single chunk, and for the later the result will be a list of chunks (flattened). The length of indices must be the same with `chunk_shape` of tileable.
__getitem__
python
mars-project/mars
mars/core/entity/tileables.py
https://github.com/mars-project/mars/blob/master/mars/core/entity/tileables.py
Apache-2.0
def results(self): """ Return result tileables or chunks. Returns ------- results """
Return result tileables or chunks. Returns ------- results
results
python
mars-project/mars
mars/core/graph/entity.py
https://github.com/mars-project/mars/blob/master/mars/core/graph/entity.py
Apache-2.0
def results(self, new_results): """ Set result tileables or chunks. Parameters ---------- new_results Returns ------- """
Set result tileables or chunks. Parameters ---------- new_results Returns -------
results
python
mars-project/mars
mars/core/graph/entity.py
https://github.com/mars-project/mars/blob/master/mars/core/graph/entity.py
Apache-2.0
def build(self) -> Generator[Union[EntityGraph, ChunkGraph], None, None]: """ Build a entity graph. Returns ------- graph : EntityGraph Entity graph. """
Build a entity graph. Returns ------- graph : EntityGraph Entity graph.
build
python
mars-project/mars
mars/core/graph/builder/base.py
https://github.com/mars-project/mars/blob/master/mars/core/graph/builder/base.py
Apache-2.0
def get_logic_key(self): """The subclass may need to override this method to ensure unique and deterministic.""" fields = self._get_logic_key_token_values() try: return tokenize(*fields) except Exception as e: # pragma: no cover raise ValueError( ...
The subclass may need to override this method to ensure unique and deterministic.
get_logic_key
python
mars-project/mars
mars/core/operand/base.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/base.py
Apache-2.0
def new_chunks( self, inputs: List[ChunkType], kws: List[Dict] = None, **kwargs ) -> List[ChunkType]: """ Create chunks. A chunk is a node in a fine grained graph, all the chunk objects are created by calling this function, it happens mostly in tiles. The generated c...
Create chunks. A chunk is a node in a fine grained graph, all the chunk objects are created by calling this function, it happens mostly in tiles. The generated chunks will be set as this operand's outputs and each chunk will hold this operand as it's op. Parameters ...
new_chunks
python
mars-project/mars
mars/core/operand/core.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/core.py
Apache-2.0
def new_tileables( self, inputs: List[TileableType], kws: List[dict] = None, **kw ) -> List[TileableType]: """ Create tileable objects(Tensors or DataFrames). This is a base function for create tileable objects like tensors or dataframes, it will be called inside the `new_te...
Create tileable objects(Tensors or DataFrames). This is a base function for create tileable objects like tensors or dataframes, it will be called inside the `new_tensors` and `new_dataframes`. If eager mode is on, it will trigger the execution after tileable objects are created. ...
new_tileables
python
mars-project/mars
mars/core/operand/core.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/core.py
Apache-2.0
def pre_tile(cls, op: OperandType): """ Operation before tile. Parameters ---------- op : OperandType Operand to tile """
Operation before tile. Parameters ---------- op : OperandType Operand to tile
pre_tile
python
mars-project/mars
mars/core/operand/core.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/core.py
Apache-2.0
def post_tile(cls, op: OperandType, results: List[TileableType]): """ Operation after tile. Parameters ---------- op : OperandType Operand to tile. results: list List of tiled results. """
Operation after tile. Parameters ---------- op : OperandType Operand to tile. results: list List of tiled results.
post_tile
python
mars-project/mars
mars/core/operand/core.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/core.py
Apache-2.0
def pre_execute(cls, ctx: Union[dict, Context], op: OperandType): """ Operation before execute. Parameters ---------- ctx : dict Data store. op : OperandType Operand to execute. """
Operation before execute. Parameters ---------- ctx : dict Data store. op : OperandType Operand to execute.
pre_execute
python
mars-project/mars
mars/core/operand/core.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/core.py
Apache-2.0
def post_execute(cls, ctx: Union[dict, Context], op: OperandType): """ Operand before execute. Parameters ---------- ctx : dict Data store op : OperandType Operand to execute. """
Operand before execute. Parameters ---------- ctx : dict Data store op : OperandType Operand to execute.
post_execute
python
mars-project/mars
mars/core/operand/core.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/core.py
Apache-2.0
def execute(cls, ctx, op): """ Fetch operand needs nothing to do. """
Fetch operand needs nothing to do.
execute
python
mars-project/mars
mars/core/operand/fetch.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/fetch.py
Apache-2.0
def execute(self, ctx, op): """The mapper stage must ensure all mapper blocks are inserted into ctx and no blocks for some reducers are missing. This is needed by shuffle fetch by index, which shuffle block are identified by the index instead of data keys. For operands implementation si...
The mapper stage must ensure all mapper blocks are inserted into ctx and no blocks for some reducers are missing. This is needed by shuffle fetch by index, which shuffle block are identified by the index instead of data keys. For operands implementation simplicity, we can sort the `ctx` by key ...
execute
python
mars-project/mars
mars/core/operand/shuffle.py
https://github.com/mars-project/mars/blob/master/mars/core/operand/shuffle.py
Apache-2.0
def to_frame(self, index: bool = True, name=None): """ Create a DataFrame with a column containing the Index. Parameters ---------- index : bool, default True Set the index of the returned DataFrame as the original Index. name : object, default None ...
Create a DataFrame with a column containing the Index. Parameters ---------- index : bool, default True Set the index of the returned DataFrame as the original Index. name : object, default None The passed name should substitute for the index name (if i...
to_frame
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def to_series(self, index=None, name=None): """ Create a Series with both index and values equal to the index keys. Useful with map for returning an indexer based on an index. Parameters ---------- index : Index, optional Index of resulting Series. If None, ...
Create a Series with both index and values equal to the index keys. Useful with map for returning an indexer based on an index. Parameters ---------- index : Index, optional Index of resulting Series. If None, defaults to original index. name : str, optiona...
to_series
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def index(self): """ The index (axis labels) of the Series. """ idx = self._data.index idx._set_df_or_series(self, 0) return idx
The index (axis labels) of the Series.
index
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def copy(self, deep=True): # pylint: disable=arguments-differ """ Make a copy of this object's indices and data. When ``deep=True`` (default), a new object will be created with a copy of the calling object's data and indices. Modifications to the data or indices of the copy wil...
Make a copy of this object's indices and data. When ``deep=True`` (default), a new object will be created with a copy of the calling object's data and indices. Modifications to the data or indices of the copy will not be reflected in the original object (see notes below). ...
copy
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def to_frame(self, name=None): """ Convert Series to DataFrame. Parameters ---------- name : object, default None The passed name should substitute for the series name (if it has one). Returns ------- DataFrame DataFra...
Convert Series to DataFrame. Parameters ---------- name : object, default None The passed name should substitute for the series name (if it has one). Returns ------- DataFrame DataFrame representation of Series. Exam...
to_frame
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def between(self, left, right, inclusive="both"): """ Return boolean Series equivalent to left <= series <= right. This function returns a boolean vector containing `True` wherever the corresponding Series element is between the boundary values `left` and `right`. NA values are t...
Return boolean Series equivalent to left <= series <= right. This function returns a boolean vector containing `True` wherever the corresponding Series element is between the boundary values `left` and `right`. NA values are treated as `False`. Parameters ---------- ...
between
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def median( self, axis=None, skipna=True, out=None, overwrite_input=False, keepdims=False ): """ Return the median of the values over the requested axis. Parameters ---------- axis : {index (0)} Axis or axes along which the medians are computed. The defau...
Return the median of the values over the requested axis. Parameters ---------- axis : {index (0)} Axis or axes along which the medians are computed. The default is to compute the median along a flattened version of the tensor. A sequence of axes is s...
median
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def itertuples(self, index=True, name="Pandas", batch_size=1000, session=None): """ Iterate over DataFrame rows as namedtuples. Parameters ---------- index : bool, default True If True, return the index as the first element of the tuple. name : str or None, d...
Iterate over DataFrame rows as namedtuples. Parameters ---------- index : bool, default True If True, return the index as the first element of the tuple. name : str or None, default "Pandas" The name of the returned namedtuples or None to return regular ...
itertuples
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def assign(self, **kwargs): """ Assign new columns to a DataFrame. Returns a new object with all original columns in addition to new ones. Existing columns that are re-assigned will be overwritten. Parameters ---------- **kwargs : dict of {str: callable or Series...
Assign new columns to a DataFrame. Returns a new object with all original columns in addition to new ones. Existing columns that are re-assigned will be overwritten. Parameters ---------- **kwargs : dict of {str: callable or Series} The column names are keyw...
assign
python
mars-project/mars
mars/dataframe/core.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/core.py
Apache-2.0
def decide_dataframe_chunk_sizes(shape, chunk_size, memory_usage): """ Decide how a given DataFrame can be split into chunk. :param shape: DataFrame's shape :param chunk_size: if dict provided, it's dimension id to chunk size; if provided, it's the chunk size for each dimension. ...
Decide how a given DataFrame can be split into chunk. :param shape: DataFrame's shape :param chunk_size: if dict provided, it's dimension id to chunk size; if provided, it's the chunk size for each dimension. :param memory_usage: pandas Series in which each column's memory usage...
decide_dataframe_chunk_sizes
python
mars-project/mars
mars/dataframe/utils.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/utils.py
Apache-2.0
def split_monotonic_index_min_max( left_min_max, left_increase, right_min_max, right_increase ): """ Split the original two min_max into new min_max. Each min_max should be a list in which each item should be a 4-tuple indicates that this chunk's min value, whether the min value is close, the max va...
Split the original two min_max into new min_max. Each min_max should be a list in which each item should be a 4-tuple indicates that this chunk's min value, whether the min value is close, the max value, and whether the max value is close. The return value would be a nested list, each item is a list ...
split_monotonic_index_min_max
python
mars-project/mars
mars/dataframe/utils.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/utils.py
Apache-2.0
def merge_index_value(to_merge_index_values: dict, store_data: bool = False): """ Merge index value according to their chunk index. Parameters ---------- to_merge_index_values : dict index to index_value store_data : bool store data in index_value Returns ------- me...
Merge index value according to their chunk index. Parameters ---------- to_merge_index_values : dict index to index_value store_data : bool store data in index_value Returns ------- merged_index_value
merge_index_value
python
mars-project/mars
mars/dataframe/utils.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/utils.py
Apache-2.0
def in_range_index(i, pd_range_index): """ Check whether the input `i` is within `pd_range_index` which is a pd.RangeIndex. """ start, stop, step = ( _get_range_index_start(pd_range_index), _get_range_index_stop(pd_range_index), _get_range_index_step(pd_range_index), ) if...
Check whether the input `i` is within `pd_range_index` which is a pd.RangeIndex.
in_range_index
python
mars-project/mars
mars/dataframe/utils.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/utils.py
Apache-2.0
def validate_axis_style_args( data, args, kwargs, arg_name, method_name ): # pragma: no cover """Argument handler for mixed index, columns / axis functions In an attempt to handle both `.method(index, columns)`, and `.method(arg, axis=.)`, we have to do some bad things to argument parsing. This tr...
Argument handler for mixed index, columns / axis functions In an attempt to handle both `.method(index, columns)`, and `.method(arg, axis=.)`, we have to do some bad things to argument parsing. This translates all arguments to `{index=., columns=.}` style. Parameters ---------- data : DataFram...
validate_axis_style_args
python
mars-project/mars
mars/dataframe/utils.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/utils.py
Apache-2.0
def fetch_corner_data(df_or_series, session=None) -> pd.DataFrame: """ Fetch corner DataFrame or Series for repr usage. :param df_or_series: DataFrame or Series :return: corner DataFrame """ from .indexing.iloc import iloc max_rows = pd.get_option("display.max_rows") try: min_r...
Fetch corner DataFrame or Series for repr usage. :param df_or_series: DataFrame or Series :return: corner DataFrame
fetch_corner_data
python
mars-project/mars
mars/dataframe/utils.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/utils.py
Apache-2.0
def patch_sa_engine_execute(): """ pandas did not resolve compatibility issue of sqlalchemy 2.0, the issue is https://github.com/pandas-dev/pandas/issues/40686. We need to patch Engine class in SQLAlchemy, and then our code can work well. """ try: from sqlalchemy.engine import Engine ...
pandas did not resolve compatibility issue of sqlalchemy 2.0, the issue is https://github.com/pandas-dev/pandas/issues/40686. We need to patch Engine class in SQLAlchemy, and then our code can work well.
patch_sa_engine_execute
python
mars-project/mars
mars/dataframe/utils.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/utils.py
Apache-2.0
def df_apply( df, func, axis=0, raw=False, result_type=None, args=(), dtypes=None, dtype=None, name=None, output_type=None, index=None, elementwise=None, skip_infer=False, **kwds, ): """ Apply a function along an axis of the DataFrame. Objects passed ...
Apply a function along an axis of the DataFrame. Objects passed to the function are Series objects whose index is either the DataFrame's index (``axis=0``) or the DataFrame's columns (``axis=1``). By default (``result_type=None``), the final return type is inferred from the return type of the appl...
df_apply
python
mars-project/mars
mars/dataframe/base/apply.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/apply.py
Apache-2.0
def series_apply( series, func, convert_dtype=True, output_type=None, args=(), dtypes=None, dtype=None, name=None, index=None, skip_infer=False, **kwds, ): """ Invoke function on values of Series. Can be ufunc (a NumPy function that applies to the entire Series) ...
Invoke function on values of Series. Can be ufunc (a NumPy function that applies to the entire Series) or a Python function that only works on single values. Parameters ---------- func : function Python function or NumPy ufunc to apply. convert_dtype : bool, default True ...
series_apply
python
mars-project/mars
mars/dataframe/base/apply.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/apply.py
Apache-2.0
def astype(df, dtype, copy=True, errors="raise"): """ Cast a pandas object to a specified dtype ``dtype``. Parameters ---------- dtype : data type, or dict of column name -> data type Use a numpy.dtype or Python type to cast entire pandas object to the same type. Alternatively, use ...
Cast a pandas object to a specified dtype ``dtype``. Parameters ---------- dtype : data type, or dict of column name -> data type Use a numpy.dtype or Python type to cast entire pandas object to the same type. Alternatively, use {col: dtype, ...}, where col is a column label an...
astype
python
mars-project/mars
mars/dataframe/base/astype.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/astype.py
Apache-2.0
def filter_by_bloom_filter( df1: TileableType, df2: TileableType, left_on: Union[str, List], right_on: Union[str, List], max_elements: int = 10000, error_rate: float = 0.1, combine_size: int = None, ): """ Use bloom filter to filter DataFrame. Parameters ---------- df1: ...
Use bloom filter to filter DataFrame. Parameters ---------- df1: DataFrame. DataFrame to be filtered. df2: DataFrame. Dataframe to build filter. left_on: str or list. Column(s) selected on df1. right_on: str or list. Column(s) selected on df2. max_elemen...
filter_by_bloom_filter
python
mars-project/mars
mars/dataframe/base/bloom_filter.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/bloom_filter.py
Apache-2.0
def cut( x, bins, right: bool = True, labels=None, retbins: bool = False, precision: int = 3, include_lowest: bool = False, duplicates: str = "raise", ordered: bool = True, ): """ Bin values into discrete intervals. Use `cut` when you need to segment and sort data values...
Bin values into discrete intervals. Use `cut` when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a categorical variable. For example, `cut` could convert ages to groups of age ranges. Supports binning into an equal number o...
cut
python
mars-project/mars
mars/dataframe/base/cut.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/cut.py
Apache-2.0
def df_diff(df, periods=1, axis=0): """ First discrete difference of element. Calculates the difference of a DataFrame element compared with another element in the DataFrame (default is the element in the same column of the previous row). Parameters ---------- periods : int, default 1 ...
First discrete difference of element. Calculates the difference of a DataFrame element compared with another element in the DataFrame (default is the element in the same column of the previous row). Parameters ---------- periods : int, default 1 Periods to shift for calculating dif...
df_diff
python
mars-project/mars
mars/dataframe/base/diff.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/diff.py
Apache-2.0
def df_pop(df, item): """ Return item and drop from frame. Raise KeyError if not found. Parameters ---------- item : str Label of column to be popped. Returns ------- Series Examples -------- >>> import numpy as np >>> import mars.dataframe as md >>> df = m...
Return item and drop from frame. Raise KeyError if not found. Parameters ---------- item : str Label of column to be popped. Returns ------- Series Examples -------- >>> import numpy as np >>> import mars.dataframe as md >>> df = md.DataFrame([('falcon', 'bird...
df_pop
python
mars-project/mars
mars/dataframe/base/drop.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/drop.py
Apache-2.0
def series_drop( series, labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors="raise", ): """ Return Series with specified index labels removed. Remove elements of a Series based on specifying the index labels. When using a multi-index, labels...
Return Series with specified index labels removed. Remove elements of a Series based on specifying the index labels. When using a multi-index, labels on different levels can be removed by specifying the level. Parameters ---------- labels : single label or list-like Index labels t...
series_drop
python
mars-project/mars
mars/dataframe/base/drop.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/drop.py
Apache-2.0
def series_drop_duplicates(series, keep="first", inplace=False, method="auto"): """ Return Series with duplicate values removed. Parameters ---------- keep : {'first', 'last', ``False``}, default 'first' Method to handle dropping duplicates: - 'first' : Drop duplicates except for t...
Return Series with duplicate values removed. Parameters ---------- keep : {'first', 'last', ``False``}, default 'first' Method to handle dropping duplicates: - 'first' : Drop duplicates except for the first occurrence. - 'last' : Drop duplicates except for the last occurrence....
series_drop_duplicates
python
mars-project/mars
mars/dataframe/base/drop_duplicates.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/drop_duplicates.py
Apache-2.0
def index_drop_duplicates(index, keep="first", method="auto"): """ Return Index with duplicate values removed. Parameters ---------- keep : {'first', 'last', ``False``}, default 'first' - 'first' : Drop duplicates except for the first occurrence. - 'last' : Drop duplicates except fo...
Return Index with duplicate values removed. Parameters ---------- keep : {'first', 'last', ``False``}, default 'first' - 'first' : Drop duplicates except for the first occurrence. - 'last' : Drop duplicates except for the last occurrence. - ``False`` : Drop all duplicates. ...
index_drop_duplicates
python
mars-project/mars
mars/dataframe/base/drop_duplicates.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/drop_duplicates.py
Apache-2.0
def df_duplicated(df, subset=None, keep="first", method="auto"): """ Return boolean Series denoting duplicate rows. Considering certain columns is optional. Parameters ---------- subset : column label or sequence of labels, optional Only consider certain columns for identifying duplica...
Return boolean Series denoting duplicate rows. Considering certain columns is optional. Parameters ---------- subset : column label or sequence of labels, optional Only consider certain columns for identifying duplicates, by default use all of the columns. keep : {'first', 'la...
df_duplicated
python
mars-project/mars
mars/dataframe/base/duplicated.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/duplicated.py
Apache-2.0
def series_duplicated(series, keep="first", method="auto"): """ Indicate duplicate Series values. Duplicated values are indicated as ``True`` values in the resulting Series. Either all duplicates, all except the first or all except the last occurrence of duplicates can be indicated. Parameters...
Indicate duplicate Series values. Duplicated values are indicated as ``True`` values in the resulting Series. Either all duplicates, all except the first or all except the last occurrence of duplicates can be indicated. Parameters ---------- keep : {'first', 'last', False}, default 'first...
series_duplicated
python
mars-project/mars
mars/dataframe/base/duplicated.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/duplicated.py
Apache-2.0
def mars_eval( expr, parser="mars", engine=None, local_dict=None, global_dict=None, resolvers=(), level=0, target=None, inplace=False, ): """ Evaluate a Python expression as a string using various backends. The following arithmetic operations are supported: ``+``, ``-``...
Evaluate a Python expression as a string using various backends. The following arithmetic operations are supported: ``+``, ``-``, ``*``, ``/``, ``**``, ``%``, ``//`` (python engine only) along with the following boolean operations: ``|`` (or), ``&`` (and), and ``~`` (not). Additionally, the ``'pa...
mars_eval
python
mars-project/mars
mars/dataframe/base/eval.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/eval.py
Apache-2.0
def df_eval(df, expr, inplace=False, **kwargs): """ Evaluate a string describing operations on DataFrame columns. Operates on columns only, not specific rows or elements. This allows `eval` to run arbitrary code, which can make you vulnerable to code injection if you pass user input to this functi...
Evaluate a string describing operations on DataFrame columns. Operates on columns only, not specific rows or elements. This allows `eval` to run arbitrary code, which can make you vulnerable to code injection if you pass user input to this function. Parameters ---------- expr : str ...
df_eval
python
mars-project/mars
mars/dataframe/base/eval.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/eval.py
Apache-2.0
def df_query(df, expr, inplace=False, **kwargs): """ Query the columns of a DataFrame with a boolean expression. Parameters ---------- expr : str The query string to evaluate. You can refer to variables in the environment by prefixing them with an '@' character like ...
Query the columns of a DataFrame with a boolean expression. Parameters ---------- expr : str The query string to evaluate. You can refer to variables in the environment by prefixing them with an '@' character like ``@a + b``. You can refer to column names that...
df_query
python
mars-project/mars
mars/dataframe/base/eval.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/eval.py
Apache-2.0
def series_isin(elements, values): """ Whether elements in Series are contained in `values`. Return a boolean Series showing whether each element in the Series matches an element in the passed sequence of `values` exactly. Parameters ---------- values : set or list-like The sequenc...
Whether elements in Series are contained in `values`. Return a boolean Series showing whether each element in the Series matches an element in the passed sequence of `values` exactly. Parameters ---------- values : set or list-like The sequence of values to test. Passing in a single s...
series_isin
python
mars-project/mars
mars/dataframe/base/isin.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/isin.py
Apache-2.0
def df_isin(df, values): """ Whether each element in the DataFrame is contained in values. Parameters ---------- values : iterable, Series, DataFrame or dict The result will only be true at a location if all the labels match. If `values` is a Series, that's the index. If `va...
Whether each element in the DataFrame is contained in values. Parameters ---------- values : iterable, Series, DataFrame or dict The result will only be true at a location if all the labels match. If `values` is a Series, that's the index. If `values` is a dict, the keys must b...
df_isin
python
mars-project/mars
mars/dataframe/base/isin.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/isin.py
Apache-2.0
def series_map( series, arg, na_action=None, dtype=None, memory_scale=None, skip_infer=False ): """ Map values of Series according to input correspondence. Used for substituting each value in a Series with another value, that may be derived from a function, a ``dict`` or a :class:`Series`. ...
Map values of Series according to input correspondence. Used for substituting each value in a Series with another value, that may be derived from a function, a ``dict`` or a :class:`Series`. Parameters ---------- arg : function, collections.abc.Mapping subclass or Series Mapping c...
series_map
python
mars-project/mars
mars/dataframe/base/map.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/map.py
Apache-2.0
def index_map( idx, mapper, na_action=None, dtype=None, memory_scale=None, skip_infer=False ): """ Map values using input correspondence (a dict, Series, or function). Parameters ---------- mapper : function, dict, or Series Mapping correspondence. na_action : {None, 'ignore'} ...
Map values using input correspondence (a dict, Series, or function). Parameters ---------- mapper : function, dict, or Series Mapping correspondence. na_action : {None, 'ignore'} If 'ignore', propagate NA values, without passing them to the mapping correspondence. dtype...
index_map
python
mars-project/mars
mars/dataframe/base/map.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/map.py
Apache-2.0
def map_chunk(df_or_series, func, args=(), kwargs=None, skip_infer=False, **kw): """ Apply function to each chunk. Parameters ---------- func : function Function to apply to each chunk. args : tuple Positional arguments to pass to func in addition to the array/series. kwargs...
Apply function to each chunk. Parameters ---------- func : function Function to apply to each chunk. args : tuple Positional arguments to pass to func in addition to the array/series. kwargs: Dict Additional keyword arguments to pass as keywords arguments to func. s...
map_chunk
python
mars-project/mars
mars/dataframe/base/map_chunk.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/map_chunk.py
Apache-2.0
def melt( frame, id_vars=None, value_vars=None, var_name=None, value_name="value", col_level=None, ): """ Unpivot a DataFrame from wide to long format, optionally leaving identifiers set. This function is useful to massage a DataFrame into a format where one or more columns are ...
Unpivot a DataFrame from wide to long format, optionally leaving identifiers set. This function is useful to massage a DataFrame into a format where one or more columns are identifier variables (`id_vars`), while all other columns, considered measured variables (`value_vars`), are "unpivoted" to t...
melt
python
mars-project/mars
mars/dataframe/base/melt.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/melt.py
Apache-2.0
def _adapt_index(self, input_index, index=0): """ When ``index=True`` is passed, an extra column will be prepended to the result series Thus we need to update the index of initial chunk for returned dataframe chunks """ if not self.index or index != 0: return input_in...
When ``index=True`` is passed, an extra column will be prepended to the result series Thus we need to update the index of initial chunk for returned dataframe chunks
_adapt_index
python
mars-project/mars
mars/dataframe/base/memory_usage.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/memory_usage.py
Apache-2.0
def _adapt_nsplits(self, input_nsplit): """ When ``index=True`` is passed, the size of returned series is one element larger than the number of columns, which affects ``nsplits``. """ if not self.index: return (input_nsplit[-1],) nsplits_list = list(input_nspl...
When ``index=True`` is passed, the size of returned series is one element larger than the number of columns, which affects ``nsplits``.
_adapt_nsplits
python
mars-project/mars
mars/dataframe/base/memory_usage.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/memory_usage.py
Apache-2.0
def _tile_single(cls, op: "DataFrameMemoryUsage"): """ Tile when input data has only one chunk on rows """ df_or_series = op.inputs[0] output = op.outputs[0] chunks = [] for c in df_or_series.chunks: new_op = op.copy().reset_key() if c.ndi...
Tile when input data has only one chunk on rows
_tile_single
python
mars-project/mars
mars/dataframe/base/memory_usage.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/memory_usage.py
Apache-2.0
def qcut(x, q, labels=None, retbins=False, precision=3, duplicate="raise"): """ Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating qua...
Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating quantile membership for each data point. Parameters ---------- x : 1d ten...
qcut
python
mars-project/mars
mars/dataframe/base/qcut.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/qcut.py
Apache-2.0
def rebalance( df_or_series, factor=None, axis=0, num_partitions=None, reassign_worker=True ): """ Make Data more balanced across entire cluster. Parameters ---------- factor : float Specified so that number of chunks after balance is total CPU count of cluster * factor. axi...
Make Data more balanced across entire cluster. Parameters ---------- factor : float Specified so that number of chunks after balance is total CPU count of cluster * factor. axis : int The axis to rebalance. num_partitions : int Specified so the number of chunks ...
rebalance
python
mars-project/mars
mars/dataframe/base/rebalance.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/rebalance.py
Apache-2.0
def select_dtypes(df, include=None, exclude=None): """ Return a subset of the DataFrame's columns based on the column dtypes. Parameters ---------- include, exclude : scalar or list-like A selection of dtypes or strings to be included/excluded. At least one of these parameters must ...
Return a subset of the DataFrame's columns based on the column dtypes. Parameters ---------- include, exclude : scalar or list-like A selection of dtypes or strings to be included/excluded. At least one of these parameters must be supplied. Returns ------- DataFrame ...
select_dtypes
python
mars-project/mars
mars/dataframe/base/select_dtypes.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/select_dtypes.py
Apache-2.0
def shift(df_or_series, periods=1, freq=None, axis=0, fill_value=None): """ Shift index by desired number of periods with an optional time `freq`. When `freq` is not passed, shift the index without realigning the data. If `freq` is passed (in this case, the index must be date or datetime, or it wil...
Shift index by desired number of periods with an optional time `freq`. When `freq` is not passed, shift the index without realigning the data. If `freq` is passed (in this case, the index must be date or datetime, or it will raise a `NotImplementedError`), the index will be increased using the per...
shift
python
mars-project/mars
mars/dataframe/base/shift.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/shift.py
Apache-2.0
def df_transform(df, func, axis=0, *args, dtypes=None, skip_infer=False, **kwargs): """ Call ``func`` on self producing a DataFrame with transformed values. Produced DataFrame will have same axis length as self. Parameters ---------- func : function, str, list or dict Function to use f...
Call ``func`` on self producing a DataFrame with transformed values. Produced DataFrame will have same axis length as self. Parameters ---------- func : function, str, list or dict Function to use for transforming the data. If a function, must either work when passed a DataFrame o...
df_transform
python
mars-project/mars
mars/dataframe/base/transform.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/transform.py
Apache-2.0
def series_transform( series, func, convert_dtype=True, axis=0, *args, skip_infer=False, dtype=None, **kwargs ): """ Call ``func`` on self producing a Series with transformed values. Produced Series will have same axis length as self. Parameters ---------- func ...
Call ``func`` on self producing a Series with transformed values. Produced Series will have same axis length as self. Parameters ---------- func : function, str, list or dict Function to use for transforming the data. If a function, must either work when passed a Series or when passed to ...
series_transform
python
mars-project/mars
mars/dataframe/base/transform.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/transform.py
Apache-2.0
def value_counts( series, normalize=False, sort=True, ascending=False, bins=None, dropna=True, method="auto", ): """ Return a Series containing counts of unique values. The resulting object will be in descending order so that the first element is the most frequently-occurrin...
Return a Series containing counts of unique values. The resulting object will be in descending order so that the first element is the most frequently-occurring element. Excludes NA values by default. Parameters ---------- normalize : bool, default False If True then the object ret...
value_counts
python
mars-project/mars
mars/dataframe/base/value_counts.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/base/value_counts.py
Apache-2.0
def to_ray_dataset(df, num_shards: int = None): """Create a Ray Dataset from Mars DataFrame Args: df (mars.dataframe.Dataframe): the Mars DataFrame num_shards (int, optional): the number of shards that will be created for the Ray Dataset. Defaults to None. If num_shards ...
Create a Ray Dataset from Mars DataFrame Args: df (mars.dataframe.Dataframe): the Mars DataFrame num_shards (int, optional): the number of shards that will be created for the Ray Dataset. Defaults to None. If num_shards is None, chunks will be grouped by nodes where they lie...
to_ray_dataset
python
mars-project/mars
mars/dataframe/contrib/raydataset/dataset.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/contrib/raydataset/dataset.py
Apache-2.0
def __init__(self, shard_id: int, obj_refs: "ray.ObjectRef"): """Iterable batch holding a list of ray.ObjectRefs. Args: shard_id (int): id of the shard prefix (str): prefix name of the batch obj_refs (List[ray.ObjectRefs]): list of ray.ObjectRefs """ ...
Iterable batch holding a list of ray.ObjectRefs. Args: shard_id (int): id of the shard prefix (str): prefix name of the batch obj_refs (List[ray.ObjectRefs]): list of ray.ObjectRefs
__init__
python
mars-project/mars
mars/dataframe/contrib/raydataset/mldataset.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/contrib/raydataset/mldataset.py
Apache-2.0
def _group_chunk_refs( chunk_addr_refs: List[Tuple[Tuple, "ray.ObjectRef"]], num_shards: int ): """Group fetched ray.ObjectRefs into a dict for later use. Args: chunk_addr_refs (List[Tuple[Tuple, ray.ObjectRef]]): a list of tuples of band & ray.ObjectRef of each chunk. num_shard...
Group fetched ray.ObjectRefs into a dict for later use. Args: chunk_addr_refs (List[Tuple[Tuple, ray.ObjectRef]]): a list of tuples of band & ray.ObjectRef of each chunk. num_shards (int): the number of shards that will be created for the MLDataset. Returns: Dict[str, List[...
_group_chunk_refs
python
mars-project/mars
mars/dataframe/contrib/raydataset/mldataset.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/contrib/raydataset/mldataset.py
Apache-2.0
def to_ray_mldataset(df, num_shards: int = None): """Create a MLDataset from Mars DataFrame Args: df (mars.dataframe.Dataframe): the Mars DataFrame num_shards (int, optional): the number of shards that will be created for the MLDataset. Defaults to None. If num_shards is...
Create a MLDataset from Mars DataFrame Args: df (mars.dataframe.Dataframe): the Mars DataFrame num_shards (int, optional): the number of shards that will be created for the MLDataset. Defaults to None. If num_shards is None, chunks will be grouped by nodes where they lie. ...
to_ray_mldataset
python
mars-project/mars
mars/dataframe/contrib/raydataset/mldataset.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/contrib/raydataset/mldataset.py
Apache-2.0
def _infer_tz_from_endpoints(start, end, tz): # pragma: no cover """ If a timezone is not explicitly given via `tz`, see if one can be inferred from the `start` and `end` endpoints. If more than one of these inputs provides a timezone, require that they all agree. Parameters ---------- st...
If a timezone is not explicitly given via `tz`, see if one can be inferred from the `start` and `end` endpoints. If more than one of these inputs provides a timezone, require that they all agree. Parameters ---------- start : Timestamp end : Timestamp tz : tzinfo or None Returns ...
_infer_tz_from_endpoints
python
mars-project/mars
mars/dataframe/datasource/date_range.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/datasource/date_range.py
Apache-2.0
def _maybe_localize_point( ts, is_none, is_not_none, freq, tz, ambiguous, nonexistent ): # pragma: no cover """ Localize a start or end Timestamp to the timezone of the corresponding start or end Timestamp Parameters ---------- ts : start or end Timestamp to potentially localize is_non...
Localize a start or end Timestamp to the timezone of the corresponding start or end Timestamp Parameters ---------- ts : start or end Timestamp to potentially localize is_none : argument that should be None is_not_none : argument that should not be None freq : Tick, DateOffset, or None...
_maybe_localize_point
python
mars-project/mars
mars/dataframe/datasource/date_range.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/datasource/date_range.py
Apache-2.0
def read_parquet( path, engine: str = "auto", columns: list = None, groups_as_chunks: bool = False, use_arrow_dtype: bool = None, incremental_index: bool = False, storage_options: dict = None, memory_scale: int = None, merge_small_files: bool = True, merge_small_file_options: dic...
Load a parquet object from the file path, returning a DataFrame. Parameters ---------- path : str, path object or file-like object Any valid string path is acceptable. The string could be a URL. For file URLs, a host is expected. A local file could be: ``file://localhost/path/t...
read_parquet
python
mars-project/mars
mars/dataframe/datasource/read_parquet.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/datasource/read_parquet.py
Apache-2.0
def _update_key(self): """We can't direct generate token for mldataset when we use ray client, so we use all mldataset's actor_id to generate token. """ datas = [] for value in self._values_: if isinstance(value, ray.util.data.MLDataset): actor...
We can't direct generate token for mldataset when we use ray client, so we use all mldataset's actor_id to generate token.
_update_key
python
mars-project/mars
mars/dataframe/datasource/read_raydataset.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/datasource/read_raydataset.py
Apache-2.0
def to_parquet( df, path, engine="auto", compression="snappy", index=None, partition_cols=None, storage_options: dict = None, **kwargs, ): """ Write a DataFrame to the binary parquet format, each chunk will be written to a Parquet file. Parameters ---------- path...
Write a DataFrame to the binary parquet format, each chunk will be written to a Parquet file. Parameters ---------- path : str or file-like object If path is a string with wildcard e.g. '/to/path/out-*.parquet', `to_parquet` will try to write multiple files, for instance, c...
to_parquet
python
mars-project/mars
mars/dataframe/datastore/to_parquet.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/datastore/to_parquet.py
Apache-2.0
def to_sql( df, name: str, con, schema=None, if_exists: str = "fail", index: bool = True, index_label=None, chunksize=None, dtype=None, method=None, ): """ Write records stored in a DataFrame to a SQL database. Databases supported by SQLAlchemy [1]_ are supported. Ta...
Write records stored in a DataFrame to a SQL database. Databases supported by SQLAlchemy [1]_ are supported. Tables can be newly created, appended to, or overwritten. Parameters ---------- name : str Name of SQL table. con : sqlalchemy.engine.Engine or sqlite3.Connection U...
to_sql
python
mars-project/mars
mars/dataframe/datastore/to_sql.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/datastore/to_sql.py
Apache-2.0
def agg(groupby, func=None, method="auto", combine_size=None, *args, **kwargs): """ Aggregate using one or more operations on grouped data. Parameters ---------- groupby : Mars Groupby Groupby data. func : str or list-like Aggregation functions. method : {'auto', 'shuffle', ...
Aggregate using one or more operations on grouped data. Parameters ---------- groupby : Mars Groupby Groupby data. func : str or list-like Aggregation functions. method : {'auto', 'shuffle', 'tree'}, default 'auto' 'tree' method provide a better performance, 'shuffle' i...
agg
python
mars-project/mars
mars/dataframe/groupby/aggregation.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/groupby/aggregation.py
Apache-2.0
def groupby_apply( groupby, func, *args, output_type=None, dtypes=None, dtype=None, name=None, index=None, skip_infer=None, **kwargs, ): """ Apply function `func` group-wise and combine the results together. The function passed to `apply` must take a dataframe as its...
Apply function `func` group-wise and combine the results together. The function passed to `apply` must take a dataframe as its first argument and return a DataFrame, Series or scalar. `apply` will then take care of combining the results back together into a single dataframe or series. `apply` is t...
groupby_apply
python
mars-project/mars
mars/dataframe/groupby/apply.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/groupby/apply.py
Apache-2.0
def execute_map(cls, op, in_data: pd.DataFrame) -> Union[pd.DataFrame, pd.Series]: """ Map stage implement. Parameters ------- op : Any operand DataFrame operand. in_data : pd.DataFrame Input dataframe. Returns ------- ...
Map stage implement. Parameters ------- op : Any operand DataFrame operand. in_data : pd.DataFrame Input dataframe. Returns ------- The result of op map stage.
execute_map
python
mars-project/mars
mars/dataframe/groupby/custom_aggregation.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/groupby/custom_aggregation.py
Apache-2.0
def execute_combine( cls, op, in_data: pd.DataFrame ) -> Union[pd.DataFrame, pd.Series]: """ Combine stage implement. Parameters ---------- op : Any operand DataFrame operand. in_data : pd.Dataframe Input dataframe. Returns ...
Combine stage implement. Parameters ---------- op : Any operand DataFrame operand. in_data : pd.Dataframe Input dataframe. Returns ------- The result of op combine stage.
execute_combine
python
mars-project/mars
mars/dataframe/groupby/custom_aggregation.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/groupby/custom_aggregation.py
Apache-2.0
def execute_agg(cls, op, in_data: pd.DataFrame) -> Union[pd.DataFrame, pd.Series]: """ Agg stage implement. Parameters ---------- op : Any operand DataFrame operand. in_data : pd.Dataframe Input dataframe. Returns ------- ...
Agg stage implement. Parameters ---------- op : Any operand DataFrame operand. in_data : pd.Dataframe Input dataframe. Returns ------- The result of op agg stage.
execute_agg
python
mars-project/mars
mars/dataframe/groupby/custom_aggregation.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/groupby/custom_aggregation.py
Apache-2.0
def head(groupby, n=5): """ Return first n rows of each group. Similar to ``.apply(lambda x: x.head(n))``, but it returns a subset of rows from the original Series or DataFrame with original index and order preserved (``as_index`` flag is ignored). Does not work for negative values of `n`. ...
Return first n rows of each group. Similar to ``.apply(lambda x: x.head(n))``, but it returns a subset of rows from the original Series or DataFrame with original index and order preserved (``as_index`` flag is ignored). Does not work for negative values of `n`. Returns ------- Serie...
head
python
mars-project/mars
mars/dataframe/groupby/head.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/groupby/head.py
Apache-2.0
def _get_level_indexes( cls, op: DataFrameGroupByAgg, data: pd.DataFrame ) -> List[int]: """ When group by level, get the level index list. Level can be int, level name, or sequence of such. This function calculates the corresponding indexes. Parameters ------...
When group by level, get the level index list. Level can be int, level name, or sequence of such. This function calculates the corresponding indexes. Parameters ---------- op data Returns -------
_get_level_indexes
python
mars-project/mars
mars/dataframe/groupby/nunique.py
https://github.com/mars-project/mars/blob/master/mars/dataframe/groupby/nunique.py
Apache-2.0