partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
is_bool_dtype
Check whether the provided array or dtype is of a boolean dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of a boolean dtype. Notes ----- An ExtensionArray is considere...
pandas/core/dtypes/common.py
def is_bool_dtype(arr_or_dtype): """ Check whether the provided array or dtype is of a boolean dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of a boolean dtype. Notes...
def is_bool_dtype(arr_or_dtype): """ Check whether the provided array or dtype is of a boolean dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of a boolean dtype. Notes...
[ "Check", "whether", "the", "provided", "array", "or", "dtype", "is", "of", "a", "boolean", "dtype", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1600-L1663
[ "def", "is_bool_dtype", "(", "arr_or_dtype", ")", ":", "if", "arr_or_dtype", "is", "None", ":", "return", "False", "try", ":", "dtype", "=", "_get_dtype", "(", "arr_or_dtype", ")", "except", "TypeError", ":", "return", "False", "if", "isinstance", "(", "arr_...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
is_extension_type
Check whether an array-like is of a pandas extension class instance. Extension classes include categoricals, pandas sparse objects (i.e. classes represented within the pandas library and not ones external to it like scipy sparse matrices), and datetime-like arrays. Parameters ---------- arr : ...
pandas/core/dtypes/common.py
def is_extension_type(arr): """ Check whether an array-like is of a pandas extension class instance. Extension classes include categoricals, pandas sparse objects (i.e. classes represented within the pandas library and not ones external to it like scipy sparse matrices), and datetime-like arrays. ...
def is_extension_type(arr): """ Check whether an array-like is of a pandas extension class instance. Extension classes include categoricals, pandas sparse objects (i.e. classes represented within the pandas library and not ones external to it like scipy sparse matrices), and datetime-like arrays. ...
[ "Check", "whether", "an", "array", "-", "like", "is", "of", "a", "pandas", "extension", "class", "instance", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1666-L1722
[ "def", "is_extension_type", "(", "arr", ")", ":", "if", "is_categorical", "(", "arr", ")", ":", "return", "True", "elif", "is_sparse", "(", "arr", ")", ":", "return", "True", "elif", "is_datetime64tz_dtype", "(", "arr", ")", ":", "return", "True", "return"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
is_extension_array_dtype
Check if an object is a pandas extension array type. See the :ref:`Use Guide <extending.extension-types>` for more. Parameters ---------- arr_or_dtype : object For array-like input, the ``.dtype`` attribute will be extracted. Returns ------- bool Whether the `arr_o...
pandas/core/dtypes/common.py
def is_extension_array_dtype(arr_or_dtype): """ Check if an object is a pandas extension array type. See the :ref:`Use Guide <extending.extension-types>` for more. Parameters ---------- arr_or_dtype : object For array-like input, the ``.dtype`` attribute will be extracted. ...
def is_extension_array_dtype(arr_or_dtype): """ Check if an object is a pandas extension array type. See the :ref:`Use Guide <extending.extension-types>` for more. Parameters ---------- arr_or_dtype : object For array-like input, the ``.dtype`` attribute will be extracted. ...
[ "Check", "if", "an", "object", "is", "a", "pandas", "extension", "array", "type", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1725-L1772
[ "def", "is_extension_array_dtype", "(", "arr_or_dtype", ")", ":", "dtype", "=", "getattr", "(", "arr_or_dtype", ",", "'dtype'", ",", "arr_or_dtype", ")", "return", "(", "isinstance", "(", "dtype", ",", "ExtensionDtype", ")", "or", "registry", ".", "find", "(",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_is_dtype
Return a boolean if the condition is satisfied for the arr_or_dtype. Parameters ---------- arr_or_dtype : array-like, str, np.dtype, or ExtensionArrayType The array-like or dtype object whose dtype we want to extract. condition : callable[Union[np.dtype, ExtensionDtype]] Returns ------...
pandas/core/dtypes/common.py
def _is_dtype(arr_or_dtype, condition): """ Return a boolean if the condition is satisfied for the arr_or_dtype. Parameters ---------- arr_or_dtype : array-like, str, np.dtype, or ExtensionArrayType The array-like or dtype object whose dtype we want to extract. condition : callable[Unio...
def _is_dtype(arr_or_dtype, condition): """ Return a boolean if the condition is satisfied for the arr_or_dtype. Parameters ---------- arr_or_dtype : array-like, str, np.dtype, or ExtensionArrayType The array-like or dtype object whose dtype we want to extract. condition : callable[Unio...
[ "Return", "a", "boolean", "if", "the", "condition", "is", "satisfied", "for", "the", "arr_or_dtype", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1808-L1830
[ "def", "_is_dtype", "(", "arr_or_dtype", ",", "condition", ")", ":", "if", "arr_or_dtype", "is", "None", ":", "return", "False", "try", ":", "dtype", "=", "_get_dtype", "(", "arr_or_dtype", ")", "except", "(", "TypeError", ",", "ValueError", ",", "UnicodeEnc...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_dtype
Get the dtype instance associated with an array or dtype object. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. Returns ------- obj_dtype : The extract dtype instance from the passed in array or dtype o...
pandas/core/dtypes/common.py
def _get_dtype(arr_or_dtype): """ Get the dtype instance associated with an array or dtype object. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. Returns ------- obj_dtype : The extract dtype instance from the ...
def _get_dtype(arr_or_dtype): """ Get the dtype instance associated with an array or dtype object. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. Returns ------- obj_dtype : The extract dtype instance from the ...
[ "Get", "the", "dtype", "instance", "associated", "with", "an", "array", "or", "dtype", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1833-L1866
[ "def", "_get_dtype", "(", "arr_or_dtype", ")", ":", "if", "arr_or_dtype", "is", "None", ":", "raise", "TypeError", "(", "\"Cannot deduce dtype from null object\"", ")", "# fastpath", "elif", "isinstance", "(", "arr_or_dtype", ",", "np", ".", "dtype", ")", ":", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_is_dtype_type
Return a boolean if the condition is satisfied for the arr_or_dtype. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. condition : callable[Union[np.dtype, ExtensionDtypeType]] Returns ------- bool : if the condition is s...
pandas/core/dtypes/common.py
def _is_dtype_type(arr_or_dtype, condition): """ Return a boolean if the condition is satisfied for the arr_or_dtype. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. condition : callable[Union[np.dtype, ExtensionDtypeType]] ...
def _is_dtype_type(arr_or_dtype, condition): """ Return a boolean if the condition is satisfied for the arr_or_dtype. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. condition : callable[Union[np.dtype, ExtensionDtypeType]] ...
[ "Return", "a", "boolean", "if", "the", "condition", "is", "satisfied", "for", "the", "arr_or_dtype", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1869-L1913
[ "def", "_is_dtype_type", "(", "arr_or_dtype", ",", "condition", ")", ":", "if", "arr_or_dtype", "is", "None", ":", "return", "condition", "(", "type", "(", "None", ")", ")", "# fastpath", "if", "isinstance", "(", "arr_or_dtype", ",", "np", ".", "dtype", ")...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
infer_dtype_from_object
Get a numpy dtype.type-style object for a dtype object. This methods also includes handling of the datetime64[ns] and datetime64[ns, TZ] objects. If no dtype can be found, we return ``object``. Parameters ---------- dtype : dtype, type The dtype object whose numpy dtype.type-style ...
pandas/core/dtypes/common.py
def infer_dtype_from_object(dtype): """ Get a numpy dtype.type-style object for a dtype object. This methods also includes handling of the datetime64[ns] and datetime64[ns, TZ] objects. If no dtype can be found, we return ``object``. Parameters ---------- dtype : dtype, type T...
def infer_dtype_from_object(dtype): """ Get a numpy dtype.type-style object for a dtype object. This methods also includes handling of the datetime64[ns] and datetime64[ns, TZ] objects. If no dtype can be found, we return ``object``. Parameters ---------- dtype : dtype, type T...
[ "Get", "a", "numpy", "dtype", ".", "type", "-", "style", "object", "for", "a", "dtype", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1916-L1977
[ "def", "infer_dtype_from_object", "(", "dtype", ")", ":", "if", "isinstance", "(", "dtype", ",", "type", ")", "and", "issubclass", "(", "dtype", ",", "np", ".", "generic", ")", ":", "# Type object from a dtype", "return", "dtype", "elif", "isinstance", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_validate_date_like_dtype
Check whether the dtype is a date-like dtype. Raises an error if invalid. Parameters ---------- dtype : dtype, type The dtype to check. Raises ------ TypeError : The dtype could not be casted to a date-like dtype. ValueError : The dtype is an illegal date-like dtype (e.g. the ...
pandas/core/dtypes/common.py
def _validate_date_like_dtype(dtype): """ Check whether the dtype is a date-like dtype. Raises an error if invalid. Parameters ---------- dtype : dtype, type The dtype to check. Raises ------ TypeError : The dtype could not be casted to a date-like dtype. ValueError : The d...
def _validate_date_like_dtype(dtype): """ Check whether the dtype is a date-like dtype. Raises an error if invalid. Parameters ---------- dtype : dtype, type The dtype to check. Raises ------ TypeError : The dtype could not be casted to a date-like dtype. ValueError : The d...
[ "Check", "whether", "the", "dtype", "is", "a", "date", "-", "like", "dtype", ".", "Raises", "an", "error", "if", "invalid", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1980-L2002
[ "def", "_validate_date_like_dtype", "(", "dtype", ")", ":", "try", ":", "typ", "=", "np", ".", "datetime_data", "(", "dtype", ")", "[", "0", "]", "except", "ValueError", "as", "e", ":", "raise", "TypeError", "(", "'{error}'", ".", "format", "(", "error",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
pandas_dtype
Convert input into a pandas only dtype object or a numpy dtype object. Parameters ---------- dtype : object to be converted Returns ------- np.dtype or a pandas dtype Raises ------ TypeError if not a dtype
pandas/core/dtypes/common.py
def pandas_dtype(dtype): """ Convert input into a pandas only dtype object or a numpy dtype object. Parameters ---------- dtype : object to be converted Returns ------- np.dtype or a pandas dtype Raises ------ TypeError if not a dtype """ # short-circuit if isi...
def pandas_dtype(dtype): """ Convert input into a pandas only dtype object or a numpy dtype object. Parameters ---------- dtype : object to be converted Returns ------- np.dtype or a pandas dtype Raises ------ TypeError if not a dtype """ # short-circuit if isi...
[ "Convert", "input", "into", "a", "pandas", "only", "dtype", "object", "or", "a", "numpy", "dtype", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L2005-L2055
[ "def", "pandas_dtype", "(", "dtype", ")", ":", "# short-circuit", "if", "isinstance", "(", "dtype", ",", "np", ".", "ndarray", ")", ":", "return", "dtype", ".", "dtype", "elif", "isinstance", "(", "dtype", ",", "(", "np", ".", "dtype", ",", "PandasExtens...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_groupby_and_merge
groupby & merge; we are always performing a left-by type operation Parameters ---------- by: field to group on: duplicates field left: left frame right: right frame _merge_pieces: function for merging check_duplicates: boolean, default True should we check & clean duplicates
pandas/core/reshape/merge.py
def _groupby_and_merge(by, on, left, right, _merge_pieces, check_duplicates=True): """ groupby & merge; we are always performing a left-by type operation Parameters ---------- by: field to group on: duplicates field left: left frame right: right frame _merge_p...
def _groupby_and_merge(by, on, left, right, _merge_pieces, check_duplicates=True): """ groupby & merge; we are always performing a left-by type operation Parameters ---------- by: field to group on: duplicates field left: left frame right: right frame _merge_p...
[ "groupby", "&", "merge", ";", "we", "are", "always", "performing", "a", "left", "-", "by", "type", "operation" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L54-L128
[ "def", "_groupby_and_merge", "(", "by", ",", "on", ",", "left", ",", "right", ",", "_merge_pieces", ",", "check_duplicates", "=", "True", ")", ":", "pieces", "=", "[", "]", "if", "not", "isinstance", "(", "by", ",", "(", "list", ",", "tuple", ")", ")...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
merge_ordered
Perform merge with optional filling/interpolation designed for ordered data like time series data. Optionally perform group-wise merge (see examples) Parameters ---------- left : DataFrame right : DataFrame on : label or list Field names to join on. Must be found in both DataFrames....
pandas/core/reshape/merge.py
def merge_ordered(left, right, on=None, left_on=None, right_on=None, left_by=None, right_by=None, fill_method=None, suffixes=('_x', '_y'), how='outer'): """Perform merge with optional filling/interpolation designed for ordered data like tim...
def merge_ordered(left, right, on=None, left_on=None, right_on=None, left_by=None, right_by=None, fill_method=None, suffixes=('_x', '_y'), how='outer'): """Perform merge with optional filling/interpolation designed for ordered data like tim...
[ "Perform", "merge", "with", "optional", "filling", "/", "interpolation", "designed", "for", "ordered", "data", "like", "time", "series", "data", ".", "Optionally", "perform", "group", "-", "wise", "merge", "(", "see", "examples", ")" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L131-L232
[ "def", "merge_ordered", "(", "left", ",", "right", ",", "on", "=", "None", ",", "left_on", "=", "None", ",", "right_on", "=", "None", ",", "left_by", "=", "None", ",", "right_by", "=", "None", ",", "fill_method", "=", "None", ",", "suffixes", "=", "(...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
merge_asof
Perform an asof merge. This is similar to a left-join except that we match on nearest key rather than equal keys. Both DataFrames must be sorted by the key. For each row in the left DataFrame: - A "backward" search selects the last row in the right DataFrame whose 'on' key is less than or e...
pandas/core/reshape/merge.py
def merge_asof(left, right, on=None, left_on=None, right_on=None, left_index=False, right_index=False, by=None, left_by=None, right_by=None, suffixes=('_x', '_y'), tolerance=None, allow_exact_matches=True, direction...
def merge_asof(left, right, on=None, left_on=None, right_on=None, left_index=False, right_index=False, by=None, left_by=None, right_by=None, suffixes=('_x', '_y'), tolerance=None, allow_exact_matches=True, direction...
[ "Perform", "an", "asof", "merge", ".", "This", "is", "similar", "to", "a", "left", "-", "join", "except", "that", "we", "match", "on", "nearest", "key", "rather", "than", "equal", "keys", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L235-L467
[ "def", "merge_asof", "(", "left", ",", "right", ",", "on", "=", "None", ",", "left_on", "=", "None", ",", "right_on", "=", "None", ",", "left_index", "=", "False", ",", "right_index", "=", "False", ",", "by", "=", "None", ",", "left_by", "=", "None",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_restore_dropped_levels_multijoin
*this is an internal non-public method* Returns the levels, labels and names of a multi-index to multi-index join. Depending on the type of join, this method restores the appropriate dropped levels of the joined multi-index. The method relies on lidx, rindexer which hold the index positions of left...
pandas/core/reshape/merge.py
def _restore_dropped_levels_multijoin(left, right, dropped_level_names, join_index, lindexer, rindexer): """ *this is an internal non-public method* Returns the levels, labels and names of a multi-index to multi-index join. Depending on the type of join, this metho...
def _restore_dropped_levels_multijoin(left, right, dropped_level_names, join_index, lindexer, rindexer): """ *this is an internal non-public method* Returns the levels, labels and names of a multi-index to multi-index join. Depending on the type of join, this metho...
[ "*", "this", "is", "an", "internal", "non", "-", "public", "method", "*" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L1195-L1281
[ "def", "_restore_dropped_levels_multijoin", "(", "left", ",", "right", ",", "dropped_level_names", ",", "join_index", ",", "lindexer", ",", "rindexer", ")", ":", "def", "_convert_to_mulitindex", "(", "index", ")", ":", "if", "isinstance", "(", "index", ",", "Mul...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_MergeOperation._maybe_restore_index_levels
Restore index levels specified as `on` parameters Here we check for cases where `self.left_on` and `self.right_on` pairs each reference an index level in their respective DataFrames. The joined columns corresponding to these pairs are then restored to the index of `result`. **N...
pandas/core/reshape/merge.py
def _maybe_restore_index_levels(self, result): """ Restore index levels specified as `on` parameters Here we check for cases where `self.left_on` and `self.right_on` pairs each reference an index level in their respective DataFrames. The joined columns corresponding to these pai...
def _maybe_restore_index_levels(self, result): """ Restore index levels specified as `on` parameters Here we check for cases where `self.left_on` and `self.right_on` pairs each reference an index level in their respective DataFrames. The joined columns corresponding to these pai...
[ "Restore", "index", "levels", "specified", "as", "on", "parameters" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L619-L650
[ "def", "_maybe_restore_index_levels", "(", "self", ",", "result", ")", ":", "names_to_restore", "=", "[", "]", "for", "name", ",", "left_key", ",", "right_key", "in", "zip", "(", "self", ".", "join_names", ",", "self", ".", "left_on", ",", "self", ".", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_MergeOperation._get_join_indexers
return the join indexers
pandas/core/reshape/merge.py
def _get_join_indexers(self): """ return the join indexers """ return _get_join_indexers(self.left_join_keys, self.right_join_keys, sort=self.sort, how=self.how)
def _get_join_indexers(self): """ return the join indexers """ return _get_join_indexers(self.left_join_keys, self.right_join_keys, sort=self.sort, how=self.how)
[ "return", "the", "join", "indexers" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L735-L740
[ "def", "_get_join_indexers", "(", "self", ")", ":", "return", "_get_join_indexers", "(", "self", ".", "left_join_keys", ",", "self", ".", "right_join_keys", ",", "sort", "=", "self", ".", "sort", ",", "how", "=", "self", ".", "how", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_MergeOperation._create_join_index
Create a join index by rearranging one index to match another Parameters ---------- index: Index being rearranged other_index: Index used to supply values not found in index indexer: how to rearrange index how: replacement is only necessary if indexer based on other_inde...
pandas/core/reshape/merge.py
def _create_join_index(self, index, other_index, indexer, other_indexer, how='left'): """ Create a join index by rearranging one index to match another Parameters ---------- index: Index being rearranged other_index: Index used to supply values...
def _create_join_index(self, index, other_index, indexer, other_indexer, how='left'): """ Create a join index by rearranging one index to match another Parameters ---------- index: Index being rearranged other_index: Index used to supply values...
[ "Create", "a", "join", "index", "by", "rearranging", "one", "index", "to", "match", "another" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L790-L821
[ "def", "_create_join_index", "(", "self", ",", "index", ",", "other_index", ",", "indexer", ",", "other_indexer", ",", "how", "=", "'left'", ")", ":", "join_index", "=", "index", ".", "take", "(", "indexer", ")", "if", "(", "self", ".", "how", "in", "(...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_MergeOperation._get_merge_keys
Note: has side effects (copy/delete key columns) Parameters ---------- left right on Returns ------- left_keys, right_keys
pandas/core/reshape/merge.py
def _get_merge_keys(self): """ Note: has side effects (copy/delete key columns) Parameters ---------- left right on Returns ------- left_keys, right_keys """ left_keys = [] right_keys = [] join_names = [] ...
def _get_merge_keys(self): """ Note: has side effects (copy/delete key columns) Parameters ---------- left right on Returns ------- left_keys, right_keys """ left_keys = [] right_keys = [] join_names = [] ...
[ "Note", ":", "has", "side", "effects", "(", "copy", "/", "delete", "key", "columns", ")" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L823-L933
[ "def", "_get_merge_keys", "(", "self", ")", ":", "left_keys", "=", "[", "]", "right_keys", "=", "[", "]", "join_names", "=", "[", "]", "right_drop", "=", "[", "]", "left_drop", "=", "[", "]", "left", ",", "right", "=", "self", ".", "left", ",", "se...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_AsOfMerge._get_join_indexers
return the join indexers
pandas/core/reshape/merge.py
def _get_join_indexers(self): """ return the join indexers """ def flip(xs): """ unlike np.transpose, this returns an array of tuples """ labels = list(string.ascii_lowercase[:len(xs)]) dtypes = [x.dtype for x in xs] labeled_dtypes = list(zip(labels, dtyp...
def _get_join_indexers(self): """ return the join indexers """ def flip(xs): """ unlike np.transpose, this returns an array of tuples """ labels = list(string.ascii_lowercase[:len(xs)]) dtypes = [x.dtype for x in xs] labeled_dtypes = list(zip(labels, dtyp...
[ "return", "the", "join", "indexers" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L1495-L1573
[ "def", "_get_join_indexers", "(", "self", ")", ":", "def", "flip", "(", "xs", ")", ":", "\"\"\" unlike np.transpose, this returns an array of tuples \"\"\"", "labels", "=", "list", "(", "string", ".", "ascii_lowercase", "[", ":", "len", "(", "xs", ")", "]", ")",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_DtypeOpsMixin.is_dtype
Check if we match 'dtype'. Parameters ---------- dtype : object The object to check. Returns ------- is_dtype : bool Notes ----- The default implementation is True if 1. ``cls.construct_from_string(dtype)`` is an instance ...
pandas/core/dtypes/base.py
def is_dtype(cls, dtype): """Check if we match 'dtype'. Parameters ---------- dtype : object The object to check. Returns ------- is_dtype : bool Notes ----- The default implementation is True if 1. ``cls.construct_f...
def is_dtype(cls, dtype): """Check if we match 'dtype'. Parameters ---------- dtype : object The object to check. Returns ------- is_dtype : bool Notes ----- The default implementation is True if 1. ``cls.construct_f...
[ "Check", "if", "we", "match", "dtype", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/base.py#L75-L113
[ "def", "is_dtype", "(", "cls", ",", "dtype", ")", ":", "dtype", "=", "getattr", "(", "dtype", ",", "'dtype'", ",", "dtype", ")", "if", "isinstance", "(", "dtype", ",", "(", "ABCSeries", ",", "ABCIndexClass", ",", "ABCDataFrame", ",", "np", ".", "dtype"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
cat_core
Auxiliary function for :meth:`str.cat` Parameters ---------- list_of_columns : list of numpy arrays List of arrays to be concatenated with sep; these arrays may not contain NaNs! sep : string The separator string for concatenating the columns Returns ------- nd.arra...
pandas/core/strings.py
def cat_core(list_of_columns, sep): """ Auxiliary function for :meth:`str.cat` Parameters ---------- list_of_columns : list of numpy arrays List of arrays to be concatenated with sep; these arrays may not contain NaNs! sep : string The separator string for concatenating ...
def cat_core(list_of_columns, sep): """ Auxiliary function for :meth:`str.cat` Parameters ---------- list_of_columns : list of numpy arrays List of arrays to be concatenated with sep; these arrays may not contain NaNs! sep : string The separator string for concatenating ...
[ "Auxiliary", "function", "for", ":", "meth", ":", "str", ".", "cat" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L33-L52
[ "def", "cat_core", "(", "list_of_columns", ",", "sep", ")", ":", "list_with_sep", "=", "[", "sep", "]", "*", "(", "2", "*", "len", "(", "list_of_columns", ")", "-", "1", ")", "list_with_sep", "[", ":", ":", "2", "]", "=", "list_of_columns", "return", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_count
Count occurrences of pattern in each string of the Series/Index. This function is used to count the number of times a particular regex pattern is repeated in each of the string elements of the :class:`~pandas.Series`. Parameters ---------- pat : str Valid regular expression. flags ...
pandas/core/strings.py
def str_count(arr, pat, flags=0): """ Count occurrences of pattern in each string of the Series/Index. This function is used to count the number of times a particular regex pattern is repeated in each of the string elements of the :class:`~pandas.Series`. Parameters ---------- pat : st...
def str_count(arr, pat, flags=0): """ Count occurrences of pattern in each string of the Series/Index. This function is used to count the number of times a particular regex pattern is repeated in each of the string elements of the :class:`~pandas.Series`. Parameters ---------- pat : st...
[ "Count", "occurrences", "of", "pattern", "in", "each", "string", "of", "the", "Series", "/", "Index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L98-L164
[ "def", "str_count", "(", "arr", ",", "pat", ",", "flags", "=", "0", ")", ":", "regex", "=", "re", ".", "compile", "(", "pat", ",", "flags", "=", "flags", ")", "f", "=", "lambda", "x", ":", "len", "(", "regex", ".", "findall", "(", "x", ")", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_contains
Test if pattern or regex is contained within a string of a Series or Index. Return boolean Series or Index based on whether a given pattern or regex is contained within a string of a Series or Index. Parameters ---------- pat : str Character sequence or regular expression. case : bool,...
pandas/core/strings.py
def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True): """ Test if pattern or regex is contained within a string of a Series or Index. Return boolean Series or Index based on whether a given pattern or regex is contained within a string of a Series or Index. Parameters --------...
def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True): """ Test if pattern or regex is contained within a string of a Series or Index. Return boolean Series or Index based on whether a given pattern or regex is contained within a string of a Series or Index. Parameters --------...
[ "Test", "if", "pattern", "or", "regex", "is", "contained", "within", "a", "string", "of", "a", "Series", "or", "Index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L167-L310
[ "def", "str_contains", "(", "arr", ",", "pat", ",", "case", "=", "True", ",", "flags", "=", "0", ",", "na", "=", "np", ".", "nan", ",", "regex", "=", "True", ")", ":", "if", "regex", ":", "if", "not", "case", ":", "flags", "|=", "re", ".", "I...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_startswith
Test if the start of each string element matches a pattern. Equivalent to :meth:`str.startswith`. Parameters ---------- pat : str Character sequence. Regular expressions are not accepted. na : object, default NaN Object shown if element tested is not a string. Returns ----...
pandas/core/strings.py
def str_startswith(arr, pat, na=np.nan): """ Test if the start of each string element matches a pattern. Equivalent to :meth:`str.startswith`. Parameters ---------- pat : str Character sequence. Regular expressions are not accepted. na : object, default NaN Object shown if ...
def str_startswith(arr, pat, na=np.nan): """ Test if the start of each string element matches a pattern. Equivalent to :meth:`str.startswith`. Parameters ---------- pat : str Character sequence. Regular expressions are not accepted. na : object, default NaN Object shown if ...
[ "Test", "if", "the", "start", "of", "each", "string", "element", "matches", "a", "pattern", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L313-L365
[ "def", "str_startswith", "(", "arr", ",", "pat", ",", "na", "=", "np", ".", "nan", ")", ":", "f", "=", "lambda", "x", ":", "x", ".", "startswith", "(", "pat", ")", "return", "_na_map", "(", "f", ",", "arr", ",", "na", ",", "dtype", "=", "bool",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_endswith
Test if the end of each string element matches a pattern. Equivalent to :meth:`str.endswith`. Parameters ---------- pat : str Character sequence. Regular expressions are not accepted. na : object, default NaN Object shown if element tested is not a string. Returns ------- ...
pandas/core/strings.py
def str_endswith(arr, pat, na=np.nan): """ Test if the end of each string element matches a pattern. Equivalent to :meth:`str.endswith`. Parameters ---------- pat : str Character sequence. Regular expressions are not accepted. na : object, default NaN Object shown if elemen...
def str_endswith(arr, pat, na=np.nan): """ Test if the end of each string element matches a pattern. Equivalent to :meth:`str.endswith`. Parameters ---------- pat : str Character sequence. Regular expressions are not accepted. na : object, default NaN Object shown if elemen...
[ "Test", "if", "the", "end", "of", "each", "string", "element", "matches", "a", "pattern", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L368-L420
[ "def", "str_endswith", "(", "arr", ",", "pat", ",", "na", "=", "np", ".", "nan", ")", ":", "f", "=", "lambda", "x", ":", "x", ".", "endswith", "(", "pat", ")", "return", "_na_map", "(", "f", ",", "arr", ",", "na", ",", "dtype", "=", "bool", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_replace
r""" Replace occurrences of pattern/regex in the Series/Index with some other string. Equivalent to :meth:`str.replace` or :func:`re.sub`. Parameters ---------- pat : str or compiled regex String can be a character sequence or regular expression. .. versionadded:: 0.20.0 ...
pandas/core/strings.py
def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True): r""" Replace occurrences of pattern/regex in the Series/Index with some other string. Equivalent to :meth:`str.replace` or :func:`re.sub`. Parameters ---------- pat : str or compiled regex String can be a charact...
def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True): r""" Replace occurrences of pattern/regex in the Series/Index with some other string. Equivalent to :meth:`str.replace` or :func:`re.sub`. Parameters ---------- pat : str or compiled regex String can be a charact...
[ "r", "Replace", "occurrences", "of", "pattern", "/", "regex", "in", "the", "Series", "/", "Index", "with", "some", "other", "string", ".", "Equivalent", "to", ":", "meth", ":", "str", ".", "replace", "or", ":", "func", ":", "re", ".", "sub", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L423-L578
[ "def", "str_replace", "(", "arr", ",", "pat", ",", "repl", ",", "n", "=", "-", "1", ",", "case", "=", "None", ",", "flags", "=", "0", ",", "regex", "=", "True", ")", ":", "# Check whether repl is valid (GH 13438, GH 15055)", "if", "not", "(", "is_string_...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_repeat
Duplicate each string in the Series or Index. Parameters ---------- repeats : int or sequence of int Same value for all (int) or different value per (sequence). Returns ------- Series or Index of object Series or Index of repeated string objects specified by input param...
pandas/core/strings.py
def str_repeat(arr, repeats): """ Duplicate each string in the Series or Index. Parameters ---------- repeats : int or sequence of int Same value for all (int) or different value per (sequence). Returns ------- Series or Index of object Series or Index of repeated strin...
def str_repeat(arr, repeats): """ Duplicate each string in the Series or Index. Parameters ---------- repeats : int or sequence of int Same value for all (int) or different value per (sequence). Returns ------- Series or Index of object Series or Index of repeated strin...
[ "Duplicate", "each", "string", "in", "the", "Series", "or", "Index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L581-L639
[ "def", "str_repeat", "(", "arr", ",", "repeats", ")", ":", "if", "is_scalar", "(", "repeats", ")", ":", "def", "scalar_rep", "(", "x", ")", ":", "try", ":", "return", "bytes", ".", "__mul__", "(", "x", ",", "repeats", ")", "except", "TypeError", ":",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_match
Determine if each string matches a regular expression. Parameters ---------- pat : str Character sequence or regular expression. case : bool, default True If True, case sensitive. flags : int, default 0 (no flags) re module flags, e.g. re.IGNORECASE. na : default NaN ...
pandas/core/strings.py
def str_match(arr, pat, case=True, flags=0, na=np.nan): """ Determine if each string matches a regular expression. Parameters ---------- pat : str Character sequence or regular expression. case : bool, default True If True, case sensitive. flags : int, default 0 (no flags) ...
def str_match(arr, pat, case=True, flags=0, na=np.nan): """ Determine if each string matches a regular expression. Parameters ---------- pat : str Character sequence or regular expression. case : bool, default True If True, case sensitive. flags : int, default 0 (no flags) ...
[ "Determine", "if", "each", "string", "matches", "a", "regular", "expression", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L642-L675
[ "def", "str_match", "(", "arr", ",", "pat", ",", "case", "=", "True", ",", "flags", "=", "0", ",", "na", "=", "np", ".", "nan", ")", ":", "if", "not", "case", ":", "flags", "|=", "re", ".", "IGNORECASE", "regex", "=", "re", ".", "compile", "(",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_groups_or_na_fun
Used in both extract_noexpand and extract_frame
pandas/core/strings.py
def _groups_or_na_fun(regex): """Used in both extract_noexpand and extract_frame""" if regex.groups == 0: raise ValueError("pattern contains no capture groups") empty_row = [np.nan] * regex.groups def f(x): if not isinstance(x, str): return empty_row m = regex.search...
def _groups_or_na_fun(regex): """Used in both extract_noexpand and extract_frame""" if regex.groups == 0: raise ValueError("pattern contains no capture groups") empty_row = [np.nan] * regex.groups def f(x): if not isinstance(x, str): return empty_row m = regex.search...
[ "Used", "in", "both", "extract_noexpand", "and", "extract_frame" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L685-L699
[ "def", "_groups_or_na_fun", "(", "regex", ")", ":", "if", "regex", ".", "groups", "==", "0", ":", "raise", "ValueError", "(", "\"pattern contains no capture groups\"", ")", "empty_row", "=", "[", "np", ".", "nan", "]", "*", "regex", ".", "groups", "def", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_str_extract_noexpand
Find groups in each string in the Series using passed regular expression. This function is called from str_extract(expand=False), and can return Series, DataFrame, or Index.
pandas/core/strings.py
def _str_extract_noexpand(arr, pat, flags=0): """ Find groups in each string in the Series using passed regular expression. This function is called from str_extract(expand=False), and can return Series, DataFrame, or Index. """ from pandas import DataFrame, Index regex = re.compile(pat...
def _str_extract_noexpand(arr, pat, flags=0): """ Find groups in each string in the Series using passed regular expression. This function is called from str_extract(expand=False), and can return Series, DataFrame, or Index. """ from pandas import DataFrame, Index regex = re.compile(pat...
[ "Find", "groups", "in", "each", "string", "in", "the", "Series", "using", "passed", "regular", "expression", ".", "This", "function", "is", "called", "from", "str_extract", "(", "expand", "=", "False", ")", "and", "can", "return", "Series", "DataFrame", "or"...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L702-L732
[ "def", "_str_extract_noexpand", "(", "arr", ",", "pat", ",", "flags", "=", "0", ")", ":", "from", "pandas", "import", "DataFrame", ",", "Index", "regex", "=", "re", ".", "compile", "(", "pat", ",", "flags", "=", "flags", ")", "groups_or_na", "=", "_gro...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_str_extract_frame
For each subject string in the Series, extract groups from the first match of regular expression pat. This function is called from str_extract(expand=True), and always returns a DataFrame.
pandas/core/strings.py
def _str_extract_frame(arr, pat, flags=0): """ For each subject string in the Series, extract groups from the first match of regular expression pat. This function is called from str_extract(expand=True), and always returns a DataFrame. """ from pandas import DataFrame regex = re.compile(pa...
def _str_extract_frame(arr, pat, flags=0): """ For each subject string in the Series, extract groups from the first match of regular expression pat. This function is called from str_extract(expand=True), and always returns a DataFrame. """ from pandas import DataFrame regex = re.compile(pa...
[ "For", "each", "subject", "string", "in", "the", "Series", "extract", "groups", "from", "the", "first", "match", "of", "regular", "expression", "pat", ".", "This", "function", "is", "called", "from", "str_extract", "(", "expand", "=", "True", ")", "and", "...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L735-L759
[ "def", "_str_extract_frame", "(", "arr", ",", "pat", ",", "flags", "=", "0", ")", ":", "from", "pandas", "import", "DataFrame", "regex", "=", "re", ".", "compile", "(", "pat", ",", "flags", "=", "flags", ")", "groups_or_na", "=", "_groups_or_na_fun", "("...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_extract
r""" Extract capture groups in the regex `pat` as columns in a DataFrame. For each subject string in the Series, extract groups from the first match of regular expression `pat`. Parameters ---------- pat : str Regular expression pattern with capturing groups. flags : int, default 0...
pandas/core/strings.py
def str_extract(arr, pat, flags=0, expand=True): r""" Extract capture groups in the regex `pat` as columns in a DataFrame. For each subject string in the Series, extract groups from the first match of regular expression `pat`. Parameters ---------- pat : str Regular expression patt...
def str_extract(arr, pat, flags=0, expand=True): r""" Extract capture groups in the regex `pat` as columns in a DataFrame. For each subject string in the Series, extract groups from the first match of regular expression `pat`. Parameters ---------- pat : str Regular expression patt...
[ "r", "Extract", "capture", "groups", "in", "the", "regex", "pat", "as", "columns", "in", "a", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L762-L851
[ "def", "str_extract", "(", "arr", ",", "pat", ",", "flags", "=", "0", ",", "expand", "=", "True", ")", ":", "if", "not", "isinstance", "(", "expand", ",", "bool", ")", ":", "raise", "ValueError", "(", "\"expand must be True or False\"", ")", "if", "expan...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_extractall
r""" For each subject string in the Series, extract groups from all matches of regular expression pat. When each subject string in the Series has exactly one match, extractall(pat).xs(0, level='match') is the same as extract(pat). .. versionadded:: 0.18.0 Parameters ---------- pat : st...
pandas/core/strings.py
def str_extractall(arr, pat, flags=0): r""" For each subject string in the Series, extract groups from all matches of regular expression pat. When each subject string in the Series has exactly one match, extractall(pat).xs(0, level='match') is the same as extract(pat). .. versionadded:: 0.18.0 ...
def str_extractall(arr, pat, flags=0): r""" For each subject string in the Series, extract groups from all matches of regular expression pat. When each subject string in the Series has exactly one match, extractall(pat).xs(0, level='match') is the same as extract(pat). .. versionadded:: 0.18.0 ...
[ "r", "For", "each", "subject", "string", "in", "the", "Series", "extract", "groups", "from", "all", "matches", "of", "regular", "expression", "pat", ".", "When", "each", "subject", "string", "in", "the", "Series", "has", "exactly", "one", "match", "extractal...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L854-L964
[ "def", "str_extractall", "(", "arr", ",", "pat", ",", "flags", "=", "0", ")", ":", "regex", "=", "re", ".", "compile", "(", "pat", ",", "flags", "=", "flags", ")", "# the regex must contain capture groups.", "if", "regex", ".", "groups", "==", "0", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_get_dummies
Split each string in the Series by sep and return a DataFrame of dummy/indicator variables. Parameters ---------- sep : str, default "|" String to split on. Returns ------- DataFrame Dummy variables corresponding to values of the Series. See Also -------- get_d...
pandas/core/strings.py
def str_get_dummies(arr, sep='|'): """ Split each string in the Series by sep and return a DataFrame of dummy/indicator variables. Parameters ---------- sep : str, default "|" String to split on. Returns ------- DataFrame Dummy variables corresponding to values of t...
def str_get_dummies(arr, sep='|'): """ Split each string in the Series by sep and return a DataFrame of dummy/indicator variables. Parameters ---------- sep : str, default "|" String to split on. Returns ------- DataFrame Dummy variables corresponding to values of t...
[ "Split", "each", "string", "in", "the", "Series", "by", "sep", "and", "return", "a", "DataFrame", "of", "dummy", "/", "indicator", "variables", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L967-L1017
[ "def", "str_get_dummies", "(", "arr", ",", "sep", "=", "'|'", ")", ":", "arr", "=", "arr", ".", "fillna", "(", "''", ")", "try", ":", "arr", "=", "sep", "+", "arr", "+", "sep", "except", "TypeError", ":", "arr", "=", "sep", "+", "arr", ".", "as...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_findall
Find all occurrences of pattern or regular expression in the Series/Index. Equivalent to applying :func:`re.findall` to all the elements in the Series/Index. Parameters ---------- pat : str Pattern or regular expression. flags : int, default 0 Flags from ``re`` module, e.g. `re...
pandas/core/strings.py
def str_findall(arr, pat, flags=0): """ Find all occurrences of pattern or regular expression in the Series/Index. Equivalent to applying :func:`re.findall` to all the elements in the Series/Index. Parameters ---------- pat : str Pattern or regular expression. flags : int, defa...
def str_findall(arr, pat, flags=0): """ Find all occurrences of pattern or regular expression in the Series/Index. Equivalent to applying :func:`re.findall` to all the elements in the Series/Index. Parameters ---------- pat : str Pattern or regular expression. flags : int, defa...
[ "Find", "all", "occurrences", "of", "pattern", "or", "regular", "expression", "in", "the", "Series", "/", "Index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1085-L1176
[ "def", "str_findall", "(", "arr", ",", "pat", ",", "flags", "=", "0", ")", ":", "regex", "=", "re", ".", "compile", "(", "pat", ",", "flags", "=", "flags", ")", "return", "_na_map", "(", "regex", ".", "findall", ",", "arr", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_find
Return indexes in each strings in the Series/Index where the substring is fully contained between [start:end]. Return -1 on failure. Parameters ---------- sub : str Substring being searched. start : int Left edge index. end : int Right edge index. side : {'left', 'ri...
pandas/core/strings.py
def str_find(arr, sub, start=0, end=None, side='left'): """ Return indexes in each strings in the Series/Index where the substring is fully contained between [start:end]. Return -1 on failure. Parameters ---------- sub : str Substring being searched. start : int Left edge in...
def str_find(arr, sub, start=0, end=None, side='left'): """ Return indexes in each strings in the Series/Index where the substring is fully contained between [start:end]. Return -1 on failure. Parameters ---------- sub : str Substring being searched. start : int Left edge in...
[ "Return", "indexes", "in", "each", "strings", "in", "the", "Series", "/", "Index", "where", "the", "substring", "is", "fully", "contained", "between", "[", "start", ":", "end", "]", ".", "Return", "-", "1", "on", "failure", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1179-L1217
[ "def", "str_find", "(", "arr", ",", "sub", ",", "start", "=", "0", ",", "end", "=", "None", ",", "side", "=", "'left'", ")", ":", "if", "not", "isinstance", "(", "sub", ",", "str", ")", ":", "msg", "=", "'expected a string object, not {0}'", "raise", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_pad
Pad strings in the Series/Index up to width. Parameters ---------- width : int Minimum width of resulting string; additional characters will be filled with character defined in `fillchar`. side : {'left', 'right', 'both'}, default 'left' Side from which to fill resulting string....
pandas/core/strings.py
def str_pad(arr, width, side='left', fillchar=' '): """ Pad strings in the Series/Index up to width. Parameters ---------- width : int Minimum width of resulting string; additional characters will be filled with character defined in `fillchar`. side : {'left', 'right', 'both'}, ...
def str_pad(arr, width, side='left', fillchar=' '): """ Pad strings in the Series/Index up to width. Parameters ---------- width : int Minimum width of resulting string; additional characters will be filled with character defined in `fillchar`. side : {'left', 'right', 'both'}, ...
[ "Pad", "strings", "in", "the", "Series", "/", "Index", "up", "to", "width", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1240-L1313
[ "def", "str_pad", "(", "arr", ",", "width", ",", "side", "=", "'left'", ",", "fillchar", "=", "' '", ")", ":", "if", "not", "isinstance", "(", "fillchar", ",", "str", ")", ":", "msg", "=", "'fillchar must be a character, not {0}'", "raise", "TypeError", "(...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_slice
Slice substrings from each element in the Series or Index. Parameters ---------- start : int, optional Start position for slice operation. stop : int, optional Stop position for slice operation. step : int, optional Step size for slice operation. Returns ------- ...
pandas/core/strings.py
def str_slice(arr, start=None, stop=None, step=None): """ Slice substrings from each element in the Series or Index. Parameters ---------- start : int, optional Start position for slice operation. stop : int, optional Stop position for slice operation. step : int, optional ...
def str_slice(arr, start=None, stop=None, step=None): """ Slice substrings from each element in the Series or Index. Parameters ---------- start : int, optional Start position for slice operation. stop : int, optional Stop position for slice operation. step : int, optional ...
[ "Slice", "substrings", "from", "each", "element", "in", "the", "Series", "or", "Index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1345-L1413
[ "def", "str_slice", "(", "arr", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "step", "=", "None", ")", ":", "obj", "=", "slice", "(", "start", ",", "stop", ",", "step", ")", "f", "=", "lambda", "x", ":", "x", "[", "obj", "]", "re...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_slice_replace
Replace a positional slice of a string with another value. Parameters ---------- start : int, optional Left index position to use for the slice. If not specified (None), the slice is unbounded on the left, i.e. slice from the start of the string. stop : int, optional Rig...
pandas/core/strings.py
def str_slice_replace(arr, start=None, stop=None, repl=None): """ Replace a positional slice of a string with another value. Parameters ---------- start : int, optional Left index position to use for the slice. If not specified (None), the slice is unbounded on the left, i.e. slice ...
def str_slice_replace(arr, start=None, stop=None, repl=None): """ Replace a positional slice of a string with another value. Parameters ---------- start : int, optional Left index position to use for the slice. If not specified (None), the slice is unbounded on the left, i.e. slice ...
[ "Replace", "a", "positional", "slice", "of", "a", "string", "with", "another", "value", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1416-L1504
[ "def", "str_slice_replace", "(", "arr", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "repl", "=", "None", ")", ":", "if", "repl", "is", "None", ":", "repl", "=", "''", "def", "f", "(", "x", ")", ":", "if", "x", "[", "start", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_strip
Strip whitespace (including newlines) from each string in the Series/Index. Parameters ---------- to_strip : str or unicode side : {'left', 'right', 'both'}, default 'both' Returns ------- Series or Index
pandas/core/strings.py
def str_strip(arr, to_strip=None, side='both'): """ Strip whitespace (including newlines) from each string in the Series/Index. Parameters ---------- to_strip : str or unicode side : {'left', 'right', 'both'}, default 'both' Returns ------- Series or Index """ if side =...
def str_strip(arr, to_strip=None, side='both'): """ Strip whitespace (including newlines) from each string in the Series/Index. Parameters ---------- to_strip : str or unicode side : {'left', 'right', 'both'}, default 'both' Returns ------- Series or Index """ if side =...
[ "Strip", "whitespace", "(", "including", "newlines", ")", "from", "each", "string", "in", "the", "Series", "/", "Index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1507-L1529
[ "def", "str_strip", "(", "arr", ",", "to_strip", "=", "None", ",", "side", "=", "'both'", ")", ":", "if", "side", "==", "'both'", ":", "f", "=", "lambda", "x", ":", "x", ".", "strip", "(", "to_strip", ")", "elif", "side", "==", "'left'", ":", "f"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_wrap
r""" Wrap long strings in the Series/Index to be formatted in paragraphs with length less than a given width. This method has the same keyword parameters and defaults as :class:`textwrap.TextWrapper`. Parameters ---------- width : int Maximum line width. expand_tabs : bool, opt...
pandas/core/strings.py
def str_wrap(arr, width, **kwargs): r""" Wrap long strings in the Series/Index to be formatted in paragraphs with length less than a given width. This method has the same keyword parameters and defaults as :class:`textwrap.TextWrapper`. Parameters ---------- width : int Maximum...
def str_wrap(arr, width, **kwargs): r""" Wrap long strings in the Series/Index to be formatted in paragraphs with length less than a given width. This method has the same keyword parameters and defaults as :class:`textwrap.TextWrapper`. Parameters ---------- width : int Maximum...
[ "r", "Wrap", "long", "strings", "in", "the", "Series", "/", "Index", "to", "be", "formatted", "in", "paragraphs", "with", "length", "less", "than", "a", "given", "width", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1532-L1593
[ "def", "str_wrap", "(", "arr", ",", "width", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'width'", "]", "=", "width", "tw", "=", "textwrap", ".", "TextWrapper", "(", "*", "*", "kwargs", ")", "return", "_na_map", "(", "lambda", "s", ":", "'\\...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_get
Extract element from each component at specified position. Extract element from lists, tuples, or strings in each element in the Series/Index. Parameters ---------- i : int Position of element to extract. Returns ------- Series or Index Examples -------- >>> s = p...
pandas/core/strings.py
def str_get(arr, i): """ Extract element from each component at specified position. Extract element from lists, tuples, or strings in each element in the Series/Index. Parameters ---------- i : int Position of element to extract. Returns ------- Series or Index Ex...
def str_get(arr, i): """ Extract element from each component at specified position. Extract element from lists, tuples, or strings in each element in the Series/Index. Parameters ---------- i : int Position of element to extract. Returns ------- Series or Index Ex...
[ "Extract", "element", "from", "each", "component", "at", "specified", "position", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1616-L1673
[ "def", "str_get", "(", "arr", ",", "i", ")", ":", "def", "f", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "dict", ")", ":", "return", "x", ".", "get", "(", "i", ")", "elif", "len", "(", "x", ")", ">", "i", ">=", "-", "len", "("...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_decode
Decode character string in the Series/Index using indicated encoding. Equivalent to :meth:`str.decode` in python2 and :meth:`bytes.decode` in python3. Parameters ---------- encoding : str errors : str, optional Returns ------- Series or Index
pandas/core/strings.py
def str_decode(arr, encoding, errors="strict"): """ Decode character string in the Series/Index using indicated encoding. Equivalent to :meth:`str.decode` in python2 and :meth:`bytes.decode` in python3. Parameters ---------- encoding : str errors : str, optional Returns -------...
def str_decode(arr, encoding, errors="strict"): """ Decode character string in the Series/Index using indicated encoding. Equivalent to :meth:`str.decode` in python2 and :meth:`bytes.decode` in python3. Parameters ---------- encoding : str errors : str, optional Returns -------...
[ "Decode", "character", "string", "in", "the", "Series", "/", "Index", "using", "indicated", "encoding", ".", "Equivalent", "to", ":", "meth", ":", "str", ".", "decode", "in", "python2", "and", ":", "meth", ":", "bytes", ".", "decode", "in", "python3", "....
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1676-L1697
[ "def", "str_decode", "(", "arr", ",", "encoding", ",", "errors", "=", "\"strict\"", ")", ":", "if", "encoding", "in", "_cpython_optimized_decoders", ":", "# CPython optimized implementation", "f", "=", "lambda", "x", ":", "x", ".", "decode", "(", "encoding", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
str_encode
Encode character string in the Series/Index using indicated encoding. Equivalent to :meth:`str.encode`. Parameters ---------- encoding : str errors : str, optional Returns ------- encoded : Series/Index of objects
pandas/core/strings.py
def str_encode(arr, encoding, errors="strict"): """ Encode character string in the Series/Index using indicated encoding. Equivalent to :meth:`str.encode`. Parameters ---------- encoding : str errors : str, optional Returns ------- encoded : Series/Index of objects """ ...
def str_encode(arr, encoding, errors="strict"): """ Encode character string in the Series/Index using indicated encoding. Equivalent to :meth:`str.encode`. Parameters ---------- encoding : str errors : str, optional Returns ------- encoded : Series/Index of objects """ ...
[ "Encode", "character", "string", "in", "the", "Series", "/", "Index", "using", "indicated", "encoding", ".", "Equivalent", "to", ":", "meth", ":", "str", ".", "encode", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1700-L1720
[ "def", "str_encode", "(", "arr", ",", "encoding", ",", "errors", "=", "\"strict\"", ")", ":", "if", "encoding", "in", "_cpython_optimized_encoders", ":", "# CPython optimized implementation", "f", "=", "lambda", "x", ":", "x", ".", "encode", "(", "encoding", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
copy
Copy a docstring from another source function (if present)
pandas/core/strings.py
def copy(source): "Copy a docstring from another source function (if present)" def do_copy(target): if source.__doc__: target.__doc__ = source.__doc__ return target return do_copy
def copy(source): "Copy a docstring from another source function (if present)" def do_copy(target): if source.__doc__: target.__doc__ = source.__doc__ return target return do_copy
[ "Copy", "a", "docstring", "from", "another", "source", "function", "(", "if", "present", ")" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1759-L1767
[ "def", "copy", "(", "source", ")", ":", "def", "do_copy", "(", "target", ")", ":", "if", "source", ".", "__doc__", ":", "target", ".", "__doc__", "=", "source", ".", "__doc__", "return", "target", "return", "do_copy" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StringMethods._get_series_list
Auxiliary function for :meth:`str.cat`. Turn potentially mixed input into a list of Series (elements without an index must match the length of the calling Series/Index). Parameters ---------- others : Series, Index, DataFrame, np.ndarray, list-like or list-like of ob...
pandas/core/strings.py
def _get_series_list(self, others, ignore_index=False): """ Auxiliary function for :meth:`str.cat`. Turn potentially mixed input into a list of Series (elements without an index must match the length of the calling Series/Index). Parameters ---------- others : Se...
def _get_series_list(self, others, ignore_index=False): """ Auxiliary function for :meth:`str.cat`. Turn potentially mixed input into a list of Series (elements without an index must match the length of the calling Series/Index). Parameters ---------- others : Se...
[ "Auxiliary", "function", "for", ":", "meth", ":", "str", ".", "cat", ".", "Turn", "potentially", "mixed", "input", "into", "a", "list", "of", "Series", "(", "elements", "without", "an", "index", "must", "match", "the", "length", "of", "the", "calling", "...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1922-L2032
[ "def", "_get_series_list", "(", "self", ",", "others", ",", "ignore_index", "=", "False", ")", ":", "# Once str.cat defaults to alignment, this function can be simplified;", "# will not need `ignore_index` and the second boolean output anymore", "from", "pandas", "import", "Index",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StringMethods.cat
Concatenate strings in the Series/Index with given separator. If `others` is specified, this function concatenates the Series/Index and elements of `others` element-wise. If `others` is not passed, then all values in the Series/Index are concatenated into a single string with a given `s...
pandas/core/strings.py
def cat(self, others=None, sep=None, na_rep=None, join=None): """ Concatenate strings in the Series/Index with given separator. If `others` is specified, this function concatenates the Series/Index and elements of `others` element-wise. If `others` is not passed, then all values...
def cat(self, others=None, sep=None, na_rep=None, join=None): """ Concatenate strings in the Series/Index with given separator. If `others` is specified, this function concatenates the Series/Index and elements of `others` element-wise. If `others` is not passed, then all values...
[ "Concatenate", "strings", "in", "the", "Series", "/", "Index", "with", "given", "separator", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L2034-L2256
[ "def", "cat", "(", "self", ",", "others", "=", "None", ",", "sep", "=", "None", ",", "na_rep", "=", "None", ",", "join", "=", "None", ")", ":", "from", "pandas", "import", "Index", ",", "Series", ",", "concat", "if", "isinstance", "(", "others", ",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StringMethods.zfill
Pad strings in the Series/Index by prepending '0' characters. Strings in the Series/Index are padded with '0' characters on the left of the string to reach a total string length `width`. Strings in the Series/Index with length greater or equal to `width` are unchanged. Paramet...
pandas/core/strings.py
def zfill(self, width): """ Pad strings in the Series/Index by prepending '0' characters. Strings in the Series/Index are padded with '0' characters on the left of the string to reach a total string length `width`. Strings in the Series/Index with length greater or equal to `wi...
def zfill(self, width): """ Pad strings in the Series/Index by prepending '0' characters. Strings in the Series/Index are padded with '0' characters on the left of the string to reach a total string length `width`. Strings in the Series/Index with length greater or equal to `wi...
[ "Pad", "strings", "in", "the", "Series", "/", "Index", "by", "prepending", "0", "characters", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L2564-L2625
[ "def", "zfill", "(", "self", ",", "width", ")", ":", "result", "=", "str_pad", "(", "self", ".", "_parent", ",", "width", ",", "side", "=", "'left'", ",", "fillchar", "=", "'0'", ")", "return", "self", ".", "_wrap_result", "(", "result", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StringMethods.normalize
Return the Unicode normal form for the strings in the Series/Index. For more information on the forms, see the :func:`unicodedata.normalize`. Parameters ---------- form : {'NFC', 'NFKC', 'NFD', 'NFKD'} Unicode form Returns ------- normalized ...
pandas/core/strings.py
def normalize(self, form): """ Return the Unicode normal form for the strings in the Series/Index. For more information on the forms, see the :func:`unicodedata.normalize`. Parameters ---------- form : {'NFC', 'NFKC', 'NFD', 'NFKD'} Unicode form ...
def normalize(self, form): """ Return the Unicode normal form for the strings in the Series/Index. For more information on the forms, see the :func:`unicodedata.normalize`. Parameters ---------- form : {'NFC', 'NFKC', 'NFD', 'NFKD'} Unicode form ...
[ "Return", "the", "Unicode", "normal", "form", "for", "the", "strings", "in", "the", "Series", "/", "Index", ".", "For", "more", "information", "on", "the", "forms", "see", "the", ":", "func", ":", "unicodedata", ".", "normalize", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L2798-L2816
[ "def", "normalize", "(", "self", ",", "form", ")", ":", "import", "unicodedata", "f", "=", "lambda", "x", ":", "unicodedata", ".", "normalize", "(", "form", ",", "x", ")", "result", "=", "_na_map", "(", "f", ",", "self", ".", "_parent", ")", "return"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_sys_info
Returns system information as a dict
pandas/util/_print_versions.py
def get_sys_info(): "Returns system information as a dict" blob = [] # get full commit hash commit = None if os.path.isdir(".git") and os.path.isdir("pandas"): try: pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "), stdout=subpr...
def get_sys_info(): "Returns system information as a dict" blob = [] # get full commit hash commit = None if os.path.isdir(".git") and os.path.isdir("pandas"): try: pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "), stdout=subpr...
[ "Returns", "system", "information", "as", "a", "dict" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_print_versions.py#L11-L56
[ "def", "get_sys_info", "(", ")", ":", "blob", "=", "[", "]", "# get full commit hash", "commit", "=", "None", "if", "os", ".", "path", ".", "isdir", "(", "\".git\"", ")", "and", "os", ".", "path", ".", "isdir", "(", "\"pandas\"", ")", ":", "try", ":"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
whitelist_method_generator
Yields all GroupBy member defs for DataFrame/Series names in whitelist. Parameters ---------- base : class base class klass : class class where members are defined. Should be Series or DataFrame whitelist : list list of names of klass methods to be constructed R...
pandas/core/groupby/base.py
def whitelist_method_generator(base, klass, whitelist): """ Yields all GroupBy member defs for DataFrame/Series names in whitelist. Parameters ---------- base : class base class klass : class class where members are defined. Should be Series or DataFrame whitelist : ...
def whitelist_method_generator(base, klass, whitelist): """ Yields all GroupBy member defs for DataFrame/Series names in whitelist. Parameters ---------- base : class base class klass : class class where members are defined. Should be Series or DataFrame whitelist : ...
[ "Yields", "all", "GroupBy", "member", "defs", "for", "DataFrame", "/", "Series", "names", "in", "whitelist", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/base.py#L96-L157
[ "def", "whitelist_method_generator", "(", "base", ",", "klass", ",", "whitelist", ")", ":", "method_wrapper_template", "=", "\"\"\"def %(name)s(%(sig)s) :\n \\\"\"\"\n %(doc)s\n \\\"\"\"\n f = %(self)s.__getattr__('%(name)s')\n return f(%(args)s)\"\"\"", "property_wrapper_te...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupByMixin._dispatch
Dispatch to apply.
pandas/core/groupby/base.py
def _dispatch(name, *args, **kwargs): """ Dispatch to apply. """ def outer(self, *args, **kwargs): def f(x): x = self._shallow_copy(x, groupby=self._groupby) return getattr(x, name)(*args, **kwargs) return self._groupby.apply(f) ...
def _dispatch(name, *args, **kwargs): """ Dispatch to apply. """ def outer(self, *args, **kwargs): def f(x): x = self._shallow_copy(x, groupby=self._groupby) return getattr(x, name)(*args, **kwargs) return self._groupby.apply(f) ...
[ "Dispatch", "to", "apply", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/base.py#L20-L31
[ "def", "_dispatch", "(", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "outer", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "f", "(", "x", ")", ":", "x", "=", "self", ".", "_shallow_copy", "(...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
GroupByMixin._gotitem
Sub-classes to define. Return a sliced object. Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on
pandas/core/groupby/base.py
def _gotitem(self, key, ndim, subset=None): """ Sub-classes to define. Return a sliced object. Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on ...
def _gotitem(self, key, ndim, subset=None): """ Sub-classes to define. Return a sliced object. Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on ...
[ "Sub", "-", "classes", "to", "define", ".", "Return", "a", "sliced", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/base.py#L33-L67
[ "def", "_gotitem", "(", "self", ",", "key", ",", "ndim", ",", "subset", "=", "None", ")", ":", "# create a new object to prevent aliasing", "if", "subset", "is", "None", ":", "subset", "=", "self", ".", "obj", "# we need to make a shallow copy of ourselves", "# wi...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
to_str
Convert bytes and non-string into Python 3 str
pandas/compat/__init__.py
def to_str(s): """ Convert bytes and non-string into Python 3 str """ if isinstance(s, bytes): s = s.decode('utf-8') elif not isinstance(s, str): s = str(s) return s
def to_str(s): """ Convert bytes and non-string into Python 3 str """ if isinstance(s, bytes): s = s.decode('utf-8') elif not isinstance(s, str): s = str(s) return s
[ "Convert", "bytes", "and", "non", "-", "string", "into", "Python", "3", "str" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/__init__.py#L44-L52
[ "def", "to_str", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "bytes", ")", ":", "s", "=", "s", ".", "decode", "(", "'utf-8'", ")", "elif", "not", "isinstance", "(", "s", ",", "str", ")", ":", "s", "=", "str", "(", "s", ")", "return...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
set_function_name
Bind the name/qualname attributes of the function
pandas/compat/__init__.py
def set_function_name(f, name, cls): """ Bind the name/qualname attributes of the function """ f.__name__ = name f.__qualname__ = '{klass}.{name}'.format( klass=cls.__name__, name=name) f.__module__ = cls.__module__ return f
def set_function_name(f, name, cls): """ Bind the name/qualname attributes of the function """ f.__name__ = name f.__qualname__ = '{klass}.{name}'.format( klass=cls.__name__, name=name) f.__module__ = cls.__module__ return f
[ "Bind", "the", "name", "/", "qualname", "attributes", "of", "the", "function" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/__init__.py#L55-L64
[ "def", "set_function_name", "(", "f", ",", "name", ",", "cls", ")", ":", "f", ".", "__name__", "=", "name", "f", ".", "__qualname__", "=", "'{klass}.{name}'", ".", "format", "(", "klass", "=", "cls", ".", "__name__", ",", "name", "=", "name", ")", "f...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
raise_with_traceback
Raise exception with existing traceback. If traceback is not passed, uses sys.exc_info() to get traceback.
pandas/compat/__init__.py
def raise_with_traceback(exc, traceback=Ellipsis): """ Raise exception with existing traceback. If traceback is not passed, uses sys.exc_info() to get traceback. """ if traceback == Ellipsis: _, _, traceback = sys.exc_info() raise exc.with_traceback(traceback)
def raise_with_traceback(exc, traceback=Ellipsis): """ Raise exception with existing traceback. If traceback is not passed, uses sys.exc_info() to get traceback. """ if traceback == Ellipsis: _, _, traceback = sys.exc_info() raise exc.with_traceback(traceback)
[ "Raise", "exception", "with", "existing", "traceback", ".", "If", "traceback", "is", "not", "passed", "uses", "sys", ".", "exc_info", "()", "to", "get", "traceback", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/__init__.py#L67-L74
[ "def", "raise_with_traceback", "(", "exc", ",", "traceback", "=", "Ellipsis", ")", ":", "if", "traceback", "==", "Ellipsis", ":", "_", ",", "_", ",", "traceback", "=", "sys", ".", "exc_info", "(", ")", "raise", "exc", ".", "with_traceback", "(", "traceba...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_OpenpyxlWriter._convert_to_style
converts a style_dict to an openpyxl style object Parameters ---------- style_dict : style dictionary to convert
pandas/io/excel/_openpyxl.py
def _convert_to_style(cls, style_dict): """ converts a style_dict to an openpyxl style object Parameters ---------- style_dict : style dictionary to convert """ from openpyxl.style import Style xls_style = Style() for key, value in style_dict.item...
def _convert_to_style(cls, style_dict): """ converts a style_dict to an openpyxl style object Parameters ---------- style_dict : style dictionary to convert """ from openpyxl.style import Style xls_style = Style() for key, value in style_dict.item...
[ "converts", "a", "style_dict", "to", "an", "openpyxl", "style", "object", "Parameters", "----------", "style_dict", ":", "style", "dictionary", "to", "convert" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L38-L56
[ "def", "_convert_to_style", "(", "cls", ",", "style_dict", ")", ":", "from", "openpyxl", ".", "style", "import", "Style", "xls_style", "=", "Style", "(", ")", "for", "key", ",", "value", "in", "style_dict", ".", "items", "(", ")", ":", "for", "nk", ","...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_OpenpyxlWriter._convert_to_style_kwargs
Convert a style_dict to a set of kwargs suitable for initializing or updating-on-copy an openpyxl v2 style object Parameters ---------- style_dict : dict A dict with zero or more of the following keys (or their synonyms). 'font' 'fill' ...
pandas/io/excel/_openpyxl.py
def _convert_to_style_kwargs(cls, style_dict): """ Convert a style_dict to a set of kwargs suitable for initializing or updating-on-copy an openpyxl v2 style object Parameters ---------- style_dict : dict A dict with zero or more of the following keys (or thei...
def _convert_to_style_kwargs(cls, style_dict): """ Convert a style_dict to a set of kwargs suitable for initializing or updating-on-copy an openpyxl v2 style object Parameters ---------- style_dict : dict A dict with zero or more of the following keys (or thei...
[ "Convert", "a", "style_dict", "to", "a", "set", "of", "kwargs", "suitable", "for", "initializing", "or", "updating", "-", "on", "-", "copy", "an", "openpyxl", "v2", "style", "object", "Parameters", "----------", "style_dict", ":", "dict", "A", "dict", "with"...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L59-L95
[ "def", "_convert_to_style_kwargs", "(", "cls", ",", "style_dict", ")", ":", "_style_key_map", "=", "{", "'borders'", ":", "'border'", ",", "}", "style_kwargs", "=", "{", "}", "for", "k", ",", "v", "in", "style_dict", ".", "items", "(", ")", ":", "if", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_OpenpyxlWriter._convert_to_color
Convert ``color_spec`` to an openpyxl v2 Color object Parameters ---------- color_spec : str, dict A 32-bit ARGB hex string, or a dict with zero or more of the following keys. 'rgb' 'indexed' 'auto' 'theme' ...
pandas/io/excel/_openpyxl.py
def _convert_to_color(cls, color_spec): """ Convert ``color_spec`` to an openpyxl v2 Color object Parameters ---------- color_spec : str, dict A 32-bit ARGB hex string, or a dict with zero or more of the following keys. 'rgb' ...
def _convert_to_color(cls, color_spec): """ Convert ``color_spec`` to an openpyxl v2 Color object Parameters ---------- color_spec : str, dict A 32-bit ARGB hex string, or a dict with zero or more of the following keys. 'rgb' ...
[ "Convert", "color_spec", "to", "an", "openpyxl", "v2", "Color", "object", "Parameters", "----------", "color_spec", ":", "str", "dict", "A", "32", "-", "bit", "ARGB", "hex", "string", "or", "a", "dict", "with", "zero", "or", "more", "of", "the", "following...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L98-L123
[ "def", "_convert_to_color", "(", "cls", ",", "color_spec", ")", ":", "from", "openpyxl", ".", "styles", "import", "Color", "if", "isinstance", "(", "color_spec", ",", "str", ")", ":", "return", "Color", "(", "color_spec", ")", "else", ":", "return", "Color...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_OpenpyxlWriter._convert_to_font
Convert ``font_dict`` to an openpyxl v2 Font object Parameters ---------- font_dict : dict A dict with zero or more of the following keys (or their synonyms). 'name' 'size' ('sz') 'bold' ('b') 'italic' ('i') ...
pandas/io/excel/_openpyxl.py
def _convert_to_font(cls, font_dict): """ Convert ``font_dict`` to an openpyxl v2 Font object Parameters ---------- font_dict : dict A dict with zero or more of the following keys (or their synonyms). 'name' 'size' ('sz') ...
def _convert_to_font(cls, font_dict): """ Convert ``font_dict`` to an openpyxl v2 Font object Parameters ---------- font_dict : dict A dict with zero or more of the following keys (or their synonyms). 'name' 'size' ('sz') ...
[ "Convert", "font_dict", "to", "an", "openpyxl", "v2", "Font", "object", "Parameters", "----------", "font_dict", ":", "dict", "A", "dict", "with", "zero", "or", "more", "of", "the", "following", "keys", "(", "or", "their", "synonyms", ")", ".", "name", "si...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L126-L171
[ "def", "_convert_to_font", "(", "cls", ",", "font_dict", ")", ":", "from", "openpyxl", ".", "styles", "import", "Font", "_font_key_map", "=", "{", "'sz'", ":", "'size'", ",", "'b'", ":", "'bold'", ",", "'i'", ":", "'italic'", ",", "'u'", ":", "'underline...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_OpenpyxlWriter._convert_to_fill
Convert ``fill_dict`` to an openpyxl v2 Fill object Parameters ---------- fill_dict : dict A dict with one or more of the following keys (or their synonyms), 'fill_type' ('patternType', 'patterntype') 'start_color' ('fgColor', 'fgcolor') ...
pandas/io/excel/_openpyxl.py
def _convert_to_fill(cls, fill_dict): """ Convert ``fill_dict`` to an openpyxl v2 Fill object Parameters ---------- fill_dict : dict A dict with one or more of the following keys (or their synonyms), 'fill_type' ('patternType', 'patterntype') ...
def _convert_to_fill(cls, fill_dict): """ Convert ``fill_dict`` to an openpyxl v2 Fill object Parameters ---------- fill_dict : dict A dict with one or more of the following keys (or their synonyms), 'fill_type' ('patternType', 'patterntype') ...
[ "Convert", "fill_dict", "to", "an", "openpyxl", "v2", "Fill", "object", "Parameters", "----------", "fill_dict", ":", "dict", "A", "dict", "with", "one", "or", "more", "of", "the", "following", "keys", "(", "or", "their", "synonyms", ")", "fill_type", "(", ...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L191-L252
[ "def", "_convert_to_fill", "(", "cls", ",", "fill_dict", ")", ":", "from", "openpyxl", ".", "styles", "import", "PatternFill", ",", "GradientFill", "_pattern_fill_key_map", "=", "{", "'patternType'", ":", "'fill_type'", ",", "'patterntype'", ":", "'fill_type'", ",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_OpenpyxlWriter._convert_to_side
Convert ``side_spec`` to an openpyxl v2 Side object Parameters ---------- side_spec : str, dict A string specifying the border style, or a dict with zero or more of the following keys (or their synonyms). 'style' ('border_style') 'color' ...
pandas/io/excel/_openpyxl.py
def _convert_to_side(cls, side_spec): """ Convert ``side_spec`` to an openpyxl v2 Side object Parameters ---------- side_spec : str, dict A string specifying the border style, or a dict with zero or more of the following keys (or their synonyms). ...
def _convert_to_side(cls, side_spec): """ Convert ``side_spec`` to an openpyxl v2 Side object Parameters ---------- side_spec : str, dict A string specifying the border style, or a dict with zero or more of the following keys (or their synonyms). ...
[ "Convert", "side_spec", "to", "an", "openpyxl", "v2", "Side", "object", "Parameters", "----------", "side_spec", ":", "str", "dict", "A", "string", "specifying", "the", "border", "style", "or", "a", "dict", "with", "zero", "or", "more", "of", "the", "followi...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L255-L287
[ "def", "_convert_to_side", "(", "cls", ",", "side_spec", ")", ":", "from", "openpyxl", ".", "styles", "import", "Side", "_side_key_map", "=", "{", "'border_style'", ":", "'style'", ",", "}", "if", "isinstance", "(", "side_spec", ",", "str", ")", ":", "retu...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_OpenpyxlWriter._convert_to_border
Convert ``border_dict`` to an openpyxl v2 Border object Parameters ---------- border_dict : dict A dict with zero or more of the following keys (or their synonyms). 'left' 'right' 'top' 'bottom' 'diagonal...
pandas/io/excel/_openpyxl.py
def _convert_to_border(cls, border_dict): """ Convert ``border_dict`` to an openpyxl v2 Border object Parameters ---------- border_dict : dict A dict with zero or more of the following keys (or their synonyms). 'left' 'right' ...
def _convert_to_border(cls, border_dict): """ Convert ``border_dict`` to an openpyxl v2 Border object Parameters ---------- border_dict : dict A dict with zero or more of the following keys (or their synonyms). 'left' 'right' ...
[ "Convert", "border_dict", "to", "an", "openpyxl", "v2", "Border", "object", "Parameters", "----------", "border_dict", ":", "dict", "A", "dict", "with", "zero", "or", "more", "of", "the", "following", "keys", "(", "or", "their", "synonyms", ")", ".", "left",...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L290-L330
[ "def", "_convert_to_border", "(", "cls", ",", "border_dict", ")", ":", "from", "openpyxl", ".", "styles", "import", "Border", "_border_key_map", "=", "{", "'diagonalup'", ":", "'diagonalUp'", ",", "'diagonaldown'", ":", "'diagonalDown'", ",", "}", "border_kwargs",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
frame_apply
construct and return a row or column based frame apply object
pandas/core/apply.py
def frame_apply(obj, func, axis=0, broadcast=None, raw=False, reduce=None, result_type=None, ignore_failures=False, args=None, kwds=None): """ construct and return a row or column based frame apply object """ axis = obj._get_axis_number(axis) if axis == 0: ...
def frame_apply(obj, func, axis=0, broadcast=None, raw=False, reduce=None, result_type=None, ignore_failures=False, args=None, kwds=None): """ construct and return a row or column based frame apply object """ axis = obj._get_axis_number(axis) if axis == 0: ...
[ "construct", "and", "return", "a", "row", "or", "column", "based", "frame", "apply", "object" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L16-L31
[ "def", "frame_apply", "(", "obj", ",", "func", ",", "axis", "=", "0", ",", "broadcast", "=", "None", ",", "raw", "=", "False", ",", "reduce", "=", "None", ",", "result_type", "=", "None", ",", "ignore_failures", "=", "False", ",", "args", "=", "None"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FrameApply.get_result
compute the results
pandas/core/apply.py
def get_result(self): """ compute the results """ # dispatch to agg if is_list_like(self.f) or is_dict_like(self.f): return self.obj.aggregate(self.f, axis=self.axis, *self.args, **self.kwds) # all empty if len(self.columns) == ...
def get_result(self): """ compute the results """ # dispatch to agg if is_list_like(self.f) or is_dict_like(self.f): return self.obj.aggregate(self.f, axis=self.axis, *self.args, **self.kwds) # all empty if len(self.columns) == ...
[ "compute", "the", "results" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L108-L150
[ "def", "get_result", "(", "self", ")", ":", "# dispatch to agg", "if", "is_list_like", "(", "self", ".", "f", ")", "or", "is_dict_like", "(", "self", ".", "f", ")", ":", "return", "self", ".", "obj", ".", "aggregate", "(", "self", ".", "f", ",", "axi...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FrameApply.apply_empty_result
we have an empty result; at least 1 axis is 0 we will try to apply the function to an empty series in order to see if this is a reduction function
pandas/core/apply.py
def apply_empty_result(self): """ we have an empty result; at least 1 axis is 0 we will try to apply the function to an empty series in order to see if this is a reduction function """ # we are not asked to reduce or infer reduction # so just return a copy of th...
def apply_empty_result(self): """ we have an empty result; at least 1 axis is 0 we will try to apply the function to an empty series in order to see if this is a reduction function """ # we are not asked to reduce or infer reduction # so just return a copy of th...
[ "we", "have", "an", "empty", "result", ";", "at", "least", "1", "axis", "is", "0" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L152-L181
[ "def", "apply_empty_result", "(", "self", ")", ":", "# we are not asked to reduce or infer reduction", "# so just return a copy of the existing object", "if", "self", ".", "result_type", "not", "in", "[", "'reduce'", ",", "None", "]", ":", "return", "self", ".", "obj", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FrameApply.apply_raw
apply to the values as a numpy array
pandas/core/apply.py
def apply_raw(self): """ apply to the values as a numpy array """ try: result = reduction.reduce(self.values, self.f, axis=self.axis) except Exception: result = np.apply_along_axis(self.f, self.axis, self.values) # TODO: mixed type case if result.ndim ==...
def apply_raw(self): """ apply to the values as a numpy array """ try: result = reduction.reduce(self.values, self.f, axis=self.axis) except Exception: result = np.apply_along_axis(self.f, self.axis, self.values) # TODO: mixed type case if result.ndim ==...
[ "apply", "to", "the", "values", "as", "a", "numpy", "array" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L183-L198
[ "def", "apply_raw", "(", "self", ")", ":", "try", ":", "result", "=", "reduction", ".", "reduce", "(", "self", ".", "values", ",", "self", ".", "f", ",", "axis", "=", "self", ".", "axis", ")", "except", "Exception", ":", "result", "=", "np", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FrameRowApply.wrap_results_for_axis
return the results for the rows
pandas/core/apply.py
def wrap_results_for_axis(self): """ return the results for the rows """ results = self.results result = self.obj._constructor(data=results) if not isinstance(results[0], ABCSeries): try: result.index = self.res_columns except ValueError: ...
def wrap_results_for_axis(self): """ return the results for the rows """ results = self.results result = self.obj._constructor(data=results) if not isinstance(results[0], ABCSeries): try: result.index = self.res_columns except ValueError: ...
[ "return", "the", "results", "for", "the", "rows" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L335-L352
[ "def", "wrap_results_for_axis", "(", "self", ")", ":", "results", "=", "self", ".", "results", "result", "=", "self", ".", "obj", ".", "_constructor", "(", "data", "=", "results", ")", "if", "not", "isinstance", "(", "results", "[", "0", "]", ",", "ABC...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FrameColumnApply.wrap_results_for_axis
return the results for the columns
pandas/core/apply.py
def wrap_results_for_axis(self): """ return the results for the columns """ results = self.results # we have requested to expand if self.result_type == 'expand': result = self.infer_to_same_shape() # we have a non-series and don't want inference elif not isi...
def wrap_results_for_axis(self): """ return the results for the columns """ results = self.results # we have requested to expand if self.result_type == 'expand': result = self.infer_to_same_shape() # we have a non-series and don't want inference elif not isi...
[ "return", "the", "results", "for", "the", "columns" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L377-L395
[ "def", "wrap_results_for_axis", "(", "self", ")", ":", "results", "=", "self", ".", "results", "# we have requested to expand", "if", "self", ".", "result_type", "==", "'expand'", ":", "result", "=", "self", ".", "infer_to_same_shape", "(", ")", "# we have a non-s...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FrameColumnApply.infer_to_same_shape
infer the results to the same shape as the input object
pandas/core/apply.py
def infer_to_same_shape(self): """ infer the results to the same shape as the input object """ results = self.results result = self.obj._constructor(data=results) result = result.T # set the index result.index = self.res_index # infer dtypes result = re...
def infer_to_same_shape(self): """ infer the results to the same shape as the input object """ results = self.results result = self.obj._constructor(data=results) result = result.T # set the index result.index = self.res_index # infer dtypes result = re...
[ "infer", "the", "results", "to", "the", "same", "shape", "as", "the", "input", "object" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L397-L410
[ "def", "infer_to_same_shape", "(", "self", ")", ":", "results", "=", "self", ".", "results", "result", "=", "self", ".", "obj", ".", "_constructor", "(", "data", "=", "results", ")", "result", "=", "result", ".", "T", "# set the index", "result", ".", "i...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
cartesian_product
Numpy version of itertools.product. Sometimes faster (for large inputs)... Parameters ---------- X : list-like of list-likes Returns ------- product : list of ndarrays Examples -------- >>> cartesian_product([list('ABC'), [1, 2]]) [array(['A', 'A', 'B', 'B', 'C', 'C'], dty...
pandas/core/reshape/util.py
def cartesian_product(X): """ Numpy version of itertools.product. Sometimes faster (for large inputs)... Parameters ---------- X : list-like of list-likes Returns ------- product : list of ndarrays Examples -------- >>> cartesian_product([list('ABC'), [1, 2]]) [arr...
def cartesian_product(X): """ Numpy version of itertools.product. Sometimes faster (for large inputs)... Parameters ---------- X : list-like of list-likes Returns ------- product : list of ndarrays Examples -------- >>> cartesian_product([list('ABC'), [1, 2]]) [arr...
[ "Numpy", "version", "of", "itertools", ".", "product", ".", "Sometimes", "faster", "(", "for", "large", "inputs", ")", "..." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/util.py#L8-L56
[ "def", "cartesian_product", "(", "X", ")", ":", "msg", "=", "\"Input must be a list-like of list-likes\"", "if", "not", "is_list_like", "(", "X", ")", ":", "raise", "TypeError", "(", "msg", ")", "for", "x", "in", "X", ":", "if", "not", "is_list_like", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_strip_schema
Returns the url without the s3:// part
pandas/io/s3.py
def _strip_schema(url): """Returns the url without the s3:// part""" result = parse_url(url, allow_fragments=False) return result.netloc + result.path
def _strip_schema(url): """Returns the url without the s3:// part""" result = parse_url(url, allow_fragments=False) return result.netloc + result.path
[ "Returns", "the", "url", "without", "the", "s3", ":", "//", "part" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/s3.py#L11-L14
[ "def", "_strip_schema", "(", "url", ")", ":", "result", "=", "parse_url", "(", "url", ",", "allow_fragments", "=", "False", ")", "return", "result", ".", "netloc", "+", "result", ".", "path" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
xception
Preview version of Xception network. Not tested yet - use at own risk. No pretrained model yet.
fastai/vision/models/xception.py
def xception(c, k=8, n_middle=8): "Preview version of Xception network. Not tested yet - use at own risk. No pretrained model yet." layers = [ conv(3, k*4, 3, 2), conv(k*4, k*8, 3), ConvSkip(k*8, k*16, act=False), ConvSkip(k*16, k*32), ConvSkip(k*32, k*91), ] for ...
def xception(c, k=8, n_middle=8): "Preview version of Xception network. Not tested yet - use at own risk. No pretrained model yet." layers = [ conv(3, k*4, 3, 2), conv(k*4, k*8, 3), ConvSkip(k*8, k*16, act=False), ConvSkip(k*16, k*32), ConvSkip(k*32, k*91), ] for ...
[ "Preview", "version", "of", "Xception", "network", ".", "Not", "tested", "yet", "-", "use", "at", "own", "risk", ".", "No", "pretrained", "model", "yet", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/models/xception.py#L41-L60
[ "def", "xception", "(", "c", ",", "k", "=", "8", ",", "n_middle", "=", "8", ")", ":", "layers", "=", "[", "conv", "(", "3", ",", "k", "*", "4", ",", "3", ",", "2", ")", ",", "conv", "(", "k", "*", "4", ",", "k", "*", "8", ",", "3", ")...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
LanguageModelData.get_model
Method returns a RNN_Learner object, that wraps an instance of the RNN_Encoder module. Args: opt_fn (Optimizer): the torch optimizer function to use emb_sz (int): embedding size n_hid (int): number of hidden inputs n_layers (int): number of hidden layers ...
old/fastai/nlp.py
def get_model(self, opt_fn, emb_sz, n_hid, n_layers, **kwargs): """ Method returns a RNN_Learner object, that wraps an instance of the RNN_Encoder module. Args: opt_fn (Optimizer): the torch optimizer function to use emb_sz (int): embedding size n_hid (int): number o...
def get_model(self, opt_fn, emb_sz, n_hid, n_layers, **kwargs): """ Method returns a RNN_Learner object, that wraps an instance of the RNN_Encoder module. Args: opt_fn (Optimizer): the torch optimizer function to use emb_sz (int): embedding size n_hid (int): number o...
[ "Method", "returns", "a", "RNN_Learner", "object", "that", "wraps", "an", "instance", "of", "the", "RNN_Encoder", "module", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/old/fastai/nlp.py#L263-L279
[ "def", "get_model", "(", "self", ",", "opt_fn", ",", "emb_sz", ",", "n_hid", ",", "n_layers", ",", "*", "*", "kwargs", ")", ":", "m", "=", "get_language_model", "(", "self", ".", "nt", ",", "emb_sz", ",", "n_hid", ",", "n_layers", ",", "self", ".", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
LanguageModelData.from_text_files
Method used to instantiate a LanguageModelData object that can be used for a supported nlp task. Args: path (str): the absolute path in which temporary model data will be saved field (Field): torchtext field train (str): file location of the training data ...
old/fastai/nlp.py
def from_text_files(cls, path, field, train, validation, test=None, bs=64, bptt=70, **kwargs): """ Method used to instantiate a LanguageModelData object that can be used for a supported nlp task. Args: path (str): the absolute path in which temporary model data will be saved ...
def from_text_files(cls, path, field, train, validation, test=None, bs=64, bptt=70, **kwargs): """ Method used to instantiate a LanguageModelData object that can be used for a supported nlp task. Args: path (str): the absolute path in which temporary model data will be saved ...
[ "Method", "used", "to", "instantiate", "a", "LanguageModelData", "object", "that", "can", "be", "used", "for", "a", "supported", "nlp", "task", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/old/fastai/nlp.py#L288-L313
[ "def", "from_text_files", "(", "cls", ",", "path", ",", "field", ",", "train", ",", "validation", ",", "test", "=", "None", ",", "bs", "=", "64", ",", "bptt", "=", "70", ",", "*", "*", "kwargs", ")", ":", "trn_ds", ",", "val_ds", ",", "test_ds", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
get_files
Return list of files in `path` that have a suffix in `extensions`; optionally `recurse`.
fastai/data_block.py
def get_files(path:PathOrStr, extensions:Collection[str]=None, recurse:bool=False, include:Optional[Collection[str]]=None)->FilePathList: "Return list of files in `path` that have a suffix in `extensions`; optionally `recurse`." if recurse: res = [] for i,(p,d,f) in enumerate(os.wa...
def get_files(path:PathOrStr, extensions:Collection[str]=None, recurse:bool=False, include:Optional[Collection[str]]=None)->FilePathList: "Return list of files in `path` that have a suffix in `extensions`; optionally `recurse`." if recurse: res = [] for i,(p,d,f) in enumerate(os.wa...
[ "Return", "list", "of", "files", "in", "path", "that", "have", "a", "suffix", "in", "extensions", ";", "optionally", "recurse", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L23-L36
[ "def", "get_files", "(", "path", ":", "PathOrStr", ",", "extensions", ":", "Collection", "[", "str", "]", "=", "None", ",", "recurse", ":", "bool", "=", "False", ",", "include", ":", "Optional", "[", "Collection", "[", "str", "]", "]", "=", "None", "...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
_databunch_load_empty
Load an empty `DataBunch` from the exported file in `path/fname` with optional `tfms`.
fastai/data_block.py
def _databunch_load_empty(cls, path, fname:str='export.pkl'): "Load an empty `DataBunch` from the exported file in `path/fname` with optional `tfms`." sd = LabelLists.load_empty(path, fn=fname) return sd.databunch()
def _databunch_load_empty(cls, path, fname:str='export.pkl'): "Load an empty `DataBunch` from the exported file in `path/fname` with optional `tfms`." sd = LabelLists.load_empty(path, fn=fname) return sd.databunch()
[ "Load", "an", "empty", "DataBunch", "from", "the", "exported", "file", "in", "path", "/", "fname", "with", "optional", "tfms", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L734-L737
[ "def", "_databunch_load_empty", "(", "cls", ",", "path", ",", "fname", ":", "str", "=", "'export.pkl'", ")", ":", "sd", "=", "LabelLists", ".", "load_empty", "(", "path", ",", "fn", "=", "fname", ")", "return", "sd", ".", "databunch", "(", ")" ]
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.process
Apply `processor` or `self.processor` to `self`.
fastai/data_block.py
def process(self, processor:PreProcessors=None): "Apply `processor` or `self.processor` to `self`." if processor is not None: self.processor = processor self.processor = listify(self.processor) for p in self.processor: p.process(self) return self
def process(self, processor:PreProcessors=None): "Apply `processor` or `self.processor` to `self`." if processor is not None: self.processor = processor self.processor = listify(self.processor) for p in self.processor: p.process(self) return self
[ "Apply", "processor", "or", "self", ".", "processor", "to", "self", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L71-L76
[ "def", "process", "(", "self", ",", "processor", ":", "PreProcessors", "=", "None", ")", ":", "if", "processor", "is", "not", "None", ":", "self", ".", "processor", "=", "processor", "self", ".", "processor", "=", "listify", "(", "self", ".", "processor"...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.process_one
Apply `processor` or `self.processor` to `item`.
fastai/data_block.py
def process_one(self, item:ItemBase, processor:PreProcessors=None): "Apply `processor` or `self.processor` to `item`." if processor is not None: self.processor = processor self.processor = listify(self.processor) for p in self.processor: item = p.process_one(item) return item
def process_one(self, item:ItemBase, processor:PreProcessors=None): "Apply `processor` or `self.processor` to `item`." if processor is not None: self.processor = processor self.processor = listify(self.processor) for p in self.processor: item = p.process_one(item) return item
[ "Apply", "processor", "or", "self", ".", "processor", "to", "item", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L78-L83
[ "def", "process_one", "(", "self", ",", "item", ":", "ItemBase", ",", "processor", ":", "PreProcessors", "=", "None", ")", ":", "if", "processor", "is", "not", "None", ":", "self", ".", "processor", "=", "processor", "self", ".", "processor", "=", "listi...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.reconstruct
Reconstruct one of the underlying item for its data `t`.
fastai/data_block.py
def reconstruct(self, t:Tensor, x:Tensor=None): "Reconstruct one of the underlying item for its data `t`." return self[0].reconstruct(t,x) if has_arg(self[0].reconstruct, 'x') else self[0].reconstruct(t)
def reconstruct(self, t:Tensor, x:Tensor=None): "Reconstruct one of the underlying item for its data `t`." return self[0].reconstruct(t,x) if has_arg(self[0].reconstruct, 'x') else self[0].reconstruct(t)
[ "Reconstruct", "one", "of", "the", "underlying", "item", "for", "its", "data", "t", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L89-L91
[ "def", "reconstruct", "(", "self", ",", "t", ":", "Tensor", ",", "x", ":", "Tensor", "=", "None", ")", ":", "return", "self", "[", "0", "]", ".", "reconstruct", "(", "t", ",", "x", ")", "if", "has_arg", "(", "self", "[", "0", "]", ".", "reconst...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.new
Create a new `ItemList` from `items`, keeping the same attributes.
fastai/data_block.py
def new(self, items:Iterator, processor:PreProcessors=None, **kwargs)->'ItemList': "Create a new `ItemList` from `items`, keeping the same attributes." processor = ifnone(processor, self.processor) copy_d = {o:getattr(self,o) for o in self.copy_new} kwargs = {**copy_d, **kwargs} ...
def new(self, items:Iterator, processor:PreProcessors=None, **kwargs)->'ItemList': "Create a new `ItemList` from `items`, keeping the same attributes." processor = ifnone(processor, self.processor) copy_d = {o:getattr(self,o) for o in self.copy_new} kwargs = {**copy_d, **kwargs} ...
[ "Create", "a", "new", "ItemList", "from", "items", "keeping", "the", "same", "attributes", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L93-L98
[ "def", "new", "(", "self", ",", "items", ":", "Iterator", ",", "processor", ":", "PreProcessors", "=", "None", ",", "*", "*", "kwargs", ")", "->", "'ItemList'", ":", "processor", "=", "ifnone", "(", "processor", ",", "self", ".", "processor", ")", "cop...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.from_folder
Create an `ItemList` in `path` from the filenames that have a suffix in `extensions`. `recurse` determines if we search subfolders.
fastai/data_block.py
def from_folder(cls, path:PathOrStr, extensions:Collection[str]=None, recurse:bool=True, include:Optional[Collection[str]]=None, processor:PreProcessors=None, **kwargs)->'ItemList': """Create an `ItemList` in `path` from the filenames that have a suffix in `extensions`. `recurse` det...
def from_folder(cls, path:PathOrStr, extensions:Collection[str]=None, recurse:bool=True, include:Optional[Collection[str]]=None, processor:PreProcessors=None, **kwargs)->'ItemList': """Create an `ItemList` in `path` from the filenames that have a suffix in `extensions`. `recurse` det...
[ "Create", "an", "ItemList", "in", "path", "from", "the", "filenames", "that", "have", "a", "suffix", "in", "extensions", ".", "recurse", "determines", "if", "we", "search", "subfolders", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L113-L118
[ "def", "from_folder", "(", "cls", ",", "path", ":", "PathOrStr", ",", "extensions", ":", "Collection", "[", "str", "]", "=", "None", ",", "recurse", ":", "bool", "=", "True", ",", "include", ":", "Optional", "[", "Collection", "[", "str", "]", "]", "...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.from_df
Create an `ItemList` in `path` from the inputs in the `cols` of `df`.
fastai/data_block.py
def from_df(cls, df:DataFrame, path:PathOrStr='.', cols:IntsOrStrs=0, processor:PreProcessors=None, **kwargs)->'ItemList': "Create an `ItemList` in `path` from the inputs in the `cols` of `df`." inputs = df.iloc[:,df_names_to_idx(cols, df)] assert inputs.isna().sum().sum() == 0, f"You have NaN v...
def from_df(cls, df:DataFrame, path:PathOrStr='.', cols:IntsOrStrs=0, processor:PreProcessors=None, **kwargs)->'ItemList': "Create an `ItemList` in `path` from the inputs in the `cols` of `df`." inputs = df.iloc[:,df_names_to_idx(cols, df)] assert inputs.isna().sum().sum() == 0, f"You have NaN v...
[ "Create", "an", "ItemList", "in", "path", "from", "the", "inputs", "in", "the", "cols", "of", "df", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L121-L126
[ "def", "from_df", "(", "cls", ",", "df", ":", "DataFrame", ",", "path", ":", "PathOrStr", "=", "'.'", ",", "cols", ":", "IntsOrStrs", "=", "0", ",", "processor", ":", "PreProcessors", "=", "None", ",", "*", "*", "kwargs", ")", "->", "'ItemList'", ":"...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.from_csv
Create an `ItemList` in `path` from the inputs in the `cols` of `path/csv_name`
fastai/data_block.py
def from_csv(cls, path:PathOrStr, csv_name:str, cols:IntsOrStrs=0, delimiter:str=None, header:str='infer', processor:PreProcessors=None, **kwargs)->'ItemList': """Create an `ItemList` in `path` from the inputs in the `cols` of `path/csv_name`""" df = pd.read_csv(Path(path)/csv_name, del...
def from_csv(cls, path:PathOrStr, csv_name:str, cols:IntsOrStrs=0, delimiter:str=None, header:str='infer', processor:PreProcessors=None, **kwargs)->'ItemList': """Create an `ItemList` in `path` from the inputs in the `cols` of `path/csv_name`""" df = pd.read_csv(Path(path)/csv_name, del...
[ "Create", "an", "ItemList", "in", "path", "from", "the", "inputs", "in", "the", "cols", "of", "path", "/", "csv_name" ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L129-L133
[ "def", "from_csv", "(", "cls", ",", "path", ":", "PathOrStr", ",", "csv_name", ":", "str", ",", "cols", ":", "IntsOrStrs", "=", "0", ",", "delimiter", ":", "str", "=", "None", ",", "header", ":", "str", "=", "'infer'", ",", "processor", ":", "PreProc...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.use_partial_data
Use only a sample of `sample_pct`of the full dataset and an optional `seed`.
fastai/data_block.py
def use_partial_data(self, sample_pct:float=0.01, seed:int=None)->'ItemList': "Use only a sample of `sample_pct`of the full dataset and an optional `seed`." if seed is not None: np.random.seed(seed) rand_idx = np.random.permutation(range_of(self)) cut = int(sample_pct * len(self)) ...
def use_partial_data(self, sample_pct:float=0.01, seed:int=None)->'ItemList': "Use only a sample of `sample_pct`of the full dataset and an optional `seed`." if seed is not None: np.random.seed(seed) rand_idx = np.random.permutation(range_of(self)) cut = int(sample_pct * len(self)) ...
[ "Use", "only", "a", "sample", "of", "sample_pct", "of", "the", "full", "dataset", "and", "an", "optional", "seed", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L138-L143
[ "def", "use_partial_data", "(", "self", ",", "sample_pct", ":", "float", "=", "0.01", ",", "seed", ":", "int", "=", "None", ")", "->", "'ItemList'", ":", "if", "seed", "is", "not", "None", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "r...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.to_text
Save `self.items` to `fn` in `self.path`.
fastai/data_block.py
def to_text(self, fn:str): "Save `self.items` to `fn` in `self.path`." with open(self.path/fn, 'w') as f: f.writelines([f'{o}\n' for o in self._relative_item_paths()])
def to_text(self, fn:str): "Save `self.items` to `fn` in `self.path`." with open(self.path/fn, 'w') as f: f.writelines([f'{o}\n' for o in self._relative_item_paths()])
[ "Save", "self", ".", "items", "to", "fn", "in", "self", ".", "path", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L145-L147
[ "def", "to_text", "(", "self", ",", "fn", ":", "str", ")", ":", "with", "open", "(", "self", ".", "path", "/", "fn", ",", "'w'", ")", "as", "f", ":", "f", ".", "writelines", "(", "[", "f'{o}\\n'", "for", "o", "in", "self", ".", "_relative_item_pa...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.filter_by_func
Only keep elements for which `func` returns `True`.
fastai/data_block.py
def filter_by_func(self, func:Callable)->'ItemList': "Only keep elements for which `func` returns `True`." self.items = array([o for o in self.items if func(o)]) return self
def filter_by_func(self, func:Callable)->'ItemList': "Only keep elements for which `func` returns `True`." self.items = array([o for o in self.items if func(o)]) return self
[ "Only", "keep", "elements", "for", "which", "func", "returns", "True", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L149-L152
[ "def", "filter_by_func", "(", "self", ",", "func", ":", "Callable", ")", "->", "'ItemList'", ":", "self", ".", "items", "=", "array", "(", "[", "o", "for", "o", "in", "self", ".", "items", "if", "func", "(", "o", ")", "]", ")", "return", "self" ]
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.filter_by_folder
Only keep filenames in `include` folder or reject the ones in `exclude`.
fastai/data_block.py
def filter_by_folder(self, include=None, exclude=None): "Only keep filenames in `include` folder or reject the ones in `exclude`." include,exclude = listify(include),listify(exclude) def _inner(o): if isinstance(o, Path): n = o.relative_to(self.path).parts[0] else: n = o....
def filter_by_folder(self, include=None, exclude=None): "Only keep filenames in `include` folder or reject the ones in `exclude`." include,exclude = listify(include),listify(exclude) def _inner(o): if isinstance(o, Path): n = o.relative_to(self.path).parts[0] else: n = o....
[ "Only", "keep", "filenames", "in", "include", "folder", "or", "reject", "the", "ones", "in", "exclude", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L154-L163
[ "def", "filter_by_folder", "(", "self", ",", "include", "=", "None", ",", "exclude", "=", "None", ")", ":", "include", ",", "exclude", "=", "listify", "(", "include", ")", ",", "listify", "(", "exclude", ")", "def", "_inner", "(", "o", ")", ":", "if"...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.filter_by_rand
Keep random sample of `items` with probability `p` and an optional `seed`.
fastai/data_block.py
def filter_by_rand(self, p:float, seed:int=None): "Keep random sample of `items` with probability `p` and an optional `seed`." if seed is not None: np.random.seed(seed) return self.filter_by_func(lambda o: rand_bool(p))
def filter_by_rand(self, p:float, seed:int=None): "Keep random sample of `items` with probability `p` and an optional `seed`." if seed is not None: np.random.seed(seed) return self.filter_by_func(lambda o: rand_bool(p))
[ "Keep", "random", "sample", "of", "items", "with", "probability", "p", "and", "an", "optional", "seed", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L165-L168
[ "def", "filter_by_rand", "(", "self", ",", "p", ":", "float", ",", "seed", ":", "int", "=", "None", ")", ":", "if", "seed", "is", "not", "None", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "return", "self", ".", "filter_by_func", "(", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_none
Don't split the data and create an empty validation set.
fastai/data_block.py
def split_none(self): "Don't split the data and create an empty validation set." val = self[[]] val.ignore_empty = True return self._split(self.path, self, val)
def split_none(self): "Don't split the data and create an empty validation set." val = self[[]] val.ignore_empty = True return self._split(self.path, self, val)
[ "Don", "t", "split", "the", "data", "and", "create", "an", "empty", "validation", "set", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L174-L178
[ "def", "split_none", "(", "self", ")", ":", "val", "=", "self", "[", "[", "]", "]", "val", ".", "ignore_empty", "=", "True", "return", "self", ".", "_split", "(", "self", ".", "path", ",", "self", ",", "val", ")" ]
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_by_list
Split the data between `train` and `valid`.
fastai/data_block.py
def split_by_list(self, train, valid): "Split the data between `train` and `valid`." return self._split(self.path, train, valid)
def split_by_list(self, train, valid): "Split the data between `train` and `valid`." return self._split(self.path, train, valid)
[ "Split", "the", "data", "between", "train", "and", "valid", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L180-L182
[ "def", "split_by_list", "(", "self", ",", "train", ",", "valid", ")", ":", "return", "self", ".", "_split", "(", "self", ".", "path", ",", "train", ",", "valid", ")" ]
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_by_idxs
Split the data between `train_idx` and `valid_idx`.
fastai/data_block.py
def split_by_idxs(self, train_idx, valid_idx): "Split the data between `train_idx` and `valid_idx`." return self.split_by_list(self[train_idx], self[valid_idx])
def split_by_idxs(self, train_idx, valid_idx): "Split the data between `train_idx` and `valid_idx`." return self.split_by_list(self[train_idx], self[valid_idx])
[ "Split", "the", "data", "between", "train_idx", "and", "valid_idx", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L184-L186
[ "def", "split_by_idxs", "(", "self", ",", "train_idx", ",", "valid_idx", ")", ":", "return", "self", ".", "split_by_list", "(", "self", "[", "train_idx", "]", ",", "self", "[", "valid_idx", "]", ")" ]
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_by_idx
Split the data according to the indexes in `valid_idx`.
fastai/data_block.py
def split_by_idx(self, valid_idx:Collection[int])->'ItemLists': "Split the data according to the indexes in `valid_idx`." #train_idx = [i for i in range_of(self.items) if i not in valid_idx] train_idx = np.setdiff1d(arange_of(self.items), valid_idx) return self.split_by_idxs(train_idx, v...
def split_by_idx(self, valid_idx:Collection[int])->'ItemLists': "Split the data according to the indexes in `valid_idx`." #train_idx = [i for i in range_of(self.items) if i not in valid_idx] train_idx = np.setdiff1d(arange_of(self.items), valid_idx) return self.split_by_idxs(train_idx, v...
[ "Split", "the", "data", "according", "to", "the", "indexes", "in", "valid_idx", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L188-L192
[ "def", "split_by_idx", "(", "self", ",", "valid_idx", ":", "Collection", "[", "int", "]", ")", "->", "'ItemLists'", ":", "#train_idx = [i for i in range_of(self.items) if i not in valid_idx]", "train_idx", "=", "np", ".", "setdiff1d", "(", "arange_of", "(", "self", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_by_folder
Split the data depending on the folder (`train` or `valid`) in which the filenames are.
fastai/data_block.py
def split_by_folder(self, train:str='train', valid:str='valid')->'ItemLists': "Split the data depending on the folder (`train` or `valid`) in which the filenames are." return self.split_by_idxs(self._get_by_folder(train), self._get_by_folder(valid))
def split_by_folder(self, train:str='train', valid:str='valid')->'ItemLists': "Split the data depending on the folder (`train` or `valid`) in which the filenames are." return self.split_by_idxs(self._get_by_folder(train), self._get_by_folder(valid))
[ "Split", "the", "data", "depending", "on", "the", "folder", "(", "train", "or", "valid", ")", "in", "which", "the", "filenames", "are", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L198-L200
[ "def", "split_by_folder", "(", "self", ",", "train", ":", "str", "=", "'train'", ",", "valid", ":", "str", "=", "'valid'", ")", "->", "'ItemLists'", ":", "return", "self", ".", "split_by_idxs", "(", "self", ".", "_get_by_folder", "(", "train", ")", ",", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_by_rand_pct
Split the items randomly by putting `valid_pct` in the validation set, optional `seed` can be passed.
fastai/data_block.py
def split_by_rand_pct(self, valid_pct:float=0.2, seed:int=None)->'ItemLists': "Split the items randomly by putting `valid_pct` in the validation set, optional `seed` can be passed." if valid_pct==0.: return self.split_none() if seed is not None: np.random.seed(seed) rand_idx = np.random....
def split_by_rand_pct(self, valid_pct:float=0.2, seed:int=None)->'ItemLists': "Split the items randomly by putting `valid_pct` in the validation set, optional `seed` can be passed." if valid_pct==0.: return self.split_none() if seed is not None: np.random.seed(seed) rand_idx = np.random....
[ "Split", "the", "items", "randomly", "by", "putting", "valid_pct", "in", "the", "validation", "set", "optional", "seed", "can", "be", "passed", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L206-L212
[ "def", "split_by_rand_pct", "(", "self", ",", "valid_pct", ":", "float", "=", "0.2", ",", "seed", ":", "int", "=", "None", ")", "->", "'ItemLists'", ":", "if", "valid_pct", "==", "0.", ":", "return", "self", ".", "split_none", "(", ")", "if", "seed", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_subsets
Split the items into train set with size `train_size * n` and valid set with size `valid_size * n`.
fastai/data_block.py
def split_subsets(self, train_size:float, valid_size:float, seed=None) -> 'ItemLists': "Split the items into train set with size `train_size * n` and valid set with size `valid_size * n`." assert 0 < train_size < 1 assert 0 < valid_size < 1 assert train_size + valid_size <= 1. if...
def split_subsets(self, train_size:float, valid_size:float, seed=None) -> 'ItemLists': "Split the items into train set with size `train_size * n` and valid set with size `valid_size * n`." assert 0 < train_size < 1 assert 0 < valid_size < 1 assert train_size + valid_size <= 1. if...
[ "Split", "the", "items", "into", "train", "set", "with", "size", "train_size", "*", "n", "and", "valid", "set", "with", "size", "valid_size", "*", "n", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L214-L223
[ "def", "split_subsets", "(", "self", ",", "train_size", ":", "float", ",", "valid_size", ":", "float", ",", "seed", "=", "None", ")", "->", "'ItemLists'", ":", "assert", "0", "<", "train_size", "<", "1", "assert", "0", "<", "valid_size", "<", "1", "ass...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_by_valid_func
Split the data by result of `func` (which returns `True` for validation set).
fastai/data_block.py
def split_by_valid_func(self, func:Callable)->'ItemLists': "Split the data by result of `func` (which returns `True` for validation set)." valid_idx = [i for i,o in enumerate(self.items) if func(o)] return self.split_by_idx(valid_idx)
def split_by_valid_func(self, func:Callable)->'ItemLists': "Split the data by result of `func` (which returns `True` for validation set)." valid_idx = [i for i,o in enumerate(self.items) if func(o)] return self.split_by_idx(valid_idx)
[ "Split", "the", "data", "by", "result", "of", "func", "(", "which", "returns", "True", "for", "validation", "set", ")", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L225-L228
[ "def", "split_by_valid_func", "(", "self", ",", "func", ":", "Callable", ")", "->", "'ItemLists'", ":", "valid_idx", "=", "[", "i", "for", "i", ",", "o", "in", "enumerate", "(", "self", ".", "items", ")", "if", "func", "(", "o", ")", "]", "return", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_by_files
Split the data by using the names in `valid_names` for validation.
fastai/data_block.py
def split_by_files(self, valid_names:'ItemList')->'ItemLists': "Split the data by using the names in `valid_names` for validation." if isinstance(self.items[0], Path): return self.split_by_valid_func(lambda o: o.name in valid_names) else: return self.split_by_valid_func(lambda o: os.path.basenam...
def split_by_files(self, valid_names:'ItemList')->'ItemLists': "Split the data by using the names in `valid_names` for validation." if isinstance(self.items[0], Path): return self.split_by_valid_func(lambda o: o.name in valid_names) else: return self.split_by_valid_func(lambda o: os.path.basenam...
[ "Split", "the", "data", "by", "using", "the", "names", "in", "valid_names", "for", "validation", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L230-L233
[ "def", "split_by_files", "(", "self", ",", "valid_names", ":", "'ItemList'", ")", "->", "'ItemLists'", ":", "if", "isinstance", "(", "self", ".", "items", "[", "0", "]", ",", "Path", ")", ":", "return", "self", ".", "split_by_valid_func", "(", "lambda", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_by_fname_file
Split the data by using the names in `fname` for the validation set. `path` will override `self.path`.
fastai/data_block.py
def split_by_fname_file(self, fname:PathOrStr, path:PathOrStr=None)->'ItemLists': "Split the data by using the names in `fname` for the validation set. `path` will override `self.path`." path = Path(ifnone(path, self.path)) valid_names = loadtxt_str(path/fname) return self.split_by_files...
def split_by_fname_file(self, fname:PathOrStr, path:PathOrStr=None)->'ItemLists': "Split the data by using the names in `fname` for the validation set. `path` will override `self.path`." path = Path(ifnone(path, self.path)) valid_names = loadtxt_str(path/fname) return self.split_by_files...
[ "Split", "the", "data", "by", "using", "the", "names", "in", "fname", "for", "the", "validation", "set", ".", "path", "will", "override", "self", ".", "path", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L235-L239
[ "def", "split_by_fname_file", "(", "self", ",", "fname", ":", "PathOrStr", ",", "path", ":", "PathOrStr", "=", "None", ")", "->", "'ItemLists'", ":", "path", "=", "Path", "(", "ifnone", "(", "path", ",", "self", ".", "path", ")", ")", "valid_names", "=...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.split_from_df
Split the data from the `col` in the dataframe in `self.inner_df`.
fastai/data_block.py
def split_from_df(self, col:IntsOrStrs=2): "Split the data from the `col` in the dataframe in `self.inner_df`." valid_idx = np.where(self.inner_df.iloc[:,df_names_to_idx(col, self.inner_df)])[0] return self.split_by_idx(valid_idx)
def split_from_df(self, col:IntsOrStrs=2): "Split the data from the `col` in the dataframe in `self.inner_df`." valid_idx = np.where(self.inner_df.iloc[:,df_names_to_idx(col, self.inner_df)])[0] return self.split_by_idx(valid_idx)
[ "Split", "the", "data", "from", "the", "col", "in", "the", "dataframe", "in", "self", ".", "inner_df", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L241-L244
[ "def", "split_from_df", "(", "self", ",", "col", ":", "IntsOrStrs", "=", "2", ")", ":", "valid_idx", "=", "np", ".", "where", "(", "self", ".", "inner_df", ".", "iloc", "[", ":", ",", "df_names_to_idx", "(", "col", ",", "self", ".", "inner_df", ")", ...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67
train
ItemList.get_label_cls
Return `label_cls` or guess one from the first element of `labels`.
fastai/data_block.py
def get_label_cls(self, labels, label_cls:Callable=None, label_delim:str=None, **kwargs): "Return `label_cls` or guess one from the first element of `labels`." if label_cls is not None: return label_cls if self.label_cls is not None: return self.label_cls if label_...
def get_label_cls(self, labels, label_cls:Callable=None, label_delim:str=None, **kwargs): "Return `label_cls` or guess one from the first element of `labels`." if label_cls is not None: return label_cls if self.label_cls is not None: return self.label_cls if label_...
[ "Return", "label_cls", "or", "guess", "one", "from", "the", "first", "element", "of", "labels", "." ]
fastai/fastai
python
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L246-L255
[ "def", "get_label_cls", "(", "self", ",", "labels", ",", "label_cls", ":", "Callable", "=", "None", ",", "label_delim", ":", "str", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "label_cls", "is", "not", "None", ":", "return", "label_cls", "if"...
9fb84a5cdefe5a766cdb792b8f5d8971737b7e67