partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
BusinessHourMixin.rollback
Roll provided date backward to next offset only if not on offset.
pandas/tseries/offsets.py
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): """ 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...
[ "Roll", "provided", "date", "backward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L654-L666
[ "def", "rollback", "(", "self", ",", "dt", ")", ":", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "businesshours", "=", "self", ".", "_get_business_hours_by_sec", "if", "self", ".", "n", ">=", "0", ":", "dt", "=", "self", ".", "_prev_op...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BusinessHourMixin.rollforward
Roll provided date forward to next offset only if not on offset.
pandas/tseries/offsets.py
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): """ 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...
[ "Roll", "provided", "date", "forward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L669-L678
[ "def", "rollforward", "(", "self", ",", "dt", ")", ":", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "if", "self", ".", "n", ">=", "0", ":", "return", "self", ".", "_next_opening_time", "(", "dt", ")", "else", ":", "return", "self", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BusinessHourMixin._onOffset
Slight speedups using calculated values.
pandas/tseries/offsets.py
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): """ 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...
[ "Slight", "speedups", "using", "calculated", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L767-L783
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_CustomBusinessMonth.cbday_roll
Define default roll function to be called in apply method.
pandas/tseries/offsets.py
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): """ 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: ...
[ "Define", "default", "roll", "function", "to", "be", "called", "in", "apply", "method", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1007-L1019
[ "def", "cbday_roll", "(", "self", ")", ":", "cbday", "=", "CustomBusinessDay", "(", "n", "=", "self", ".", "n", ",", "normalize", "=", "False", ",", "*", "*", "self", ".", "kwds", ")", "if", "self", ".", "_prefix", ".", "endswith", "(", "'S'", ")",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_CustomBusinessMonth.month_roll
Define default roll function to be called in apply method.
pandas/tseries/offsets.py
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): """ 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...
[ "Define", "default", "roll", "function", "to", "be", "called", "in", "apply", "method", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1032-L1042
[ "def", "month_roll", "(", "self", ")", ":", "if", "self", ".", "_prefix", ".", "endswith", "(", "'S'", ")", ":", "# MonthBegin", "roll_func", "=", "self", ".", "m_offset", ".", "rollback", "else", ":", "# MonthEnd", "roll_func", "=", "self", ".", "m_offs...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SemiMonthBegin._apply_index_days
Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex
pandas/tseries/offsets.py
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): """ Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex """ nanos = (roll % 2) * Timedelta(day...
[ "Add", "days", "portion", "of", "offset", "to", "DatetimeIndex", "i", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1279-L1293
[ "def", "_apply_index_days", "(", "self", ",", "i", ",", "roll", ")", ":", "nanos", "=", "(", "roll", "%", "2", ")", "*", "Timedelta", "(", "days", "=", "self", ".", "day_of_month", "-", "1", ")", ".", "value", "return", "i", "+", "nanos", ".", "a...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Week._end_apply_index
Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex
pandas/tseries/offsets.py
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): """ Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex """ off = dtin...
[ "Add", "self", "to", "the", "given", "DatetimeIndex", "specialized", "for", "case", "where", "self", ".", "weekday", "is", "non", "-", "null", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1354-L1390
[ "def", "_end_apply_index", "(", "self", ",", "dtindex", ")", ":", "off", "=", "dtindex", ".", "to_perioddelta", "(", "'D'", ")", "base", ",", "mult", "=", "libfrequencies", ".", "get_freq_code", "(", "self", ".", "freqstr", ")", "base_period", "=", "dtinde...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
WeekOfMonth._get_offset_day
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
pandas/tseries/offsets.py
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): """ 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", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1474-L1490
[ "def", "_get_offset_day", "(", "self", ",", "other", ")", ":", "mstart", "=", "datetime", "(", "other", ".", "year", ",", "other", ".", "month", ",", "1", ")", "wday", "=", "mstart", ".", "weekday", "(", ")", "shift_days", "=", "(", "self", ".", "w...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
LastWeekOfMonth._get_offset_day
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
pandas/tseries/offsets.py
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): """ 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 ...
[ "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", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1543-L1560
[ "def", "_get_offset_day", "(", "self", ",", "other", ")", ":", "dim", "=", "ccalendar", ".", "get_days_in_month", "(", "other", ".", "year", ",", "other", ".", "month", ")", "mend", "=", "datetime", "(", "other", ".", "year", ",", "other", ".", "month"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FY5253Quarter._rollback_to_year
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...
pandas/tseries/offsets.py
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): """ 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...
[ "Roll", "other", "back", "to", "the", "most", "recent", "date", "that", "was", "on", "a", "fiscal", "year", "end", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L2054-L2099
[ "def", "_rollback_to_year", "(", "self", ",", "other", ")", ":", "num_qtrs", "=", "0", "norm", "=", "Timestamp", "(", "other", ")", ".", "tz_localize", "(", "None", ")", "start", "=", "self", ".", "_offset", ".", "rollback", "(", "norm", ")", "# Note: ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
concat
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 : ...
pandas/core/reshape/concat.py
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_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...
[ "Concatenate", "pandas", "objects", "along", "a", "particular", "axis", "with", "optional", "set", "logic", "along", "the", "other", "axes", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/concat.py#L24-L229
[ "def", "concat", "(", "objs", ",", "axis", "=", "0", ",", "join", "=", "'outer'", ",", "join_axes", "=", "None", ",", "ignore_index", "=", "False", ",", "keys", "=", "None", ",", "levels", "=", "None", ",", "names", "=", "None", ",", "verify_integrit...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_Concatenator._get_concat_axis
Return index to be used along concatenation axis.
pandas/core/reshape/concat.py
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): """ 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)) ...
[ "Return", "index", "to", "be", "used", "along", "concatenation", "axis", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/concat.py#L475-L521
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_in
Compute the vectorized membership of ``x in y`` if possible, otherwise use Python.
pandas/core/computation/ops.py
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): """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 ...
[ "Compute", "the", "vectorized", "membership", "of", "x", "in", "y", "if", "possible", "otherwise", "use", "Python", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L234-L246
[ "def", "_in", "(", "x", ",", "y", ")", ":", "try", ":", "return", "x", ".", "isin", "(", "y", ")", "except", "AttributeError", ":", "if", "is_list_like", "(", "x", ")", ":", "try", ":", "return", "y", ".", "isin", "(", "x", ")", "except", "Attr...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_not_in
Compute the vectorized membership of ``x not in y`` if possible, otherwise use Python.
pandas/core/computation/ops.py
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): """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...
[ "Compute", "the", "vectorized", "membership", "of", "x", "not", "in", "y", "if", "possible", "otherwise", "use", "Python", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L249-L261
[ "def", "_not_in", "(", "x", ",", "y", ")", ":", "try", ":", "return", "~", "x", ".", "isin", "(", "y", ")", "except", "AttributeError", ":", "if", "is_list_like", "(", "x", ")", ":", "try", ":", "return", "~", "y", ".", "isin", "(", "x", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_cast_inplace
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.
pandas/core/computation/ops.py
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): """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 ...
[ "Cast", "an", "expression", "inplace", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L288-L312
[ "def", "_cast_inplace", "(", "terms", ",", "acceptable_dtypes", ",", "dtype", ")", ":", "dt", "=", "np", ".", "dtype", "(", "dtype", ")", "for", "term", "in", "terms", ":", "if", "term", ".", "type", "in", "acceptable_dtypes", ":", "continue", "try", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Term.update
search order for local (i.e., @variable) variables: scope, key_variable [('locals', 'local_name'), ('globals', 'local_name'), ('locals', 'key'), ('globals', 'key')]
pandas/core/computation/ops.py
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): """ 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 ...
[ "search", "order", "for", "local", "(", "i", ".", "e", ".", "@variable", ")", "variables", ":" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L88-L104
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BinOp.evaluate
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...
pandas/core/computation/ops.py
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): """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 ...
[ "Evaluate", "a", "binary", "operation", "*", "before", "*", "being", "passed", "to", "the", "engine", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L369-L405
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BinOp.convert_values
Convert datetimes to a comparable value in an expression.
pandas/core/computation/ops.py
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): """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: ...
[ "Convert", "datetimes", "to", "a", "comparable", "value", "in", "an", "expression", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L407-L436
[ "def", "convert_values", "(", "self", ")", ":", "def", "stringify", "(", "value", ")", ":", "if", "self", ".", "encoding", "is", "not", "None", ":", "encoder", "=", "partial", "(", "pprint_thing_encoded", ",", "encoding", "=", "self", ".", "encoding", ")...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
crosstab
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...
pandas/core/reshape/pivot.py
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=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...
[ "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...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/pivot.py#L391-L528
[ "def", "crosstab", "(", "index", ",", "columns", ",", "values", "=", "None", ",", "rownames", "=", "None", ",", "colnames", "=", "None", ",", "aggfunc", "=", "None", ",", "margins", "=", "False", ",", "margins_name", "=", "'All'", ",", "dropna", "=", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TablePlotter._shape
Calculate table chape considering index levels.
pandas/util/_doctools.py
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): """ Calculate table chape considering index levels. """ row, col = df.shape return row + df.columns.nlevels, col + df.index.nlevels
[ "Calculate", "table", "chape", "considering", "index", "levels", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L17-L23
[ "def", "_shape", "(", "self", ",", "df", ")", ":", "row", ",", "col", "=", "df", ".", "shape", "return", "row", "+", "df", ".", "columns", ".", "nlevels", ",", "col", "+", "df", ".", "index", ".", "nlevels" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TablePlotter._get_cells
Calculate appropriate figure size based on left and right data.
pandas/util/_doctools.py
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): """ 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...
[ "Calculate", "appropriate", "figure", "size", "based", "on", "left", "and", "right", "data", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L25-L41
[ "def", "_get_cells", "(", "self", ",", "left", ",", "right", ",", "vertical", ")", ":", "if", "vertical", ":", "# calculate required number of cells", "vcells", "=", "max", "(", "sum", "(", "self", ".", "_shape", "(", "l", ")", "[", "0", "]", "for", "l...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TablePlotter.plot
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...
pandas/util/_doctools.py
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): """ 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...
[ "Plot", "left", "/", "right", "DataFrames", "in", "specified", "layout", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L43-L101
[ "def", "plot", "(", "self", ",", "left", ",", "right", ",", "labels", "=", "None", ",", "vertical", "=", "True", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "import", "matplotlib", ".", "gridspec", "as", "gridspec", "if", "not", "isin...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TablePlotter._conv
Convert each input to appropriate for table outplot
pandas/util/_doctools.py
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): """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
[ "Convert", "each", "input", "to", "appropriate", "for", "table", "outplot" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L103-L111
[ "def", "_conv", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "pd", ".", "Series", ")", ":", "if", "data", ".", "name", "is", "None", ":", "data", "=", "data", ".", "to_frame", "(", "name", "=", "''", ")", "else", ":...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
cut
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...
pandas/core/reshape/tile.py
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'): """ 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 ...
[ "Bin", "values", "into", "discrete", "intervals", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L23-L245
[ "def", "cut", "(", "x", ",", "bins", ",", "right", "=", "True", ",", "labels", "=", "None", ",", "retbins", "=", "False", ",", "precision", "=", "3", ",", "include_lowest", "=", "False", ",", "duplicates", "=", "'raise'", ")", ":", "# NOTE: this binnin...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
qcut
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...
pandas/core/reshape/tile.py
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'): """ Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating qua...
[ "Quantile", "-", "based", "discretization", "function", ".", "Discretize", "variable", "into", "equal", "-", "sized", "buckets", "based", "on", "rank", "or", "based", "on", "sample", "quantiles", ".", "For", "example", "1000", "values", "for", "10", "quantiles...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L248-L317
[ "def", "qcut", "(", "x", ",", "q", ",", "labels", "=", "None", ",", "retbins", "=", "False", ",", "precision", "=", "3", ",", "duplicates", "=", "'raise'", ")", ":", "x_is_series", ",", "series_index", ",", "name", ",", "x", "=", "_preprocess_for_cut",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_coerce_to_type
if the passed data is of datetime/timedelta type, this method converts it to numeric so that cut method can handle it
pandas/core/reshape/tile.py
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): """ 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 =...
[ "if", "the", "passed", "data", "is", "of", "datetime", "/", "timedelta", "type", "this", "method", "converts", "it", "to", "numeric", "so", "that", "cut", "method", "can", "handle", "it" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L377-L398
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_convert_bin_to_numeric_type
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
pandas/core/reshape/tile.py
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): """ 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" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L401-L427
[ "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'", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_convert_bin_to_datelike_type
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
pandas/core/reshape/tile.py
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): """ 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...
[ "Convert", "bins", "to", "a", "DatetimeIndex", "or", "TimedeltaIndex", "if", "the", "orginal", "dtype", "is", "datelike" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L430-L450
[ "def", "_convert_bin_to_datelike_type", "(", "bins", ",", "dtype", ")", ":", "if", "is_datetime64tz_dtype", "(", "dtype", ")", ":", "bins", "=", "to_datetime", "(", "bins", ".", "astype", "(", "np", ".", "int64", ")", ",", "utc", "=", "True", ")", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_format_labels
based on the dtype, return our labels
pandas/core/reshape/tile.py
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): """ 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...
[ "based", "on", "the", "dtype", "return", "our", "labels" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L453-L484
[ "def", "_format_labels", "(", "bins", ",", "precision", ",", "right", "=", "True", ",", "include_lowest", "=", "False", ",", "dtype", "=", "None", ")", ":", "closed", "=", "'right'", "if", "right", "else", "'left'", "if", "is_datetime64tz_dtype", "(", "dty...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_preprocess_for_cut
handles preprocessing for cut where we convert passed input to array, strip the index information and store it separately
pandas/core/reshape/tile.py
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): """ 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...
[ "handles", "preprocessing", "for", "cut", "where", "we", "convert", "passed", "input", "to", "array", "strip", "the", "index", "information", "and", "store", "it", "separately" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L487-L509
[ "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", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_postprocess_for_cut
handles post processing for the cut method where we combine the index information if the originally passed datatype was a series
pandas/core/reshape/tile.py
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): """ 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=...
[ "handles", "post", "processing", "for", "the", "cut", "method", "where", "we", "combine", "the", "index", "information", "if", "the", "originally", "passed", "datatype", "was", "a", "series" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L512-L527
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_round_frac
Round the fractional part of the given number
pandas/core/reshape/tile.py
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): """ 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...
[ "Round", "the", "fractional", "part", "of", "the", "given", "number" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L530-L542
[ "def", "_round_frac", "(", "x", ",", "precision", ")", ":", "if", "not", "np", ".", "isfinite", "(", "x", ")", "or", "x", "==", "0", ":", "return", "x", "else", ":", "frac", ",", "whole", "=", "np", ".", "modf", "(", "x", ")", "if", "whole", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_infer_precision
Infer an appropriate precision for _round_frac
pandas/core/reshape/tile.py
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): """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
[ "Infer", "an", "appropriate", "precision", "for", "_round_frac" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L545-L552
[ "def", "_infer_precision", "(", "base_precision", ",", "bins", ")", ":", "for", "precision", "in", "range", "(", "base_precision", ",", "20", ")", ":", "levels", "=", "[", "_round_frac", "(", "b", ",", "precision", ")", "for", "b", "in", "bins", "]", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
detect_console_encoding
Try to find the most capable encoding supported by the console. slightly modified from the way IPython handles the same issue.
pandas/_config/display.py
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(): """ 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...
[ "Try", "to", "find", "the", "most", "capable", "encoding", "supported", "by", "the", "console", ".", "slightly", "modified", "from", "the", "way", "IPython", "handles", "the", "same", "issue", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/display.py#L14-L43
[ "def", "detect_console_encoding", "(", ")", ":", "global", "_initial_defencoding", "encoding", "=", "None", "try", ":", "encoding", "=", "sys", ".", "stdout", ".", "encoding", "or", "sys", ".", "stdin", ".", "encoding", "except", "(", "AttributeError", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_check_arg_length
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.
pandas/util/_validators.py
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): """ 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 ...
[ "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", "...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L10-L29
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_check_for_default_values
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
pandas/util/_validators.py
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): """ 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", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L32-L69
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_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 the function being passed the `*args` parameter args: tuple The `...
pandas/util/_validators.py
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): """ 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 ...
[ "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", ...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L72-L111
[ "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", "#...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_check_for_invalid_keys
Checks whether 'kwargs' contains any keys that are not in 'compat_args' and raises a TypeError if there is one.
pandas/util/_validators.py
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): """ 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...
[ "Checks", "whether", "kwargs", "contains", "any", "keys", "that", "are", "not", "in", "compat_args", "and", "raises", "a", "TypeError", "if", "there", "is", "one", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L114-L127
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_kwargs
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...
pandas/util/_validators.py
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): """ 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...
[ "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...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L130-L157
[ "def", "validate_kwargs", "(", "fname", ",", "kwargs", ",", "compat_args", ")", ":", "kwds", "=", "kwargs", ".", "copy", "(", ")", "_check_for_invalid_keys", "(", "fname", ",", "kwargs", ",", "compat_args", ")", "_check_for_default_values", "(", "fname", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_args_and_kwargs
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...
pandas/util/_validators.py
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): """ 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 ...
[ "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",...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L160-L218
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_bool_kwarg
Ensures that argument passed in arg_name is of type bool.
pandas/util/_validators.py
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): """ 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, ...
[ "Ensures", "that", "argument", "passed", "in", "arg_name", "is", "of", "type", "bool", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L221-L227
[ "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}.'", "."...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_axis_style_args
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...
pandas/util/_validators.py
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): """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 ...
[ "Argument", "handler", "for", "mixed", "index", "columns", "/", "axis", "functions" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L230-L322
[ "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 = {...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_fillna_kwargs
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...
pandas/util/_validators.py
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): """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 :...
[ "Validate", "the", "keyword", "arguments", "to", "fillna", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L325-L358
[ "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", ":...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_maybe_process_deprecations
Potentially we might have a deprecation warning, show it but call the appropriate methods anyhow.
pandas/core/resample.py
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): """ 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}()...
[ "Potentially", "we", "might", "have", "a", "deprecation", "warning", "show", "it", "but", "call", "the", "appropriate", "methods", "anyhow", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L877-L922
[ "def", "_maybe_process_deprecations", "(", "r", ",", "how", "=", "None", ",", "fill_method", "=", "None", ",", "limit", "=", "None", ")", ":", "if", "how", "is", "not", "None", ":", "# .resample(..., how='sum')", "if", "isinstance", "(", "how", ",", "str",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
resample
Create a TimeGrouper and return our resampler.
pandas/core/resample.py
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): """ Create a TimeGrouper and return our resampler. """ tg = TimeGrouper(**kwds) return tg._get_resampler(obj, kind=kind)
[ "Create", "a", "TimeGrouper", "and", "return", "our", "resampler", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1238-L1243
[ "def", "resample", "(", "obj", ",", "kind", "=", "None", ",", "*", "*", "kwds", ")", ":", "tg", "=", "TimeGrouper", "(", "*", "*", "kwds", ")", "return", "tg", ".", "_get_resampler", "(", "obj", ",", "kind", "=", "kind", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_resampler_for_grouping
Return our appropriate resampler when grouping as well.
pandas/core/resample.py
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): """ Return our appropriate resampler when grouping as well. """ # .resample uses 'on' similar to how .groupby uses 'key' kwargs['key'] = kwargs.pop('on', None) ...
[ "Return", "our", "appropriate", "resampler", "when", "grouping", "as", "well", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1249-L1264
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_timestamp_range_edges
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...
pandas/core/resample.py
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): """ 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...
[ "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", "...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1582-L1634
[ "def", "_get_timestamp_range_edges", "(", "first", ",", "last", ",", "offset", ",", "closed", "=", "'left'", ",", "base", "=", "0", ")", ":", "if", "isinstance", "(", "offset", ",", "Tick", ")", ":", "if", "isinstance", "(", "offset", ",", "Day", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_period_range_edges
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...
pandas/core/resample.py
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): """ 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...
[ "Adjust", "the", "provided", "first", "and", "last", "Periods", "to", "the", "respective", "Period", "of", "the", "given", "offset", "that", "encompasses", "them", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1637-L1673
[ "def", "_get_period_range_edges", "(", "first", ",", "last", ",", "offset", ",", "closed", "=", "'left'", ",", "base", "=", "0", ")", ":", "if", "not", "all", "(", "isinstance", "(", "obj", ",", "pd", ".", "Period", ")", "for", "obj", "in", "[", "f...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
asfreq
Utility frequency conversion method for Series/DataFrame.
pandas/core/resample.py
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): """ 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 ...
[ "Utility", "frequency", "conversion", "method", "for", "Series", "/", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1734-L1759
[ "def", "asfreq", "(", "obj", ",", "freq", ",", "method", "=", "None", ",", "how", "=", "None", ",", "normalize", "=", "False", ",", "fill_value", "=", "None", ")", ":", "if", "isinstance", "(", "obj", ".", "index", ",", "PeriodIndex", ")", ":", "if...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler._from_selection
Is the resampling from a DataFrame column or MultiIndex level.
pandas/core/resample.py
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): """ 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...
[ "Is", "the", "resampling", "from", "a", "DataFrame", "column", "or", "MultiIndex", "level", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L135-L143
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler._set_binner
Setup our binners. Cache these as we are an immutable object
pandas/core/resample.py
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): """ Setup our binners. Cache these as we are an immutable object """ if self.binner is None: self.binner, self.grouper = self._get_binner()
[ "Setup", "our", "binners", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L163-L170
[ "def", "_set_binner", "(", "self", ")", ":", "if", "self", ".", "binner", "is", "None", ":", "self", ".", "binner", ",", "self", ".", "grouper", "=", "self", ".", "_get_binner", "(", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler._get_binner
Create the BinGrouper, assume that self.set_grouper(obj) has already been called.
pandas/core/resample.py
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): """ 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...
[ "Create", "the", "BinGrouper", "assume", "that", "self", ".", "set_grouper", "(", "obj", ")", "has", "already", "been", "called", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L172-L180
[ "def", "_get_binner", "(", "self", ")", ":", "binner", ",", "bins", ",", "binlabels", "=", "self", ".", "_get_binner_for_time", "(", ")", "bin_grouper", "=", "BinGrouper", "(", "bins", ",", "binlabels", ",", "indexer", "=", "self", ".", "groupby", ".", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler.transform
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...
pandas/core/resample.py
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): """ 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...
[ "Call", "function", "producing", "a", "like", "-", "indexed", "Series", "on", "each", "group", "and", "return", "a", "Series", "with", "the", "transformed", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L280-L299
[ "def", "transform", "(", "self", ",", "arg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_selected_obj", ".", "groupby", "(", "self", ".", "groupby", ")", ".", "transform", "(", "arg", ",", "*", "args", ",", "*", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler._gotitem
Sub-classes to define. Return a sliced object. Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on
pandas/core/resample.py
def _gotitem(self, key, ndim, subset=None): """ Sub-classes to define. Return a sliced object. Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on ...
def _gotitem(self, key, ndim, subset=None): """ Sub-classes to define. Return a sliced object. Parameters ---------- key : string / list of selections ndim : 1,2 requested ndim of result subset : object, default None subset to act on ...
[ "Sub", "-", "classes", "to", "define", ".", "Return", "a", "sliced", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L307-L329
[ "def", "_gotitem", "(", "self", ",", "key", ",", "ndim", ",", "subset", "=", "None", ")", ":", "self", ".", "_set_binner", "(", ")", "grouper", "=", "self", ".", "grouper", "if", "subset", "is", "None", ":", "subset", "=", "self", ".", "obj", "grou...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler._groupby_and_aggregate
Re-evaluate the obj with a groupby aggregation.
pandas/core/resample.py
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): """ 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, ...
[ "Re", "-", "evaluate", "the", "obj", "with", "a", "groupby", "aggregation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L331-L357
[ "def", "_groupby_and_aggregate", "(", "self", ",", "how", ",", "grouper", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "grouper", "is", "None", ":", "self", ".", "_set_binner", "(", ")", "grouper", "=", "self", ".", "groupe...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler._apply_loffset
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
pandas/core/resample.py
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): """ 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", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L359-L383
[ "def", "_apply_loffset", "(", "self", ",", "result", ")", ":", "needs_offset", "=", "(", "isinstance", "(", "self", ".", "loffset", ",", "(", "DateOffset", ",", "timedelta", ",", "np", ".", "timedelta64", ")", ")", "and", "isinstance", "(", "result", "."...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler._get_resampler_for_grouping
Return the correct class for resampling with groupby.
pandas/core/resample.py
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 the correct class for resampling with groupby. """ return self._resampler_for_grouping(self, groupby=groupby, **kwargs)
[ "Return", "the", "correct", "class", "for", "resampling", "with", "groupby", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L385-L389
[ "def", "_get_resampler_for_grouping", "(", "self", ",", "groupby", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_resampler_for_grouping", "(", "self", ",", "groupby", "=", "groupby", ",", "*", "*", "kwargs", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler._wrap_result
Potentially wrap any results.
pandas/core/resample.py
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): """ 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...
[ "Potentially", "wrap", "any", "results", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L391-L406
[ "def", "_wrap_result", "(", "self", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "ABCSeries", ")", "and", "self", ".", "_selection", "is", "not", "None", ":", "result", ".", "name", "=", "self", ".", "_selection", "if", "isinstance", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler.interpolate
Interpolate values according to different methods. .. versionadded:: 0.18.1
pandas/core/resample.py
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, **kwargs): """ Interpolate values according to different methods. .. versionadded:: 0.18.1 """ result = se...
[ "Interpolate", "values", "according", "to", "different", "methods", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L756-L769
[ "def", "interpolate", "(", "self", ",", "method", "=", "'linear'", ",", "axis", "=", "0", ",", "limit", "=", "None", ",", "inplace", "=", "False", ",", "limit_direction", "=", "'forward'", ",", "limit_area", "=", "None", ",", "downcast", "=", "None", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler.std
Compute standard deviation of groups, excluding missing values. Parameters ---------- ddof : integer, default 1 Degrees of freedom.
pandas/core/resample.py
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): """ 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...
[ "Compute", "standard", "deviation", "of", "groups", "excluding", "missing", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L790-L800
[ "def", "std", "(", "self", ",", "ddof", "=", "1", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_resampler_func", "(", "'std'", ",", "args", ",", "kwargs", ")", "return", "self", ".", "_downsample", "(", "'std'", ",", "dd...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Resampler.var
Compute variance of groups, excluding missing values. Parameters ---------- ddof : integer, default 1 degrees of freedom
pandas/core/resample.py
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): """ 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...
[ "Compute", "variance", "of", "groups", "excluding", "missing", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L802-L812
[ "def", "var", "(", "self", ",", "ddof", "=", "1", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_resampler_func", "(", "'var'", ",", "args", ",", "kwargs", ")", "return", "self", ".", "_downsample", "(", "'var'", ",", "dd...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_GroupByMixin._apply
Dispatch to _upsample; we are stripping all of the _upsample kwargs and performing the original function call on the grouped object.
pandas/core/resample.py
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): """ 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) ...
[ "Dispatch", "to", "_upsample", ";", "we", "are", "stripping", "all", "of", "the", "_upsample", "kwargs", "and", "performing", "the", "original", "function", "call", "on", "the", "grouped", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L947-L962
[ "def", "_apply", "(", "self", ",", "f", ",", "grouper", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "func", "(", "x", ")", ":", "x", "=", "self", ".", "_shallow_copy", "(", "x", ",", "groupby", "=", "self", ".", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeIndexResampler._downsample
Downsample the cython defined function. Parameters ---------- how : string / cython mapped function **kwargs : kw args passed to how function
pandas/core/resample.py
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): """ 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 ...
[ "Downsample", "the", "cython", "defined", "function", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L982-L1016
[ "def", "_downsample", "(", "self", ",", "how", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_set_binner", "(", ")", "how", "=", "self", ".", "_is_cython_func", "(", "how", ")", "or", "how", "ax", "=", "self", ".", "ax", "obj", "=", "self", "....
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeIndexResampler._adjust_binner_for_upsample
Adjust our binner when upsampling. The range of a new index should not be outside specified range
pandas/core/resample.py
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): """ 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...
[ "Adjust", "our", "binner", "when", "upsampling", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1018-L1028
[ "def", "_adjust_binner_for_upsample", "(", "self", ",", "binner", ")", ":", "if", "self", ".", "closed", "==", "'right'", ":", "binner", "=", "binner", "[", "1", ":", "]", "else", ":", "binner", "=", "binner", "[", ":", "-", "1", "]", "return", "binn...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeIndexResampler._upsample
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...
pandas/core/resample.py
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): """ Parameters ---------- method : string {'backfill', 'bfill', 'pad', 'ffill', 'asfreq'} method for upsampling limit : int, default None Maximum size gap to fill when reindexing fill_value ...
[ "Parameters", "----------", "method", ":", "string", "{", "backfill", "bfill", "pad", "ffill", "asfreq", "}", "method", "for", "upsampling", "limit", ":", "int", "default", "None", "Maximum", "size", "gap", "to", "fill", "when", "reindexing", "fill_value", ":"...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1030-L1069
[ "def", "_upsample", "(", "self", ",", "method", ",", "limit", "=", "None", ",", "fill_value", "=", "None", ")", ":", "self", ".", "_set_binner", "(", ")", "if", "self", ".", "axis", ":", "raise", "AssertionError", "(", "'axis must be 0'", ")", "if", "s...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PeriodIndexResampler._downsample
Downsample the cython defined function. Parameters ---------- how : string / cython mapped function **kwargs : kw args passed to how function
pandas/core/resample.py
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): """ 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 ...
[ "Downsample", "the", "cython", "defined", "function", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1124-L1159
[ "def", "_downsample", "(", "self", ",", "how", ",", "*", "*", "kwargs", ")", ":", "# we may need to actually resample as if we are timestamps", "if", "self", ".", "kind", "==", "'timestamp'", ":", "return", "super", "(", ")", ".", "_downsample", "(", "how", ",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PeriodIndexResampler._upsample
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 ...
pandas/core/resample.py
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): """ Parameters ---------- method : string {'backfill', 'bfill', 'pad', 'ffill'} method for upsampling limit : int, default None Maximum size gap to fill when reindexing fill_value : scalar, ...
[ "Parameters", "----------", "method", ":", "string", "{", "backfill", "bfill", "pad", "ffill", "}", "method", "for", "upsampling", "limit", ":", "int", "default", "None", "Maximum", "size", "gap", "to", "fill", "when", "reindexing", "fill_value", ":", "scalar"...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1161-L1194
[ "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", "(", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TimeGrouper._get_resampler
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...
pandas/core/resample.py
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): """ 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...
[ "Return", "my", "resampler", "or", "raise", "if", "we", "have", "an", "invalid", "axis", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1334-L1373
[ "def", "_get_resampler", "(", "self", ",", "obj", ",", "kind", "=", "None", ")", ":", "self", ".", "_set_grouper", "(", "obj", ")", "ax", "=", "self", ".", "ax", "if", "isinstance", "(", "ax", ",", "DatetimeIndex", ")", ":", "return", "DatetimeIndexRes...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_combine_hash_arrays
Parameters ---------- arrays : generator num_items : int Should be the same as CPython's tupleobject.c
pandas/core/util/hashing.py
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): """ 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...
[ "Parameters", "----------", "arrays", ":", "generator", "num_items", ":", "int" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L21-L46
[ "def", "_combine_hash_arrays", "(", "arrays", ",", "num_items", ")", ":", "try", ":", "first", "=", "next", "(", "arrays", ")", "except", "StopIteration", ":", "return", "np", ".", "array", "(", "[", "]", ",", "dtype", "=", "np", ".", "uint64", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
hash_pandas_object
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...
pandas/core/util/hashing.py
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): """ 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...
[ "Return", "a", "data", "hash", "of", "the", "Index", "/", "Series", "/", "DataFrame" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L49-L117
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
hash_tuples
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...
pandas/core/util/hashing.py
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): """ 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...
[ "Hash", "an", "MultiIndex", "/", "list", "-", "of", "-", "tuples", "efficiently" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L120-L164
[ "def", "hash_tuples", "(", "vals", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ")", ":", "is_tuple", "=", "False", "if", "isinstance", "(", "vals", ",", "tuple", ")", ":", "vals", "=", "[", "vals", "]", "is_tuple", "=", "True", "eli...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
hash_tuple
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
pandas/core/util/hashing.py
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): """ 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...
[ "Hash", "a", "single", "tuple", "efficiently" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L167-L187
[ "def", "hash_tuple", "(", "val", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ")", ":", "hashes", "=", "(", "_hash_scalar", "(", "v", ",", "encoding", "=", "encoding", ",", "hash_key", "=", "hash_key", ")", "for", "v", "in", "val", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_hash_categorical
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 ...
pandas/core/util/hashing.py
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): """ 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 ...
[ "Hash", "a", "Categorical", "by", "hashing", "its", "categories", "and", "then", "mapping", "the", "codes", "to", "the", "hashes" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L190-L226
[ "def", "_hash_categorical", "(", "c", ",", "encoding", ",", "hash_key", ")", ":", "# Convert ExtensionArrays to ndarrays", "values", "=", "np", ".", "asarray", "(", "c", ".", "categories", ".", "values", ")", "hashed", "=", "hash_array", "(", "values", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
hash_array
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 : ...
pandas/core/util/hashing.py
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): """ 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 ...
[ "Given", "a", "1d", "array", "return", "an", "array", "of", "deterministic", "integers", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L229-L305
[ "def", "hash_array", "(", "vals", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ",", "categorize", "=", "True", ")", ":", "if", "not", "hasattr", "(", "vals", ",", "'dtype'", ")", ":", "raise", "TypeError", "(", "\"must pass a ndarray-like\...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_hash_scalar
Hash scalar value Returns ------- 1d uint64 numpy array of hash value, of length 1
pandas/core/util/hashing.py
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): """ 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...
[ "Hash", "scalar", "value" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L308-L333
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder._process_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 (e.g. reference/api/pandas.DataFrame.head.rst).
doc/make.py
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): """ 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 ...
[ "Make", "sure", "the", "provided", "value", "for", "--", "single", "is", "a", "path", "to", "an", "existing", ".", "rst", "/", ".", "ipynb", "file", "or", "a", "pandas", "object", "that", "can", "be", "imported", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L59-L88
[ "def", "_process_single_doc", "(", "self", ",", "single_doc", ")", ":", "base_name", ",", "extension", "=", "os", ".", "path", ".", "splitext", "(", "single_doc", ")", "if", "extension", "in", "(", "'.rst'", ",", "'.ipynb'", ")", ":", "if", "os", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder._run_os
Execute a command as a OS terminal. Parameters ---------- *args : list of str Command and parameters to be executed Examples -------- >>> DocBuilder()._run_os('python', '--version')
doc/make.py
def _run_os(*args): """ Execute a command as a OS terminal. Parameters ---------- *args : list of str Command and parameters to be executed Examples -------- >>> DocBuilder()._run_os('python', '--version') """ subprocess.check...
def _run_os(*args): """ Execute a command as a OS terminal. Parameters ---------- *args : list of str Command and parameters to be executed Examples -------- >>> DocBuilder()._run_os('python', '--version') """ subprocess.check...
[ "Execute", "a", "command", "as", "a", "OS", "terminal", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L91-L104
[ "def", "_run_os", "(", "*", "args", ")", ":", "subprocess", ".", "check_call", "(", "args", ",", "stdout", "=", "sys", ".", "stdout", ",", "stderr", "=", "sys", ".", "stderr", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder._sphinx_build
Call sphinx to build documentation. Attribute `num_jobs` from the class is used. Parameters ---------- kind : {'html', 'latex'} Examples -------- >>> DocBuilder(num_jobs=4)._sphinx_build('html')
doc/make.py
def _sphinx_build(self, kind): """ Call sphinx to build documentation. Attribute `num_jobs` from the class is used. Parameters ---------- kind : {'html', 'latex'} Examples -------- >>> DocBuilder(num_jobs=4)._sphinx_build('html') """ ...
def _sphinx_build(self, kind): """ Call sphinx to build documentation. Attribute `num_jobs` from the class is used. Parameters ---------- kind : {'html', 'latex'} Examples -------- >>> DocBuilder(num_jobs=4)._sphinx_build('html') """ ...
[ "Call", "sphinx", "to", "build", "documentation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L106-L133
[ "def", "_sphinx_build", "(", "self", ",", "kind", ")", ":", "if", "kind", "not", "in", "(", "'html'", ",", "'latex'", ")", ":", "raise", "ValueError", "(", "'kind must be html or latex, '", "'not {}'", ".", "format", "(", "kind", ")", ")", "cmd", "=", "[...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder._open_browser
Open a browser tab showing single
doc/make.py
def _open_browser(self, single_doc_html): """ Open a browser tab showing single """ url = os.path.join('file://', DOC_PATH, 'build', 'html', single_doc_html) webbrowser.open(url, new=2)
def _open_browser(self, single_doc_html): """ Open a browser tab showing single """ url = os.path.join('file://', DOC_PATH, 'build', 'html', single_doc_html) webbrowser.open(url, new=2)
[ "Open", "a", "browser", "tab", "showing", "single" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L135-L141
[ "def", "_open_browser", "(", "self", ",", "single_doc_html", ")", ":", "url", "=", "os", ".", "path", ".", "join", "(", "'file://'", ",", "DOC_PATH", ",", "'build'", ",", "'html'", ",", "single_doc_html", ")", "webbrowser", ".", "open", "(", "url", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder._get_page_title
Open the rst file `page` and extract its title.
doc/make.py
def _get_page_title(self, page): """ Open the rst file `page` and extract its title. """ fname = os.path.join(SOURCE_PATH, '{}.rst'.format(page)) option_parser = docutils.frontend.OptionParser( components=(docutils.parsers.rst.Parser,)) doc = docutils.utils.ne...
def _get_page_title(self, page): """ Open the rst file `page` and extract its title. """ fname = os.path.join(SOURCE_PATH, '{}.rst'.format(page)) option_parser = docutils.frontend.OptionParser( components=(docutils.parsers.rst.Parser,)) doc = docutils.utils.ne...
[ "Open", "the", "rst", "file", "page", "and", "extract", "its", "title", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L143-L167
[ "def", "_get_page_title", "(", "self", ",", "page", ")", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "SOURCE_PATH", ",", "'{}.rst'", ".", "format", "(", "page", ")", ")", "option_parser", "=", "docutils", ".", "frontend", ".", "OptionParser",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder._add_redirects
Create in the build directory an html file with a redirect, for every row in REDIRECTS_FILE.
doc/make.py
def _add_redirects(self): """ Create in the build directory an html file with a redirect, for every row in REDIRECTS_FILE. """ html = ''' <html> <head> <meta http-equiv="refresh" content="0;URL={url}"/> </head> <body> ...
def _add_redirects(self): """ Create in the build directory an html file with a redirect, for every row in REDIRECTS_FILE. """ html = ''' <html> <head> <meta http-equiv="refresh" content="0;URL={url}"/> </head> <body> ...
[ "Create", "in", "the", "build", "directory", "an", "html", "file", "with", "a", "redirect", "for", "every", "row", "in", "REDIRECTS_FILE", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L169-L212
[ "def", "_add_redirects", "(", "self", ")", ":", "html", "=", "'''\n <html>\n <head>\n <meta http-equiv=\"refresh\" content=\"0;URL={url}\"/>\n </head>\n <body>\n <p>\n The page has been moved to <a href=\"{url}\...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder.html
Build HTML documentation.
doc/make.py
def html(self): """ Build HTML documentation. """ ret_code = self._sphinx_build('html') zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip') if os.path.exists(zip_fname): os.remove(zip_fname) if self.single_doc_html is not None: self...
def html(self): """ Build HTML documentation. """ ret_code = self._sphinx_build('html') zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip') if os.path.exists(zip_fname): os.remove(zip_fname) if self.single_doc_html is not None: self...
[ "Build", "HTML", "documentation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L214-L227
[ "def", "html", "(", "self", ")", ":", "ret_code", "=", "self", ".", "_sphinx_build", "(", "'html'", ")", "zip_fname", "=", "os", ".", "path", ".", "join", "(", "BUILD_PATH", ",", "'html'", ",", "'pandas.zip'", ")", "if", "os", ".", "path", ".", "exis...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder.latex
Build PDF documentation.
doc/make.py
def latex(self, force=False): """ Build PDF documentation. """ if sys.platform == 'win32': sys.stderr.write('latex build has not been tested on windows\n') else: ret_code = self._sphinx_build('latex') os.chdir(os.path.join(BUILD_PATH, 'latex'))...
def latex(self, force=False): """ Build PDF documentation. """ if sys.platform == 'win32': sys.stderr.write('latex build has not been tested on windows\n') else: ret_code = self._sphinx_build('latex') os.chdir(os.path.join(BUILD_PATH, 'latex'))...
[ "Build", "PDF", "documentation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L229-L247
[ "def", "latex", "(", "self", ",", "force", "=", "False", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "sys", ".", "stderr", ".", "write", "(", "'latex build has not been tested on windows\\n'", ")", "else", ":", "ret_code", "=", "self", "....
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder.clean
Clean documentation generated files.
doc/make.py
def clean(): """ Clean documentation generated files. """ shutil.rmtree(BUILD_PATH, ignore_errors=True) shutil.rmtree(os.path.join(SOURCE_PATH, 'reference', 'api'), ignore_errors=True)
def clean(): """ Clean documentation generated files. """ shutil.rmtree(BUILD_PATH, ignore_errors=True) shutil.rmtree(os.path.join(SOURCE_PATH, 'reference', 'api'), ignore_errors=True)
[ "Clean", "documentation", "generated", "files", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L256-L262
[ "def", "clean", "(", ")", ":", "shutil", ".", "rmtree", "(", "BUILD_PATH", ",", "ignore_errors", "=", "True", ")", "shutil", ".", "rmtree", "(", "os", ".", "path", ".", "join", "(", "SOURCE_PATH", ",", "'reference'", ",", "'api'", ")", ",", "ignore_err...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DocBuilder.zip_html
Compress HTML documentation into a zip file.
doc/make.py
def zip_html(self): """ Compress HTML documentation into a zip file. """ zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip') if os.path.exists(zip_fname): os.remove(zip_fname) dirname = os.path.join(BUILD_PATH, 'html') fnames = os.listdir(dirnam...
def zip_html(self): """ Compress HTML documentation into a zip file. """ zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip') if os.path.exists(zip_fname): os.remove(zip_fname) dirname = os.path.join(BUILD_PATH, 'html') fnames = os.listdir(dirnam...
[ "Compress", "HTML", "documentation", "into", "a", "zip", "file", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L264-L278
[ "def", "zip_html", "(", "self", ")", ":", "zip_fname", "=", "os", ".", "path", ".", "join", "(", "BUILD_PATH", ",", "'html'", ",", "'pandas.zip'", ")", "if", "os", ".", "path", ".", "exists", "(", "zip_fname", ")", ":", "os", ".", "remove", "(", "z...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
LatexFormatter.write_result
Render a DataFrame to a LaTeX tabular/longtable environment output.
pandas/io/formats/latex.py
def write_result(self, buf): """ Render a DataFrame to a LaTeX tabular/longtable environment output. """ # string representation of the columns if len(self.frame.columns) == 0 or len(self.frame.index) == 0: info_line = ('Empty {name}\nColumns: {col}\nIndex: {idx}' ...
def write_result(self, buf): """ Render a DataFrame to a LaTeX tabular/longtable environment output. """ # string representation of the columns if len(self.frame.columns) == 0 or len(self.frame.index) == 0: info_line = ('Empty {name}\nColumns: {col}\nIndex: {idx}' ...
[ "Render", "a", "DataFrame", "to", "a", "LaTeX", "tabular", "/", "longtable", "environment", "output", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L40-L163
[ "def", "write_result", "(", "self", ",", "buf", ")", ":", "# string representation of the columns", "if", "len", "(", "self", ".", "frame", ".", "columns", ")", "==", "0", "or", "len", "(", "self", ".", "frame", ".", "index", ")", "==", "0", ":", "info...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
LatexFormatter._format_multicolumn
r""" Combine columns belonging to a group to a single multicolumn entry according to self.multicolumn_format e.g.: a & & & b & c & will become \multicolumn{3}{l}{a} & b & \multicolumn{2}{l}{c}
pandas/io/formats/latex.py
def _format_multicolumn(self, row, ilevels): r""" Combine columns belonging to a group to a single multicolumn entry according to self.multicolumn_format e.g.: a & & & b & c & will become \multicolumn{3}{l}{a} & b & \multicolumn{2}{l}{c} """ row...
def _format_multicolumn(self, row, ilevels): r""" Combine columns belonging to a group to a single multicolumn entry according to self.multicolumn_format e.g.: a & & & b & c & will become \multicolumn{3}{l}{a} & b & \multicolumn{2}{l}{c} """ row...
[ "r", "Combine", "columns", "belonging", "to", "a", "group", "to", "a", "single", "multicolumn", "entry", "according", "to", "self", ".", "multicolumn_format" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L165-L201
[ "def", "_format_multicolumn", "(", "self", ",", "row", ",", "ilevels", ")", ":", "row2", "=", "list", "(", "row", "[", ":", "ilevels", "]", ")", "ncol", "=", "1", "coltext", "=", "''", "def", "append_col", "(", ")", ":", "# write multicolumn if needed", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
LatexFormatter._format_multirow
r""" Check following rows, whether row should be a multirow e.g.: becomes: a & 0 & \multirow{2}{*}{a} & 0 & & 1 & & 1 & b & 0 & \cline{1-2} b & 0 &
pandas/io/formats/latex.py
def _format_multirow(self, row, ilevels, i, rows): r""" Check following rows, whether row should be a multirow e.g.: becomes: a & 0 & \multirow{2}{*}{a} & 0 & & 1 & & 1 & b & 0 & \cline{1-2} b & 0 & """ for j in range(ileve...
def _format_multirow(self, row, ilevels, i, rows): r""" Check following rows, whether row should be a multirow e.g.: becomes: a & 0 & \multirow{2}{*}{a} & 0 & & 1 & & 1 & b & 0 & \cline{1-2} b & 0 & """ for j in range(ileve...
[ "r", "Check", "following", "rows", "whether", "row", "should", "be", "a", "multirow" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L203-L227
[ "def", "_format_multirow", "(", "self", ",", "row", ",", "ilevels", ",", "i", ",", "rows", ")", ":", "for", "j", "in", "range", "(", "ilevels", ")", ":", "if", "row", "[", "j", "]", ".", "strip", "(", ")", ":", "nrow", "=", "1", "for", "r", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
LatexFormatter._print_cline
Print clines after multirow-blocks are finished
pandas/io/formats/latex.py
def _print_cline(self, buf, i, icol): """ Print clines after multirow-blocks are finished """ for cl in self.clinebuf: if cl[0] == i: buf.write('\\cline{{{cl:d}-{icol:d}}}\n' .format(cl=cl[1], icol=icol)) # remove entries that...
def _print_cline(self, buf, i, icol): """ Print clines after multirow-blocks are finished """ for cl in self.clinebuf: if cl[0] == i: buf.write('\\cline{{{cl:d}-{icol:d}}}\n' .format(cl=cl[1], icol=icol)) # remove entries that...
[ "Print", "clines", "after", "multirow", "-", "blocks", "are", "finished" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L229-L238
[ "def", "_print_cline", "(", "self", ",", "buf", ",", "i", ",", "icol", ")", ":", "for", "cl", "in", "self", ".", "clinebuf", ":", "if", "cl", "[", "0", "]", "==", "i", ":", "buf", ".", "write", "(", "'\\\\cline{{{cl:d}-{icol:d}}}\\n'", ".", "format",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_validate_integer
Checks whether the 'name' parameter for parsing is either an integer OR float that can SAFELY be cast to an integer without losing accuracy. Raises a ValueError if that is not the case. Parameters ---------- name : string Parameter name (used for error reporting) val : int or float ...
pandas/io/parsers.py
def _validate_integer(name, val, min_val=0): """ Checks whether the 'name' parameter for parsing is either an integer OR float that can SAFELY be cast to an integer without losing accuracy. Raises a ValueError if that is not the case. Parameters ---------- name : string Paramete...
def _validate_integer(name, val, min_val=0): """ Checks whether the 'name' parameter for parsing is either an integer OR float that can SAFELY be cast to an integer without losing accuracy. Raises a ValueError if that is not the case. Parameters ---------- name : string Paramete...
[ "Checks", "whether", "the", "name", "parameter", "for", "parsing", "is", "either", "an", "integer", "OR", "float", "that", "can", "SAFELY", "be", "cast", "to", "an", "integer", "without", "losing", "accuracy", ".", "Raises", "a", "ValueError", "if", "that", ...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L349-L376
[ "def", "_validate_integer", "(", "name", ",", "val", ",", "min_val", "=", "0", ")", ":", "msg", "=", "\"'{name:s}' must be an integer >={min_val:d}\"", ".", "format", "(", "name", "=", "name", ",", "min_val", "=", "min_val", ")", "if", "val", "is", "not", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_validate_names
Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ------- names : array-like or None ...
pandas/io/parsers.py
def _validate_names(names): """ Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ---...
def _validate_names(names): """ Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ---...
[ "Check", "if", "the", "names", "parameter", "contains", "duplicates", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L379-L402
[ "def", "_validate_names", "(", "names", ")", ":", "if", "names", "is", "not", "None", ":", "if", "len", "(", "names", ")", "!=", "len", "(", "set", "(", "names", ")", ")", ":", "msg", "=", "(", "\"Duplicate names specified. This \"", "\"will raise an error...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_read
Generic reader of line files.
pandas/io/parsers.py
def _read(filepath_or_buffer: FilePathOrBuffer, kwds): """Generic reader of line files.""" encoding = kwds.get('encoding', None) if encoding is not None: encoding = re.sub('_', '-', encoding).lower() kwds['encoding'] = encoding compression = kwds.get('compression', 'infer') compress...
def _read(filepath_or_buffer: FilePathOrBuffer, kwds): """Generic reader of line files.""" encoding = kwds.get('encoding', None) if encoding is not None: encoding = re.sub('_', '-', encoding).lower() kwds['encoding'] = encoding compression = kwds.get('compression', 'infer') compress...
[ "Generic", "reader", "of", "line", "files", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L405-L452
[ "def", "_read", "(", "filepath_or_buffer", ":", "FilePathOrBuffer", ",", "kwds", ")", ":", "encoding", "=", "kwds", ".", "get", "(", "'encoding'", ",", "None", ")", "if", "encoding", "is", "not", "None", ":", "encoding", "=", "re", ".", "sub", "(", "'_...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
read_fwf
r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. Additional help can be found in the `online docs for IO Tools <http://pandas.pydata.org/pandas-docs/stable/io.html>`_. Parameters ---------- filepat...
pandas/io/parsers.py
def read_fwf(filepath_or_buffer: FilePathOrBuffer, colspecs='infer', widths=None, infer_nrows=100, **kwds): r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. ...
def read_fwf(filepath_or_buffer: FilePathOrBuffer, colspecs='infer', widths=None, infer_nrows=100, **kwds): r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. ...
[ "r", "Read", "a", "table", "of", "fixed", "-", "width", "formatted", "lines", "into", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L735-L813
[ "def", "read_fwf", "(", "filepath_or_buffer", ":", "FilePathOrBuffer", ",", "colspecs", "=", "'infer'", ",", "widths", "=", "None", ",", "infer_nrows", "=", "100", ",", "*", "*", "kwds", ")", ":", "# Check input arguments.", "if", "colspecs", "is", "None", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_is_potential_multi_index
Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not columns could become a MultiIndex
pandas/io/parsers.py
def _is_potential_multi_index(columns): """ Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not co...
def _is_potential_multi_index(columns): """ Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not co...
[ "Check", "whether", "or", "not", "the", "columns", "parameter", "could", "be", "converted", "into", "a", "MultiIndex", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1190-L1205
[ "def", "_is_potential_multi_index", "(", "columns", ")", ":", "return", "(", "len", "(", "columns", ")", "and", "not", "isinstance", "(", "columns", ",", "MultiIndex", ")", "and", "all", "(", "isinstance", "(", "c", ",", "tuple", ")", "for", "c", "in", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_evaluate_usecols
Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'.
pandas/io/parsers.py
def _evaluate_usecols(usecols, names): """ Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'. """ if callable(usecols): ...
def _evaluate_usecols(usecols, names): """ Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'. """ if callable(usecols): ...
[ "Check", "whether", "or", "not", "the", "usecols", "parameter", "is", "a", "callable", ".", "If", "so", "enumerates", "the", "names", "parameter", "and", "returns", "a", "set", "of", "indices", "for", "each", "entry", "in", "names", "that", "evaluates", "t...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1208-L1218
[ "def", "_evaluate_usecols", "(", "usecols", ",", "names", ")", ":", "if", "callable", "(", "usecols", ")", ":", "return", "{", "i", "for", "i", ",", "name", "in", "enumerate", "(", "names", ")", "if", "usecols", "(", "name", ")", "}", "return", "usec...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_validate_usecols_names
Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. names : iterable of names The column names to check ...
pandas/io/parsers.py
def _validate_usecols_names(usecols, names): """ Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. nam...
def _validate_usecols_names(usecols, names): """ Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. nam...
[ "Validates", "that", "all", "usecols", "are", "present", "in", "a", "given", "list", "of", "names", ".", "If", "not", "raise", "a", "ValueError", "that", "shows", "what", "usecols", "are", "missing", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1221-L1250
[ "def", "_validate_usecols_names", "(", "usecols", ",", "names", ")", ":", "missing", "=", "[", "c", "for", "c", "in", "usecols", "if", "c", "not", "in", "names", "]", "if", "len", "(", "missing", ")", ">", "0", ":", "raise", "ValueError", "(", "\"Use...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_validate_usecols_arg
Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- usecols : list-like, callable, or None List o...
pandas/io/parsers.py
def _validate_usecols_arg(usecols): """ Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- useco...
def _validate_usecols_arg(usecols): """ Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- useco...
[ "Validate", "the", "usecols", "parameter", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1284-L1330
[ "def", "_validate_usecols_arg", "(", "usecols", ")", ":", "msg", "=", "(", "\"'usecols' must either be list-like of all strings, all unicode, \"", "\"all integers or a callable.\"", ")", "if", "usecols", "is", "not", "None", ":", "if", "callable", "(", "usecols", ")", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_validate_parse_dates_arg
Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case.
pandas/io/parsers.py
def _validate_parse_dates_arg(parse_dates): """ Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case. """ msg = ("Only booleans, lists, and " "dictionaries are accepted " "for the 'parse_dates' parameter") if...
def _validate_parse_dates_arg(parse_dates): """ Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case. """ msg = ("Only booleans, lists, and " "dictionaries are accepted " "for the 'parse_dates' parameter") if...
[ "Check", "whether", "or", "not", "the", "parse_dates", "parameter", "is", "a", "non", "-", "boolean", "scalar", ".", "Raises", "a", "ValueError", "if", "that", "is", "the", "case", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1333-L1351
[ "def", "_validate_parse_dates_arg", "(", "parse_dates", ")", ":", "msg", "=", "(", "\"Only booleans, lists, and \"", "\"dictionaries are accepted \"", "\"for the 'parse_dates' parameter\"", ")", "if", "parse_dates", "is", "not", "None", ":", "if", "is_scalar", "(", "parse...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_stringify_na_values
return a stringified and numeric for these values
pandas/io/parsers.py
def _stringify_na_values(na_values): """ return a stringified and numeric for these values """ result = [] for x in na_values: result.append(str(x)) result.append(x) try: v = float(x) # we are like 999 here if v == int(v): v = int(...
def _stringify_na_values(na_values): """ return a stringified and numeric for these values """ result = [] for x in na_values: result.append(str(x)) result.append(x) try: v = float(x) # we are like 999 here if v == int(v): v = int(...
[ "return", "a", "stringified", "and", "numeric", "for", "these", "values" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3425-L3447
[ "def", "_stringify_na_values", "(", "na_values", ")", ":", "result", "=", "[", "]", "for", "x", "in", "na_values", ":", "result", ".", "append", "(", "str", "(", "x", ")", ")", "result", ".", "append", "(", "x", ")", "try", ":", "v", "=", "float", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_na_values
Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict The object listing the NaN values as floats. keep_default_na : bool ...
pandas/io/parsers.py
def _get_na_values(col, na_values, na_fvalues, keep_default_na): """ Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict ...
def _get_na_values(col, na_values, na_fvalues, keep_default_na): """ Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict ...
[ "Get", "the", "NaN", "values", "for", "a", "given", "column", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3450-L3483
[ "def", "_get_na_values", "(", "col", ",", "na_values", ",", "na_fvalues", ",", "keep_default_na", ")", ":", "if", "isinstance", "(", "na_values", ",", "dict", ")", ":", "if", "col", "in", "na_values", ":", "return", "na_values", "[", "col", "]", ",", "na...
9feb3ad92cc0397a04b665803a49299ee7aa1037