id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
19,800
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.astype
def astype(self, dtype, copy=True): """ Coerce this type to another dtype Parameters ---------- dtype : numpy dtype or pandas type copy : bool, default True By default, astype always returns a newly allocated object. If copy is set to False and dt...
python
def astype(self, dtype, copy=True): """ Coerce this type to another dtype Parameters ---------- dtype : numpy dtype or pandas type copy : bool, default True By default, astype always returns a newly allocated object. If copy is set to False and dt...
[ "def", "astype", "(", "self", ",", "dtype", ",", "copy", "=", "True", ")", ":", "if", "is_categorical_dtype", "(", "dtype", ")", ":", "# GH 10696/18593", "dtype", "=", "self", ".", "dtype", ".", "update_dtype", "(", "dtype", ")", "self", "=", "self", "...
Coerce this type to another dtype Parameters ---------- dtype : numpy dtype or pandas type copy : bool, default True By default, astype always returns a newly allocated object. If copy is set to False and dtype is categorical, the original object is r...
[ "Coerce", "this", "type", "to", "another", "dtype" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L463-L485
19,801
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._from_inferred_categories
def _from_inferred_categories(cls, inferred_categories, inferred_codes, dtype, true_values=None): """ Construct a Categorical from inferred values. For inferred categories (`dtype` is None) the categories are sorted. For explicit `dtype`, the `inferred_...
python
def _from_inferred_categories(cls, inferred_categories, inferred_codes, dtype, true_values=None): """ Construct a Categorical from inferred values. For inferred categories (`dtype` is None) the categories are sorted. For explicit `dtype`, the `inferred_...
[ "def", "_from_inferred_categories", "(", "cls", ",", "inferred_categories", ",", "inferred_codes", ",", "dtype", ",", "true_values", "=", "None", ")", ":", "from", "pandas", "import", "Index", ",", "to_numeric", ",", "to_datetime", ",", "to_timedelta", "cats", "...
Construct a Categorical from inferred values. For inferred categories (`dtype` is None) the categories are sorted. For explicit `dtype`, the `inferred_categories` are cast to the appropriate type. Parameters ---------- inferred_categories : Index inferred_codes ...
[ "Construct", "a", "Categorical", "from", "inferred", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L528-L586
19,802
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.from_codes
def from_codes(cls, codes, categories=None, ordered=None, dtype=None): """ Make a Categorical type from codes and categories or dtype. This constructor is useful if you already have codes and categories/dtype and so do not need the (computation intensive) factorization step, whi...
python
def from_codes(cls, codes, categories=None, ordered=None, dtype=None): """ Make a Categorical type from codes and categories or dtype. This constructor is useful if you already have codes and categories/dtype and so do not need the (computation intensive) factorization step, whi...
[ "def", "from_codes", "(", "cls", ",", "codes", ",", "categories", "=", "None", ",", "ordered", "=", "None", ",", "dtype", "=", "None", ")", ":", "dtype", "=", "CategoricalDtype", ".", "_from_values_or_dtype", "(", "categories", "=", "categories", ",", "ord...
Make a Categorical type from codes and categories or dtype. This constructor is useful if you already have codes and categories/dtype and so do not need the (computation intensive) factorization step, which is usually done on the constructor. If your data does not follow this conventio...
[ "Make", "a", "Categorical", "type", "from", "codes", "and", "categories", "or", "dtype", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L589-L655
19,803
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._get_codes
def _get_codes(self): """ Get the codes. Returns ------- codes : integer array view A non writable view of the `codes` array. """ v = self._codes.view() v.flags.writeable = False return v
python
def _get_codes(self): """ Get the codes. Returns ------- codes : integer array view A non writable view of the `codes` array. """ v = self._codes.view() v.flags.writeable = False return v
[ "def", "_get_codes", "(", "self", ")", ":", "v", "=", "self", ".", "_codes", ".", "view", "(", ")", "v", ".", "flags", ".", "writeable", "=", "False", "return", "v" ]
Get the codes. Returns ------- codes : integer array view A non writable view of the `codes` array.
[ "Get", "the", "codes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L659-L670
19,804
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._set_categories
def _set_categories(self, categories, fastpath=False): """ Sets new categories inplace Parameters ---------- fastpath : bool, default False Don't perform validation of the categories for uniqueness or nulls Examples -------- >>> c = pd.Categor...
python
def _set_categories(self, categories, fastpath=False): """ Sets new categories inplace Parameters ---------- fastpath : bool, default False Don't perform validation of the categories for uniqueness or nulls Examples -------- >>> c = pd.Categor...
[ "def", "_set_categories", "(", "self", ",", "categories", ",", "fastpath", "=", "False", ")", ":", "if", "fastpath", ":", "new_dtype", "=", "CategoricalDtype", ".", "_from_fastpath", "(", "categories", ",", "self", ".", "ordered", ")", "else", ":", "new_dtyp...
Sets new categories inplace Parameters ---------- fastpath : bool, default False Don't perform validation of the categories for uniqueness or nulls Examples -------- >>> c = pd.Categorical(['a', 'b']) >>> c [a, b] Categories (2, object...
[ "Sets", "new", "categories", "inplace" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L680-L712
19,805
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._set_dtype
def _set_dtype(self, dtype): """ Internal method for directly updating the CategoricalDtype Parameters ---------- dtype : CategoricalDtype Notes ----- We don't do any validation here. It's assumed that the dtype is a (valid) instance of `Categori...
python
def _set_dtype(self, dtype): """ Internal method for directly updating the CategoricalDtype Parameters ---------- dtype : CategoricalDtype Notes ----- We don't do any validation here. It's assumed that the dtype is a (valid) instance of `Categori...
[ "def", "_set_dtype", "(", "self", ",", "dtype", ")", ":", "codes", "=", "_recode_for_categories", "(", "self", ".", "codes", ",", "self", ".", "categories", ",", "dtype", ".", "categories", ")", "return", "type", "(", "self", ")", "(", "codes", ",", "d...
Internal method for directly updating the CategoricalDtype Parameters ---------- dtype : CategoricalDtype Notes ----- We don't do any validation here. It's assumed that the dtype is a (valid) instance of `CategoricalDtype`.
[ "Internal", "method", "for", "directly", "updating", "the", "CategoricalDtype" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L714-L729
19,806
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.set_ordered
def set_ordered(self, value, inplace=False): """ Set the ordered attribute to the boolean value. Parameters ---------- value : bool Set whether this categorical is ordered (True) or not (False). inplace : bool, default False Whether or not to set th...
python
def set_ordered(self, value, inplace=False): """ Set the ordered attribute to the boolean value. Parameters ---------- value : bool Set whether this categorical is ordered (True) or not (False). inplace : bool, default False Whether or not to set th...
[ "def", "set_ordered", "(", "self", ",", "value", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "new_dtype", "=", "CategoricalDtype", "(", "self", ".", "categories", ",", "ordered", "=", ...
Set the ordered attribute to the boolean value. Parameters ---------- value : bool Set whether this categorical is ordered (True) or not (False). inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this ...
[ "Set", "the", "ordered", "attribute", "to", "the", "boolean", "value", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L731-L748
19,807
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.as_ordered
def as_ordered(self, inplace=False): """ Set the Categorical to be ordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to True. """ ...
python
def as_ordered(self, inplace=False): """ Set the Categorical to be ordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to True. """ ...
[ "def", "as_ordered", "(", "self", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "return", "self", ".", "set_ordered", "(", "True", ",", "inplace", "=", "inplace", ")" ]
Set the Categorical to be ordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to True.
[ "Set", "the", "Categorical", "to", "be", "ordered", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L750-L761
19,808
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.as_unordered
def as_unordered(self, inplace=False): """ Set the Categorical to be unordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to False. ...
python
def as_unordered(self, inplace=False): """ Set the Categorical to be unordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to False. ...
[ "def", "as_unordered", "(", "self", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "return", "self", ".", "set_ordered", "(", "False", ",", "inplace", "=", "inplace", ")" ]
Set the Categorical to be unordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to False.
[ "Set", "the", "Categorical", "to", "be", "unordered", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L763-L774
19,809
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.set_categories
def set_categories(self, new_categories, ordered=None, rename=False, inplace=False): """ Set the categories to the specified new_categories. `new_categories` can include new categories (which will result in unused categories) or remove old categories (which result...
python
def set_categories(self, new_categories, ordered=None, rename=False, inplace=False): """ Set the categories to the specified new_categories. `new_categories` can include new categories (which will result in unused categories) or remove old categories (which result...
[ "def", "set_categories", "(", "self", ",", "new_categories", ",", "ordered", "=", "None", ",", "rename", "=", "False", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "ordered", "i...
Set the categories to the specified new_categories. `new_categories` can include new categories (which will result in unused categories) or remove old categories (which results in values set to NaN). If `rename==True`, the categories will simple be renamed (less or more items than in ol...
[ "Set", "the", "categories", "to", "the", "specified", "new_categories", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L776-L846
19,810
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.rename_categories
def rename_categories(self, new_categories, inplace=False): """ Rename categories. Parameters ---------- new_categories : list-like, dict-like or callable * list-like: all items must be unique and the number of items in the new categories must match the ...
python
def rename_categories(self, new_categories, inplace=False): """ Rename categories. Parameters ---------- new_categories : list-like, dict-like or callable * list-like: all items must be unique and the number of items in the new categories must match the ...
[ "def", "rename_categories", "(", "self", ",", "new_categories", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "cat", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")"...
Rename categories. Parameters ---------- new_categories : list-like, dict-like or callable * list-like: all items must be unique and the number of items in the new categories must match the existing number of categories. * dict-like: specifies a mapping from...
[ "Rename", "categories", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L848-L940
19,811
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.reorder_categories
def reorder_categories(self, new_categories, ordered=None, inplace=False): """ Reorder categories as specified in new_categories. `new_categories` need to include all old categories and no new category items. Parameters ---------- new_categories : Index-like ...
python
def reorder_categories(self, new_categories, ordered=None, inplace=False): """ Reorder categories as specified in new_categories. `new_categories` need to include all old categories and no new category items. Parameters ---------- new_categories : Index-like ...
[ "def", "reorder_categories", "(", "self", ",", "new_categories", ",", "ordered", "=", "None", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "set", "(", "self", ".", "dtype", ".",...
Reorder categories as specified in new_categories. `new_categories` need to include all old categories and no new category items. Parameters ---------- new_categories : Index-like The categories in new order. ordered : bool, optional Whether or not...
[ "Reorder", "categories", "as", "specified", "in", "new_categories", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L942-L983
19,812
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.add_categories
def add_categories(self, new_categories, inplace=False): """ Add new categories. `new_categories` will be included at the last/highest place in the categories and will be unused directly after this call. Parameters ---------- new_categories : category or list-li...
python
def add_categories(self, new_categories, inplace=False): """ Add new categories. `new_categories` will be included at the last/highest place in the categories and will be unused directly after this call. Parameters ---------- new_categories : category or list-li...
[ "def", "add_categories", "(", "self", ",", "new_categories", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "not", "is_list_like", "(", "new_categories", ")", ":", "new_categories", "...
Add new categories. `new_categories` will be included at the last/highest place in the categories and will be unused directly after this call. Parameters ---------- new_categories : category or list-like of category The new categories to be included. inplace ...
[ "Add", "new", "categories", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L985-L1033
19,813
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.remove_categories
def remove_categories(self, removals, inplace=False): """ Remove the specified categories. `removals` must be included in the old categories. Values which were in the removed categories will be set to NaN Parameters ---------- removals : category or list of cate...
python
def remove_categories(self, removals, inplace=False): """ Remove the specified categories. `removals` must be included in the old categories. Values which were in the removed categories will be set to NaN Parameters ---------- removals : category or list of cate...
[ "def", "remove_categories", "(", "self", ",", "removals", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "not", "is_list_like", "(", "removals", ")", ":", "removals", "=", "[", "r...
Remove the specified categories. `removals` must be included in the old categories. Values which were in the removed categories will be set to NaN Parameters ---------- removals : category or list of categories The categories which should be removed. inplace ...
[ "Remove", "the", "specified", "categories", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1035-L1086
19,814
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.remove_unused_categories
def remove_unused_categories(self, inplace=False): """ Remove categories which are not used. Parameters ---------- inplace : bool, default False Whether or not to drop unused categories inplace or return a copy of this categorical with unused categories dro...
python
def remove_unused_categories(self, inplace=False): """ Remove categories which are not used. Parameters ---------- inplace : bool, default False Whether or not to drop unused categories inplace or return a copy of this categorical with unused categories dro...
[ "def", "remove_unused_categories", "(", "self", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "cat", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "idx", ",", ...
Remove categories which are not used. Parameters ---------- inplace : bool, default False Whether or not to drop unused categories inplace or return a copy of this categorical with unused categories dropped. Returns ------- cat : Categorical with u...
[ "Remove", "categories", "which", "are", "not", "used", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1088-L1124
19,815
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.shift
def shift(self, periods, fill_value=None): """ Shift Categorical by desired number of periods. Parameters ---------- periods : int Number of periods to move, can be positive or negative fill_value : object, optional The scalar value to use for new...
python
def shift(self, periods, fill_value=None): """ Shift Categorical by desired number of periods. Parameters ---------- periods : int Number of periods to move, can be positive or negative fill_value : object, optional The scalar value to use for new...
[ "def", "shift", "(", "self", ",", "periods", ",", "fill_value", "=", "None", ")", ":", "# since categoricals always have ndim == 1, an axis parameter", "# doesn't make any sense here.", "codes", "=", "self", ".", "codes", "if", "codes", ".", "ndim", ">", "1", ":", ...
Shift Categorical by desired number of periods. Parameters ---------- periods : int Number of periods to move, can be positive or negative fill_value : object, optional The scalar value to use for newly introduced missing values. .. versionadded:: 0....
[ "Shift", "Categorical", "by", "desired", "number", "of", "periods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1230-L1267
19,816
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.memory_usage
def memory_usage(self, deep=False): """ Memory usage of my values Parameters ---------- deep : bool Introspect the data deeply, interrogate `object` dtypes for system-level memory consumption Returns ------- bytes used No...
python
def memory_usage(self, deep=False): """ Memory usage of my values Parameters ---------- deep : bool Introspect the data deeply, interrogate `object` dtypes for system-level memory consumption Returns ------- bytes used No...
[ "def", "memory_usage", "(", "self", ",", "deep", "=", "False", ")", ":", "return", "self", ".", "_codes", ".", "nbytes", "+", "self", ".", "dtype", ".", "categories", ".", "memory_usage", "(", "deep", "=", "deep", ")" ]
Memory usage of my values Parameters ---------- deep : bool Introspect the data deeply, interrogate `object` dtypes for system-level memory consumption Returns ------- bytes used Notes ----- Memory usage does not include ...
[ "Memory", "usage", "of", "my", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1331-L1355
19,817
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.value_counts
def value_counts(self, dropna=True): """ Return a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : bool, default True Don't include counts of NaN. Returns ...
python
def value_counts(self, dropna=True): """ Return a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : bool, default True Don't include counts of NaN. Returns ...
[ "def", "value_counts", "(", "self", ",", "dropna", "=", "True", ")", ":", "from", "numpy", "import", "bincount", "from", "pandas", "import", "Series", ",", "CategoricalIndex", "code", ",", "cat", "=", "self", ".", "_codes", ",", "self", ".", "categories", ...
Return a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : bool, default True Don't include counts of NaN. Returns ------- counts : Series See Also ...
[ "Return", "a", "Series", "containing", "counts", "of", "each", "category", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1438-L1475
19,818
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.get_values
def get_values(self): """ Return the values. For internal compatibility with pandas formatting. Returns ------- numpy.array A numpy array of the same dtype as categorical.categories.dtype or Index if datetime / periods. """ # if w...
python
def get_values(self): """ Return the values. For internal compatibility with pandas formatting. Returns ------- numpy.array A numpy array of the same dtype as categorical.categories.dtype or Index if datetime / periods. """ # if w...
[ "def", "get_values", "(", "self", ")", ":", "# if we are a datetime and period index, return Index to keep metadata", "if", "is_datetimelike", "(", "self", ".", "categories", ")", ":", "return", "self", ".", "categories", ".", "take", "(", "self", ".", "_codes", ","...
Return the values. For internal compatibility with pandas formatting. Returns ------- numpy.array A numpy array of the same dtype as categorical.categories.dtype or Index if datetime / periods.
[ "Return", "the", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1477-L1495
19,819
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.sort_values
def sort_values(self, inplace=False, ascending=True, na_position='last'): """ Sort the Categorical by category value returning a new Categorical by default. While an ordering is applied to the category values, sorting in this context refers more to organizing and grouping togeth...
python
def sort_values(self, inplace=False, ascending=True, na_position='last'): """ Sort the Categorical by category value returning a new Categorical by default. While an ordering is applied to the category values, sorting in this context refers more to organizing and grouping togeth...
[ "def", "sort_values", "(", "self", ",", "inplace", "=", "False", ",", "ascending", "=", "True", ",", "na_position", "=", "'last'", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "na_position", "not", "in", "["...
Sort the Categorical by category value returning a new Categorical by default. While an ordering is applied to the category values, sorting in this context refers more to organizing and grouping together based on matching category values. Thus, this function can be called on an ...
[ "Sort", "the", "Categorical", "by", "category", "value", "returning", "a", "new", "Categorical", "by", "default", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1554-L1642
19,820
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.take_nd
def take_nd(self, indexer, allow_fill=None, fill_value=None): """ Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow...
python
def take_nd(self, indexer, allow_fill=None, fill_value=None): """ Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow...
[ "def", "take_nd", "(", "self", ",", "indexer", ",", "allow_fill", "=", "None", ",", "fill_value", "=", "None", ")", ":", "indexer", "=", "np", ".", "asarray", "(", "indexer", ",", "dtype", "=", "np", ".", "intp", ")", "if", "allow_fill", "is", "None"...
Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow_fill`. allow_fill : bool, default None How to handle negative...
[ "Take", "elements", "from", "the", "Categorical", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1792-L1889
19,821
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._slice
def _slice(self, slicer): """ Return a slice of myself. For internal compatibility with numpy arrays. """ # only allow 1 dimensional slicing, but can # in a 2-d case be passd (slice(None),....) if isinstance(slicer, tuple) and len(slicer) == 2: if no...
python
def _slice(self, slicer): """ Return a slice of myself. For internal compatibility with numpy arrays. """ # only allow 1 dimensional slicing, but can # in a 2-d case be passd (slice(None),....) if isinstance(slicer, tuple) and len(slicer) == 2: if no...
[ "def", "_slice", "(", "self", ",", "slicer", ")", ":", "# only allow 1 dimensional slicing, but can", "# in a 2-d case be passd (slice(None),....)", "if", "isinstance", "(", "slicer", ",", "tuple", ")", "and", "len", "(", "slicer", ")", "==", "2", ":", "if", "not"...
Return a slice of myself. For internal compatibility with numpy arrays.
[ "Return", "a", "slice", "of", "myself", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1893-L1909
19,822
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._repr_categories
def _repr_categories(self): """ return the base repr for the categories """ max_categories = (10 if get_option("display.max_categories") == 0 else get_option("display.max_categories")) from pandas.io.formats import format as fmt if len(self.categ...
python
def _repr_categories(self): """ return the base repr for the categories """ max_categories = (10 if get_option("display.max_categories") == 0 else get_option("display.max_categories")) from pandas.io.formats import format as fmt if len(self.categ...
[ "def", "_repr_categories", "(", "self", ")", ":", "max_categories", "=", "(", "10", "if", "get_option", "(", "\"display.max_categories\"", ")", "==", "0", "else", "get_option", "(", "\"display.max_categories\"", ")", ")", "from", "pandas", ".", "io", ".", "for...
return the base repr for the categories
[ "return", "the", "base", "repr", "for", "the", "categories" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1948-L1965
19,823
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._repr_categories_info
def _repr_categories_info(self): """ Returns a string representation of the footer. """ category_strs = self._repr_categories() dtype = getattr(self.categories, 'dtype_str', str(self.categories.dtype)) levheader = "Categories ({length}, {dtype}):...
python
def _repr_categories_info(self): """ Returns a string representation of the footer. """ category_strs = self._repr_categories() dtype = getattr(self.categories, 'dtype_str', str(self.categories.dtype)) levheader = "Categories ({length}, {dtype}):...
[ "def", "_repr_categories_info", "(", "self", ")", ":", "category_strs", "=", "self", ".", "_repr_categories", "(", ")", "dtype", "=", "getattr", "(", "self", ".", "categories", ",", "'dtype_str'", ",", "str", "(", "self", ".", "categories", ".", "dtype", "...
Returns a string representation of the footer.
[ "Returns", "a", "string", "representation", "of", "the", "footer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1967-L1998
19,824
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._maybe_coerce_indexer
def _maybe_coerce_indexer(self, indexer): """ return an indexer coerced to the codes dtype """ if isinstance(indexer, np.ndarray) and indexer.dtype.kind == 'i': indexer = indexer.astype(self._codes.dtype) return indexer
python
def _maybe_coerce_indexer(self, indexer): """ return an indexer coerced to the codes dtype """ if isinstance(indexer, np.ndarray) and indexer.dtype.kind == 'i': indexer = indexer.astype(self._codes.dtype) return indexer
[ "def", "_maybe_coerce_indexer", "(", "self", ",", "indexer", ")", ":", "if", "isinstance", "(", "indexer", ",", "np", ".", "ndarray", ")", "and", "indexer", ".", "dtype", ".", "kind", "==", "'i'", ":", "indexer", "=", "indexer", ".", "astype", "(", "se...
return an indexer coerced to the codes dtype
[ "return", "an", "indexer", "coerced", "to", "the", "codes", "dtype" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2031-L2037
19,825
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical._reverse_indexer
def _reverse_indexer(self): """ Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(li...
python
def _reverse_indexer(self): """ Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(li...
[ "def", "_reverse_indexer", "(", "self", ")", ":", "categories", "=", "self", ".", "categories", "r", ",", "counts", "=", "libalgos", ".", "groupsort_indexer", "(", "self", ".", "codes", ".", "astype", "(", "'int64'", ")", ",", "categories", ".", "size", ...
Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(list('aabca')) In [2]: c Out[2]: ...
[ "Compute", "the", "inverse", "of", "a", "categorical", "returning", "a", "dict", "of", "categories", "-", ">", "indexers", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2119-L2155
19,826
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.min
def min(self, numeric_only=None, **kwargs): """ The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Ca...
python
def min(self, numeric_only=None, **kwargs): """ The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Ca...
[ "def", "min", "(", "self", ",", "numeric_only", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "check_for_ordered", "(", "'min'", ")", "if", "numeric_only", ":", "good", "=", "self", ".", "_codes", "!=", "-", "1", "pointer", "=", "self"...
The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Categorical`
[ "The", "minimum", "value", "of", "the", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2165-L2189
19,827
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.unique
def unique(self): """ Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, ca...
python
def unique(self): """ Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, ca...
[ "def", "unique", "(", "self", ")", ":", "# unlike np.unique, unique1d does not sort", "unique_codes", "=", "unique1d", "(", "self", ".", "codes", ")", "cat", "=", "self", ".", "copy", "(", ")", "# keep nan in codes", "cat", ".", "_codes", "=", "unique_codes", ...
Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, categories keeps existing orde...
[ "Return", "the", "Categorical", "which", "categories", "and", "codes", "are", "unique", ".", "Unused", "categories", "are", "NOT", "returned", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2243-L2297
19,828
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.equals
def equals(self, other): """ Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool """ if self.is_dtype_equal(other): if self.categories.equals(other.categories): ...
python
def equals(self, other): """ Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool """ if self.is_dtype_equal(other): if self.categories.equals(other.categories): ...
[ "def", "equals", "(", "self", ",", "other", ")", ":", "if", "self", ".", "is_dtype_equal", "(", "other", ")", ":", "if", "self", ".", "categories", ".", "equals", "(", "other", ".", "categories", ")", ":", "# fastpath to avoid re-coding", "other_codes", "=...
Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool
[ "Returns", "True", "if", "categorical", "arrays", "are", "equal", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2308-L2329
19,829
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.is_dtype_equal
def is_dtype_equal(self, other): """ Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool """ try: return hash(self.dtype) ...
python
def is_dtype_equal(self, other): """ Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool """ try: return hash(self.dtype) ...
[ "def", "is_dtype_equal", "(", "self", ",", "other", ")", ":", "try", ":", "return", "hash", "(", "self", ".", "dtype", ")", "==", "hash", "(", "other", ".", "dtype", ")", "except", "(", "AttributeError", ",", "TypeError", ")", ":", "return", "False" ]
Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool
[ "Returns", "True", "if", "categoricals", "are", "the", "same", "dtype", "same", "categories", "and", "same", "ordered" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2331-L2348
19,830
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.describe
def describe(self): """ Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category. """ counts = self.value_counts(dropna=False) freqs = counts / float(counts.sum()) from pand...
python
def describe(self): """ Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category. """ counts = self.value_counts(dropna=False) freqs = counts / float(counts.sum()) from pand...
[ "def", "describe", "(", "self", ")", ":", "counts", "=", "self", ".", "value_counts", "(", "dropna", "=", "False", ")", "freqs", "=", "counts", "/", "float", "(", "counts", ".", "sum", "(", ")", ")", "from", "pandas", ".", "core", ".", "reshape", "...
Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category.
[ "Describes", "this", "Categorical" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2350-L2367
19,831
pandas-dev/pandas
pandas/core/arrays/categorical.py
Categorical.isin
def isin(self, values): """ Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : se...
python
def isin(self, values): """ Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : se...
[ "def", "isin", "(", "self", ",", "values", ")", ":", "from", "pandas", ".", "core", ".", "internals", ".", "construction", "import", "sanitize_array", "if", "not", "is_list_like", "(", "values", ")", ":", "raise", "TypeError", "(", "\"only list-like objects ar...
Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : set or list-like The sequence of v...
[ "Check", "whether", "values", "are", "contained", "in", "Categorical", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2387-L2438
19,832
pandas-dev/pandas
pandas/core/tools/timedeltas.py
to_timedelta
def to_timedelta(arg, unit='ns', box=True, errors='raise'): """ Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Tim...
python
def to_timedelta(arg, unit='ns', box=True, errors='raise'): """ Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Tim...
[ "def", "to_timedelta", "(", "arg", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ")", ":", "unit", "=", "parse_timedelta_unit", "(", "unit", ")", "if", "errors", "not", "in", "(", "'ignore'", ",", "'raise'", ",", "...
Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Timedelta type. Parameters ---------- arg : str, timedelta, li...
[ "Convert", "argument", "to", "timedelta", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L20-L128
19,833
pandas-dev/pandas
pandas/core/tools/timedeltas.py
_coerce_scalar_to_timedelta_type
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'): """Convert string 'r' to a timedelta object.""" try: result = Timedelta(r, unit) if not box: # explicitly view as timedelta64 for case when result is pd.NaT result = result.asm8.view('timedelta...
python
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'): """Convert string 'r' to a timedelta object.""" try: result = Timedelta(r, unit) if not box: # explicitly view as timedelta64 for case when result is pd.NaT result = result.asm8.view('timedelta...
[ "def", "_coerce_scalar_to_timedelta_type", "(", "r", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ")", ":", "try", ":", "result", "=", "Timedelta", "(", "r", ",", "unit", ")", "if", "not", "box", ":", "# explicitly ...
Convert string 'r' to a timedelta object.
[ "Convert", "string", "r", "to", "a", "timedelta", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L131-L148
19,834
pandas-dev/pandas
pandas/core/tools/timedeltas.py
_convert_listlike
def _convert_listlike(arg, unit='ns', box=True, errors='raise', name=None): """Convert a list of objects to a timedelta index object.""" if isinstance(arg, (list, tuple)) or not hasattr(arg, 'dtype'): # This is needed only to ensure that in the case where we end up # returning arg (errors == "...
python
def _convert_listlike(arg, unit='ns', box=True, errors='raise', name=None): """Convert a list of objects to a timedelta index object.""" if isinstance(arg, (list, tuple)) or not hasattr(arg, 'dtype'): # This is needed only to ensure that in the case where we end up # returning arg (errors == "...
[ "def", "_convert_listlike", "(", "arg", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ",", "name", "=", "None", ")", ":", "if", "isinstance", "(", "arg", ",", "(", "list", ",", "tuple", ")", ")", "or", "not", "...
Convert a list of objects to a timedelta index object.
[ "Convert", "a", "list", "of", "objects", "to", "a", "timedelta", "index", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L151-L180
19,835
pandas-dev/pandas
pandas/tseries/offsets.py
generate_range
def generate_range(start=None, end=None, periods=None, offset=BDay()): """ Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default ...
python
def generate_range(start=None, end=None, periods=None, offset=BDay()): """ Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default ...
[ "def", "generate_range", "(", "start", "=", "None", ",", "end", "=", "None", ",", "periods", "=", "None", ",", "offset", "=", "BDay", "(", ")", ")", ":", "from", "pandas", ".", "tseries", ".", "frequencies", "import", "to_offset", "offset", "=", "to_of...
Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default None) end : datetime (default None) periods : int, (default None) offse...
[ "Generates", "a", "sequence", "of", "dates", "corresponding", "to", "the", "specified", "time", "offset", ".", "Similar", "to", "dateutil", ".", "rrule", "except", "uses", "pandas", "DateOffset", "objects", "to", "represent", "time", "increments", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L2412-L2478
19,836
pandas-dev/pandas
pandas/tseries/offsets.py
DateOffset.apply_index
def apply_index(self, i): """ Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex """...
python
def apply_index(self, i): """ Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex """...
[ "def", "apply_index", "(", "self", ",", "i", ")", ":", "if", "type", "(", "self", ")", "is", "not", "DateOffset", ":", "raise", "NotImplementedError", "(", "\"DateOffset subclass {name} \"", "\"does not have a vectorized \"", "\"implementation\"", ".", "format", "("...
Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex
[ "Vectorized", "apply", "of", "DateOffset", "to", "DatetimeIndex", "raises", "NotImplentedError", "for", "offsets", "without", "a", "vectorized", "implementation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L245-L304
19,837
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin.next_bday
def next_bday(self): """ Used for moving to next business day. """ if self.n >= 0: nb_offset = 1 else: nb_offset = -1 if self._prefix.startswith('C'): # CustomBusinessHour return CustomBusinessDay(n=nb_offset, ...
python
def next_bday(self): """ Used for moving to next business day. """ if self.n >= 0: nb_offset = 1 else: nb_offset = -1 if self._prefix.startswith('C'): # CustomBusinessHour return CustomBusinessDay(n=nb_offset, ...
[ "def", "next_bday", "(", "self", ")", ":", "if", "self", ".", "n", ">=", "0", ":", "nb_offset", "=", "1", "else", ":", "nb_offset", "=", "-", "1", "if", "self", ".", "_prefix", ".", "startswith", "(", "'C'", ")", ":", "# CustomBusinessHour", "return"...
Used for moving to next business day.
[ "Used", "for", "moving", "to", "next", "business", "day", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L579-L594
19,838
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin._next_opening_time
def _next_opening_time(self, other): """ If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight. ...
python
def _next_opening_time(self, other): """ If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight. ...
[ "def", "_next_opening_time", "(", "self", ",", "other", ")", ":", "if", "not", "self", ".", "next_bday", ".", "onOffset", "(", "other", ")", ":", "other", "=", "other", "+", "self", ".", "next_bday", "else", ":", "if", "self", ".", "n", ">=", "0", ...
If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight.
[ "If", "n", "is", "positive", "return", "tomorrow", "s", "business", "day", "opening", "time", ".", "Otherwise", "yesterday", "s", "business", "day", "s", "opening", "time", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L605-L621
19,839
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin._get_business_hours_by_sec
def _get_business_hours_by_sec(self): """ Return business hours in a day by seconds. """ if self._get_daytime_flag: # create dummy datetime to calculate businesshours in a day dtstart = datetime(2014, 4, 1, self.start.hour, self.start.minute) until = d...
python
def _get_business_hours_by_sec(self): """ Return business hours in a day by seconds. """ if self._get_daytime_flag: # create dummy datetime to calculate businesshours in a day dtstart = datetime(2014, 4, 1, self.start.hour, self.start.minute) until = d...
[ "def", "_get_business_hours_by_sec", "(", "self", ")", ":", "if", "self", ".", "_get_daytime_flag", ":", "# create dummy datetime to calculate businesshours in a day", "dtstart", "=", "datetime", "(", "2014", ",", "4", ",", "1", ",", "self", ".", "start", ".", "ho...
Return business hours in a day by seconds.
[ "Return", "business", "hours", "in", "a", "day", "by", "seconds", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L639-L651
19,840
pandas-dev/pandas
pandas/tseries/offsets.py
BusinessHourMixin._onOffset
def _onOffset(self, dt, businesshours): """ Slight speedups using calculated values. """ # if self.normalize and not _is_normalized(dt): # return False # Valid BH can be on the different BusinessDay during midnight # Distinguish by the time spent from previous...
python
def _onOffset(self, dt, businesshours): """ Slight speedups using calculated values. """ # if self.normalize and not _is_normalized(dt): # return False # Valid BH can be on the different BusinessDay during midnight # Distinguish by the time spent from previous...
[ "def", "_onOffset", "(", "self", ",", "dt", ",", "businesshours", ")", ":", "# if self.normalize and not _is_normalized(dt):", "# return False", "# Valid BH can be on the different BusinessDay during midnight", "# Distinguish by the time spent from previous opening time", "if", "se...
Slight speedups using calculated values.
[ "Slight", "speedups", "using", "calculated", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L767-L783
19,841
pandas-dev/pandas
pandas/tseries/offsets.py
SemiMonthBegin._apply_index_days
def _apply_index_days(self, i, roll): """ Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex """ nanos = (roll % 2) * Timedelta(day...
python
def _apply_index_days(self, i, roll): """ Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex """ nanos = (roll % 2) * Timedelta(day...
[ "def", "_apply_index_days", "(", "self", ",", "i", ",", "roll", ")", ":", "nanos", "=", "(", "roll", "%", "2", ")", "*", "Timedelta", "(", "days", "=", "self", ".", "day_of_month", "-", "1", ")", ".", "value", "return", "i", "+", "nanos", ".", "a...
Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex
[ "Add", "days", "portion", "of", "offset", "to", "DatetimeIndex", "i", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1279-L1293
19,842
pandas-dev/pandas
pandas/tseries/offsets.py
Week._end_apply_index
def _end_apply_index(self, dtindex): """ Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex """ off = dtin...
python
def _end_apply_index(self, dtindex): """ Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex """ off = dtin...
[ "def", "_end_apply_index", "(", "self", ",", "dtindex", ")", ":", "off", "=", "dtindex", ".", "to_perioddelta", "(", "'D'", ")", "base", ",", "mult", "=", "libfrequencies", ".", "get_freq_code", "(", "self", ".", "freqstr", ")", "base_period", "=", "dtinde...
Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex
[ "Add", "self", "to", "the", "given", "DatetimeIndex", "specialized", "for", "case", "where", "self", ".", "weekday", "is", "non", "-", "null", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1354-L1390
19,843
pandas-dev/pandas
pandas/tseries/offsets.py
WeekOfMonth._get_offset_day
def _get_offset_day(self, other): """ Find the day in the same month as other that has the same weekday as self.weekday and is the self.week'th such day in the month. Parameters ---------- other : datetime Returns ------- day : int """ ...
python
def _get_offset_day(self, other): """ Find the day in the same month as other that has the same weekday as self.weekday and is the self.week'th such day in the month. Parameters ---------- other : datetime Returns ------- day : int """ ...
[ "def", "_get_offset_day", "(", "self", ",", "other", ")", ":", "mstart", "=", "datetime", "(", "other", ".", "year", ",", "other", ".", "month", ",", "1", ")", "wday", "=", "mstart", ".", "weekday", "(", ")", "shift_days", "=", "(", "self", ".", "w...
Find the day in the same month as other that has the same weekday as self.weekday and is the self.week'th such day in the month. Parameters ---------- other : datetime Returns ------- day : int
[ "Find", "the", "day", "in", "the", "same", "month", "as", "other", "that", "has", "the", "same", "weekday", "as", "self", ".", "weekday", "and", "is", "the", "self", ".", "week", "th", "such", "day", "in", "the", "month", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1474-L1490
19,844
pandas-dev/pandas
pandas/tseries/offsets.py
LastWeekOfMonth._get_offset_day
def _get_offset_day(self, other): """ Find the day in the same month as other that has the same weekday as self.weekday and is the last such day in the month. Parameters ---------- other: datetime Returns ------- day: int """ dim ...
python
def _get_offset_day(self, other): """ Find the day in the same month as other that has the same weekday as self.weekday and is the last such day in the month. Parameters ---------- other: datetime Returns ------- day: int """ dim ...
[ "def", "_get_offset_day", "(", "self", ",", "other", ")", ":", "dim", "=", "ccalendar", ".", "get_days_in_month", "(", "other", ".", "year", ",", "other", ".", "month", ")", "mend", "=", "datetime", "(", "other", ".", "year", ",", "other", ".", "month"...
Find the day in the same month as other that has the same weekday as self.weekday and is the last such day in the month. Parameters ---------- other: datetime Returns ------- day: int
[ "Find", "the", "day", "in", "the", "same", "month", "as", "other", "that", "has", "the", "same", "weekday", "as", "self", ".", "weekday", "and", "is", "the", "last", "such", "day", "in", "the", "month", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L1543-L1560
19,845
pandas-dev/pandas
pandas/tseries/offsets.py
FY5253Quarter._rollback_to_year
def _rollback_to_year(self, other): """ Roll `other` back to the most recent date that was on a fiscal year end. Return the date of that year-end, the number of full quarters elapsed between that year-end and other, and the remaining Timedelta since the most recent quart...
python
def _rollback_to_year(self, other): """ Roll `other` back to the most recent date that was on a fiscal year end. Return the date of that year-end, the number of full quarters elapsed between that year-end and other, and the remaining Timedelta since the most recent quart...
[ "def", "_rollback_to_year", "(", "self", ",", "other", ")", ":", "num_qtrs", "=", "0", "norm", "=", "Timestamp", "(", "other", ")", ".", "tz_localize", "(", "None", ")", "start", "=", "self", ".", "_offset", ".", "rollback", "(", "norm", ")", "# Note: ...
Roll `other` back to the most recent date that was on a fiscal year end. Return the date of that year-end, the number of full quarters elapsed between that year-end and other, and the remaining Timedelta since the most recent quarter-end. Parameters ---------- o...
[ "Roll", "other", "back", "to", "the", "most", "recent", "date", "that", "was", "on", "a", "fiscal", "year", "end", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L2054-L2099
19,846
pandas-dev/pandas
pandas/core/reshape/concat.py
concat
def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, sort=None, copy=True): """ Concatenate pandas objects along a particular axis with optional set logic along the other axes. Can also add a layer o...
python
def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, sort=None, copy=True): """ Concatenate pandas objects along a particular axis with optional set logic along the other axes. Can also add a layer o...
[ "def", "concat", "(", "objs", ",", "axis", "=", "0", ",", "join", "=", "'outer'", ",", "join_axes", "=", "None", ",", "ignore_index", "=", "False", ",", "keys", "=", "None", ",", "levels", "=", "None", ",", "names", "=", "None", ",", "verify_integrit...
Concatenate pandas objects along a particular axis with optional set logic along the other axes. Can also add a layer of hierarchical indexing on the concatenation axis, which may be useful if the labels are the same (or overlapping) on the passed axis number. Parameters ---------- objs : ...
[ "Concatenate", "pandas", "objects", "along", "a", "particular", "axis", "with", "optional", "set", "logic", "along", "the", "other", "axes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/concat.py#L24-L229
19,847
pandas-dev/pandas
pandas/core/reshape/concat.py
_Concatenator._get_concat_axis
def _get_concat_axis(self): """ Return index to be used along concatenation axis. """ if self._is_series: if self.axis == 0: indexes = [x.index for x in self.objs] elif self.ignore_index: idx = ibase.default_index(len(self.objs)) ...
python
def _get_concat_axis(self): """ Return index to be used along concatenation axis. """ if self._is_series: if self.axis == 0: indexes = [x.index for x in self.objs] elif self.ignore_index: idx = ibase.default_index(len(self.objs)) ...
[ "def", "_get_concat_axis", "(", "self", ")", ":", "if", "self", ".", "_is_series", ":", "if", "self", ".", "axis", "==", "0", ":", "indexes", "=", "[", "x", ".", "index", "for", "x", "in", "self", ".", "objs", "]", "elif", "self", ".", "ignore_inde...
Return index to be used along concatenation axis.
[ "Return", "index", "to", "be", "used", "along", "concatenation", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/concat.py#L475-L521
19,848
pandas-dev/pandas
pandas/core/computation/ops.py
_in
def _in(x, y): """Compute the vectorized membership of ``x in y`` if possible, otherwise use Python. """ try: return x.isin(y) except AttributeError: if is_list_like(x): try: return y.isin(x) except AttributeError: pass ...
python
def _in(x, y): """Compute the vectorized membership of ``x in y`` if possible, otherwise use Python. """ try: return x.isin(y) except AttributeError: if is_list_like(x): try: return y.isin(x) except AttributeError: pass ...
[ "def", "_in", "(", "x", ",", "y", ")", ":", "try", ":", "return", "x", ".", "isin", "(", "y", ")", "except", "AttributeError", ":", "if", "is_list_like", "(", "x", ")", ":", "try", ":", "return", "y", ".", "isin", "(", "x", ")", "except", "Attr...
Compute the vectorized membership of ``x in y`` if possible, otherwise use Python.
[ "Compute", "the", "vectorized", "membership", "of", "x", "in", "y", "if", "possible", "otherwise", "use", "Python", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L234-L246
19,849
pandas-dev/pandas
pandas/core/computation/ops.py
_not_in
def _not_in(x, y): """Compute the vectorized membership of ``x not in y`` if possible, otherwise use Python. """ try: return ~x.isin(y) except AttributeError: if is_list_like(x): try: return ~y.isin(x) except AttributeError: pas...
python
def _not_in(x, y): """Compute the vectorized membership of ``x not in y`` if possible, otherwise use Python. """ try: return ~x.isin(y) except AttributeError: if is_list_like(x): try: return ~y.isin(x) except AttributeError: pas...
[ "def", "_not_in", "(", "x", ",", "y", ")", ":", "try", ":", "return", "~", "x", ".", "isin", "(", "y", ")", "except", "AttributeError", ":", "if", "is_list_like", "(", "x", ")", ":", "try", ":", "return", "~", "y", ".", "isin", "(", "x", ")", ...
Compute the vectorized membership of ``x not in y`` if possible, otherwise use Python.
[ "Compute", "the", "vectorized", "membership", "of", "x", "not", "in", "y", "if", "possible", "otherwise", "use", "Python", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L249-L261
19,850
pandas-dev/pandas
pandas/core/computation/ops.py
_cast_inplace
def _cast_inplace(terms, acceptable_dtypes, dtype): """Cast an expression inplace. Parameters ---------- terms : Op The expression that should cast. acceptable_dtypes : list of acceptable numpy.dtype Will not cast if term's dtype in this list. .. versionadded:: 0.19.0 ...
python
def _cast_inplace(terms, acceptable_dtypes, dtype): """Cast an expression inplace. Parameters ---------- terms : Op The expression that should cast. acceptable_dtypes : list of acceptable numpy.dtype Will not cast if term's dtype in this list. .. versionadded:: 0.19.0 ...
[ "def", "_cast_inplace", "(", "terms", ",", "acceptable_dtypes", ",", "dtype", ")", ":", "dt", "=", "np", ".", "dtype", "(", "dtype", ")", "for", "term", "in", "terms", ":", "if", "term", ".", "type", "in", "acceptable_dtypes", ":", "continue", "try", "...
Cast an expression inplace. Parameters ---------- terms : Op The expression that should cast. acceptable_dtypes : list of acceptable numpy.dtype Will not cast if term's dtype in this list. .. versionadded:: 0.19.0 dtype : str or numpy.dtype The dtype to cast to.
[ "Cast", "an", "expression", "inplace", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L288-L312
19,851
pandas-dev/pandas
pandas/core/computation/ops.py
BinOp.convert_values
def convert_values(self): """Convert datetimes to a comparable value in an expression. """ def stringify(value): if self.encoding is not None: encoder = partial(pprint_thing_encoded, encoding=self.encoding) else: ...
python
def convert_values(self): """Convert datetimes to a comparable value in an expression. """ def stringify(value): if self.encoding is not None: encoder = partial(pprint_thing_encoded, encoding=self.encoding) else: ...
[ "def", "convert_values", "(", "self", ")", ":", "def", "stringify", "(", "value", ")", ":", "if", "self", ".", "encoding", "is", "not", "None", ":", "encoder", "=", "partial", "(", "pprint_thing_encoded", ",", "encoding", "=", "self", ".", "encoding", ")...
Convert datetimes to a comparable value in an expression.
[ "Convert", "datetimes", "to", "a", "comparable", "value", "in", "an", "expression", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/ops.py#L407-L436
19,852
pandas-dev/pandas
pandas/util/_doctools.py
TablePlotter._shape
def _shape(self, df): """ Calculate table chape considering index levels. """ row, col = df.shape return row + df.columns.nlevels, col + df.index.nlevels
python
def _shape(self, df): """ Calculate table chape considering index levels. """ row, col = df.shape return row + df.columns.nlevels, col + df.index.nlevels
[ "def", "_shape", "(", "self", ",", "df", ")", ":", "row", ",", "col", "=", "df", ".", "shape", "return", "row", "+", "df", ".", "columns", ".", "nlevels", ",", "col", "+", "df", ".", "index", ".", "nlevels" ]
Calculate table chape considering index levels.
[ "Calculate", "table", "chape", "considering", "index", "levels", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L17-L23
19,853
pandas-dev/pandas
pandas/util/_doctools.py
TablePlotter._get_cells
def _get_cells(self, left, right, vertical): """ Calculate appropriate figure size based on left and right data. """ if vertical: # calculate required number of cells vcells = max(sum(self._shape(l)[0] for l in left), self._shape(right)[0...
python
def _get_cells(self, left, right, vertical): """ Calculate appropriate figure size based on left and right data. """ if vertical: # calculate required number of cells vcells = max(sum(self._shape(l)[0] for l in left), self._shape(right)[0...
[ "def", "_get_cells", "(", "self", ",", "left", ",", "right", ",", "vertical", ")", ":", "if", "vertical", ":", "# calculate required number of cells", "vcells", "=", "max", "(", "sum", "(", "self", ".", "_shape", "(", "l", ")", "[", "0", "]", "for", "l...
Calculate appropriate figure size based on left and right data.
[ "Calculate", "appropriate", "figure", "size", "based", "on", "left", "and", "right", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L25-L41
19,854
pandas-dev/pandas
pandas/util/_doctools.py
TablePlotter._conv
def _conv(self, data): """Convert each input to appropriate for table outplot""" if isinstance(data, pd.Series): if data.name is None: data = data.to_frame(name='') else: data = data.to_frame() data = data.fillna('NaN') return data
python
def _conv(self, data): """Convert each input to appropriate for table outplot""" if isinstance(data, pd.Series): if data.name is None: data = data.to_frame(name='') else: data = data.to_frame() data = data.fillna('NaN') return data
[ "def", "_conv", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "pd", ".", "Series", ")", ":", "if", "data", ".", "name", "is", "None", ":", "data", "=", "data", ".", "to_frame", "(", "name", "=", "''", ")", "else", ":...
Convert each input to appropriate for table outplot
[ "Convert", "each", "input", "to", "appropriate", "for", "table", "outplot" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_doctools.py#L103-L111
19,855
pandas-dev/pandas
pandas/core/reshape/tile.py
cut
def cut(x, bins, right=True, labels=None, retbins=False, precision=3, include_lowest=False, duplicates='raise'): """ Bin values into discrete intervals. Use `cut` when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a ...
python
def cut(x, bins, right=True, labels=None, retbins=False, precision=3, include_lowest=False, duplicates='raise'): """ Bin values into discrete intervals. Use `cut` when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a ...
[ "def", "cut", "(", "x", ",", "bins", ",", "right", "=", "True", ",", "labels", "=", "None", ",", "retbins", "=", "False", ",", "precision", "=", "3", ",", "include_lowest", "=", "False", ",", "duplicates", "=", "'raise'", ")", ":", "# NOTE: this binnin...
Bin values into discrete intervals. Use `cut` when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a categorical variable. For example, `cut` could convert ages to groups of age ranges. Supports binning into an equal number of bin...
[ "Bin", "values", "into", "discrete", "intervals", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L23-L245
19,856
pandas-dev/pandas
pandas/core/reshape/tile.py
qcut
def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'): """ Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating qua...
python
def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'): """ Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating qua...
[ "def", "qcut", "(", "x", ",", "q", ",", "labels", "=", "None", ",", "retbins", "=", "False", ",", "precision", "=", "3", ",", "duplicates", "=", "'raise'", ")", ":", "x_is_series", ",", "series_index", ",", "name", ",", "x", "=", "_preprocess_for_cut",...
Quantile-based discretization function. Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating quantile membership for each data point. Parameters ---------- x : 1d ndarray o...
[ "Quantile", "-", "based", "discretization", "function", ".", "Discretize", "variable", "into", "equal", "-", "sized", "buckets", "based", "on", "rank", "or", "based", "on", "sample", "quantiles", ".", "For", "example", "1000", "values", "for", "10", "quantiles...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L248-L317
19,857
pandas-dev/pandas
pandas/core/reshape/tile.py
_convert_bin_to_datelike_type
def _convert_bin_to_datelike_type(bins, dtype): """ Convert bins to a DatetimeIndex or TimedeltaIndex if the orginal dtype is datelike Parameters ---------- bins : list-like of bins dtype : dtype of data Returns ------- bins : Array-like of bins, DatetimeIndex or TimedeltaIndex...
python
def _convert_bin_to_datelike_type(bins, dtype): """ Convert bins to a DatetimeIndex or TimedeltaIndex if the orginal dtype is datelike Parameters ---------- bins : list-like of bins dtype : dtype of data Returns ------- bins : Array-like of bins, DatetimeIndex or TimedeltaIndex...
[ "def", "_convert_bin_to_datelike_type", "(", "bins", ",", "dtype", ")", ":", "if", "is_datetime64tz_dtype", "(", "dtype", ")", ":", "bins", "=", "to_datetime", "(", "bins", ".", "astype", "(", "np", ".", "int64", ")", ",", "utc", "=", "True", ")", ".", ...
Convert bins to a DatetimeIndex or TimedeltaIndex if the orginal dtype is datelike Parameters ---------- bins : list-like of bins dtype : dtype of data Returns ------- bins : Array-like of bins, DatetimeIndex or TimedeltaIndex if dtype is datelike
[ "Convert", "bins", "to", "a", "DatetimeIndex", "or", "TimedeltaIndex", "if", "the", "orginal", "dtype", "is", "datelike" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L430-L450
19,858
pandas-dev/pandas
pandas/core/reshape/tile.py
_format_labels
def _format_labels(bins, precision, right=True, include_lowest=False, dtype=None): """ based on the dtype, return our labels """ closed = 'right' if right else 'left' if is_datetime64tz_dtype(dtype): formatter = partial(Timestamp, tz=dtype.tz) adjust = lambda x: x - Time...
python
def _format_labels(bins, precision, right=True, include_lowest=False, dtype=None): """ based on the dtype, return our labels """ closed = 'right' if right else 'left' if is_datetime64tz_dtype(dtype): formatter = partial(Timestamp, tz=dtype.tz) adjust = lambda x: x - Time...
[ "def", "_format_labels", "(", "bins", ",", "precision", ",", "right", "=", "True", ",", "include_lowest", "=", "False", ",", "dtype", "=", "None", ")", ":", "closed", "=", "'right'", "if", "right", "else", "'left'", "if", "is_datetime64tz_dtype", "(", "dty...
based on the dtype, return our labels
[ "based", "on", "the", "dtype", "return", "our", "labels" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L453-L484
19,859
pandas-dev/pandas
pandas/core/reshape/tile.py
_preprocess_for_cut
def _preprocess_for_cut(x): """ handles preprocessing for cut where we convert passed input to array, strip the index information and store it separately """ x_is_series = isinstance(x, Series) series_index = None name = None if x_is_series: series_index = x.index na...
python
def _preprocess_for_cut(x): """ handles preprocessing for cut where we convert passed input to array, strip the index information and store it separately """ x_is_series = isinstance(x, Series) series_index = None name = None if x_is_series: series_index = x.index na...
[ "def", "_preprocess_for_cut", "(", "x", ")", ":", "x_is_series", "=", "isinstance", "(", "x", ",", "Series", ")", "series_index", "=", "None", "name", "=", "None", "if", "x_is_series", ":", "series_index", "=", "x", ".", "index", "name", "=", "x", ".", ...
handles preprocessing for cut where we convert passed input to array, strip the index information and store it separately
[ "handles", "preprocessing", "for", "cut", "where", "we", "convert", "passed", "input", "to", "array", "strip", "the", "index", "information", "and", "store", "it", "separately" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L487-L509
19,860
pandas-dev/pandas
pandas/core/reshape/tile.py
_postprocess_for_cut
def _postprocess_for_cut(fac, bins, retbins, x_is_series, series_index, name, dtype): """ handles post processing for the cut method where we combine the index information if the originally passed datatype was a series """ if x_is_series: fac = Series(fac, index=...
python
def _postprocess_for_cut(fac, bins, retbins, x_is_series, series_index, name, dtype): """ handles post processing for the cut method where we combine the index information if the originally passed datatype was a series """ if x_is_series: fac = Series(fac, index=...
[ "def", "_postprocess_for_cut", "(", "fac", ",", "bins", ",", "retbins", ",", "x_is_series", ",", "series_index", ",", "name", ",", "dtype", ")", ":", "if", "x_is_series", ":", "fac", "=", "Series", "(", "fac", ",", "index", "=", "series_index", ",", "nam...
handles post processing for the cut method where we combine the index information if the originally passed datatype was a series
[ "handles", "post", "processing", "for", "the", "cut", "method", "where", "we", "combine", "the", "index", "information", "if", "the", "originally", "passed", "datatype", "was", "a", "series" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L512-L527
19,861
pandas-dev/pandas
pandas/core/reshape/tile.py
_round_frac
def _round_frac(x, precision): """ Round the fractional part of the given number """ if not np.isfinite(x) or x == 0: return x else: frac, whole = np.modf(x) if whole == 0: digits = -int(np.floor(np.log10(abs(frac)))) - 1 + precision else: digi...
python
def _round_frac(x, precision): """ Round the fractional part of the given number """ if not np.isfinite(x) or x == 0: return x else: frac, whole = np.modf(x) if whole == 0: digits = -int(np.floor(np.log10(abs(frac)))) - 1 + precision else: digi...
[ "def", "_round_frac", "(", "x", ",", "precision", ")", ":", "if", "not", "np", ".", "isfinite", "(", "x", ")", "or", "x", "==", "0", ":", "return", "x", "else", ":", "frac", ",", "whole", "=", "np", ".", "modf", "(", "x", ")", "if", "whole", ...
Round the fractional part of the given number
[ "Round", "the", "fractional", "part", "of", "the", "given", "number" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L530-L542
19,862
pandas-dev/pandas
pandas/core/reshape/tile.py
_infer_precision
def _infer_precision(base_precision, bins): """Infer an appropriate precision for _round_frac """ for precision in range(base_precision, 20): levels = [_round_frac(b, precision) for b in bins] if algos.unique(levels).size == bins.size: return precision return base_precision
python
def _infer_precision(base_precision, bins): """Infer an appropriate precision for _round_frac """ for precision in range(base_precision, 20): levels = [_round_frac(b, precision) for b in bins] if algos.unique(levels).size == bins.size: return precision return base_precision
[ "def", "_infer_precision", "(", "base_precision", ",", "bins", ")", ":", "for", "precision", "in", "range", "(", "base_precision", ",", "20", ")", ":", "levels", "=", "[", "_round_frac", "(", "b", ",", "precision", ")", "for", "b", "in", "bins", "]", "...
Infer an appropriate precision for _round_frac
[ "Infer", "an", "appropriate", "precision", "for", "_round_frac" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/tile.py#L545-L552
19,863
pandas-dev/pandas
pandas/_config/display.py
detect_console_encoding
def detect_console_encoding(): """ Try to find the most capable encoding supported by the console. slightly modified from the way IPython handles the same issue. """ global _initial_defencoding encoding = None try: encoding = sys.stdout.encoding or sys.stdin.encoding except (Att...
python
def detect_console_encoding(): """ Try to find the most capable encoding supported by the console. slightly modified from the way IPython handles the same issue. """ global _initial_defencoding encoding = None try: encoding = sys.stdout.encoding or sys.stdin.encoding except (Att...
[ "def", "detect_console_encoding", "(", ")", ":", "global", "_initial_defencoding", "encoding", "=", "None", "try", ":", "encoding", "=", "sys", ".", "stdout", ".", "encoding", "or", "sys", ".", "stdin", ".", "encoding", "except", "(", "AttributeError", ",", ...
Try to find the most capable encoding supported by the console. slightly modified from the way IPython handles the same issue.
[ "Try", "to", "find", "the", "most", "capable", "encoding", "supported", "by", "the", "console", ".", "slightly", "modified", "from", "the", "way", "IPython", "handles", "the", "same", "issue", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/display.py#L14-L43
19,864
pandas-dev/pandas
pandas/util/_validators.py
_check_arg_length
def _check_arg_length(fname, args, max_fname_arg_count, compat_args): """ Checks whether 'args' has length of at most 'compat_args'. Raises a TypeError if that is not the case, similar to in Python when a function is called with too many arguments. """ if max_fname_arg_count < 0: raise ...
python
def _check_arg_length(fname, args, max_fname_arg_count, compat_args): """ Checks whether 'args' has length of at most 'compat_args'. Raises a TypeError if that is not the case, similar to in Python when a function is called with too many arguments. """ if max_fname_arg_count < 0: raise ...
[ "def", "_check_arg_length", "(", "fname", ",", "args", ",", "max_fname_arg_count", ",", "compat_args", ")", ":", "if", "max_fname_arg_count", "<", "0", ":", "raise", "ValueError", "(", "\"'max_fname_arg_count' must be non-negative\"", ")", "if", "len", "(", "args", ...
Checks whether 'args' has length of at most 'compat_args'. Raises a TypeError if that is not the case, similar to in Python when a function is called with too many arguments.
[ "Checks", "whether", "args", "has", "length", "of", "at", "most", "compat_args", ".", "Raises", "a", "TypeError", "if", "that", "is", "not", "the", "case", "similar", "to", "in", "Python", "when", "a", "function", "is", "called", "with", "too", "many", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L10-L29
19,865
pandas-dev/pandas
pandas/util/_validators.py
_check_for_default_values
def _check_for_default_values(fname, arg_val_dict, compat_args): """ Check that the keys in `arg_val_dict` are mapped to their default values as specified in `compat_args`. Note that this function is to be called only when it has been checked that arg_val_dict.keys() is a subset of compat_args ...
python
def _check_for_default_values(fname, arg_val_dict, compat_args): """ Check that the keys in `arg_val_dict` are mapped to their default values as specified in `compat_args`. Note that this function is to be called only when it has been checked that arg_val_dict.keys() is a subset of compat_args ...
[ "def", "_check_for_default_values", "(", "fname", ",", "arg_val_dict", ",", "compat_args", ")", ":", "for", "key", "in", "arg_val_dict", ":", "# try checking equality directly with '=' operator,", "# as comparison may have been overridden for the left", "# hand object", "try", ...
Check that the keys in `arg_val_dict` are mapped to their default values as specified in `compat_args`. Note that this function is to be called only when it has been checked that arg_val_dict.keys() is a subset of compat_args
[ "Check", "that", "the", "keys", "in", "arg_val_dict", "are", "mapped", "to", "their", "default", "values", "as", "specified", "in", "compat_args", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L32-L69
19,866
pandas-dev/pandas
pandas/util/_validators.py
_check_for_invalid_keys
def _check_for_invalid_keys(fname, kwargs, compat_args): """ Checks whether 'kwargs' contains any keys that are not in 'compat_args' and raises a TypeError if there is one. """ # set(dict) --> set of the dictionary's keys diff = set(kwargs) - set(compat_args) if diff: bad_arg = lis...
python
def _check_for_invalid_keys(fname, kwargs, compat_args): """ Checks whether 'kwargs' contains any keys that are not in 'compat_args' and raises a TypeError if there is one. """ # set(dict) --> set of the dictionary's keys diff = set(kwargs) - set(compat_args) if diff: bad_arg = lis...
[ "def", "_check_for_invalid_keys", "(", "fname", ",", "kwargs", ",", "compat_args", ")", ":", "# set(dict) --> set of the dictionary's keys", "diff", "=", "set", "(", "kwargs", ")", "-", "set", "(", "compat_args", ")", "if", "diff", ":", "bad_arg", "=", "list", ...
Checks whether 'kwargs' contains any keys that are not in 'compat_args' and raises a TypeError if there is one.
[ "Checks", "whether", "kwargs", "contains", "any", "keys", "that", "are", "not", "in", "compat_args", "and", "raises", "a", "TypeError", "if", "there", "is", "one", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L114-L127
19,867
pandas-dev/pandas
pandas/util/_validators.py
validate_bool_kwarg
def validate_bool_kwarg(value, arg_name): """ Ensures that argument passed in arg_name is of type bool. """ if not (is_bool(value) or value is None): raise ValueError('For argument "{arg}" expected type bool, received ' 'type {typ}.'.format(arg=arg_name, ...
python
def validate_bool_kwarg(value, arg_name): """ Ensures that argument passed in arg_name is of type bool. """ if not (is_bool(value) or value is None): raise ValueError('For argument "{arg}" expected type bool, received ' 'type {typ}.'.format(arg=arg_name, ...
[ "def", "validate_bool_kwarg", "(", "value", ",", "arg_name", ")", ":", "if", "not", "(", "is_bool", "(", "value", ")", "or", "value", "is", "None", ")", ":", "raise", "ValueError", "(", "'For argument \"{arg}\" expected type bool, received '", "'type {typ}.'", "."...
Ensures that argument passed in arg_name is of type bool.
[ "Ensures", "that", "argument", "passed", "in", "arg_name", "is", "of", "type", "bool", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L221-L227
19,868
pandas-dev/pandas
pandas/util/_validators.py
validate_fillna_kwargs
def validate_fillna_kwargs(value, method, validate_scalar_dict_value=True): """Validate the keyword arguments to 'fillna'. This checks that exactly one of 'value' and 'method' is specified. If 'method' is specified, this validates that it's a valid method. Parameters ---------- value, method :...
python
def validate_fillna_kwargs(value, method, validate_scalar_dict_value=True): """Validate the keyword arguments to 'fillna'. This checks that exactly one of 'value' and 'method' is specified. If 'method' is specified, this validates that it's a valid method. Parameters ---------- value, method :...
[ "def", "validate_fillna_kwargs", "(", "value", ",", "method", ",", "validate_scalar_dict_value", "=", "True", ")", ":", "from", "pandas", ".", "core", ".", "missing", "import", "clean_fill_method", "if", "value", "is", "None", "and", "method", "is", "None", ":...
Validate the keyword arguments to 'fillna'. This checks that exactly one of 'value' and 'method' is specified. If 'method' is specified, this validates that it's a valid method. Parameters ---------- value, method : object The 'value' and 'method' keyword arguments for 'fillna'. valida...
[ "Validate", "the", "keyword", "arguments", "to", "fillna", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L325-L358
19,869
pandas-dev/pandas
pandas/core/resample.py
_maybe_process_deprecations
def _maybe_process_deprecations(r, how=None, fill_method=None, limit=None): """ Potentially we might have a deprecation warning, show it but call the appropriate methods anyhow. """ if how is not None: # .resample(..., how='sum') if isinstance(how, str): method = "{0}()...
python
def _maybe_process_deprecations(r, how=None, fill_method=None, limit=None): """ Potentially we might have a deprecation warning, show it but call the appropriate methods anyhow. """ if how is not None: # .resample(..., how='sum') if isinstance(how, str): method = "{0}()...
[ "def", "_maybe_process_deprecations", "(", "r", ",", "how", "=", "None", ",", "fill_method", "=", "None", ",", "limit", "=", "None", ")", ":", "if", "how", "is", "not", "None", ":", "# .resample(..., how='sum')", "if", "isinstance", "(", "how", ",", "str",...
Potentially we might have a deprecation warning, show it but call the appropriate methods anyhow.
[ "Potentially", "we", "might", "have", "a", "deprecation", "warning", "show", "it", "but", "call", "the", "appropriate", "methods", "anyhow", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L877-L922
19,870
pandas-dev/pandas
pandas/core/resample.py
resample
def resample(obj, kind=None, **kwds): """ Create a TimeGrouper and return our resampler. """ tg = TimeGrouper(**kwds) return tg._get_resampler(obj, kind=kind)
python
def resample(obj, kind=None, **kwds): """ Create a TimeGrouper and return our resampler. """ tg = TimeGrouper(**kwds) return tg._get_resampler(obj, kind=kind)
[ "def", "resample", "(", "obj", ",", "kind", "=", "None", ",", "*", "*", "kwds", ")", ":", "tg", "=", "TimeGrouper", "(", "*", "*", "kwds", ")", "return", "tg", ".", "_get_resampler", "(", "obj", ",", "kind", "=", "kind", ")" ]
Create a TimeGrouper and return our resampler.
[ "Create", "a", "TimeGrouper", "and", "return", "our", "resampler", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1238-L1243
19,871
pandas-dev/pandas
pandas/core/resample.py
get_resampler_for_grouping
def get_resampler_for_grouping(groupby, rule, how=None, fill_method=None, limit=None, kind=None, **kwargs): """ Return our appropriate resampler when grouping as well. """ # .resample uses 'on' similar to how .groupby uses 'key' kwargs['key'] = kwargs.pop('on', None) ...
python
def get_resampler_for_grouping(groupby, rule, how=None, fill_method=None, limit=None, kind=None, **kwargs): """ Return our appropriate resampler when grouping as well. """ # .resample uses 'on' similar to how .groupby uses 'key' kwargs['key'] = kwargs.pop('on', None) ...
[ "def", "get_resampler_for_grouping", "(", "groupby", ",", "rule", ",", "how", "=", "None", ",", "fill_method", "=", "None", ",", "limit", "=", "None", ",", "kind", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# .resample uses 'on' similar to how .groupby u...
Return our appropriate resampler when grouping as well.
[ "Return", "our", "appropriate", "resampler", "when", "grouping", "as", "well", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1249-L1264
19,872
pandas-dev/pandas
pandas/core/resample.py
_get_timestamp_range_edges
def _get_timestamp_range_edges(first, last, offset, closed='left', base=0): """ Adjust the `first` Timestamp to the preceeding Timestamp that resides on the provided offset. Adjust the `last` Timestamp to the following Timestamp that resides on the provided offset. Input Timestamps that already resi...
python
def _get_timestamp_range_edges(first, last, offset, closed='left', base=0): """ Adjust the `first` Timestamp to the preceeding Timestamp that resides on the provided offset. Adjust the `last` Timestamp to the following Timestamp that resides on the provided offset. Input Timestamps that already resi...
[ "def", "_get_timestamp_range_edges", "(", "first", ",", "last", ",", "offset", ",", "closed", "=", "'left'", ",", "base", "=", "0", ")", ":", "if", "isinstance", "(", "offset", ",", "Tick", ")", ":", "if", "isinstance", "(", "offset", ",", "Day", ")", ...
Adjust the `first` Timestamp to the preceeding Timestamp that resides on the provided offset. Adjust the `last` Timestamp to the following Timestamp that resides on the provided offset. Input Timestamps that already reside on the offset will be adjusted depending on the type of offset and the `closed` p...
[ "Adjust", "the", "first", "Timestamp", "to", "the", "preceeding", "Timestamp", "that", "resides", "on", "the", "provided", "offset", ".", "Adjust", "the", "last", "Timestamp", "to", "the", "following", "Timestamp", "that", "resides", "on", "the", "provided", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1582-L1634
19,873
pandas-dev/pandas
pandas/core/resample.py
_get_period_range_edges
def _get_period_range_edges(first, last, offset, closed='left', base=0): """ Adjust the provided `first` and `last` Periods to the respective Period of the given offset that encompasses them. Parameters ---------- first : pd.Period The beginning Period of the range to be adjusted. l...
python
def _get_period_range_edges(first, last, offset, closed='left', base=0): """ Adjust the provided `first` and `last` Periods to the respective Period of the given offset that encompasses them. Parameters ---------- first : pd.Period The beginning Period of the range to be adjusted. l...
[ "def", "_get_period_range_edges", "(", "first", ",", "last", ",", "offset", ",", "closed", "=", "'left'", ",", "base", "=", "0", ")", ":", "if", "not", "all", "(", "isinstance", "(", "obj", ",", "pd", ".", "Period", ")", "for", "obj", "in", "[", "f...
Adjust the provided `first` and `last` Periods to the respective Period of the given offset that encompasses them. Parameters ---------- first : pd.Period The beginning Period of the range to be adjusted. last : pd.Period The ending Period of the range to be adjusted. offset : p...
[ "Adjust", "the", "provided", "first", "and", "last", "Periods", "to", "the", "respective", "Period", "of", "the", "given", "offset", "that", "encompasses", "them", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1637-L1673
19,874
pandas-dev/pandas
pandas/core/resample.py
Resampler._from_selection
def _from_selection(self): """ Is the resampling from a DataFrame column or MultiIndex level. """ # upsampling and PeriodIndex resampling do not work # with selection, this state used to catch and raise an error return (self.groupby is not None and (self.g...
python
def _from_selection(self): """ Is the resampling from a DataFrame column or MultiIndex level. """ # upsampling and PeriodIndex resampling do not work # with selection, this state used to catch and raise an error return (self.groupby is not None and (self.g...
[ "def", "_from_selection", "(", "self", ")", ":", "# upsampling and PeriodIndex resampling do not work", "# with selection, this state used to catch and raise an error", "return", "(", "self", ".", "groupby", "is", "not", "None", "and", "(", "self", ".", "groupby", ".", "k...
Is the resampling from a DataFrame column or MultiIndex level.
[ "Is", "the", "resampling", "from", "a", "DataFrame", "column", "or", "MultiIndex", "level", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L135-L143
19,875
pandas-dev/pandas
pandas/core/resample.py
Resampler._set_binner
def _set_binner(self): """ Setup our binners. Cache these as we are an immutable object """ if self.binner is None: self.binner, self.grouper = self._get_binner()
python
def _set_binner(self): """ Setup our binners. Cache these as we are an immutable object """ if self.binner is None: self.binner, self.grouper = self._get_binner()
[ "def", "_set_binner", "(", "self", ")", ":", "if", "self", ".", "binner", "is", "None", ":", "self", ".", "binner", ",", "self", ".", "grouper", "=", "self", ".", "_get_binner", "(", ")" ]
Setup our binners. Cache these as we are an immutable object
[ "Setup", "our", "binners", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L163-L170
19,876
pandas-dev/pandas
pandas/core/resample.py
Resampler.transform
def transform(self, arg, *args, **kwargs): """ Call function producing a like-indexed Series on each group and return a Series with the transformed values. Parameters ---------- arg : function To apply to each group. Should return a Series with the same index...
python
def transform(self, arg, *args, **kwargs): """ Call function producing a like-indexed Series on each group and return a Series with the transformed values. Parameters ---------- arg : function To apply to each group. Should return a Series with the same index...
[ "def", "transform", "(", "self", ",", "arg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_selected_obj", ".", "groupby", "(", "self", ".", "groupby", ")", ".", "transform", "(", "arg", ",", "*", "args", ",", "*", ...
Call function producing a like-indexed Series on each group and return a Series with the transformed values. Parameters ---------- arg : function To apply to each group. Should return a Series with the same index. Returns ------- transformed : Series...
[ "Call", "function", "producing", "a", "like", "-", "indexed", "Series", "on", "each", "group", "and", "return", "a", "Series", "with", "the", "transformed", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L280-L299
19,877
pandas-dev/pandas
pandas/core/resample.py
Resampler._groupby_and_aggregate
def _groupby_and_aggregate(self, how, grouper=None, *args, **kwargs): """ Re-evaluate the obj with a groupby aggregation. """ if grouper is None: self._set_binner() grouper = self.grouper obj = self._selected_obj grouped = groupby(obj, by=None, ...
python
def _groupby_and_aggregate(self, how, grouper=None, *args, **kwargs): """ Re-evaluate the obj with a groupby aggregation. """ if grouper is None: self._set_binner() grouper = self.grouper obj = self._selected_obj grouped = groupby(obj, by=None, ...
[ "def", "_groupby_and_aggregate", "(", "self", ",", "how", ",", "grouper", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "grouper", "is", "None", ":", "self", ".", "_set_binner", "(", ")", "grouper", "=", "self", ".", "groupe...
Re-evaluate the obj with a groupby aggregation.
[ "Re", "-", "evaluate", "the", "obj", "with", "a", "groupby", "aggregation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L331-L357
19,878
pandas-dev/pandas
pandas/core/resample.py
Resampler._apply_loffset
def _apply_loffset(self, result): """ If loffset is set, offset the result index. This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample """ ...
python
def _apply_loffset(self, result): """ If loffset is set, offset the result index. This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample """ ...
[ "def", "_apply_loffset", "(", "self", ",", "result", ")", ":", "needs_offset", "=", "(", "isinstance", "(", "self", ".", "loffset", ",", "(", "DateOffset", ",", "timedelta", ",", "np", ".", "timedelta64", ")", ")", "and", "isinstance", "(", "result", "."...
If loffset is set, offset the result index. This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample
[ "If", "loffset", "is", "set", "offset", "the", "result", "index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L359-L383
19,879
pandas-dev/pandas
pandas/core/resample.py
Resampler._get_resampler_for_grouping
def _get_resampler_for_grouping(self, groupby, **kwargs): """ Return the correct class for resampling with groupby. """ return self._resampler_for_grouping(self, groupby=groupby, **kwargs)
python
def _get_resampler_for_grouping(self, groupby, **kwargs): """ Return the correct class for resampling with groupby. """ return self._resampler_for_grouping(self, groupby=groupby, **kwargs)
[ "def", "_get_resampler_for_grouping", "(", "self", ",", "groupby", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_resampler_for_grouping", "(", "self", ",", "groupby", "=", "groupby", ",", "*", "*", "kwargs", ")" ]
Return the correct class for resampling with groupby.
[ "Return", "the", "correct", "class", "for", "resampling", "with", "groupby", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L385-L389
19,880
pandas-dev/pandas
pandas/core/resample.py
Resampler._wrap_result
def _wrap_result(self, result): """ Potentially wrap any results. """ if isinstance(result, ABCSeries) and self._selection is not None: result.name = self._selection if isinstance(result, ABCSeries) and result.empty: obj = self.obj if isinstan...
python
def _wrap_result(self, result): """ Potentially wrap any results. """ if isinstance(result, ABCSeries) and self._selection is not None: result.name = self._selection if isinstance(result, ABCSeries) and result.empty: obj = self.obj if isinstan...
[ "def", "_wrap_result", "(", "self", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "ABCSeries", ")", "and", "self", ".", "_selection", "is", "not", "None", ":", "result", ".", "name", "=", "self", ".", "_selection", "if", "isinstance", ...
Potentially wrap any results.
[ "Potentially", "wrap", "any", "results", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L391-L406
19,881
pandas-dev/pandas
pandas/core/resample.py
_GroupByMixin._apply
def _apply(self, f, grouper=None, *args, **kwargs): """ Dispatch to _upsample; we are stripping all of the _upsample kwargs and performing the original function call on the grouped object. """ def func(x): x = self._shallow_copy(x, groupby=self.groupby) ...
python
def _apply(self, f, grouper=None, *args, **kwargs): """ Dispatch to _upsample; we are stripping all of the _upsample kwargs and performing the original function call on the grouped object. """ def func(x): x = self._shallow_copy(x, groupby=self.groupby) ...
[ "def", "_apply", "(", "self", ",", "f", ",", "grouper", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "func", "(", "x", ")", ":", "x", "=", "self", ".", "_shallow_copy", "(", "x", ",", "groupby", "=", "self", ".", "...
Dispatch to _upsample; we are stripping all of the _upsample kwargs and performing the original function call on the grouped object.
[ "Dispatch", "to", "_upsample", ";", "we", "are", "stripping", "all", "of", "the", "_upsample", "kwargs", "and", "performing", "the", "original", "function", "call", "on", "the", "grouped", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L947-L962
19,882
pandas-dev/pandas
pandas/core/resample.py
DatetimeIndexResampler._adjust_binner_for_upsample
def _adjust_binner_for_upsample(self, binner): """ Adjust our binner when upsampling. The range of a new index should not be outside specified range """ if self.closed == 'right': binner = binner[1:] else: binner = binner[:-1] return binne...
python
def _adjust_binner_for_upsample(self, binner): """ Adjust our binner when upsampling. The range of a new index should not be outside specified range """ if self.closed == 'right': binner = binner[1:] else: binner = binner[:-1] return binne...
[ "def", "_adjust_binner_for_upsample", "(", "self", ",", "binner", ")", ":", "if", "self", ".", "closed", "==", "'right'", ":", "binner", "=", "binner", "[", "1", ":", "]", "else", ":", "binner", "=", "binner", "[", ":", "-", "1", "]", "return", "binn...
Adjust our binner when upsampling. The range of a new index should not be outside specified range
[ "Adjust", "our", "binner", "when", "upsampling", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1018-L1028
19,883
pandas-dev/pandas
pandas/core/resample.py
TimeGrouper._get_resampler
def _get_resampler(self, obj, kind=None): """ Return my resampler or raise if we have an invalid axis. Parameters ---------- obj : input object kind : string, optional 'period','timestamp','timedelta' are valid Returns ------- a Resam...
python
def _get_resampler(self, obj, kind=None): """ Return my resampler or raise if we have an invalid axis. Parameters ---------- obj : input object kind : string, optional 'period','timestamp','timedelta' are valid Returns ------- a Resam...
[ "def", "_get_resampler", "(", "self", ",", "obj", ",", "kind", "=", "None", ")", ":", "self", ".", "_set_grouper", "(", "obj", ")", "ax", "=", "self", ".", "ax", "if", "isinstance", "(", "ax", ",", "DatetimeIndex", ")", ":", "return", "DatetimeIndexRes...
Return my resampler or raise if we have an invalid axis. Parameters ---------- obj : input object kind : string, optional 'period','timestamp','timedelta' are valid Returns ------- a Resampler Raises ------ TypeError if incom...
[ "Return", "my", "resampler", "or", "raise", "if", "we", "have", "an", "invalid", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L1334-L1373
19,884
pandas-dev/pandas
pandas/core/util/hashing.py
hash_tuple
def hash_tuple(val, encoding='utf8', hash_key=None): """ Hash a single tuple efficiently Parameters ---------- val : single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- hash """ hashes = (_hash_sc...
python
def hash_tuple(val, encoding='utf8', hash_key=None): """ Hash a single tuple efficiently Parameters ---------- val : single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- hash """ hashes = (_hash_sc...
[ "def", "hash_tuple", "(", "val", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ")", ":", "hashes", "=", "(", "_hash_scalar", "(", "v", ",", "encoding", "=", "encoding", ",", "hash_key", "=", "hash_key", ")", "for", "v", "in", "val", "...
Hash a single tuple efficiently Parameters ---------- val : single tuple encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- hash
[ "Hash", "a", "single", "tuple", "efficiently" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L167-L187
19,885
pandas-dev/pandas
pandas/core/util/hashing.py
_hash_categorical
def _hash_categorical(c, encoding, hash_key): """ Hash a Categorical by hashing its categories, and then mapping the codes to the hashes Parameters ---------- c : Categorical encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ...
python
def _hash_categorical(c, encoding, hash_key): """ Hash a Categorical by hashing its categories, and then mapping the codes to the hashes Parameters ---------- c : Categorical encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ...
[ "def", "_hash_categorical", "(", "c", ",", "encoding", ",", "hash_key", ")", ":", "# Convert ExtensionArrays to ndarrays", "values", "=", "np", ".", "asarray", "(", "c", ".", "categories", ".", "values", ")", "hashed", "=", "hash_array", "(", "values", ",", ...
Hash a Categorical by hashing its categories, and then mapping the codes to the hashes Parameters ---------- c : Categorical encoding : string, default 'utf8' hash_key : string key to encode, default to _default_hash_key Returns ------- ndarray of hashed values array, same size as ...
[ "Hash", "a", "Categorical", "by", "hashing", "its", "categories", "and", "then", "mapping", "the", "codes", "to", "the", "hashes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L190-L226
19,886
pandas-dev/pandas
pandas/core/util/hashing.py
hash_array
def hash_array(vals, encoding='utf8', hash_key=None, categorize=True): """ Given a 1d array, return an array of deterministic integers. .. versionadded:: 0.19.2 Parameters ---------- vals : ndarray, Categorical encoding : string, default 'utf8' encoding for data & key when strings ...
python
def hash_array(vals, encoding='utf8', hash_key=None, categorize=True): """ Given a 1d array, return an array of deterministic integers. .. versionadded:: 0.19.2 Parameters ---------- vals : ndarray, Categorical encoding : string, default 'utf8' encoding for data & key when strings ...
[ "def", "hash_array", "(", "vals", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ",", "categorize", "=", "True", ")", ":", "if", "not", "hasattr", "(", "vals", ",", "'dtype'", ")", ":", "raise", "TypeError", "(", "\"must pass a ndarray-like\...
Given a 1d array, return an array of deterministic integers. .. versionadded:: 0.19.2 Parameters ---------- vals : ndarray, Categorical encoding : string, default 'utf8' encoding for data & key when strings hash_key : string key to encode, default to _default_hash_key categorize : ...
[ "Given", "a", "1d", "array", "return", "an", "array", "of", "deterministic", "integers", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L229-L305
19,887
pandas-dev/pandas
pandas/core/util/hashing.py
_hash_scalar
def _hash_scalar(val, encoding='utf8', hash_key=None): """ Hash scalar value Returns ------- 1d uint64 numpy array of hash value, of length 1 """ if isna(val): # this is to be consistent with the _hash_categorical implementation return np.array([np.iinfo(np.uint64).max], dt...
python
def _hash_scalar(val, encoding='utf8', hash_key=None): """ Hash scalar value Returns ------- 1d uint64 numpy array of hash value, of length 1 """ if isna(val): # this is to be consistent with the _hash_categorical implementation return np.array([np.iinfo(np.uint64).max], dt...
[ "def", "_hash_scalar", "(", "val", ",", "encoding", "=", "'utf8'", ",", "hash_key", "=", "None", ")", ":", "if", "isna", "(", "val", ")", ":", "# this is to be consistent with the _hash_categorical implementation", "return", "np", ".", "array", "(", "[", "np", ...
Hash scalar value Returns ------- 1d uint64 numpy array of hash value, of length 1
[ "Hash", "scalar", "value" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/util/hashing.py#L308-L333
19,888
pandas-dev/pandas
doc/make.py
DocBuilder._run_os
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...
python
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", ")", ":", "subprocess", ".", "check_call", "(", "args", ",", "stdout", "=", "sys", ".", "stdout", ",", "stderr", "=", "sys", ".", "stderr", ")" ]
Execute a command as a OS terminal. Parameters ---------- *args : list of str Command and parameters to be executed Examples -------- >>> DocBuilder()._run_os('python', '--version')
[ "Execute", "a", "command", "as", "a", "OS", "terminal", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L91-L104
19,889
pandas-dev/pandas
doc/make.py
DocBuilder._sphinx_build
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') """ ...
python
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", ")", ":", "if", "kind", "not", "in", "(", "'html'", ",", "'latex'", ")", ":", "raise", "ValueError", "(", "'kind must be html or latex, '", "'not {}'", ".", "format", "(", "kind", ")", ")", "cmd", "=", "[...
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", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L106-L133
19,890
pandas-dev/pandas
doc/make.py
DocBuilder._open_browser
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)
python
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", ")", ":", "url", "=", "os", ".", "path", ".", "join", "(", "'file://'", ",", "DOC_PATH", ",", "'build'", ",", "'html'", ",", "single_doc_html", ")", "webbrowser", ".", "open", "(", "url", ",", ...
Open a browser tab showing single
[ "Open", "a", "browser", "tab", "showing", "single" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L135-L141
19,891
pandas-dev/pandas
doc/make.py
DocBuilder._get_page_title
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...
python
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", ")", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "SOURCE_PATH", ",", "'{}.rst'", ".", "format", "(", "page", ")", ")", "option_parser", "=", "docutils", ".", "frontend", ".", "OptionParser",...
Open the rst file `page` and extract its title.
[ "Open", "the", "rst", "file", "page", "and", "extract", "its", "title", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L143-L167
19,892
pandas-dev/pandas
doc/make.py
DocBuilder.html
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...
python
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", ")", ":", "ret_code", "=", "self", ".", "_sphinx_build", "(", "'html'", ")", "zip_fname", "=", "os", ".", "path", ".", "join", "(", "BUILD_PATH", ",", "'html'", ",", "'pandas.zip'", ")", "if", "os", ".", "path", ".", "exis...
Build HTML documentation.
[ "Build", "HTML", "documentation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L214-L227
19,893
pandas-dev/pandas
doc/make.py
DocBuilder.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'))...
python
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", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "sys", ".", "stderr", ".", "write", "(", "'latex build has not been tested on windows\\n'", ")", "else", ":", "ret_code", "=", "self", "....
Build PDF documentation.
[ "Build", "PDF", "documentation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L229-L247
19,894
pandas-dev/pandas
doc/make.py
DocBuilder.clean
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)
python
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", "(", ")", ":", "shutil", ".", "rmtree", "(", "BUILD_PATH", ",", "ignore_errors", "=", "True", ")", "shutil", ".", "rmtree", "(", "os", ".", "path", ".", "join", "(", "SOURCE_PATH", ",", "'reference'", ",", "'api'", ")", ",", "ignore_err...
Clean documentation generated files.
[ "Clean", "documentation", "generated", "files", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L256-L262
19,895
pandas-dev/pandas
doc/make.py
DocBuilder.zip_html
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...
python
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", ")", ":", "zip_fname", "=", "os", ".", "path", ".", "join", "(", "BUILD_PATH", ",", "'html'", ",", "'pandas.zip'", ")", "if", "os", ".", "path", ".", "exists", "(", "zip_fname", ")", ":", "os", ".", "remove", "(", "z...
Compress HTML documentation into a zip file.
[ "Compress", "HTML", "documentation", "into", "a", "zip", "file", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L264-L278
19,896
pandas-dev/pandas
pandas/io/formats/latex.py
LatexFormatter._format_multicolumn
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...
python
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", ")", ":", "row2", "=", "list", "(", "row", "[", ":", "ilevels", "]", ")", "ncol", "=", "1", "coltext", "=", "''", "def", "append_col", "(", ")", ":", "# write multicolumn if needed", ...
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}
[ "r", "Combine", "columns", "belonging", "to", "a", "group", "to", "a", "single", "multicolumn", "entry", "according", "to", "self", ".", "multicolumn_format" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L165-L201
19,897
pandas-dev/pandas
pandas/io/formats/latex.py
LatexFormatter._format_multirow
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...
python
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", ")", ":", "for", "j", "in", "range", "(", "ilevels", ")", ":", "if", "row", "[", "j", "]", ".", "strip", "(", ")", ":", "nrow", "=", "1", "for", "r", "...
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 &
[ "r", "Check", "following", "rows", "whether", "row", "should", "be", "a", "multirow" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L203-L227
19,898
pandas-dev/pandas
pandas/io/formats/latex.py
LatexFormatter._print_cline
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...
python
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", ")", ":", "for", "cl", "in", "self", ".", "clinebuf", ":", "if", "cl", "[", "0", "]", "==", "i", ":", "buf", ".", "write", "(", "'\\\\cline{{{cl:d}-{icol:d}}}\\n'", ".", "format",...
Print clines after multirow-blocks are finished
[ "Print", "clines", "after", "multirow", "-", "blocks", "are", "finished" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L229-L238
19,899
pandas-dev/pandas
pandas/io/parsers.py
_validate_integer
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...
python
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", ")", ":", "msg", "=", "\"'{name:s}' must be an integer >={min_val:d}\"", ".", "format", "(", "name", "=", "name", ",", "min_val", "=", "min_val", ")", "if", "val", "is", "not", ...
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 ...
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L349-L376