repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.take_nd
def take_nd(self, indexer, allow_fill=None, fill_value=None): """ Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow...
python
def take_nd(self, indexer, allow_fill=None, fill_value=None): """ Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow...
[ "def", "take_nd", "(", "self", ",", "indexer", ",", "allow_fill", "=", "None", ",", "fill_value", "=", "None", ")", ":", "indexer", "=", "np", ".", "asarray", "(", "indexer", ",", "dtype", "=", "np", ".", "intp", ")", "if", "allow_fill", "is", "None"...
Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow_fill`. allow_fill : bool, default None How to handle negative...
[ "Take", "elements", "from", "the", "Categorical", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1792-L1889
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._slice
def _slice(self, slicer): """ Return a slice of myself. For internal compatibility with numpy arrays. """ # only allow 1 dimensional slicing, but can # in a 2-d case be passd (slice(None),....) if isinstance(slicer, tuple) and len(slicer) == 2: if no...
python
def _slice(self, slicer): """ Return a slice of myself. For internal compatibility with numpy arrays. """ # only allow 1 dimensional slicing, but can # in a 2-d case be passd (slice(None),....) if isinstance(slicer, tuple) and len(slicer) == 2: if no...
[ "def", "_slice", "(", "self", ",", "slicer", ")", ":", "# only allow 1 dimensional slicing, but can", "# in a 2-d case be passd (slice(None),....)", "if", "isinstance", "(", "slicer", ",", "tuple", ")", "and", "len", "(", "slicer", ")", "==", "2", ":", "if", "not"...
Return a slice of myself. For internal compatibility with numpy arrays.
[ "Return", "a", "slice", "of", "myself", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1893-L1909
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._tidy_repr
def _tidy_repr(self, max_vals=10, footer=True): """ a short repr displaying only max_vals and an optional (but default footer) """ num = max_vals // 2 head = self[:num]._get_repr(length=False, footer=False) tail = self[-(max_vals - num):]._get_repr(length=False, footer=Fa...
python
def _tidy_repr(self, max_vals=10, footer=True): """ a short repr displaying only max_vals and an optional (but default footer) """ num = max_vals // 2 head = self[:num]._get_repr(length=False, footer=False) tail = self[-(max_vals - num):]._get_repr(length=False, footer=Fa...
[ "def", "_tidy_repr", "(", "self", ",", "max_vals", "=", "10", ",", "footer", "=", "True", ")", ":", "num", "=", "max_vals", "//", "2", "head", "=", "self", "[", ":", "num", "]", ".", "_get_repr", "(", "length", "=", "False", ",", "footer", "=", "...
a short repr displaying only max_vals and an optional (but default footer)
[ "a", "short", "repr", "displaying", "only", "max_vals", "and", "an", "optional", "(", "but", "default", "footer", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1933-L1946
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._repr_categories
def _repr_categories(self): """ return the base repr for the categories """ max_categories = (10 if get_option("display.max_categories") == 0 else get_option("display.max_categories")) from pandas.io.formats import format as fmt if len(self.categ...
python
def _repr_categories(self): """ return the base repr for the categories """ max_categories = (10 if get_option("display.max_categories") == 0 else get_option("display.max_categories")) from pandas.io.formats import format as fmt if len(self.categ...
[ "def", "_repr_categories", "(", "self", ")", ":", "max_categories", "=", "(", "10", "if", "get_option", "(", "\"display.max_categories\"", ")", "==", "0", "else", "get_option", "(", "\"display.max_categories\"", ")", ")", "from", "pandas", ".", "io", ".", "for...
return the base repr for the categories
[ "return", "the", "base", "repr", "for", "the", "categories" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1948-L1965
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._repr_categories_info
def _repr_categories_info(self): """ Returns a string representation of the footer. """ category_strs = self._repr_categories() dtype = getattr(self.categories, 'dtype_str', str(self.categories.dtype)) levheader = "Categories ({length}, {dtype}):...
python
def _repr_categories_info(self): """ Returns a string representation of the footer. """ category_strs = self._repr_categories() dtype = getattr(self.categories, 'dtype_str', str(self.categories.dtype)) levheader = "Categories ({length}, {dtype}):...
[ "def", "_repr_categories_info", "(", "self", ")", ":", "category_strs", "=", "self", ".", "_repr_categories", "(", ")", "dtype", "=", "getattr", "(", "self", ".", "categories", ",", "'dtype_str'", ",", "str", "(", "self", ".", "categories", ".", "dtype", "...
Returns a string representation of the footer.
[ "Returns", "a", "string", "representation", "of", "the", "footer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1967-L1998
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._maybe_coerce_indexer
def _maybe_coerce_indexer(self, indexer): """ return an indexer coerced to the codes dtype """ if isinstance(indexer, np.ndarray) and indexer.dtype.kind == 'i': indexer = indexer.astype(self._codes.dtype) return indexer
python
def _maybe_coerce_indexer(self, indexer): """ return an indexer coerced to the codes dtype """ if isinstance(indexer, np.ndarray) and indexer.dtype.kind == 'i': indexer = indexer.astype(self._codes.dtype) return indexer
[ "def", "_maybe_coerce_indexer", "(", "self", ",", "indexer", ")", ":", "if", "isinstance", "(", "indexer", ",", "np", ".", "ndarray", ")", "and", "indexer", ".", "dtype", ".", "kind", "==", "'i'", ":", "indexer", "=", "indexer", ".", "astype", "(", "se...
return an indexer coerced to the codes dtype
[ "return", "an", "indexer", "coerced", "to", "the", "codes", "dtype" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2031-L2037
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._reverse_indexer
def _reverse_indexer(self): """ Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(li...
python
def _reverse_indexer(self): """ Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(li...
[ "def", "_reverse_indexer", "(", "self", ")", ":", "categories", "=", "self", ".", "categories", "r", ",", "counts", "=", "libalgos", ".", "groupsort_indexer", "(", "self", ".", "codes", ".", "astype", "(", "'int64'", ")", ",", "categories", ".", "size", ...
Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(list('aabca')) In [2]: c Out[2]: ...
[ "Compute", "the", "inverse", "of", "a", "categorical", "returning", "a", "dict", "of", "categories", "-", ">", "indexers", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2119-L2155
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.min
def min(self, numeric_only=None, **kwargs): """ The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Ca...
python
def min(self, numeric_only=None, **kwargs): """ The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Ca...
[ "def", "min", "(", "self", ",", "numeric_only", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "check_for_ordered", "(", "'min'", ")", "if", "numeric_only", ":", "good", "=", "self", ".", "_codes", "!=", "-", "1", "pointer", "=", "self"...
The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Categorical`
[ "The", "minimum", "value", "of", "the", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2165-L2189
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.mode
def mode(self, dropna=True): """ Returns the mode(s) of the Categorical. Always returns `Categorical` even if only one value. Parameters ---------- dropna : bool, default True Don't consider counts of NaN/NaT. .. versionadded:: 0.24.0 R...
python
def mode(self, dropna=True): """ Returns the mode(s) of the Categorical. Always returns `Categorical` even if only one value. Parameters ---------- dropna : bool, default True Don't consider counts of NaN/NaT. .. versionadded:: 0.24.0 R...
[ "def", "mode", "(", "self", ",", "dropna", "=", "True", ")", ":", "import", "pandas", ".", "_libs", ".", "hashtable", "as", "htable", "codes", "=", "self", ".", "_codes", "if", "dropna", ":", "good", "=", "self", ".", "_codes", "!=", "-", "1", "cod...
Returns the mode(s) of the Categorical. Always returns `Categorical` even if only one value. Parameters ---------- dropna : bool, default True Don't consider counts of NaN/NaT. .. versionadded:: 0.24.0 Returns ------- modes : `Categoric...
[ "Returns", "the", "mode", "(", "s", ")", "of", "the", "Categorical", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2217-L2241
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.unique
def unique(self): """ Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, ca...
python
def unique(self): """ Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, ca...
[ "def", "unique", "(", "self", ")", ":", "# unlike np.unique, unique1d does not sort", "unique_codes", "=", "unique1d", "(", "self", ".", "codes", ")", "cat", "=", "self", ".", "copy", "(", ")", "# keep nan in codes", "cat", ".", "_codes", "=", "unique_codes", ...
Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, categories keeps existing orde...
[ "Return", "the", "Categorical", "which", "categories", "and", "codes", "are", "unique", ".", "Unused", "categories", "are", "NOT", "returned", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2243-L2297
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.equals
def equals(self, other): """ Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool """ if self.is_dtype_equal(other): if self.categories.equals(other.categories): ...
python
def equals(self, other): """ Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool """ if self.is_dtype_equal(other): if self.categories.equals(other.categories): ...
[ "def", "equals", "(", "self", ",", "other", ")", ":", "if", "self", ".", "is_dtype_equal", "(", "other", ")", ":", "if", "self", ".", "categories", ".", "equals", "(", "other", ".", "categories", ")", ":", "# fastpath to avoid re-coding", "other_codes", "=...
Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool
[ "Returns", "True", "if", "categorical", "arrays", "are", "equal", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2308-L2329
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.is_dtype_equal
def is_dtype_equal(self, other): """ Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool """ try: return hash(self.dtype) ...
python
def is_dtype_equal(self, other): """ Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool """ try: return hash(self.dtype) ...
[ "def", "is_dtype_equal", "(", "self", ",", "other", ")", ":", "try", ":", "return", "hash", "(", "self", ".", "dtype", ")", "==", "hash", "(", "other", ".", "dtype", ")", "except", "(", "AttributeError", ",", "TypeError", ")", ":", "return", "False" ]
Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool
[ "Returns", "True", "if", "categoricals", "are", "the", "same", "dtype", "same", "categories", "and", "same", "ordered" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2331-L2348
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.describe
def describe(self): """ Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category. """ counts = self.value_counts(dropna=False) freqs = counts / float(counts.sum()) from pand...
python
def describe(self): """ Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category. """ counts = self.value_counts(dropna=False) freqs = counts / float(counts.sum()) from pand...
[ "def", "describe", "(", "self", ")", ":", "counts", "=", "self", ".", "value_counts", "(", "dropna", "=", "False", ")", "freqs", "=", "counts", "/", "float", "(", "counts", ".", "sum", "(", ")", ")", "from", "pandas", ".", "core", ".", "reshape", "...
Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category.
[ "Describes", "this", "Categorical" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2350-L2367
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.isin
def isin(self, values): """ Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : se...
python
def isin(self, values): """ Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : se...
[ "def", "isin", "(", "self", ",", "values", ")", ":", "from", "pandas", ".", "core", ".", "internals", ".", "construction", "import", "sanitize_array", "if", "not", "is_list_like", "(", "values", ")", ":", "raise", "TypeError", "(", "\"only list-like objects ar...
Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : set or list-like The sequence of v...
[ "Check", "whether", "values", "are", "contained", "in", "Categorical", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2387-L2438
train
pandas-dev/pandas
pandas/core/tools/timedeltas.py
to_timedelta
def to_timedelta(arg, unit='ns', box=True, errors='raise'): """ Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Tim...
python
def to_timedelta(arg, unit='ns', box=True, errors='raise'): """ Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Tim...
[ "def", "to_timedelta", "(", "arg", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ")", ":", "unit", "=", "parse_timedelta_unit", "(", "unit", ")", "if", "errors", "not", "in", "(", "'ignore'", ",", "'raise'", ",", "...
Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Timedelta type. Parameters ---------- arg : str, timedelta, li...
[ "Convert", "argument", "to", "timedelta", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L20-L128
train
pandas-dev/pandas
pandas/core/tools/timedeltas.py
_coerce_scalar_to_timedelta_type
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'): """Convert string 'r' to a timedelta object.""" try: result = Timedelta(r, unit) if not box: # explicitly view as timedelta64 for case when result is pd.NaT result = result.asm8.view('timedelta...
python
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'): """Convert string 'r' to a timedelta object.""" try: result = Timedelta(r, unit) if not box: # explicitly view as timedelta64 for case when result is pd.NaT result = result.asm8.view('timedelta...
[ "def", "_coerce_scalar_to_timedelta_type", "(", "r", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ")", ":", "try", ":", "result", "=", "Timedelta", "(", "r", ",", "unit", ")", "if", "not", "box", ":", "# explicitly ...
Convert string 'r' to a timedelta object.
[ "Convert", "string", "r", "to", "a", "timedelta", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L131-L148
train
pandas-dev/pandas
pandas/core/tools/timedeltas.py
_convert_listlike
def _convert_listlike(arg, unit='ns', box=True, errors='raise', name=None): """Convert a list of objects to a timedelta index object.""" if isinstance(arg, (list, tuple)) or not hasattr(arg, 'dtype'): # This is needed only to ensure that in the case where we end up # returning arg (errors == "...
python
def _convert_listlike(arg, unit='ns', box=True, errors='raise', name=None): """Convert a list of objects to a timedelta index object.""" if isinstance(arg, (list, tuple)) or not hasattr(arg, 'dtype'): # This is needed only to ensure that in the case where we end up # returning arg (errors == "...
[ "def", "_convert_listlike", "(", "arg", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ",", "name", "=", "None", ")", ":", "if", "isinstance", "(", "arg", ",", "(", "list", ",", "tuple", ")", ")", "or", "not", "...
Convert a list of objects to a timedelta index object.
[ "Convert", "a", "list", "of", "objects", "to", "a", "timedelta", "index", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L151-L180
train
pandas-dev/pandas
pandas/tseries/offsets.py
generate_range
def generate_range(start=None, end=None, periods=None, offset=BDay()): """ Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default ...
python
def generate_range(start=None, end=None, periods=None, offset=BDay()): """ Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default ...
[ "def", "generate_range", "(", "start", "=", "None", ",", "end", "=", "None", ",", "periods", "=", "None", ",", "offset", "=", "BDay", "(", ")", ")", ":", "from", "pandas", ".", "tseries", ".", "frequencies", "import", "to_offset", "offset", "=", "to_of...
Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default None) end : datetime (default None) periods : int, (default None) offse...
[ "Generates", "a", "sequence", "of", "dates", "corresponding", "to", "the", "specified", "time", "offset", ".", "Similar", "to", "dateutil", ".", "rrule", "except", "uses", "pandas", "DateOffset", "objects", "to", "represent", "time", "increments", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L2412-L2478
train
pandas-dev/pandas
pandas/tseries/offsets.py
DateOffset.apply_index
def apply_index(self, i): """ Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex """...
python
def apply_index(self, i): """ Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex """...
[ "def", "apply_index", "(", "self", ",", "i", ")", ":", "if", "type", "(", "self", ")", "is", "not", "DateOffset", ":", "raise", "NotImplementedError", "(", "\"DateOffset subclass {name} \"", "\"does not have a vectorized \"", "\"implementation\"", ".", "format", "("...
Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex
[ "Vectorized", "apply", "of", "DateOffset", "to", "DatetimeIndex", "raises", "NotImplentedError", "for", "offsets", "without", "a", "vectorized", "implementation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L245-L304
train
pandas-dev/pandas
pandas/tseries/offsets.py
DateOffset.rollback
def rollback(self, dt): """ Roll provided date backward to next offset only if not on offset. """ dt = as_timestamp(dt) if not self.onOffset(dt): dt = dt - self.__class__(1, normalize=self.normalize, **self.kwds) return dt
python
def rollback(self, dt): """ Roll provided date backward to next offset only if not on offset. """ dt = as_timestamp(dt) if not self.onOffset(dt): dt = dt - self.__class__(1, normalize=self.normalize, **self.kwds) return dt
[ "def", "rollback", "(", "self", ",", "dt", ")", ":", "dt", "=", "as_timestamp", "(", "dt", ")", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "dt", "=", "dt", "-", "self", ".", "__class__", "(", "1", ",", "normalize", "=", "self", ...
Roll provided date backward to next offset only if not on offset.
[ "Roll", "provided", "date", "backward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L333-L340
train
pandas-dev/pandas
pandas/tseries/offsets.py
DateOffset.rollforward
def rollforward(self, dt): """ Roll provided date forward to next offset only if not on offset. """ dt = as_timestamp(dt) if not self.onOffset(dt): dt = dt + self.__class__(1, normalize=self.normalize, **self.kwds) return dt
python
def rollforward(self, dt): """ Roll provided date forward to next offset only if not on offset. """ dt = as_timestamp(dt) if not self.onOffset(dt): dt = dt + self.__class__(1, normalize=self.normalize, **self.kwds) return dt
[ "def", "rollforward", "(", "self", ",", "dt", ")", ":", "dt", "=", "as_timestamp", "(", "dt", ")", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "dt", "=", "dt", "+", "self", ".", "__class__", "(", "1", ",", "normalize", "=", "self",...
Roll provided date forward to next offset only if not on offset.
[ "Roll", "provided", "date", "forward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L342-L349
train
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin.next_bday
def next_bday(self): """ Used for moving to next business day. """ if self.n >= 0: nb_offset = 1 else: nb_offset = -1 if self._prefix.startswith('C'): # CustomBusinessHour return CustomBusinessDay(n=nb_offset, ...
python
def next_bday(self): """ Used for moving to next business day. """ if self.n >= 0: nb_offset = 1 else: nb_offset = -1 if self._prefix.startswith('C'): # CustomBusinessHour return CustomBusinessDay(n=nb_offset, ...
[ "def", "next_bday", "(", "self", ")", ":", "if", "self", ".", "n", ">=", "0", ":", "nb_offset", "=", "1", "else", ":", "nb_offset", "=", "-", "1", "if", "self", ".", "_prefix", ".", "startswith", "(", "'C'", ")", ":", "# CustomBusinessHour", "return"...
Used for moving to next business day.
[ "Used", "for", "moving", "to", "next", "business", "day", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L579-L594
train
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin._next_opening_time
def _next_opening_time(self, other): """ If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight. ...
python
def _next_opening_time(self, other): """ If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight. ...
[ "def", "_next_opening_time", "(", "self", ",", "other", ")", ":", "if", "not", "self", ".", "next_bday", ".", "onOffset", "(", "other", ")", ":", "other", "=", "other", "+", "self", ".", "next_bday", "else", ":", "if", "self", ".", "n", ">=", "0", ...
If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight.
[ "If", "n", "is", "positive", "return", "tomorrow", "s", "business", "day", "opening", "time", ".", "Otherwise", "yesterday", "s", "business", "day", "s", "opening", "time", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L605-L621
train
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin._get_business_hours_by_sec
def _get_business_hours_by_sec(self): """ Return business hours in a day by seconds. """ if self._get_daytime_flag: # create dummy datetime to calculate businesshours in a day dtstart = datetime(2014, 4, 1, self.start.hour, self.start.minute) until = d...
python
def _get_business_hours_by_sec(self): """ Return business hours in a day by seconds. """ if self._get_daytime_flag: # create dummy datetime to calculate businesshours in a day dtstart = datetime(2014, 4, 1, self.start.hour, self.start.minute) until = d...
[ "def", "_get_business_hours_by_sec", "(", "self", ")", ":", "if", "self", ".", "_get_daytime_flag", ":", "# create dummy datetime to calculate businesshours in a day", "dtstart", "=", "datetime", "(", "2014", ",", "4", ",", "1", ",", "self", ".", "start", ".", "ho...
Return business hours in a day by seconds.
[ "Return", "business", "hours", "in", "a", "day", "by", "seconds", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L639-L651
train
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin.rollback
def rollback(self, dt): """ Roll provided date backward to next offset only if not on offset. """ if not self.onOffset(dt): businesshours = self._get_business_hours_by_sec if self.n >= 0: dt = self._prev_opening_time( dt) + time...
python
def rollback(self, dt): """ Roll provided date backward to next offset only if not on offset. """ if not self.onOffset(dt): businesshours = self._get_business_hours_by_sec if self.n >= 0: dt = self._prev_opening_time( dt) + time...
[ "def", "rollback", "(", "self", ",", "dt", ")", ":", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "businesshours", "=", "self", ".", "_get_business_hours_by_sec", "if", "self", ".", "n", ">=", "0", ":", "dt", "=", "self", ".", "_prev_op...
Roll provided date backward to next offset only if not on offset.
[ "Roll", "provided", "date", "backward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L654-L666
train
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin.rollforward
def rollforward(self, dt): """ Roll provided date forward to next offset only if not on offset. """ if not self.onOffset(dt): if self.n >= 0: return self._next_opening_time(dt) else: return self._prev_opening_time(dt) return...
python
def rollforward(self, dt): """ Roll provided date forward to next offset only if not on offset. """ if not self.onOffset(dt): if self.n >= 0: return self._next_opening_time(dt) else: return self._prev_opening_time(dt) return...
[ "def", "rollforward", "(", "self", ",", "dt", ")", ":", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "if", "self", ".", "n", ">=", "0", ":", "return", "self", ".", "_next_opening_time", "(", "dt", ")", "else", ":", "return", "self", ...
Roll provided date forward to next offset only if not on offset.
[ "Roll", "provided", "date", "forward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L669-L678
train
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin._onOffset
def _onOffset(self, dt, businesshours): """ Slight speedups using calculated values. """ # if self.normalize and not _is_normalized(dt): # return False # Valid BH can be on the different BusinessDay during midnight # Distinguish by the time spent from previous...
python
def _onOffset(self, dt, businesshours): """ Slight speedups using calculated values. """ # if self.normalize and not _is_normalized(dt): # return False # Valid BH can be on the different BusinessDay during midnight # Distinguish by the time spent from previous...
[ "def", "_onOffset", "(", "self", ",", "dt", ",", "businesshours", ")", ":", "# if self.normalize and not _is_normalized(dt):", "# return False", "# Valid BH can be on the different BusinessDay during midnight", "# Distinguish by the time spent from previous opening time", "if", "se...
Slight speedups using calculated values.
[ "Slight", "speedups", "using", "calculated", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L767-L783
train
pandas-dev/pandas
pandas/tseries/offsets.py
_CustomBusinessMonth.cbday_roll
def cbday_roll(self): """ Define default roll function to be called in apply method. """ cbday = CustomBusinessDay(n=self.n, normalize=False, **self.kwds) if self._prefix.endswith('S'): # MonthBegin roll_func = cbday.rollforward else: ...
python
def cbday_roll(self): """ Define default roll function to be called in apply method. """ cbday = CustomBusinessDay(n=self.n, normalize=False, **self.kwds) if self._prefix.endswith('S'): # MonthBegin roll_func = cbday.rollforward else: ...
[ "def", "cbday_roll", "(", "self", ")", ":", "cbday", "=", "CustomBusinessDay", "(", "n", "=", "self", ".", "n", ",", "normalize", "=", "False", ",", "*", "*", "self", ".", "kwds", ")", "if", "self", ".", "_prefix", ".", "endswith", "(", "'S'", ")",...
Define default roll function to be called in apply method.
[ "Define", "default", "roll", "function", "to", "be", "called", "in", "apply", "method", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1007-L1019
train
pandas-dev/pandas
pandas/tseries/offsets.py
_CustomBusinessMonth.month_roll
def month_roll(self): """ Define default roll function to be called in apply method. """ if self._prefix.endswith('S'): # MonthBegin roll_func = self.m_offset.rollback else: # MonthEnd roll_func = self.m_offset.rollforward r...
python
def month_roll(self): """ Define default roll function to be called in apply method. """ if self._prefix.endswith('S'): # MonthBegin roll_func = self.m_offset.rollback else: # MonthEnd roll_func = self.m_offset.rollforward r...
[ "def", "month_roll", "(", "self", ")", ":", "if", "self", ".", "_prefix", ".", "endswith", "(", "'S'", ")", ":", "# MonthBegin", "roll_func", "=", "self", ".", "m_offset", ".", "rollback", "else", ":", "# MonthEnd", "roll_func", "=", "self", ".", "m_offs...
Define default roll function to be called in apply method.
[ "Define", "default", "roll", "function", "to", "be", "called", "in", "apply", "method", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1032-L1042
train
pandas-dev/pandas
pandas/tseries/offsets.py
SemiMonthBegin._apply_index_days
def _apply_index_days(self, i, roll): """ Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex """ nanos = (roll % 2) * Timedelta(day...
python
def _apply_index_days(self, i, roll): """ Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex """ nanos = (roll % 2) * Timedelta(day...
[ "def", "_apply_index_days", "(", "self", ",", "i", ",", "roll", ")", ":", "nanos", "=", "(", "roll", "%", "2", ")", "*", "Timedelta", "(", "days", "=", "self", ".", "day_of_month", "-", "1", ")", ".", "value", "return", "i", "+", "nanos", ".", "a...
Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex
[ "Add", "days", "portion", "of", "offset", "to", "DatetimeIndex", "i", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1279-L1293
train
pandas-dev/pandas
pandas/tseries/offsets.py
Week._end_apply_index
def _end_apply_index(self, dtindex): """ Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex """ off = dtin...
python
def _end_apply_index(self, dtindex): """ Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex """ off = dtin...
[ "def", "_end_apply_index", "(", "self", ",", "dtindex", ")", ":", "off", "=", "dtindex", ".", "to_perioddelta", "(", "'D'", ")", "base", ",", "mult", "=", "libfrequencies", ".", "get_freq_code", "(", "self", ".", "freqstr", ")", "base_period", "=", "dtinde...
Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex
[ "Add", "self", "to", "the", "given", "DatetimeIndex", "specialized", "for", "case", "where", "self", ".", "weekday", "is", "non", "-", "null", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1354-L1390
train
pandas-dev/pandas
pandas/tseries/offsets.py
WeekOfMonth._get_offset_day
def _get_offset_day(self, other): """ Find the day in the same month as other that has the same weekday as self.weekday and is the self.week'th such day in the month. Parameters ---------- other : datetime Returns ------- day : int """ ...
python
def _get_offset_day(self, other): """ Find the day in the same month as other that has the same weekday as self.weekday and is the self.week'th such day in the month. Parameters ---------- other : datetime Returns ------- day : int """ ...
[ "def", "_get_offset_day", "(", "self", ",", "other", ")", ":", "mstart", "=", "datetime", "(", "other", ".", "year", ",", "other", ".", "month", ",", "1", ")", "wday", "=", "mstart", ".", "weekday", "(", ")", "shift_days", "=", "(", "self", ".", "w...
Find the day in the same month as other that has the same weekday as self.weekday and is the self.week'th such day in the month. Parameters ---------- other : datetime Returns ------- day : int
[ "Find", "the", "day", "in", "the", "same", "month", "as", "other", "that", "has", "the", "same", "weekday", "as", "self", ".", "weekday", "and", "is", "the", "self", ".", "week", "th", "such", "day", "in", "the", "month", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1474-L1490
train
pandas-dev/pandas
pandas/tseries/offsets.py
LastWeekOfMonth._get_offset_day
def _get_offset_day(self, other): """ Find the day in the same month as other that has the same weekday as self.weekday and is the last such day in the month. Parameters ---------- other: datetime Returns ------- day: int """ dim ...
python
def _get_offset_day(self, other): """ Find the day in the same month as other that has the same weekday as self.weekday and is the last such day in the month. Parameters ---------- other: datetime Returns ------- day: int """ dim ...
[ "def", "_get_offset_day", "(", "self", ",", "other", ")", ":", "dim", "=", "ccalendar", ".", "get_days_in_month", "(", "other", ".", "year", ",", "other", ".", "month", ")", "mend", "=", "datetime", "(", "other", ".", "year", ",", "other", ".", "month"...
Find the day in the same month as other that has the same weekday as self.weekday and is the last such day in the month. Parameters ---------- other: datetime Returns ------- day: int
[ "Find", "the", "day", "in", "the", "same", "month", "as", "other", "that", "has", "the", "same", "weekday", "as", "self", ".", "weekday", "and", "is", "the", "last", "such", "day", "in", "the", "month", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1543-L1560
train
pandas-dev/pandas
pandas/tseries/offsets.py
FY5253Quarter._rollback_to_year
def _rollback_to_year(self, other): """ Roll `other` back to the most recent date that was on a fiscal year end. Return the date of that year-end, the number of full quarters elapsed between that year-end and other, and the remaining Timedelta since the most recent quart...
python
def _rollback_to_year(self, other): """ Roll `other` back to the most recent date that was on a fiscal year end. Return the date of that year-end, the number of full quarters elapsed between that year-end and other, and the remaining Timedelta since the most recent quart...
[ "def", "_rollback_to_year", "(", "self", ",", "other", ")", ":", "num_qtrs", "=", "0", "norm", "=", "Timestamp", "(", "other", ")", ".", "tz_localize", "(", "None", ")", "start", "=", "self", ".", "_offset", ".", "rollback", "(", "norm", ")", "# Note: ...
Roll `other` back to the most recent date that was on a fiscal year end. Return the date of that year-end, the number of full quarters elapsed between that year-end and other, and the remaining Timedelta since the most recent quarter-end. Parameters ---------- o...
[ "Roll", "other", "back", "to", "the", "most", "recent", "date", "that", "was", "on", "a", "fiscal", "year", "end", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L2054-L2099
train
pandas-dev/pandas
pandas/core/reshape/concat.py
concat
def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, sort=None, copy=True): """ Concatenate pandas objects along a particular axis with optional set logic along the other axes. Can also add a layer o...
python
def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, sort=None, copy=True): """ Concatenate pandas objects along a particular axis with optional set logic along the other axes. Can also add a layer o...
[ "def", "concat", "(", "objs", ",", "axis", "=", "0", ",", "join", "=", "'outer'", ",", "join_axes", "=", "None", ",", "ignore_index", "=", "False", ",", "keys", "=", "None", ",", "levels", "=", "None", ",", "names", "=", "None", ",", "verify_integrit...
Concatenate pandas objects along a particular axis with optional set logic along the other axes. Can also add a layer of hierarchical indexing on the concatenation axis, which may be useful if the labels are the same (or overlapping) on the passed axis number. Parameters ---------- objs : ...
[ "Concatenate", "pandas", "objects", "along", "a", "particular", "axis", "with", "optional", "set", "logic", "along", "the", "other", "axes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/concat.py#L24-L229
train
pandas-dev/pandas
pandas/core/reshape/concat.py
_Concatenator._get_concat_axis
def _get_concat_axis(self): """ Return index to be used along concatenation axis. """ if self._is_series: if self.axis == 0: indexes = [x.index for x in self.objs] elif self.ignore_index: idx = ibase.default_index(len(self.objs)) ...
python
def _get_concat_axis(self): """ Return index to be used along concatenation axis. """ if self._is_series: if self.axis == 0: indexes = [x.index for x in self.objs] elif self.ignore_index: idx = ibase.default_index(len(self.objs)) ...
[ "def", "_get_concat_axis", "(", "self", ")", ":", "if", "self", ".", "_is_series", ":", "if", "self", ".", "axis", "==", "0", ":", "indexes", "=", "[", "x", ".", "index", "for", "x", "in", "self", ".", "objs", "]", "elif", "self", ".", "ignore_inde...
Return index to be used along concatenation axis.
[ "Return", "index", "to", "be", "used", "along", "concatenation", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/concat.py#L475-L521
train
pandas-dev/pandas
pandas/core/computation/ops.py
_in
def _in(x, y): """Compute the vectorized membership of ``x in y`` if possible, otherwise use Python. """ try: return x.isin(y) except AttributeError: if is_list_like(x): try: return y.isin(x) except AttributeError: pass ...
python
def _in(x, y): """Compute the vectorized membership of ``x in y`` if possible, otherwise use Python. """ try: return x.isin(y) except AttributeError: if is_list_like(x): try: return y.isin(x) except AttributeError: pass ...
[ "def", "_in", "(", "x", ",", "y", ")", ":", "try", ":", "return", "x", ".", "isin", "(", "y", ")", "except", "AttributeError", ":", "if", "is_list_like", "(", "x", ")", ":", "try", ":", "return", "y", ".", "isin", "(", "x", ")", "except", "Attr...
Compute the vectorized membership of ``x in y`` if possible, otherwise use Python.
[ "Compute", "the", "vectorized", "membership", "of", "x", "in", "y", "if", "possible", "otherwise", "use", "Python", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L234-L246
train
pandas-dev/pandas
pandas/core/computation/ops.py
_not_in
def _not_in(x, y): """Compute the vectorized membership of ``x not in y`` if possible, otherwise use Python. """ try: return ~x.isin(y) except AttributeError: if is_list_like(x): try: return ~y.isin(x) except AttributeError: pas...
python
def _not_in(x, y): """Compute the vectorized membership of ``x not in y`` if possible, otherwise use Python. """ try: return ~x.isin(y) except AttributeError: if is_list_like(x): try: return ~y.isin(x) except AttributeError: pas...
[ "def", "_not_in", "(", "x", ",", "y", ")", ":", "try", ":", "return", "~", "x", ".", "isin", "(", "y", ")", "except", "AttributeError", ":", "if", "is_list_like", "(", "x", ")", ":", "try", ":", "return", "~", "y", ".", "isin", "(", "x", ")", ...
Compute the vectorized membership of ``x not in y`` if possible, otherwise use Python.
[ "Compute", "the", "vectorized", "membership", "of", "x", "not", "in", "y", "if", "possible", "otherwise", "use", "Python", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L249-L261
train
pandas-dev/pandas
pandas/core/computation/ops.py
_cast_inplace
def _cast_inplace(terms, acceptable_dtypes, dtype): """Cast an expression inplace. Parameters ---------- terms : Op The expression that should cast. acceptable_dtypes : list of acceptable numpy.dtype Will not cast if term's dtype in this list. .. versionadded:: 0.19.0 ...
python
def _cast_inplace(terms, acceptable_dtypes, dtype): """Cast an expression inplace. Parameters ---------- terms : Op The expression that should cast. acceptable_dtypes : list of acceptable numpy.dtype Will not cast if term's dtype in this list. .. versionadded:: 0.19.0 ...
[ "def", "_cast_inplace", "(", "terms", ",", "acceptable_dtypes", ",", "dtype", ")", ":", "dt", "=", "np", ".", "dtype", "(", "dtype", ")", "for", "term", "in", "terms", ":", "if", "term", ".", "type", "in", "acceptable_dtypes", ":", "continue", "try", "...
Cast an expression inplace. Parameters ---------- terms : Op The expression that should cast. acceptable_dtypes : list of acceptable numpy.dtype Will not cast if term's dtype in this list. .. versionadded:: 0.19.0 dtype : str or numpy.dtype The dtype to cast to.
[ "Cast", "an", "expression", "inplace", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L288-L312
train
pandas-dev/pandas
pandas/core/computation/ops.py
Term.update
def update(self, value): """ search order for local (i.e., @variable) variables: scope, key_variable [('locals', 'local_name'), ('globals', 'local_name'), ('locals', 'key'), ('globals', 'key')] """ key = self.name # if it's a variable ...
python
def update(self, value): """ search order for local (i.e., @variable) variables: scope, key_variable [('locals', 'local_name'), ('globals', 'local_name'), ('locals', 'key'), ('globals', 'key')] """ key = self.name # if it's a variable ...
[ "def", "update", "(", "self", ",", "value", ")", ":", "key", "=", "self", ".", "name", "# if it's a variable name (otherwise a constant)", "if", "isinstance", "(", "key", ",", "str", ")", ":", "self", ".", "env", ".", "swapkey", "(", "self", ".", "local_na...
search order for local (i.e., @variable) variables: scope, key_variable [('locals', 'local_name'), ('globals', 'local_name'), ('locals', 'key'), ('globals', 'key')]
[ "search", "order", "for", "local", "(", "i", ".", "e", ".", "@variable", ")", "variables", ":" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L88-L104
train
pandas-dev/pandas
pandas/core/computation/ops.py
BinOp.evaluate
def evaluate(self, env, engine, parser, term_type, eval_in_python): """Evaluate a binary operation *before* being passed to the engine. Parameters ---------- env : Scope engine : str parser : str term_type : type eval_in_python : list Returns ...
python
def evaluate(self, env, engine, parser, term_type, eval_in_python): """Evaluate a binary operation *before* being passed to the engine. Parameters ---------- env : Scope engine : str parser : str term_type : type eval_in_python : list Returns ...
[ "def", "evaluate", "(", "self", ",", "env", ",", "engine", ",", "parser", ",", "term_type", ",", "eval_in_python", ")", ":", "if", "engine", "==", "'python'", ":", "res", "=", "self", "(", "env", ")", "else", ":", "# recurse over the left/right nodes", "le...
Evaluate a binary operation *before* being passed to the engine. Parameters ---------- env : Scope engine : str parser : str term_type : type eval_in_python : list Returns ------- term_type The "pre-evaluated" expression as an...
[ "Evaluate", "a", "binary", "operation", "*", "before", "*", "being", "passed", "to", "the", "engine", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L369-L405
train
pandas-dev/pandas
pandas/core/computation/ops.py
BinOp.convert_values
def convert_values(self): """Convert datetimes to a comparable value in an expression. """ def stringify(value): if self.encoding is not None: encoder = partial(pprint_thing_encoded, encoding=self.encoding) else: ...
python
def convert_values(self): """Convert datetimes to a comparable value in an expression. """ def stringify(value): if self.encoding is not None: encoder = partial(pprint_thing_encoded, encoding=self.encoding) else: ...
[ "def", "convert_values", "(", "self", ")", ":", "def", "stringify", "(", "value", ")", ":", "if", "self", ".", "encoding", "is", "not", "None", ":", "encoder", "=", "partial", "(", "pprint_thing_encoded", ",", "encoding", "=", "self", ".", "encoding", ")...
Convert datetimes to a comparable value in an expression.
[ "Convert", "datetimes", "to", "a", "comparable", "value", "in", "an", "expression", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L407-L436
train
pandas-dev/pandas
pandas/core/reshape/pivot.py
crosstab
def crosstab(index, columns, values=None, rownames=None, colnames=None, aggfunc=None, margins=False, margins_name='All', dropna=True, normalize=False): """ Compute a simple cross tabulation of two (or more) factors. By default computes a frequency table of the factors unless an arr...
python
def crosstab(index, columns, values=None, rownames=None, colnames=None, aggfunc=None, margins=False, margins_name='All', dropna=True, normalize=False): """ Compute a simple cross tabulation of two (or more) factors. By default computes a frequency table of the factors unless an arr...
[ "def", "crosstab", "(", "index", ",", "columns", ",", "values", "=", "None", ",", "rownames", "=", "None", ",", "colnames", "=", "None", ",", "aggfunc", "=", "None", ",", "margins", "=", "False", ",", "margins_name", "=", "'All'", ",", "dropna", "=", ...
Compute a simple cross tabulation of two (or more) factors. By default computes a frequency table of the factors unless an array of values and an aggregation function are passed. Parameters ---------- index : array-like, Series, or list of arrays/Series Values to group by in the rows. c...
[ "Compute", "a", "simple", "cross", "tabulation", "of", "two", "(", "or", "more", ")", "factors", ".", "By", "default", "computes", "a", "frequency", "table", "of", "the", "factors", "unless", "an", "array", "of", "values", "and", "an", "aggregation", "func...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/pivot.py#L391-L528
train
pandas-dev/pandas
pandas/util/_doctools.py
TablePlotter._shape
def _shape(self, df): """ Calculate table chape considering index levels. """ row, col = df.shape return row + df.columns.nlevels, col + df.index.nlevels
python
def _shape(self, df): """ Calculate table chape considering index levels. """ row, col = df.shape return row + df.columns.nlevels, col + df.index.nlevels
[ "def", "_shape", "(", "self", ",", "df", ")", ":", "row", ",", "col", "=", "df", ".", "shape", "return", "row", "+", "df", ".", "columns", ".", "nlevels", ",", "col", "+", "df", ".", "index", ".", "nlevels" ]
Calculate table chape considering index levels.
[ "Calculate", "table", "chape", "considering", "index", "levels", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L17-L23
train
pandas-dev/pandas
pandas/util/_doctools.py
TablePlotter._get_cells
def _get_cells(self, left, right, vertical): """ Calculate appropriate figure size based on left and right data. """ if vertical: # calculate required number of cells vcells = max(sum(self._shape(l)[0] for l in left), self._shape(right)[0...
python
def _get_cells(self, left, right, vertical): """ Calculate appropriate figure size based on left and right data. """ if vertical: # calculate required number of cells vcells = max(sum(self._shape(l)[0] for l in left), self._shape(right)[0...
[ "def", "_get_cells", "(", "self", ",", "left", ",", "right", ",", "vertical", ")", ":", "if", "vertical", ":", "# calculate required number of cells", "vcells", "=", "max", "(", "sum", "(", "self", ".", "_shape", "(", "l", ")", "[", "0", "]", "for", "l...
Calculate appropriate figure size based on left and right data.
[ "Calculate", "appropriate", "figure", "size", "based", "on", "left", "and", "right", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L25-L41
train
pandas-dev/pandas
pandas/util/_doctools.py
TablePlotter.plot
def plot(self, left, right, labels=None, vertical=True): """ Plot left / right DataFrames in specified layout. Parameters ---------- left : list of DataFrames before operation is applied right : DataFrame of operation result labels : list of str to be drawn as ti...
python
def plot(self, left, right, labels=None, vertical=True): """ Plot left / right DataFrames in specified layout. Parameters ---------- left : list of DataFrames before operation is applied right : DataFrame of operation result labels : list of str to be drawn as ti...
[ "def", "plot", "(", "self", ",", "left", ",", "right", ",", "labels", "=", "None", ",", "vertical", "=", "True", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "import", "matplotlib", ".", "gridspec", "as", "gridspec", "if", "not", "isin...
Plot left / right DataFrames in specified layout. Parameters ---------- left : list of DataFrames before operation is applied right : DataFrame of operation result labels : list of str to be drawn as titles of left DataFrames vertical : bool If True, use vert...
[ "Plot", "left", "/", "right", "DataFrames", "in", "specified", "layout", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L43-L101
train
pandas-dev/pandas
pandas/util/_doctools.py
TablePlotter._conv
def _conv(self, data): """Convert each input to appropriate for table outplot""" if isinstance(data, pd.Series): if data.name is None: data = data.to_frame(name='') else: data = data.to_frame() data = data.fillna('NaN') return data
python
def _conv(self, data): """Convert each input to appropriate for table outplot""" if isinstance(data, pd.Series): if data.name is None: data = data.to_frame(name='') else: data = data.to_frame() data = data.fillna('NaN') return data
[ "def", "_conv", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "pd", ".", "Series", ")", ":", "if", "data", ".", "name", "is", "None", ":", "data", "=", "data", ".", "to_frame", "(", "name", "=", "''", ")", "else", ":...
Convert each input to appropriate for table outplot
[ "Convert", "each", "input", "to", "appropriate", "for", "table", "outplot" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L103-L111
train
pandas-dev/pandas
pandas/core/reshape/tile.py
cut
def cut(x, bins, right=True, labels=None, retbins=False, precision=3, include_lowest=False, duplicates='raise'): """ Bin values into discrete intervals. Use `cut` when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a ...
python
def cut(x, bins, right=True, labels=None, retbins=False, precision=3, include_lowest=False, duplicates='raise'): """ Bin values into discrete intervals. Use `cut` when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a ...
[ "def", "cut", "(", "x", ",", "bins", ",", "right", "=", "True", ",", "labels", "=", "None", ",", "retbins", "=", "False", ",", "precision", "=", "3", ",", "include_lowest", "=", "False", ",", "duplicates", "=", "'raise'", ")", ":", "# NOTE: this binnin...
Bin values into discrete intervals. Use `cut` when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a categorical variable. For example, `cut` could convert ages to groups of age ranges. Supports binning into an equal number of bin...
[ "Bin", "values", "into", "discrete", "intervals", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L23-L245
train
pandas-dev/pandas
pandas/core/reshape/tile.py
qcut
def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'): """ Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating qua...
python
def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'): """ Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating qua...
[ "def", "qcut", "(", "x", ",", "q", ",", "labels", "=", "None", ",", "retbins", "=", "False", ",", "precision", "=", "3", ",", "duplicates", "=", "'raise'", ")", ":", "x_is_series", ",", "series_index", ",", "name", ",", "x", "=", "_preprocess_for_cut",...
Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating quantile membership for each data point. Parameters ---------- x : 1d ndarray o...
[ "Quantile", "-", "based", "discretization", "function", ".", "Discretize", "variable", "into", "equal", "-", "sized", "buckets", "based", "on", "rank", "or", "based", "on", "sample", "quantiles", ".", "For", "example", "1000", "values", "for", "10", "quantiles...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L248-L317
train
pandas-dev/pandas
pandas/core/reshape/tile.py
_coerce_to_type
def _coerce_to_type(x): """ if the passed data is of datetime/timedelta type, this method converts it to numeric so that cut method can handle it """ dtype = None if is_datetime64tz_dtype(x): dtype = x.dtype elif is_datetime64_dtype(x): x = to_datetime(x) dtype =...
python
def _coerce_to_type(x): """ if the passed data is of datetime/timedelta type, this method converts it to numeric so that cut method can handle it """ dtype = None if is_datetime64tz_dtype(x): dtype = x.dtype elif is_datetime64_dtype(x): x = to_datetime(x) dtype =...
[ "def", "_coerce_to_type", "(", "x", ")", ":", "dtype", "=", "None", "if", "is_datetime64tz_dtype", "(", "x", ")", ":", "dtype", "=", "x", ".", "dtype", "elif", "is_datetime64_dtype", "(", "x", ")", ":", "x", "=", "to_datetime", "(", "x", ")", "dtype", ...
if the passed data is of datetime/timedelta type, this method converts it to numeric so that cut method can handle it
[ "if", "the", "passed", "data", "is", "of", "datetime", "/", "timedelta", "type", "this", "method", "converts", "it", "to", "numeric", "so", "that", "cut", "method", "can", "handle", "it" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L377-L398
train
pandas-dev/pandas
pandas/core/reshape/tile.py
_convert_bin_to_numeric_type
def _convert_bin_to_numeric_type(bins, dtype): """ if the passed bin is of datetime/timedelta type, this method converts it to integer Parameters ---------- bins : list-like of bins dtype : dtype of data Raises ------ ValueError if bins are not of a compat dtype to dtype ""...
python
def _convert_bin_to_numeric_type(bins, dtype): """ if the passed bin is of datetime/timedelta type, this method converts it to integer Parameters ---------- bins : list-like of bins dtype : dtype of data Raises ------ ValueError if bins are not of a compat dtype to dtype ""...
[ "def", "_convert_bin_to_numeric_type", "(", "bins", ",", "dtype", ")", ":", "bins_dtype", "=", "infer_dtype", "(", "bins", ",", "skipna", "=", "False", ")", "if", "is_timedelta64_dtype", "(", "dtype", ")", ":", "if", "bins_dtype", "in", "[", "'timedelta'", "...
if the passed bin is of datetime/timedelta type, this method converts it to integer Parameters ---------- bins : list-like of bins dtype : dtype of data Raises ------ ValueError if bins are not of a compat dtype to dtype
[ "if", "the", "passed", "bin", "is", "of", "datetime", "/", "timedelta", "type", "this", "method", "converts", "it", "to", "integer" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L401-L427
train
pandas-dev/pandas
pandas/core/reshape/tile.py
_convert_bin_to_datelike_type
def _convert_bin_to_datelike_type(bins, dtype): """ Convert bins to a DatetimeIndex or TimedeltaIndex if the orginal dtype is datelike Parameters ---------- bins : list-like of bins dtype : dtype of data Returns ------- bins : Array-like of bins, DatetimeIndex or TimedeltaIndex...
python
def _convert_bin_to_datelike_type(bins, dtype): """ Convert bins to a DatetimeIndex or TimedeltaIndex if the orginal dtype is datelike Parameters ---------- bins : list-like of bins dtype : dtype of data Returns ------- bins : Array-like of bins, DatetimeIndex or TimedeltaIndex...
[ "def", "_convert_bin_to_datelike_type", "(", "bins", ",", "dtype", ")", ":", "if", "is_datetime64tz_dtype", "(", "dtype", ")", ":", "bins", "=", "to_datetime", "(", "bins", ".", "astype", "(", "np", ".", "int64", ")", ",", "utc", "=", "True", ")", ".", ...
Convert bins to a DatetimeIndex or TimedeltaIndex if the orginal dtype is datelike Parameters ---------- bins : list-like of bins dtype : dtype of data Returns ------- bins : Array-like of bins, DatetimeIndex or TimedeltaIndex if dtype is datelike
[ "Convert", "bins", "to", "a", "DatetimeIndex", "or", "TimedeltaIndex", "if", "the", "orginal", "dtype", "is", "datelike" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L430-L450
train
pandas-dev/pandas
pandas/core/reshape/tile.py
_format_labels
def _format_labels(bins, precision, right=True, include_lowest=False, dtype=None): """ based on the dtype, return our labels """ closed = 'right' if right else 'left' if is_datetime64tz_dtype(dtype): formatter = partial(Timestamp, tz=dtype.tz) adjust = lambda x: x - Time...
python
def _format_labels(bins, precision, right=True, include_lowest=False, dtype=None): """ based on the dtype, return our labels """ closed = 'right' if right else 'left' if is_datetime64tz_dtype(dtype): formatter = partial(Timestamp, tz=dtype.tz) adjust = lambda x: x - Time...
[ "def", "_format_labels", "(", "bins", ",", "precision", ",", "right", "=", "True", ",", "include_lowest", "=", "False", ",", "dtype", "=", "None", ")", ":", "closed", "=", "'right'", "if", "right", "else", "'left'", "if", "is_datetime64tz_dtype", "(", "dty...
based on the dtype, return our labels
[ "based", "on", "the", "dtype", "return", "our", "labels" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L453-L484
train
pandas-dev/pandas
pandas/core/reshape/tile.py
_preprocess_for_cut
def _preprocess_for_cut(x): """ handles preprocessing for cut where we convert passed input to array, strip the index information and store it separately """ x_is_series = isinstance(x, Series) series_index = None name = None if x_is_series: series_index = x.index na...
python
def _preprocess_for_cut(x): """ handles preprocessing for cut where we convert passed input to array, strip the index information and store it separately """ x_is_series = isinstance(x, Series) series_index = None name = None if x_is_series: series_index = x.index na...
[ "def", "_preprocess_for_cut", "(", "x", ")", ":", "x_is_series", "=", "isinstance", "(", "x", ",", "Series", ")", "series_index", "=", "None", "name", "=", "None", "if", "x_is_series", ":", "series_index", "=", "x", ".", "index", "name", "=", "x", ".", ...
handles preprocessing for cut where we convert passed input to array, strip the index information and store it separately
[ "handles", "preprocessing", "for", "cut", "where", "we", "convert", "passed", "input", "to", "array", "strip", "the", "index", "information", "and", "store", "it", "separately" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L487-L509
train
pandas-dev/pandas
pandas/core/reshape/tile.py
_postprocess_for_cut
def _postprocess_for_cut(fac, bins, retbins, x_is_series, series_index, name, dtype): """ handles post processing for the cut method where we combine the index information if the originally passed datatype was a series """ if x_is_series: fac = Series(fac, index=...
python
def _postprocess_for_cut(fac, bins, retbins, x_is_series, series_index, name, dtype): """ handles post processing for the cut method where we combine the index information if the originally passed datatype was a series """ if x_is_series: fac = Series(fac, index=...
[ "def", "_postprocess_for_cut", "(", "fac", ",", "bins", ",", "retbins", ",", "x_is_series", ",", "series_index", ",", "name", ",", "dtype", ")", ":", "if", "x_is_series", ":", "fac", "=", "Series", "(", "fac", ",", "index", "=", "series_index", ",", "nam...
handles post processing for the cut method where we combine the index information if the originally passed datatype was a series
[ "handles", "post", "processing", "for", "the", "cut", "method", "where", "we", "combine", "the", "index", "information", "if", "the", "originally", "passed", "datatype", "was", "a", "series" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L512-L527
train
pandas-dev/pandas
pandas/core/reshape/tile.py
_round_frac
def _round_frac(x, precision): """ Round the fractional part of the given number """ if not np.isfinite(x) or x == 0: return x else: frac, whole = np.modf(x) if whole == 0: digits = -int(np.floor(np.log10(abs(frac)))) - 1 + precision else: digi...
python
def _round_frac(x, precision): """ Round the fractional part of the given number """ if not np.isfinite(x) or x == 0: return x else: frac, whole = np.modf(x) if whole == 0: digits = -int(np.floor(np.log10(abs(frac)))) - 1 + precision else: digi...
[ "def", "_round_frac", "(", "x", ",", "precision", ")", ":", "if", "not", "np", ".", "isfinite", "(", "x", ")", "or", "x", "==", "0", ":", "return", "x", "else", ":", "frac", ",", "whole", "=", "np", ".", "modf", "(", "x", ")", "if", "whole", ...
Round the fractional part of the given number
[ "Round", "the", "fractional", "part", "of", "the", "given", "number" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L530-L542
train
pandas-dev/pandas
pandas/core/reshape/tile.py
_infer_precision
def _infer_precision(base_precision, bins): """Infer an appropriate precision for _round_frac """ for precision in range(base_precision, 20): levels = [_round_frac(b, precision) for b in bins] if algos.unique(levels).size == bins.size: return precision return base_precision
python
def _infer_precision(base_precision, bins): """Infer an appropriate precision for _round_frac """ for precision in range(base_precision, 20): levels = [_round_frac(b, precision) for b in bins] if algos.unique(levels).size == bins.size: return precision return base_precision
[ "def", "_infer_precision", "(", "base_precision", ",", "bins", ")", ":", "for", "precision", "in", "range", "(", "base_precision", ",", "20", ")", ":", "levels", "=", "[", "_round_frac", "(", "b", ",", "precision", ")", "for", "b", "in", "bins", "]", "...
Infer an appropriate precision for _round_frac
[ "Infer", "an", "appropriate", "precision", "for", "_round_frac" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L545-L552
train
pandas-dev/pandas
pandas/_config/display.py
detect_console_encoding
def detect_console_encoding(): """ Try to find the most capable encoding supported by the console. slightly modified from the way IPython handles the same issue. """ global _initial_defencoding encoding = None try: encoding = sys.stdout.encoding or sys.stdin.encoding except (Att...
python
def detect_console_encoding(): """ Try to find the most capable encoding supported by the console. slightly modified from the way IPython handles the same issue. """ global _initial_defencoding encoding = None try: encoding = sys.stdout.encoding or sys.stdin.encoding except (Att...
[ "def", "detect_console_encoding", "(", ")", ":", "global", "_initial_defencoding", "encoding", "=", "None", "try", ":", "encoding", "=", "sys", ".", "stdout", ".", "encoding", "or", "sys", ".", "stdin", ".", "encoding", "except", "(", "AttributeError", ",", ...
Try to find the most capable encoding supported by the console. slightly modified from the way IPython handles the same issue.
[ "Try", "to", "find", "the", "most", "capable", "encoding", "supported", "by", "the", "console", ".", "slightly", "modified", "from", "the", "way", "IPython", "handles", "the", "same", "issue", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/display.py#L14-L43
train
pandas-dev/pandas
pandas/util/_validators.py
_check_arg_length
def _check_arg_length(fname, args, max_fname_arg_count, compat_args): """ Checks whether 'args' has length of at most 'compat_args'. Raises a TypeError if that is not the case, similar to in Python when a function is called with too many arguments. """ if max_fname_arg_count < 0: raise ...
python
def _check_arg_length(fname, args, max_fname_arg_count, compat_args): """ Checks whether 'args' has length of at most 'compat_args'. Raises a TypeError if that is not the case, similar to in Python when a function is called with too many arguments. """ if max_fname_arg_count < 0: raise ...
[ "def", "_check_arg_length", "(", "fname", ",", "args", ",", "max_fname_arg_count", ",", "compat_args", ")", ":", "if", "max_fname_arg_count", "<", "0", ":", "raise", "ValueError", "(", "\"'max_fname_arg_count' must be non-negative\"", ")", "if", "len", "(", "args", ...
Checks whether 'args' has length of at most 'compat_args'. Raises a TypeError if that is not the case, similar to in Python when a function is called with too many arguments.
[ "Checks", "whether", "args", "has", "length", "of", "at", "most", "compat_args", ".", "Raises", "a", "TypeError", "if", "that", "is", "not", "the", "case", "similar", "to", "in", "Python", "when", "a", "function", "is", "called", "with", "too", "many", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L10-L29
train
pandas-dev/pandas
pandas/util/_validators.py
_check_for_default_values
def _check_for_default_values(fname, arg_val_dict, compat_args): """ Check that the keys in `arg_val_dict` are mapped to their default values as specified in `compat_args`. Note that this function is to be called only when it has been checked that arg_val_dict.keys() is a subset of compat_args ...
python
def _check_for_default_values(fname, arg_val_dict, compat_args): """ Check that the keys in `arg_val_dict` are mapped to their default values as specified in `compat_args`. Note that this function is to be called only when it has been checked that arg_val_dict.keys() is a subset of compat_args ...
[ "def", "_check_for_default_values", "(", "fname", ",", "arg_val_dict", ",", "compat_args", ")", ":", "for", "key", "in", "arg_val_dict", ":", "# try checking equality directly with '=' operator,", "# as comparison may have been overridden for the left", "# hand object", "try", ...
Check that the keys in `arg_val_dict` are mapped to their default values as specified in `compat_args`. Note that this function is to be called only when it has been checked that arg_val_dict.keys() is a subset of compat_args
[ "Check", "that", "the", "keys", "in", "arg_val_dict", "are", "mapped", "to", "their", "default", "values", "as", "specified", "in", "compat_args", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L32-L69
train
pandas-dev/pandas
pandas/util/_validators.py
validate_args
def validate_args(fname, args, max_fname_arg_count, compat_args): """ Checks whether the length of the `*args` argument passed into a function has at most `len(compat_args)` arguments and whether or not all of these elements in `args` are set to their default values. fname: str The name of ...
python
def validate_args(fname, args, max_fname_arg_count, compat_args): """ Checks whether the length of the `*args` argument passed into a function has at most `len(compat_args)` arguments and whether or not all of these elements in `args` are set to their default values. fname: str The name of ...
[ "def", "validate_args", "(", "fname", ",", "args", ",", "max_fname_arg_count", ",", "compat_args", ")", ":", "_check_arg_length", "(", "fname", ",", "args", ",", "max_fname_arg_count", ",", "compat_args", ")", "# We do this so that we can provide a more informative", "#...
Checks whether the length of the `*args` argument passed into a function has at most `len(compat_args)` arguments and whether or not all of these elements in `args` are set to their default values. fname: str The name of the function being passed the `*args` parameter args: tuple The `...
[ "Checks", "whether", "the", "length", "of", "the", "*", "args", "argument", "passed", "into", "a", "function", "has", "at", "most", "len", "(", "compat_args", ")", "arguments", "and", "whether", "or", "not", "all", "of", "these", "elements", "in", "args", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L72-L111
train
pandas-dev/pandas
pandas/util/_validators.py
_check_for_invalid_keys
def _check_for_invalid_keys(fname, kwargs, compat_args): """ Checks whether 'kwargs' contains any keys that are not in 'compat_args' and raises a TypeError if there is one. """ # set(dict) --> set of the dictionary's keys diff = set(kwargs) - set(compat_args) if diff: bad_arg = lis...
python
def _check_for_invalid_keys(fname, kwargs, compat_args): """ Checks whether 'kwargs' contains any keys that are not in 'compat_args' and raises a TypeError if there is one. """ # set(dict) --> set of the dictionary's keys diff = set(kwargs) - set(compat_args) if diff: bad_arg = lis...
[ "def", "_check_for_invalid_keys", "(", "fname", ",", "kwargs", ",", "compat_args", ")", ":", "# set(dict) --> set of the dictionary's keys", "diff", "=", "set", "(", "kwargs", ")", "-", "set", "(", "compat_args", ")", "if", "diff", ":", "bad_arg", "=", "list", ...
Checks whether 'kwargs' contains any keys that are not in 'compat_args' and raises a TypeError if there is one.
[ "Checks", "whether", "kwargs", "contains", "any", "keys", "that", "are", "not", "in", "compat_args", "and", "raises", "a", "TypeError", "if", "there", "is", "one", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L114-L127
train
pandas-dev/pandas
pandas/util/_validators.py
validate_kwargs
def validate_kwargs(fname, kwargs, compat_args): """ Checks whether parameters passed to the **kwargs argument in a function `fname` are valid parameters as specified in `*compat_args` and whether or not they are set to their default values. Parameters ---------- fname: str The name...
python
def validate_kwargs(fname, kwargs, compat_args): """ Checks whether parameters passed to the **kwargs argument in a function `fname` are valid parameters as specified in `*compat_args` and whether or not they are set to their default values. Parameters ---------- fname: str The name...
[ "def", "validate_kwargs", "(", "fname", ",", "kwargs", ",", "compat_args", ")", ":", "kwds", "=", "kwargs", ".", "copy", "(", ")", "_check_for_invalid_keys", "(", "fname", ",", "kwargs", ",", "compat_args", ")", "_check_for_default_values", "(", "fname", ",", ...
Checks whether parameters passed to the **kwargs argument in a function `fname` are valid parameters as specified in `*compat_args` and whether or not they are set to their default values. Parameters ---------- fname: str The name of the function being passed the `**kwargs` parameter k...
[ "Checks", "whether", "parameters", "passed", "to", "the", "**", "kwargs", "argument", "in", "a", "function", "fname", "are", "valid", "parameters", "as", "specified", "in", "*", "compat_args", "and", "whether", "or", "not", "they", "are", "set", "to", "their...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L130-L157
train
pandas-dev/pandas
pandas/util/_validators.py
validate_args_and_kwargs
def validate_args_and_kwargs(fname, args, kwargs, max_fname_arg_count, compat_args): """ Checks whether parameters passed to the *args and **kwargs argument in a function `fname` are valid parameters as specified in `*compat_args` and whether or ...
python
def validate_args_and_kwargs(fname, args, kwargs, max_fname_arg_count, compat_args): """ Checks whether parameters passed to the *args and **kwargs argument in a function `fname` are valid parameters as specified in `*compat_args` and whether or ...
[ "def", "validate_args_and_kwargs", "(", "fname", ",", "args", ",", "kwargs", ",", "max_fname_arg_count", ",", "compat_args", ")", ":", "# Check that the total number of arguments passed in (i.e.", "# args and kwargs) does not exceed the length of compat_args", "_check_arg_length", ...
Checks whether parameters passed to the *args and **kwargs argument in a function `fname` are valid parameters as specified in `*compat_args` and whether or not they are set to their default values. Parameters ---------- fname: str The name of the function being passed the `**kwargs` parame...
[ "Checks", "whether", "parameters", "passed", "to", "the", "*", "args", "and", "**", "kwargs", "argument", "in", "a", "function", "fname", "are", "valid", "parameters", "as", "specified", "in", "*", "compat_args", "and", "whether", "or", "not", "they", "are",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L160-L218
train
pandas-dev/pandas
pandas/util/_validators.py
validate_bool_kwarg
def validate_bool_kwarg(value, arg_name): """ Ensures that argument passed in arg_name is of type bool. """ if not (is_bool(value) or value is None): raise ValueError('For argument "{arg}" expected type bool, received ' 'type {typ}.'.format(arg=arg_name, ...
python
def validate_bool_kwarg(value, arg_name): """ Ensures that argument passed in arg_name is of type bool. """ if not (is_bool(value) or value is None): raise ValueError('For argument "{arg}" expected type bool, received ' 'type {typ}.'.format(arg=arg_name, ...
[ "def", "validate_bool_kwarg", "(", "value", ",", "arg_name", ")", ":", "if", "not", "(", "is_bool", "(", "value", ")", "or", "value", "is", "None", ")", ":", "raise", "ValueError", "(", "'For argument \"{arg}\" expected type bool, received '", "'type {typ}.'", "."...
Ensures that argument passed in arg_name is of type bool.
[ "Ensures", "that", "argument", "passed", "in", "arg_name", "is", "of", "type", "bool", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L221-L227
train
pandas-dev/pandas
pandas/util/_validators.py
validate_axis_style_args
def validate_axis_style_args(data, args, kwargs, arg_name, method_name): """Argument handler for mixed index, columns / axis functions In an attempt to handle both `.method(index, columns)`, and `.method(arg, axis=.)`, we have to do some bad things to argument parsing. This translates all arguments to ...
python
def validate_axis_style_args(data, args, kwargs, arg_name, method_name): """Argument handler for mixed index, columns / axis functions In an attempt to handle both `.method(index, columns)`, and `.method(arg, axis=.)`, we have to do some bad things to argument parsing. This translates all arguments to ...
[ "def", "validate_axis_style_args", "(", "data", ",", "args", ",", "kwargs", ",", "arg_name", ",", "method_name", ")", ":", "# TODO: Change to keyword-only args and remove all this", "out", "=", "{", "}", "# Goal: fill 'out' with index/columns-style arguments", "# like out = {...
Argument handler for mixed index, columns / axis functions In an attempt to handle both `.method(index, columns)`, and `.method(arg, axis=.)`, we have to do some bad things to argument parsing. This translates all arguments to `{index=., columns=.}` style. Parameters ---------- data : DataFram...
[ "Argument", "handler", "for", "mixed", "index", "columns", "/", "axis", "functions" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L230-L322
train
pandas-dev/pandas
pandas/util/_validators.py
validate_fillna_kwargs
def validate_fillna_kwargs(value, method, validate_scalar_dict_value=True): """Validate the keyword arguments to 'fillna'. This checks that exactly one of 'value' and 'method' is specified. If 'method' is specified, this validates that it's a valid method. Parameters ---------- value, method :...
python
def validate_fillna_kwargs(value, method, validate_scalar_dict_value=True): """Validate the keyword arguments to 'fillna'. This checks that exactly one of 'value' and 'method' is specified. If 'method' is specified, this validates that it's a valid method. Parameters ---------- value, method :...
[ "def", "validate_fillna_kwargs", "(", "value", ",", "method", ",", "validate_scalar_dict_value", "=", "True", ")", ":", "from", "pandas", ".", "core", ".", "missing", "import", "clean_fill_method", "if", "value", "is", "None", "and", "method", "is", "None", ":...
Validate the keyword arguments to 'fillna'. This checks that exactly one of 'value' and 'method' is specified. If 'method' is specified, this validates that it's a valid method. Parameters ---------- value, method : object The 'value' and 'method' keyword arguments for 'fillna'. valida...
[ "Validate", "the", "keyword", "arguments", "to", "fillna", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L325-L358
train
pandas-dev/pandas
pandas/core/resample.py
_maybe_process_deprecations
def _maybe_process_deprecations(r, how=None, fill_method=None, limit=None): """ Potentially we might have a deprecation warning, show it but call the appropriate methods anyhow. """ if how is not None: # .resample(..., how='sum') if isinstance(how, str): method = "{0}()...
python
def _maybe_process_deprecations(r, how=None, fill_method=None, limit=None): """ Potentially we might have a deprecation warning, show it but call the appropriate methods anyhow. """ if how is not None: # .resample(..., how='sum') if isinstance(how, str): method = "{0}()...
[ "def", "_maybe_process_deprecations", "(", "r", ",", "how", "=", "None", ",", "fill_method", "=", "None", ",", "limit", "=", "None", ")", ":", "if", "how", "is", "not", "None", ":", "# .resample(..., how='sum')", "if", "isinstance", "(", "how", ",", "str",...
Potentially we might have a deprecation warning, show it but call the appropriate methods anyhow.
[ "Potentially", "we", "might", "have", "a", "deprecation", "warning", "show", "it", "but", "call", "the", "appropriate", "methods", "anyhow", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L877-L922
train
pandas-dev/pandas
pandas/core/resample.py
resample
def resample(obj, kind=None, **kwds): """ Create a TimeGrouper and return our resampler. """ tg = TimeGrouper(**kwds) return tg._get_resampler(obj, kind=kind)
python
def resample(obj, kind=None, **kwds): """ Create a TimeGrouper and return our resampler. """ tg = TimeGrouper(**kwds) return tg._get_resampler(obj, kind=kind)
[ "def", "resample", "(", "obj", ",", "kind", "=", "None", ",", "*", "*", "kwds", ")", ":", "tg", "=", "TimeGrouper", "(", "*", "*", "kwds", ")", "return", "tg", ".", "_get_resampler", "(", "obj", ",", "kind", "=", "kind", ")" ]
Create a TimeGrouper and return our resampler.
[ "Create", "a", "TimeGrouper", "and", "return", "our", "resampler", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1238-L1243
train
pandas-dev/pandas
pandas/core/resample.py
get_resampler_for_grouping
def get_resampler_for_grouping(groupby, rule, how=None, fill_method=None, limit=None, kind=None, **kwargs): """ Return our appropriate resampler when grouping as well. """ # .resample uses 'on' similar to how .groupby uses 'key' kwargs['key'] = kwargs.pop('on', None) ...
python
def get_resampler_for_grouping(groupby, rule, how=None, fill_method=None, limit=None, kind=None, **kwargs): """ Return our appropriate resampler when grouping as well. """ # .resample uses 'on' similar to how .groupby uses 'key' kwargs['key'] = kwargs.pop('on', None) ...
[ "def", "get_resampler_for_grouping", "(", "groupby", ",", "rule", ",", "how", "=", "None", ",", "fill_method", "=", "None", ",", "limit", "=", "None", ",", "kind", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# .resample uses 'on' similar to how .groupby u...
Return our appropriate resampler when grouping as well.
[ "Return", "our", "appropriate", "resampler", "when", "grouping", "as", "well", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1249-L1264
train
pandas-dev/pandas
pandas/core/resample.py
_get_timestamp_range_edges
def _get_timestamp_range_edges(first, last, offset, closed='left', base=0): """ Adjust the `first` Timestamp to the preceeding Timestamp that resides on the provided offset. Adjust the `last` Timestamp to the following Timestamp that resides on the provided offset. Input Timestamps that already resi...
python
def _get_timestamp_range_edges(first, last, offset, closed='left', base=0): """ Adjust the `first` Timestamp to the preceeding Timestamp that resides on the provided offset. Adjust the `last` Timestamp to the following Timestamp that resides on the provided offset. Input Timestamps that already resi...
[ "def", "_get_timestamp_range_edges", "(", "first", ",", "last", ",", "offset", ",", "closed", "=", "'left'", ",", "base", "=", "0", ")", ":", "if", "isinstance", "(", "offset", ",", "Tick", ")", ":", "if", "isinstance", "(", "offset", ",", "Day", ")", ...
Adjust the `first` Timestamp to the preceeding Timestamp that resides on the provided offset. Adjust the `last` Timestamp to the following Timestamp that resides on the provided offset. Input Timestamps that already reside on the offset will be adjusted depending on the type of offset and the `closed` p...
[ "Adjust", "the", "first", "Timestamp", "to", "the", "preceeding", "Timestamp", "that", "resides", "on", "the", "provided", "offset", ".", "Adjust", "the", "last", "Timestamp", "to", "the", "following", "Timestamp", "that", "resides", "on", "the", "provided", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1582-L1634
train
pandas-dev/pandas
pandas/core/resample.py
_get_period_range_edges
def _get_period_range_edges(first, last, offset, closed='left', base=0): """ Adjust the provided `first` and `last` Periods to the respective Period of the given offset that encompasses them. Parameters ---------- first : pd.Period The beginning Period of the range to be adjusted. l...
python
def _get_period_range_edges(first, last, offset, closed='left', base=0): """ Adjust the provided `first` and `last` Periods to the respective Period of the given offset that encompasses them. Parameters ---------- first : pd.Period The beginning Period of the range to be adjusted. l...
[ "def", "_get_period_range_edges", "(", "first", ",", "last", ",", "offset", ",", "closed", "=", "'left'", ",", "base", "=", "0", ")", ":", "if", "not", "all", "(", "isinstance", "(", "obj", ",", "pd", ".", "Period", ")", "for", "obj", "in", "[", "f...
Adjust the provided `first` and `last` Periods to the respective Period of the given offset that encompasses them. Parameters ---------- first : pd.Period The beginning Period of the range to be adjusted. last : pd.Period The ending Period of the range to be adjusted. offset : p...
[ "Adjust", "the", "provided", "first", "and", "last", "Periods", "to", "the", "respective", "Period", "of", "the", "given", "offset", "that", "encompasses", "them", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1637-L1673
train
pandas-dev/pandas
pandas/core/resample.py
asfreq
def asfreq(obj, freq, method=None, how=None, normalize=False, fill_value=None): """ Utility frequency conversion method for Series/DataFrame. """ if isinstance(obj.index, PeriodIndex): if method is not None: raise NotImplementedError("'method' argument is not supported") if ...
python
def asfreq(obj, freq, method=None, how=None, normalize=False, fill_value=None): """ Utility frequency conversion method for Series/DataFrame. """ if isinstance(obj.index, PeriodIndex): if method is not None: raise NotImplementedError("'method' argument is not supported") if ...
[ "def", "asfreq", "(", "obj", ",", "freq", ",", "method", "=", "None", ",", "how", "=", "None", ",", "normalize", "=", "False", ",", "fill_value", "=", "None", ")", ":", "if", "isinstance", "(", "obj", ".", "index", ",", "PeriodIndex", ")", ":", "if...
Utility frequency conversion method for Series/DataFrame.
[ "Utility", "frequency", "conversion", "method", "for", "Series", "/", "DataFrame", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1734-L1759
train
pandas-dev/pandas
pandas/core/resample.py
Resampler._from_selection
def _from_selection(self): """ Is the resampling from a DataFrame column or MultiIndex level. """ # upsampling and PeriodIndex resampling do not work # with selection, this state used to catch and raise an error return (self.groupby is not None and (self.g...
python
def _from_selection(self): """ Is the resampling from a DataFrame column or MultiIndex level. """ # upsampling and PeriodIndex resampling do not work # with selection, this state used to catch and raise an error return (self.groupby is not None and (self.g...
[ "def", "_from_selection", "(", "self", ")", ":", "# upsampling and PeriodIndex resampling do not work", "# with selection, this state used to catch and raise an error", "return", "(", "self", ".", "groupby", "is", "not", "None", "and", "(", "self", ".", "groupby", ".", "k...
Is the resampling from a DataFrame column or MultiIndex level.
[ "Is", "the", "resampling", "from", "a", "DataFrame", "column", "or", "MultiIndex", "level", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L135-L143
train
pandas-dev/pandas
pandas/core/resample.py
Resampler._set_binner
def _set_binner(self): """ Setup our binners. Cache these as we are an immutable object """ if self.binner is None: self.binner, self.grouper = self._get_binner()
python
def _set_binner(self): """ Setup our binners. Cache these as we are an immutable object """ if self.binner is None: self.binner, self.grouper = self._get_binner()
[ "def", "_set_binner", "(", "self", ")", ":", "if", "self", ".", "binner", "is", "None", ":", "self", ".", "binner", ",", "self", ".", "grouper", "=", "self", ".", "_get_binner", "(", ")" ]
Setup our binners. Cache these as we are an immutable object
[ "Setup", "our", "binners", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L163-L170
train
pandas-dev/pandas
pandas/core/resample.py
Resampler._get_binner
def _get_binner(self): """ Create the BinGrouper, assume that self.set_grouper(obj) has already been called. """ binner, bins, binlabels = self._get_binner_for_time() bin_grouper = BinGrouper(bins, binlabels, indexer=self.groupby.indexer) return binner, bin_group...
python
def _get_binner(self): """ Create the BinGrouper, assume that self.set_grouper(obj) has already been called. """ binner, bins, binlabels = self._get_binner_for_time() bin_grouper = BinGrouper(bins, binlabels, indexer=self.groupby.indexer) return binner, bin_group...
[ "def", "_get_binner", "(", "self", ")", ":", "binner", ",", "bins", ",", "binlabels", "=", "self", ".", "_get_binner_for_time", "(", ")", "bin_grouper", "=", "BinGrouper", "(", "bins", ",", "binlabels", ",", "indexer", "=", "self", ".", "groupby", ".", "...
Create the BinGrouper, assume that self.set_grouper(obj) has already been called.
[ "Create", "the", "BinGrouper", "assume", "that", "self", ".", "set_grouper", "(", "obj", ")", "has", "already", "been", "called", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L172-L180
train
pandas-dev/pandas
pandas/core/resample.py
Resampler.transform
def transform(self, arg, *args, **kwargs): """ Call function producing a like-indexed Series on each group and return a Series with the transformed values. Parameters ---------- arg : function To apply to each group. Should return a Series with the same index...
python
def transform(self, arg, *args, **kwargs): """ Call function producing a like-indexed Series on each group and return a Series with the transformed values. Parameters ---------- arg : function To apply to each group. Should return a Series with the same index...
[ "def", "transform", "(", "self", ",", "arg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_selected_obj", ".", "groupby", "(", "self", ".", "groupby", ")", ".", "transform", "(", "arg", ",", "*", "args", ",", "*", ...
Call function producing a like-indexed Series on each group and return a Series with the transformed values. Parameters ---------- arg : function To apply to each group. Should return a Series with the same index. Returns ------- transformed : Series...
[ "Call", "function", "producing", "a", "like", "-", "indexed", "Series", "on", "each", "group", "and", "return", "a", "Series", "with", "the", "transformed", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L280-L299
train
pandas-dev/pandas
pandas/core/resample.py
Resampler._gotitem
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 ...
python
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", ")", ":", "self", ".", "_set_binner", "(", ")", "grouper", "=", "self", ".", "grouper", "if", "subset", "is", "None", ":", "subset", "=", "self", ".", "obj", "grou...
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", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L307-L329
train
pandas-dev/pandas
pandas/core/resample.py
Resampler._groupby_and_aggregate
def _groupby_and_aggregate(self, how, grouper=None, *args, **kwargs): """ Re-evaluate the obj with a groupby aggregation. """ if grouper is None: self._set_binner() grouper = self.grouper obj = self._selected_obj grouped = groupby(obj, by=None, ...
python
def _groupby_and_aggregate(self, how, grouper=None, *args, **kwargs): """ Re-evaluate the obj with a groupby aggregation. """ if grouper is None: self._set_binner() grouper = self.grouper obj = self._selected_obj grouped = groupby(obj, by=None, ...
[ "def", "_groupby_and_aggregate", "(", "self", ",", "how", ",", "grouper", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "grouper", "is", "None", ":", "self", ".", "_set_binner", "(", ")", "grouper", "=", "self", ".", "groupe...
Re-evaluate the obj with a groupby aggregation.
[ "Re", "-", "evaluate", "the", "obj", "with", "a", "groupby", "aggregation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L331-L357
train
pandas-dev/pandas
pandas/core/resample.py
Resampler._apply_loffset
def _apply_loffset(self, result): """ If loffset is set, offset the result index. This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample """ ...
python
def _apply_loffset(self, result): """ If loffset is set, offset the result index. This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample """ ...
[ "def", "_apply_loffset", "(", "self", ",", "result", ")", ":", "needs_offset", "=", "(", "isinstance", "(", "self", ".", "loffset", ",", "(", "DateOffset", ",", "timedelta", ",", "np", ".", "timedelta64", ")", ")", "and", "isinstance", "(", "result", "."...
If loffset is set, offset the result index. This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample
[ "If", "loffset", "is", "set", "offset", "the", "result", "index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L359-L383
train
pandas-dev/pandas
pandas/core/resample.py
Resampler._get_resampler_for_grouping
def _get_resampler_for_grouping(self, groupby, **kwargs): """ Return the correct class for resampling with groupby. """ return self._resampler_for_grouping(self, groupby=groupby, **kwargs)
python
def _get_resampler_for_grouping(self, groupby, **kwargs): """ Return the correct class for resampling with groupby. """ return self._resampler_for_grouping(self, groupby=groupby, **kwargs)
[ "def", "_get_resampler_for_grouping", "(", "self", ",", "groupby", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_resampler_for_grouping", "(", "self", ",", "groupby", "=", "groupby", ",", "*", "*", "kwargs", ")" ]
Return the correct class for resampling with groupby.
[ "Return", "the", "correct", "class", "for", "resampling", "with", "groupby", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L385-L389
train
pandas-dev/pandas
pandas/core/resample.py
Resampler._wrap_result
def _wrap_result(self, result): """ Potentially wrap any results. """ if isinstance(result, ABCSeries) and self._selection is not None: result.name = self._selection if isinstance(result, ABCSeries) and result.empty: obj = self.obj if isinstan...
python
def _wrap_result(self, result): """ Potentially wrap any results. """ if isinstance(result, ABCSeries) and self._selection is not None: result.name = self._selection if isinstance(result, ABCSeries) and result.empty: obj = self.obj if isinstan...
[ "def", "_wrap_result", "(", "self", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "ABCSeries", ")", "and", "self", ".", "_selection", "is", "not", "None", ":", "result", ".", "name", "=", "self", ".", "_selection", "if", "isinstance", ...
Potentially wrap any results.
[ "Potentially", "wrap", "any", "results", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L391-L406
train
pandas-dev/pandas
pandas/core/resample.py
Resampler.interpolate
def interpolate(self, method='linear', axis=0, limit=None, inplace=False, limit_direction='forward', limit_area=None, downcast=None, **kwargs): """ Interpolate values according to different methods. .. versionadded:: 0.18.1 """ result = se...
python
def interpolate(self, method='linear', axis=0, limit=None, inplace=False, limit_direction='forward', limit_area=None, downcast=None, **kwargs): """ Interpolate values according to different methods. .. versionadded:: 0.18.1 """ result = se...
[ "def", "interpolate", "(", "self", ",", "method", "=", "'linear'", ",", "axis", "=", "0", ",", "limit", "=", "None", ",", "inplace", "=", "False", ",", "limit_direction", "=", "'forward'", ",", "limit_area", "=", "None", ",", "downcast", "=", "None", "...
Interpolate values according to different methods. .. versionadded:: 0.18.1
[ "Interpolate", "values", "according", "to", "different", "methods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L756-L769
train
pandas-dev/pandas
pandas/core/resample.py
Resampler.std
def std(self, ddof=1, *args, **kwargs): """ Compute standard deviation of groups, excluding missing values. Parameters ---------- ddof : integer, default 1 Degrees of freedom. """ nv.validate_resampler_func('std', args, kwargs) return self._do...
python
def std(self, ddof=1, *args, **kwargs): """ Compute standard deviation of groups, excluding missing values. Parameters ---------- ddof : integer, default 1 Degrees of freedom. """ nv.validate_resampler_func('std', args, kwargs) return self._do...
[ "def", "std", "(", "self", ",", "ddof", "=", "1", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_resampler_func", "(", "'std'", ",", "args", ",", "kwargs", ")", "return", "self", ".", "_downsample", "(", "'std'", ",", "dd...
Compute standard deviation of groups, excluding missing values. Parameters ---------- ddof : integer, default 1 Degrees of freedom.
[ "Compute", "standard", "deviation", "of", "groups", "excluding", "missing", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L790-L800
train
pandas-dev/pandas
pandas/core/resample.py
Resampler.var
def var(self, ddof=1, *args, **kwargs): """ Compute variance of groups, excluding missing values. Parameters ---------- ddof : integer, default 1 degrees of freedom """ nv.validate_resampler_func('var', args, kwargs) return self._downsample('v...
python
def var(self, ddof=1, *args, **kwargs): """ Compute variance of groups, excluding missing values. Parameters ---------- ddof : integer, default 1 degrees of freedom """ nv.validate_resampler_func('var', args, kwargs) return self._downsample('v...
[ "def", "var", "(", "self", ",", "ddof", "=", "1", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_resampler_func", "(", "'var'", ",", "args", ",", "kwargs", ")", "return", "self", ".", "_downsample", "(", "'var'", ",", "dd...
Compute variance of groups, excluding missing values. Parameters ---------- ddof : integer, default 1 degrees of freedom
[ "Compute", "variance", "of", "groups", "excluding", "missing", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L802-L812
train
pandas-dev/pandas
pandas/core/resample.py
_GroupByMixin._apply
def _apply(self, f, grouper=None, *args, **kwargs): """ Dispatch to _upsample; we are stripping all of the _upsample kwargs and performing the original function call on the grouped object. """ def func(x): x = self._shallow_copy(x, groupby=self.groupby) ...
python
def _apply(self, f, grouper=None, *args, **kwargs): """ Dispatch to _upsample; we are stripping all of the _upsample kwargs and performing the original function call on the grouped object. """ def func(x): x = self._shallow_copy(x, groupby=self.groupby) ...
[ "def", "_apply", "(", "self", ",", "f", ",", "grouper", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "func", "(", "x", ")", ":", "x", "=", "self", ".", "_shallow_copy", "(", "x", ",", "groupby", "=", "self", ".", "...
Dispatch to _upsample; we are stripping all of the _upsample kwargs and performing the original function call on the grouped object.
[ "Dispatch", "to", "_upsample", ";", "we", "are", "stripping", "all", "of", "the", "_upsample", "kwargs", "and", "performing", "the", "original", "function", "call", "on", "the", "grouped", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L947-L962
train
pandas-dev/pandas
pandas/core/resample.py
DatetimeIndexResampler._downsample
def _downsample(self, how, **kwargs): """ Downsample the cython defined function. Parameters ---------- how : string / cython mapped function **kwargs : kw args passed to how function """ self._set_binner() how = self._is_cython_func(how) or how ...
python
def _downsample(self, how, **kwargs): """ Downsample the cython defined function. Parameters ---------- how : string / cython mapped function **kwargs : kw args passed to how function """ self._set_binner() how = self._is_cython_func(how) or how ...
[ "def", "_downsample", "(", "self", ",", "how", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_set_binner", "(", ")", "how", "=", "self", ".", "_is_cython_func", "(", "how", ")", "or", "how", "ax", "=", "self", ".", "ax", "obj", "=", "self", "....
Downsample the cython defined function. Parameters ---------- how : string / cython mapped function **kwargs : kw args passed to how function
[ "Downsample", "the", "cython", "defined", "function", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L982-L1016
train
pandas-dev/pandas
pandas/core/resample.py
DatetimeIndexResampler._adjust_binner_for_upsample
def _adjust_binner_for_upsample(self, binner): """ Adjust our binner when upsampling. The range of a new index should not be outside specified range """ if self.closed == 'right': binner = binner[1:] else: binner = binner[:-1] return binne...
python
def _adjust_binner_for_upsample(self, binner): """ Adjust our binner when upsampling. The range of a new index should not be outside specified range """ if self.closed == 'right': binner = binner[1:] else: binner = binner[:-1] return binne...
[ "def", "_adjust_binner_for_upsample", "(", "self", ",", "binner", ")", ":", "if", "self", ".", "closed", "==", "'right'", ":", "binner", "=", "binner", "[", "1", ":", "]", "else", ":", "binner", "=", "binner", "[", ":", "-", "1", "]", "return", "binn...
Adjust our binner when upsampling. The range of a new index should not be outside specified range
[ "Adjust", "our", "binner", "when", "upsampling", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1018-L1028
train
pandas-dev/pandas
pandas/core/resample.py
DatetimeIndexResampler._upsample
def _upsample(self, method, limit=None, fill_value=None): """ Parameters ---------- method : string {'backfill', 'bfill', 'pad', 'ffill', 'asfreq'} method for upsampling limit : int, default None Maximum size gap to fill when reindexing fill_value ...
python
def _upsample(self, method, limit=None, fill_value=None): """ Parameters ---------- method : string {'backfill', 'bfill', 'pad', 'ffill', 'asfreq'} method for upsampling limit : int, default None Maximum size gap to fill when reindexing fill_value ...
[ "def", "_upsample", "(", "self", ",", "method", ",", "limit", "=", "None", ",", "fill_value", "=", "None", ")", ":", "self", ".", "_set_binner", "(", ")", "if", "self", ".", "axis", ":", "raise", "AssertionError", "(", "'axis must be 0'", ")", "if", "s...
Parameters ---------- method : string {'backfill', 'bfill', 'pad', 'ffill', 'asfreq'} method for upsampling limit : int, default None Maximum size gap to fill when reindexing fill_value : scalar, default None Value to use for missing values Se...
[ "Parameters", "----------", "method", ":", "string", "{", "backfill", "bfill", "pad", "ffill", "asfreq", "}", "method", "for", "upsampling", "limit", ":", "int", "default", "None", "Maximum", "size", "gap", "to", "fill", "when", "reindexing", "fill_value", ":"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1030-L1069
train
pandas-dev/pandas
pandas/core/resample.py
PeriodIndexResampler._downsample
def _downsample(self, how, **kwargs): """ Downsample the cython defined function. Parameters ---------- how : string / cython mapped function **kwargs : kw args passed to how function """ # we may need to actually resample as if we are timestamps ...
python
def _downsample(self, how, **kwargs): """ Downsample the cython defined function. Parameters ---------- how : string / cython mapped function **kwargs : kw args passed to how function """ # we may need to actually resample as if we are timestamps ...
[ "def", "_downsample", "(", "self", ",", "how", ",", "*", "*", "kwargs", ")", ":", "# we may need to actually resample as if we are timestamps", "if", "self", ".", "kind", "==", "'timestamp'", ":", "return", "super", "(", ")", ".", "_downsample", "(", "how", ",...
Downsample the cython defined function. Parameters ---------- how : string / cython mapped function **kwargs : kw args passed to how function
[ "Downsample", "the", "cython", "defined", "function", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1124-L1159
train
pandas-dev/pandas
pandas/core/resample.py
PeriodIndexResampler._upsample
def _upsample(self, method, limit=None, fill_value=None): """ Parameters ---------- method : string {'backfill', 'bfill', 'pad', 'ffill'} method for upsampling limit : int, default None Maximum size gap to fill when reindexing fill_value : scalar, ...
python
def _upsample(self, method, limit=None, fill_value=None): """ Parameters ---------- method : string {'backfill', 'bfill', 'pad', 'ffill'} method for upsampling limit : int, default None Maximum size gap to fill when reindexing fill_value : scalar, ...
[ "def", "_upsample", "(", "self", ",", "method", ",", "limit", "=", "None", ",", "fill_value", "=", "None", ")", ":", "# we may need to actually resample as if we are timestamps", "if", "self", ".", "kind", "==", "'timestamp'", ":", "return", "super", "(", ")", ...
Parameters ---------- method : string {'backfill', 'bfill', 'pad', 'ffill'} method for upsampling limit : int, default None Maximum size gap to fill when reindexing fill_value : scalar, default None Value to use for missing values See Also ...
[ "Parameters", "----------", "method", ":", "string", "{", "backfill", "bfill", "pad", "ffill", "}", "method", "for", "upsampling", "limit", ":", "int", "default", "None", "Maximum", "size", "gap", "to", "fill", "when", "reindexing", "fill_value", ":", "scalar"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1161-L1194
train
pandas-dev/pandas
pandas/core/resample.py
TimeGrouper._get_resampler
def _get_resampler(self, obj, kind=None): """ Return my resampler or raise if we have an invalid axis. Parameters ---------- obj : input object kind : string, optional 'period','timestamp','timedelta' are valid Returns ------- a Resam...
python
def _get_resampler(self, obj, kind=None): """ Return my resampler or raise if we have an invalid axis. Parameters ---------- obj : input object kind : string, optional 'period','timestamp','timedelta' are valid Returns ------- a Resam...
[ "def", "_get_resampler", "(", "self", ",", "obj", ",", "kind", "=", "None", ")", ":", "self", ".", "_set_grouper", "(", "obj", ")", "ax", "=", "self", ".", "ax", "if", "isinstance", "(", "ax", ",", "DatetimeIndex", ")", ":", "return", "DatetimeIndexRes...
Return my resampler or raise if we have an invalid axis. Parameters ---------- obj : input object kind : string, optional 'period','timestamp','timedelta' are valid Returns ------- a Resampler Raises ------ TypeError if incom...
[ "Return", "my", "resampler", "or", "raise", "if", "we", "have", "an", "invalid", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1334-L1373
train
pandas-dev/pandas
pandas/core/util/hashing.py
_combine_hash_arrays
def _combine_hash_arrays(arrays, num_items): """ Parameters ---------- arrays : generator num_items : int Should be the same as CPython's tupleobject.c """ try: first = next(arrays) except StopIteration: return np.array([], dtype=np.uint64) arrays = itertools.ch...
python
def _combine_hash_arrays(arrays, num_items): """ Parameters ---------- arrays : generator num_items : int Should be the same as CPython's tupleobject.c """ try: first = next(arrays) except StopIteration: return np.array([], dtype=np.uint64) arrays = itertools.ch...
[ "def", "_combine_hash_arrays", "(", "arrays", ",", "num_items", ")", ":", "try", ":", "first", "=", "next", "(", "arrays", ")", "except", "StopIteration", ":", "return", "np", ".", "array", "(", "[", "]", ",", "dtype", "=", "np", ".", "uint64", ")", ...
Parameters ---------- arrays : generator num_items : int Should be the same as CPython's tupleobject.c
[ "Parameters", "----------", "arrays", ":", "generator", "num_items", ":", "int" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L21-L46
train
pandas-dev/pandas
pandas/core/util/hashing.py
hash_pandas_object
def hash_pandas_object(obj, index=True, encoding='utf8', hash_key=None, categorize=True): """ Return a data hash of the Index/Series/DataFrame .. versionadded:: 0.19.2 Parameters ---------- index : boolean, default True include the index in the hash (if Series/Da...
python
def hash_pandas_object(obj, index=True, encoding='utf8', hash_key=None, categorize=True): """ Return a data hash of the Index/Series/DataFrame .. versionadded:: 0.19.2 Parameters ---------- index : boolean, default True include the index in the hash (if Series/Da...
[ "def", "hash_pandas_object", "(", "obj", ",", "index", "=", "True", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ",", "categorize", "=", "True", ")", ":", "from", "pandas", "import", "Series", "if", "hash_key", "is", "None", ":", "hash_k...
Return a data hash of the Index/Series/DataFrame .. versionadded:: 0.19.2 Parameters ---------- index : boolean, default True include the index in the hash (if Series/DataFrame) encoding : string, default 'utf8' encoding for data & key when strings hash_key : string key to enco...
[ "Return", "a", "data", "hash", "of", "the", "Index", "/", "Series", "/", "DataFrame" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L49-L117
train
pandas-dev/pandas
pandas/core/util/hashing.py
hash_tuples
def hash_tuples(vals, encoding='utf8', hash_key=None): """ Hash an MultiIndex / list-of-tuples efficiently .. versionadded:: 0.20.0 Parameters ---------- vals : MultiIndex, list-of-tuples, or single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _de...
python
def hash_tuples(vals, encoding='utf8', hash_key=None): """ Hash an MultiIndex / list-of-tuples efficiently .. versionadded:: 0.20.0 Parameters ---------- vals : MultiIndex, list-of-tuples, or single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _de...
[ "def", "hash_tuples", "(", "vals", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ")", ":", "is_tuple", "=", "False", "if", "isinstance", "(", "vals", ",", "tuple", ")", ":", "vals", "=", "[", "vals", "]", "is_tuple", "=", "True", "eli...
Hash an MultiIndex / list-of-tuples efficiently .. versionadded:: 0.20.0 Parameters ---------- vals : MultiIndex, list-of-tuples, or single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- ndarray of hashed value...
[ "Hash", "an", "MultiIndex", "/", "list", "-", "of", "-", "tuples", "efficiently" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L120-L164
train
pandas-dev/pandas
pandas/core/util/hashing.py
hash_tuple
def hash_tuple(val, encoding='utf8', hash_key=None): """ Hash a single tuple efficiently Parameters ---------- val : single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- hash """ hashes = (_hash_sc...
python
def hash_tuple(val, encoding='utf8', hash_key=None): """ Hash a single tuple efficiently Parameters ---------- val : single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- hash """ hashes = (_hash_sc...
[ "def", "hash_tuple", "(", "val", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ")", ":", "hashes", "=", "(", "_hash_scalar", "(", "v", ",", "encoding", "=", "encoding", ",", "hash_key", "=", "hash_key", ")", "for", "v", "in", "val", "...
Hash a single tuple efficiently Parameters ---------- val : single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- hash
[ "Hash", "a", "single", "tuple", "efficiently" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L167-L187
train
pandas-dev/pandas
pandas/core/util/hashing.py
_hash_categorical
def _hash_categorical(c, encoding, hash_key): """ Hash a Categorical by hashing its categories, and then mapping the codes to the hashes Parameters ---------- c : Categorical encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ...
python
def _hash_categorical(c, encoding, hash_key): """ Hash a Categorical by hashing its categories, and then mapping the codes to the hashes Parameters ---------- c : Categorical encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ...
[ "def", "_hash_categorical", "(", "c", ",", "encoding", ",", "hash_key", ")", ":", "# Convert ExtensionArrays to ndarrays", "values", "=", "np", ".", "asarray", "(", "c", ".", "categories", ".", "values", ")", "hashed", "=", "hash_array", "(", "values", ",", ...
Hash a Categorical by hashing its categories, and then mapping the codes to the hashes Parameters ---------- c : Categorical encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- ndarray of hashed values array, same size as ...
[ "Hash", "a", "Categorical", "by", "hashing", "its", "categories", "and", "then", "mapping", "the", "codes", "to", "the", "hashes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L190-L226
train
pandas-dev/pandas
pandas/core/util/hashing.py
hash_array
def hash_array(vals, encoding='utf8', hash_key=None, categorize=True): """ Given a 1d array, return an array of deterministic integers. .. versionadded:: 0.19.2 Parameters ---------- vals : ndarray, Categorical encoding : string, default 'utf8' encoding for data & key when strings ...
python
def hash_array(vals, encoding='utf8', hash_key=None, categorize=True): """ Given a 1d array, return an array of deterministic integers. .. versionadded:: 0.19.2 Parameters ---------- vals : ndarray, Categorical encoding : string, default 'utf8' encoding for data & key when strings ...
[ "def", "hash_array", "(", "vals", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ",", "categorize", "=", "True", ")", ":", "if", "not", "hasattr", "(", "vals", ",", "'dtype'", ")", ":", "raise", "TypeError", "(", "\"must pass a ndarray-like\...
Given a 1d array, return an array of deterministic integers. .. versionadded:: 0.19.2 Parameters ---------- vals : ndarray, Categorical encoding : string, default 'utf8' encoding for data & key when strings hash_key : string key to encode, default to _default_hash_key categorize : ...
[ "Given", "a", "1d", "array", "return", "an", "array", "of", "deterministic", "integers", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L229-L305
train
pandas-dev/pandas
pandas/core/util/hashing.py
_hash_scalar
def _hash_scalar(val, encoding='utf8', hash_key=None): """ Hash scalar value Returns ------- 1d uint64 numpy array of hash value, of length 1 """ if isna(val): # this is to be consistent with the _hash_categorical implementation return np.array([np.iinfo(np.uint64).max], dt...
python
def _hash_scalar(val, encoding='utf8', hash_key=None): """ Hash scalar value Returns ------- 1d uint64 numpy array of hash value, of length 1 """ if isna(val): # this is to be consistent with the _hash_categorical implementation return np.array([np.iinfo(np.uint64).max], dt...
[ "def", "_hash_scalar", "(", "val", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ")", ":", "if", "isna", "(", "val", ")", ":", "# this is to be consistent with the _hash_categorical implementation", "return", "np", ".", "array", "(", "[", "np", ...
Hash scalar value Returns ------- 1d uint64 numpy array of hash value, of length 1
[ "Hash", "scalar", "value" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L308-L333
train
pandas-dev/pandas
doc/make.py
DocBuilder._process_single_doc
def _process_single_doc(self, single_doc): """ Make sure the provided value for --single is a path to an existing .rst/.ipynb file, or a pandas object that can be imported. For example, categorial.rst or pandas.DataFrame.head. For the latter, return the corresponding file path ...
python
def _process_single_doc(self, single_doc): """ Make sure the provided value for --single is a path to an existing .rst/.ipynb file, or a pandas object that can be imported. For example, categorial.rst or pandas.DataFrame.head. For the latter, return the corresponding file path ...
[ "def", "_process_single_doc", "(", "self", ",", "single_doc", ")", ":", "base_name", ",", "extension", "=", "os", ".", "path", ".", "splitext", "(", "single_doc", ")", "if", "extension", "in", "(", "'.rst'", ",", "'.ipynb'", ")", ":", "if", "os", ".", ...
Make sure the provided value for --single is a path to an existing .rst/.ipynb file, or a pandas object that can be imported. For example, categorial.rst or pandas.DataFrame.head. For the latter, return the corresponding file path (e.g. reference/api/pandas.DataFrame.head.rst).
[ "Make", "sure", "the", "provided", "value", "for", "--", "single", "is", "a", "path", "to", "an", "existing", ".", "rst", "/", ".", "ipynb", "file", "or", "a", "pandas", "object", "that", "can", "be", "imported", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L59-L88
train