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
20,400
pandas-dev/pandas
pandas/core/arrays/datetimes.py
DatetimeArray._add_delta
def _add_delta(self, delta): """ Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new DatetimeArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
python
def _add_delta(self, delta): """ Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new DatetimeArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
[ "def", "_add_delta", "(", "self", ",", "delta", ")", ":", "new_values", "=", "super", "(", ")", ".", "_add_delta", "(", "delta", ")", "return", "type", "(", "self", ")", ".", "_from_sequence", "(", "new_values", ",", "tz", "=", "self", ".", "tz", ","...
Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new DatetimeArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ------- result : DatetimeArray
[ "Add", "a", "timedelta", "-", "like", "Tick", "or", "TimedeltaIndex", "-", "like", "object", "to", "self", "yielding", "a", "new", "DatetimeArray" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L759-L774
20,401
pandas-dev/pandas
pandas/core/arrays/datetimes.py
DatetimeArray.normalize
def normalize(self): """ Convert times to midnight. The time component of the date-time is converted to midnight i.e. 00:00:00. This is useful in cases, when the time does not matter. Length is unaltered. The timezones are unaffected. This method is available on Series ...
python
def normalize(self): """ Convert times to midnight. The time component of the date-time is converted to midnight i.e. 00:00:00. This is useful in cases, when the time does not matter. Length is unaltered. The timezones are unaffected. This method is available on Series ...
[ "def", "normalize", "(", "self", ")", ":", "if", "self", ".", "tz", "is", "None", "or", "timezones", ".", "is_utc", "(", "self", ".", "tz", ")", ":", "not_null", "=", "~", "self", ".", "isna", "(", ")", "DAY_NS", "=", "ccalendar", ".", "DAY_SECONDS...
Convert times to midnight. The time component of the date-time is converted to midnight i.e. 00:00:00. This is useful in cases, when the time does not matter. Length is unaltered. The timezones are unaffected. This method is available on Series with datetime values under the ``...
[ "Convert", "times", "to", "midnight", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1063-L1110
20,402
pandas-dev/pandas
pandas/core/arrays/datetimes.py
DatetimeArray.to_perioddelta
def to_perioddelta(self, freq): """ Calculate TimedeltaArray of difference between index values and index converted to PeriodArray at specified freq. Used for vectorized offsets Parameters ---------- freq : Period frequency Returns ------- ...
python
def to_perioddelta(self, freq): """ Calculate TimedeltaArray of difference between index values and index converted to PeriodArray at specified freq. Used for vectorized offsets Parameters ---------- freq : Period frequency Returns ------- ...
[ "def", "to_perioddelta", "(", "self", ",", "freq", ")", ":", "# TODO: consider privatizing (discussion in GH#23113)", "from", "pandas", ".", "core", ".", "arrays", ".", "timedeltas", "import", "TimedeltaArray", "i8delta", "=", "self", ".", "asi8", "-", "self", "."...
Calculate TimedeltaArray of difference between index values and index converted to PeriodArray at specified freq. Used for vectorized offsets Parameters ---------- freq : Period frequency Returns ------- TimedeltaArray/Index
[ "Calculate", "TimedeltaArray", "of", "difference", "between", "index", "values", "and", "index", "converted", "to", "PeriodArray", "at", "specified", "freq", ".", "Used", "for", "vectorized", "offsets" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1173-L1191
20,403
pandas-dev/pandas
pandas/core/arrays/datetimes.py
DatetimeArray.month_name
def month_name(self, locale=None): """ Return the month names of the DateTimeIndex with specified locale. .. versionadded:: 0.23.0 Parameters ---------- locale : str, optional Locale determining the language in which to return the month name. Def...
python
def month_name(self, locale=None): """ Return the month names of the DateTimeIndex with specified locale. .. versionadded:: 0.23.0 Parameters ---------- locale : str, optional Locale determining the language in which to return the month name. Def...
[ "def", "month_name", "(", "self", ",", "locale", "=", "None", ")", ":", "if", "self", ".", "tz", "is", "not", "None", "and", "not", "timezones", ".", "is_utc", "(", "self", ".", "tz", ")", ":", "values", "=", "self", ".", "_local_timestamps", "(", ...
Return the month names of the DateTimeIndex with specified locale. .. versionadded:: 0.23.0 Parameters ---------- locale : str, optional Locale determining the language in which to return the month name. Default is English locale. Returns ------...
[ "Return", "the", "month", "names", "of", "the", "DateTimeIndex", "with", "specified", "locale", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1196-L1230
20,404
pandas-dev/pandas
pandas/core/arrays/datetimes.py
DatetimeArray.time
def time(self): """ Returns numpy array of datetime.time. The time part of the Timestamps. """ # If the Timestamps have a timezone that is not UTC, # convert them into their i8 representation while # keeping their timezone and not using UTC if self.tz is not None ...
python
def time(self): """ Returns numpy array of datetime.time. The time part of the Timestamps. """ # If the Timestamps have a timezone that is not UTC, # convert them into their i8 representation while # keeping their timezone and not using UTC if self.tz is not None ...
[ "def", "time", "(", "self", ")", ":", "# If the Timestamps have a timezone that is not UTC,", "# convert them into their i8 representation while", "# keeping their timezone and not using UTC", "if", "self", ".", "tz", "is", "not", "None", "and", "not", "timezones", ".", "is_u...
Returns numpy array of datetime.time. The time part of the Timestamps.
[ "Returns", "numpy", "array", "of", "datetime", ".", "time", ".", "The", "time", "part", "of", "the", "Timestamps", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimes.py#L1269-L1281
20,405
pandas-dev/pandas
scripts/validate_docstrings.py
get_api_items
def get_api_items(api_doc_fd): """ Yield information about all public API items. Parse api.rst file from the documentation, and extract all the functions, methods, classes, attributes... This should include all pandas public API. Parameters ---------- api_doc_fd : file descriptor A...
python
def get_api_items(api_doc_fd): """ Yield information about all public API items. Parse api.rst file from the documentation, and extract all the functions, methods, classes, attributes... This should include all pandas public API. Parameters ---------- api_doc_fd : file descriptor A...
[ "def", "get_api_items", "(", "api_doc_fd", ")", ":", "current_module", "=", "'pandas'", "previous_line", "=", "current_section", "=", "current_subsection", "=", "''", "position", "=", "None", "for", "line", "in", "api_doc_fd", ":", "line", "=", "line", ".", "s...
Yield information about all public API items. Parse api.rst file from the documentation, and extract all the functions, methods, classes, attributes... This should include all pandas public API. Parameters ---------- api_doc_fd : file descriptor A file descriptor of the API documentation p...
[ "Yield", "information", "about", "all", "public", "API", "items", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L158-L223
20,406
pandas-dev/pandas
scripts/validate_docstrings.py
validate_one
def validate_one(func_name): """ Validate the docstring for the given func_name Parameters ---------- func_name : function Function whose docstring will be evaluated (e.g. pandas.read_csv). Returns ------- dict A dictionary containing all the information obtained from v...
python
def validate_one(func_name): """ Validate the docstring for the given func_name Parameters ---------- func_name : function Function whose docstring will be evaluated (e.g. pandas.read_csv). Returns ------- dict A dictionary containing all the information obtained from v...
[ "def", "validate_one", "(", "func_name", ")", ":", "doc", "=", "Docstring", "(", "func_name", ")", "errs", ",", "wrns", ",", "examples_errs", "=", "get_validation_data", "(", "doc", ")", "return", "{", "'type'", ":", "doc", ".", "type", ",", "'docstring'",...
Validate the docstring for the given func_name Parameters ---------- func_name : function Function whose docstring will be evaluated (e.g. pandas.read_csv). Returns ------- dict A dictionary containing all the information obtained from validating the docstring.
[ "Validate", "the", "docstring", "for", "the", "given", "func_name" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L788-L813
20,407
pandas-dev/pandas
scripts/validate_docstrings.py
validate_all
def validate_all(prefix, ignore_deprecated=False): """ Execute the validation of all docstrings, and return a dict with the results. Parameters ---------- prefix : str or None If provided, only the docstrings that start with this pattern will be validated. If None, all docstring...
python
def validate_all(prefix, ignore_deprecated=False): """ Execute the validation of all docstrings, and return a dict with the results. Parameters ---------- prefix : str or None If provided, only the docstrings that start with this pattern will be validated. If None, all docstring...
[ "def", "validate_all", "(", "prefix", ",", "ignore_deprecated", "=", "False", ")", ":", "result", "=", "{", "}", "seen", "=", "{", "}", "# functions from the API docs", "api_doc_fnames", "=", "os", ".", "path", ".", "join", "(", "BASE_PATH", ",", "'doc'", ...
Execute the validation of all docstrings, and return a dict with the results. Parameters ---------- prefix : str or None If provided, only the docstrings that start with this pattern will be validated. If None, all docstrings will be validated. ignore_deprecated: bool, default False...
[ "Execute", "the", "validation", "of", "all", "docstrings", "and", "return", "a", "dict", "with", "the", "results", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L816-L877
20,408
pandas-dev/pandas
scripts/validate_docstrings.py
Docstring._load_obj
def _load_obj(name): """ Import Python object from its name as string. Parameters ---------- name : str Object name to import (e.g. pandas.Series.str.upper) Returns ------- object Python object that can be a class, method, functio...
python
def _load_obj(name): """ Import Python object from its name as string. Parameters ---------- name : str Object name to import (e.g. pandas.Series.str.upper) Returns ------- object Python object that can be a class, method, functio...
[ "def", "_load_obj", "(", "name", ")", ":", "for", "maxsplit", "in", "range", "(", "1", ",", "name", ".", "count", "(", "'.'", ")", "+", "1", ")", ":", "# TODO when py3 only replace by: module, *func_parts = ...", "func_name_split", "=", "name", ".", "rsplit", ...
Import Python object from its name as string. Parameters ---------- name : str Object name to import (e.g. pandas.Series.str.upper) Returns ------- object Python object that can be a class, method, function... Examples -------- ...
[ "Import", "Python", "object", "from", "its", "name", "as", "string", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L240-L277
20,409
pandas-dev/pandas
scripts/validate_docstrings.py
Docstring._to_original_callable
def _to_original_callable(obj): """ Find the Python object that contains the source code of the object. This is useful to find the place in the source code (file and line number) where a docstring is defined. It does not currently work for all cases, but it should help find some...
python
def _to_original_callable(obj): """ Find the Python object that contains the source code of the object. This is useful to find the place in the source code (file and line number) where a docstring is defined. It does not currently work for all cases, but it should help find some...
[ "def", "_to_original_callable", "(", "obj", ")", ":", "while", "True", ":", "if", "inspect", ".", "isfunction", "(", "obj", ")", "or", "inspect", ".", "isclass", "(", "obj", ")", ":", "f", "=", "inspect", ".", "getfile", "(", "obj", ")", "if", "f", ...
Find the Python object that contains the source code of the object. This is useful to find the place in the source code (file and line number) where a docstring is defined. It does not currently work for all cases, but it should help find some (properties...).
[ "Find", "the", "Python", "object", "that", "contains", "the", "source", "code", "of", "the", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L280-L301
20,410
pandas-dev/pandas
scripts/validate_docstrings.py
Docstring.method_returns_something
def method_returns_something(self): ''' Check if the docstrings method can return something. Bare returns, returns valued None and returns from nested functions are disconsidered. Returns ------- bool Whether the docstrings method can return somethin...
python
def method_returns_something(self): ''' Check if the docstrings method can return something. Bare returns, returns valued None and returns from nested functions are disconsidered. Returns ------- bool Whether the docstrings method can return somethin...
[ "def", "method_returns_something", "(", "self", ")", ":", "def", "get_returns_not_on_nested_functions", "(", "node", ")", ":", "returns", "=", "[", "node", "]", "if", "isinstance", "(", "node", ",", "ast", ".", "Return", ")", "else", "[", "]", "for", "chil...
Check if the docstrings method can return something. Bare returns, returns valued None and returns from nested functions are disconsidered. Returns ------- bool Whether the docstrings method can return something.
[ "Check", "if", "the", "docstrings", "method", "can", "return", "something", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L503-L535
20,411
pandas-dev/pandas
pandas/io/excel/_base.py
ExcelWriter._value_with_fmt
def _value_with_fmt(self, val): """Convert numpy types to Python types for the Excel writers. Parameters ---------- val : object Value to be written into cells Returns ------- Tuple with the first element being the converted value and the second ...
python
def _value_with_fmt(self, val): """Convert numpy types to Python types for the Excel writers. Parameters ---------- val : object Value to be written into cells Returns ------- Tuple with the first element being the converted value and the second ...
[ "def", "_value_with_fmt", "(", "self", ",", "val", ")", ":", "fmt", "=", "None", "if", "is_integer", "(", "val", ")", ":", "val", "=", "int", "(", "val", ")", "elif", "is_float", "(", "val", ")", ":", "val", "=", "float", "(", "val", ")", "elif",...
Convert numpy types to Python types for the Excel writers. Parameters ---------- val : object Value to be written into cells Returns ------- Tuple with the first element being the converted value and the second being an optional format
[ "Convert", "numpy", "types", "to", "Python", "types", "for", "the", "Excel", "writers", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_base.py#L675-L706
20,412
pandas-dev/pandas
pandas/io/excel/_base.py
ExcelWriter.check_extension
def check_extension(cls, ext): """checks that path's extension against the Writer's supported extensions. If it isn't supported, raises UnsupportedFiletypeError.""" if ext.startswith('.'): ext = ext[1:] if not any(ext in extension for extension in cls.supported_extensions): ...
python
def check_extension(cls, ext): """checks that path's extension against the Writer's supported extensions. If it isn't supported, raises UnsupportedFiletypeError.""" if ext.startswith('.'): ext = ext[1:] if not any(ext in extension for extension in cls.supported_extensions): ...
[ "def", "check_extension", "(", "cls", ",", "ext", ")", ":", "if", "ext", ".", "startswith", "(", "'.'", ")", ":", "ext", "=", "ext", "[", "1", ":", "]", "if", "not", "any", "(", "ext", "in", "extension", "for", "extension", "in", "cls", ".", "sup...
checks that path's extension against the Writer's supported extensions. If it isn't supported, raises UnsupportedFiletypeError.
[ "checks", "that", "path", "s", "extension", "against", "the", "Writer", "s", "supported", "extensions", ".", "If", "it", "isn", "t", "supported", "raises", "UnsupportedFiletypeError", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_base.py#L709-L720
20,413
pandas-dev/pandas
pandas/core/computation/pytables.py
_validate_where
def _validate_where(w): """ Validate that the where statement is of the right type. The type may either be String, Expr, or list-like of Exprs. Parameters ---------- w : String term expression, Expr, or list-like of Exprs. Returns ------- where : The original where clause if the c...
python
def _validate_where(w): """ Validate that the where statement is of the right type. The type may either be String, Expr, or list-like of Exprs. Parameters ---------- w : String term expression, Expr, or list-like of Exprs. Returns ------- where : The original where clause if the c...
[ "def", "_validate_where", "(", "w", ")", ":", "if", "not", "(", "isinstance", "(", "w", ",", "(", "Expr", ",", "str", ")", ")", "or", "is_list_like", "(", "w", ")", ")", ":", "raise", "TypeError", "(", "\"where must be passed as a string, Expr, \"", "\"or ...
Validate that the where statement is of the right type. The type may either be String, Expr, or list-like of Exprs. Parameters ---------- w : String term expression, Expr, or list-like of Exprs. Returns ------- where : The original where clause if the check was successful. Raises ...
[ "Validate", "that", "the", "where", "statement", "is", "of", "the", "right", "type", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/pytables.py#L460-L483
20,414
pandas-dev/pandas
pandas/core/computation/pytables.py
maybe_expression
def maybe_expression(s): """ loose checking if s is a pytables-acceptable expression """ if not isinstance(s, str): return False ops = ExprVisitor.binary_ops + ExprVisitor.unary_ops + ('=',) # make sure we have an op at least return any(op in s for op in ops)
python
def maybe_expression(s): """ loose checking if s is a pytables-acceptable expression """ if not isinstance(s, str): return False ops = ExprVisitor.binary_ops + ExprVisitor.unary_ops + ('=',) # make sure we have an op at least return any(op in s for op in ops)
[ "def", "maybe_expression", "(", "s", ")", ":", "if", "not", "isinstance", "(", "s", ",", "str", ")", ":", "return", "False", "ops", "=", "ExprVisitor", ".", "binary_ops", "+", "ExprVisitor", ".", "unary_ops", "+", "(", "'='", ",", ")", "# make sure we ha...
loose checking if s is a pytables-acceptable expression
[ "loose", "checking", "if", "s", "is", "a", "pytables", "-", "acceptable", "expression" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/pytables.py#L598-L605
20,415
pandas-dev/pandas
pandas/core/computation/pytables.py
BinOp.conform
def conform(self, rhs): """ inplace conform rhs """ if not is_list_like(rhs): rhs = [rhs] if isinstance(rhs, np.ndarray): rhs = rhs.ravel() return rhs
python
def conform(self, rhs): """ inplace conform rhs """ if not is_list_like(rhs): rhs = [rhs] if isinstance(rhs, np.ndarray): rhs = rhs.ravel() return rhs
[ "def", "conform", "(", "self", ",", "rhs", ")", ":", "if", "not", "is_list_like", "(", "rhs", ")", ":", "rhs", "=", "[", "rhs", "]", "if", "isinstance", "(", "rhs", ",", "np", ".", "ndarray", ")", ":", "rhs", "=", "rhs", ".", "ravel", "(", ")",...
inplace conform rhs
[ "inplace", "conform", "rhs" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/pytables.py#L132-L138
20,416
pandas-dev/pandas
pandas/core/computation/pytables.py
BinOp.generate
def generate(self, v): """ create and return the op string for this TermValue """ val = v.tostring(self.encoding) return "({lhs} {op} {val})".format(lhs=self.lhs, op=self.op, val=val)
python
def generate(self, v): """ create and return the op string for this TermValue """ val = v.tostring(self.encoding) return "({lhs} {op} {val})".format(lhs=self.lhs, op=self.op, val=val)
[ "def", "generate", "(", "self", ",", "v", ")", ":", "val", "=", "v", ".", "tostring", "(", "self", ".", "encoding", ")", "return", "\"({lhs} {op} {val})\"", ".", "format", "(", "lhs", "=", "self", ".", "lhs", ",", "op", "=", "self", ".", "op", ",",...
create and return the op string for this TermValue
[ "create", "and", "return", "the", "op", "string", "for", "this", "TermValue" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/pytables.py#L166-L169
20,417
pandas-dev/pandas
pandas/core/computation/pytables.py
BinOp.convert_value
def convert_value(self, v): """ convert the expression that is in the term to something that is accepted by pytables """ def stringify(value): if self.encoding is not None: encoder = partial(pprint_thing_encoded, encoding=self.encodi...
python
def convert_value(self, v): """ convert the expression that is in the term to something that is accepted by pytables """ def stringify(value): if self.encoding is not None: encoder = partial(pprint_thing_encoded, encoding=self.encodi...
[ "def", "convert_value", "(", "self", ",", "v", ")", ":", "def", "stringify", "(", "value", ")", ":", "if", "self", ".", "encoding", "is", "not", "None", ":", "encoder", "=", "partial", "(", "pprint_thing_encoded", ",", "encoding", "=", "self", ".", "en...
convert the expression that is in the term to something that is accepted by pytables
[ "convert", "the", "expression", "that", "is", "in", "the", "term", "to", "something", "that", "is", "accepted", "by", "pytables" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/pytables.py#L171-L224
20,418
pandas-dev/pandas
pandas/core/computation/pytables.py
FilterBinOp.invert
def invert(self): """ invert the filter """ if self.filter is not None: f = list(self.filter) f[1] = self.generate_filter_op(invert=True) self.filter = tuple(f) return self
python
def invert(self): """ invert the filter """ if self.filter is not None: f = list(self.filter) f[1] = self.generate_filter_op(invert=True) self.filter = tuple(f) return self
[ "def", "invert", "(", "self", ")", ":", "if", "self", ".", "filter", "is", "not", "None", ":", "f", "=", "list", "(", "self", ".", "filter", ")", "f", "[", "1", "]", "=", "self", ".", "generate_filter_op", "(", "invert", "=", "True", ")", "self",...
invert the filter
[ "invert", "the", "filter" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/pytables.py#L236-L242
20,419
pandas-dev/pandas
pandas/core/computation/pytables.py
Expr.evaluate
def evaluate(self): """ create and return the numexpr condition and filter """ try: self.condition = self.terms.prune(ConditionBinOp) except AttributeError: raise ValueError("cannot process expression [{expr}], [{slf}] " "is not a valid condi...
python
def evaluate(self): """ create and return the numexpr condition and filter """ try: self.condition = self.terms.prune(ConditionBinOp) except AttributeError: raise ValueError("cannot process expression [{expr}], [{slf}] " "is not a valid condi...
[ "def", "evaluate", "(", "self", ")", ":", "try", ":", "self", ".", "condition", "=", "self", ".", "terms", ".", "prune", "(", "ConditionBinOp", ")", "except", "AttributeError", ":", "raise", "ValueError", "(", "\"cannot process expression [{expr}], [{slf}] \"", ...
create and return the numexpr condition and filter
[ "create", "and", "return", "the", "numexpr", "condition", "and", "filter" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/pytables.py#L556-L572
20,420
pandas-dev/pandas
pandas/core/computation/pytables.py
TermValue.tostring
def tostring(self, encoding): """ quote the string if not encoded else encode and return """ if self.kind == 'string': if encoding is not None: return self.converted return '"{converted}"'.format(converted=self.converted) elif self.kind == 'flo...
python
def tostring(self, encoding): """ quote the string if not encoded else encode and return """ if self.kind == 'string': if encoding is not None: return self.converted return '"{converted}"'.format(converted=self.converted) elif self.kind == 'flo...
[ "def", "tostring", "(", "self", ",", "encoding", ")", ":", "if", "self", ".", "kind", "==", "'string'", ":", "if", "encoding", "is", "not", "None", ":", "return", "self", ".", "converted", "return", "'\"{converted}\"'", ".", "format", "(", "converted", "...
quote the string if not encoded else encode and return
[ "quote", "the", "string", "if", "not", "encoded", "else", "encode", "and", "return" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/pytables.py#L584-L595
20,421
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_argmin_with_skipna
def validate_argmin_with_skipna(skipna, args, kwargs): """ If 'Series.argmin' is called via the 'numpy' library, the third parameter in its signature is 'out', which takes either an ndarray or 'None', so check if the 'skipna' parameter is either an instance of ndarray or is None, since 'skipna' ...
python
def validate_argmin_with_skipna(skipna, args, kwargs): """ If 'Series.argmin' is called via the 'numpy' library, the third parameter in its signature is 'out', which takes either an ndarray or 'None', so check if the 'skipna' parameter is either an instance of ndarray or is None, since 'skipna' ...
[ "def", "validate_argmin_with_skipna", "(", "skipna", ",", "args", ",", "kwargs", ")", ":", "skipna", ",", "args", "=", "process_skipna", "(", "skipna", ",", "args", ")", "validate_argmin", "(", "args", ",", "kwargs", ")", "return", "skipna" ]
If 'Series.argmin' is called via the 'numpy' library, the third parameter in its signature is 'out', which takes either an ndarray or 'None', so check if the 'skipna' parameter is either an instance of ndarray or is None, since 'skipna' itself should be a boolean
[ "If", "Series", ".", "argmin", "is", "called", "via", "the", "numpy", "library", "the", "third", "parameter", "in", "its", "signature", "is", "out", "which", "takes", "either", "an", "ndarray", "or", "None", "so", "check", "if", "the", "skipna", "parameter...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L77-L88
20,422
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_argmax_with_skipna
def validate_argmax_with_skipna(skipna, args, kwargs): """ If 'Series.argmax' is called via the 'numpy' library, the third parameter in its signature is 'out', which takes either an ndarray or 'None', so check if the 'skipna' parameter is either an instance of ndarray or is None, since 'skipna' ...
python
def validate_argmax_with_skipna(skipna, args, kwargs): """ If 'Series.argmax' is called via the 'numpy' library, the third parameter in its signature is 'out', which takes either an ndarray or 'None', so check if the 'skipna' parameter is either an instance of ndarray or is None, since 'skipna' ...
[ "def", "validate_argmax_with_skipna", "(", "skipna", ",", "args", ",", "kwargs", ")", ":", "skipna", ",", "args", "=", "process_skipna", "(", "skipna", ",", "args", ")", "validate_argmax", "(", "args", ",", "kwargs", ")", "return", "skipna" ]
If 'Series.argmax' is called via the 'numpy' library, the third parameter in its signature is 'out', which takes either an ndarray or 'None', so check if the 'skipna' parameter is either an instance of ndarray or is None, since 'skipna' itself should be a boolean
[ "If", "Series", ".", "argmax", "is", "called", "via", "the", "numpy", "library", "the", "third", "parameter", "in", "its", "signature", "is", "out", "which", "takes", "either", "an", "ndarray", "or", "None", "so", "check", "if", "the", "skipna", "parameter...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L91-L102
20,423
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_argsort_with_ascending
def validate_argsort_with_ascending(ascending, args, kwargs): """ If 'Categorical.argsort' is called via the 'numpy' library, the first parameter in its signature is 'axis', which takes either an integer or 'None', so check if the 'ascending' parameter has either integer type or is None, since 'asce...
python
def validate_argsort_with_ascending(ascending, args, kwargs): """ If 'Categorical.argsort' is called via the 'numpy' library, the first parameter in its signature is 'axis', which takes either an integer or 'None', so check if the 'ascending' parameter has either integer type or is None, since 'asce...
[ "def", "validate_argsort_with_ascending", "(", "ascending", ",", "args", ",", "kwargs", ")", ":", "if", "is_integer", "(", "ascending", ")", "or", "ascending", "is", "None", ":", "args", "=", "(", "ascending", ",", ")", "+", "args", "ascending", "=", "True...
If 'Categorical.argsort' is called via the 'numpy' library, the first parameter in its signature is 'axis', which takes either an integer or 'None', so check if the 'ascending' parameter has either integer type or is None, since 'ascending' itself should be a boolean
[ "If", "Categorical", ".", "argsort", "is", "called", "via", "the", "numpy", "library", "the", "first", "parameter", "in", "its", "signature", "is", "axis", "which", "takes", "either", "an", "integer", "or", "None", "so", "check", "if", "the", "ascending", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L123-L137
20,424
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_clip_with_axis
def validate_clip_with_axis(axis, args, kwargs): """ If 'NDFrame.clip' is called via the numpy library, the third parameter in its signature is 'out', which can takes an ndarray, so check if the 'axis' parameter is an instance of ndarray, since 'axis' itself should either be an integer or None "...
python
def validate_clip_with_axis(axis, args, kwargs): """ If 'NDFrame.clip' is called via the numpy library, the third parameter in its signature is 'out', which can takes an ndarray, so check if the 'axis' parameter is an instance of ndarray, since 'axis' itself should either be an integer or None "...
[ "def", "validate_clip_with_axis", "(", "axis", ",", "args", ",", "kwargs", ")", ":", "if", "isinstance", "(", "axis", ",", "ndarray", ")", ":", "args", "=", "(", "axis", ",", ")", "+", "args", "axis", "=", "None", "validate_clip", "(", "args", ",", "...
If 'NDFrame.clip' is called via the numpy library, the third parameter in its signature is 'out', which can takes an ndarray, so check if the 'axis' parameter is an instance of ndarray, since 'axis' itself should either be an integer or None
[ "If", "NDFrame", ".", "clip", "is", "called", "via", "the", "numpy", "library", "the", "third", "parameter", "in", "its", "signature", "is", "out", "which", "can", "takes", "an", "ndarray", "so", "check", "if", "the", "axis", "parameter", "is", "an", "in...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L145-L158
20,425
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_cum_func_with_skipna
def validate_cum_func_with_skipna(skipna, args, kwargs, name): """ If this function is called via the 'numpy' library, the third parameter in its signature is 'dtype', which takes either a 'numpy' dtype or 'None', so check if the 'skipna' parameter is a boolean or not """ if not is_bool(skip...
python
def validate_cum_func_with_skipna(skipna, args, kwargs, name): """ If this function is called via the 'numpy' library, the third parameter in its signature is 'dtype', which takes either a 'numpy' dtype or 'None', so check if the 'skipna' parameter is a boolean or not """ if not is_bool(skip...
[ "def", "validate_cum_func_with_skipna", "(", "skipna", ",", "args", ",", "kwargs", ",", "name", ")", ":", "if", "not", "is_bool", "(", "skipna", ")", ":", "args", "=", "(", "skipna", ",", ")", "+", "args", "skipna", "=", "True", "validate_cum_func", "(",...
If this function is called via the 'numpy' library, the third parameter in its signature is 'dtype', which takes either a 'numpy' dtype or 'None', so check if the 'skipna' parameter is a boolean or not
[ "If", "this", "function", "is", "called", "via", "the", "numpy", "library", "the", "third", "parameter", "in", "its", "signature", "is", "dtype", "which", "takes", "either", "a", "numpy", "dtype", "or", "None", "so", "check", "if", "the", "skipna", "parame...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L176-L188
20,426
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_take_with_convert
def validate_take_with_convert(convert, args, kwargs): """ If this function is called via the 'numpy' library, the third parameter in its signature is 'axis', which takes either an ndarray or 'None', so check if the 'convert' parameter is either an instance of ndarray or is None """ if isin...
python
def validate_take_with_convert(convert, args, kwargs): """ If this function is called via the 'numpy' library, the third parameter in its signature is 'axis', which takes either an ndarray or 'None', so check if the 'convert' parameter is either an instance of ndarray or is None """ if isin...
[ "def", "validate_take_with_convert", "(", "convert", ",", "args", ",", "kwargs", ")", ":", "if", "isinstance", "(", "convert", ",", "ndarray", ")", "or", "convert", "is", "None", ":", "args", "=", "(", "convert", ",", ")", "+", "args", "convert", "=", ...
If this function is called via the 'numpy' library, the third parameter in its signature is 'axis', which takes either an ndarray or 'None', so check if the 'convert' parameter is either an instance of ndarray or is None
[ "If", "this", "function", "is", "called", "via", "the", "numpy", "library", "the", "third", "parameter", "in", "its", "signature", "is", "axis", "which", "takes", "either", "an", "ndarray", "or", "None", "so", "check", "if", "the", "convert", "parameter", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L269-L282
20,427
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_groupby_func
def validate_groupby_func(name, args, kwargs, allowed=None): """ 'args' and 'kwargs' should be empty, except for allowed kwargs because all of their necessary parameters are explicitly listed in the function signature """ if allowed is None: allowed = [] kwargs = set(kwargs) - s...
python
def validate_groupby_func(name, args, kwargs, allowed=None): """ 'args' and 'kwargs' should be empty, except for allowed kwargs because all of their necessary parameters are explicitly listed in the function signature """ if allowed is None: allowed = [] kwargs = set(kwargs) - s...
[ "def", "validate_groupby_func", "(", "name", ",", "args", ",", "kwargs", ",", "allowed", "=", "None", ")", ":", "if", "allowed", "is", "None", ":", "allowed", "=", "[", "]", "kwargs", "=", "set", "(", "kwargs", ")", "-", "set", "(", "allowed", ")", ...
'args' and 'kwargs' should be empty, except for allowed kwargs because all of their necessary parameters are explicitly listed in the function signature
[ "args", "and", "kwargs", "should", "be", "empty", "except", "for", "allowed", "kwargs", "because", "all", "of", "their", "necessary", "parameters", "are", "explicitly", "listed", "in", "the", "function", "signature" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L349-L365
20,428
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_resampler_func
def validate_resampler_func(method, args, kwargs): """ 'args' and 'kwargs' should be empty because all of their necessary parameters are explicitly listed in the function signature """ if len(args) + len(kwargs) > 0: if method in RESAMPLER_NUMPY_OPS: raise UnsupportedFunction...
python
def validate_resampler_func(method, args, kwargs): """ 'args' and 'kwargs' should be empty because all of their necessary parameters are explicitly listed in the function signature """ if len(args) + len(kwargs) > 0: if method in RESAMPLER_NUMPY_OPS: raise UnsupportedFunction...
[ "def", "validate_resampler_func", "(", "method", ",", "args", ",", "kwargs", ")", ":", "if", "len", "(", "args", ")", "+", "len", "(", "kwargs", ")", ">", "0", ":", "if", "method", "in", "RESAMPLER_NUMPY_OPS", ":", "raise", "UnsupportedFunctionCall", "(", ...
'args' and 'kwargs' should be empty because all of their necessary parameters are explicitly listed in the function signature
[ "args", "and", "kwargs", "should", "be", "empty", "because", "all", "of", "their", "necessary", "parameters", "are", "explicitly", "listed", "in", "the", "function", "signature" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L372-L385
20,429
pandas-dev/pandas
pandas/compat/numpy/function.py
validate_minmax_axis
def validate_minmax_axis(axis): """ Ensure that the axis argument passed to min, max, argmin, or argmax is zero or None, as otherwise it will be incorrectly ignored. Parameters ---------- axis : int or None Raises ------ ValueError """ ndim = 1 # hard-coded for Index i...
python
def validate_minmax_axis(axis): """ Ensure that the axis argument passed to min, max, argmin, or argmax is zero or None, as otherwise it will be incorrectly ignored. Parameters ---------- axis : int or None Raises ------ ValueError """ ndim = 1 # hard-coded for Index i...
[ "def", "validate_minmax_axis", "(", "axis", ")", ":", "ndim", "=", "1", "# hard-coded for Index", "if", "axis", "is", "None", ":", "return", "if", "axis", ">=", "ndim", "or", "(", "axis", "<", "0", "and", "ndim", "+", "axis", "<", "0", ")", ":", "rai...
Ensure that the axis argument passed to min, max, argmin, or argmax is zero or None, as otherwise it will be incorrectly ignored. Parameters ---------- axis : int or None Raises ------ ValueError
[ "Ensure", "that", "the", "axis", "argument", "passed", "to", "min", "max", "argmin", "or", "argmax", "is", "zero", "or", "None", "as", "otherwise", "it", "will", "be", "incorrectly", "ignored", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/numpy/function.py#L388-L406
20,430
pandas-dev/pandas
pandas/io/packers.py
read_msgpack
def read_msgpack(path_or_buf, encoding='utf-8', iterator=False, **kwargs): """ Load msgpack pandas object from the specified file path THIS IS AN EXPERIMENTAL LIBRARY and the storage format may not be stable until a future release. Parameters ---------- path_or_buf : string File path, ...
python
def read_msgpack(path_or_buf, encoding='utf-8', iterator=False, **kwargs): """ Load msgpack pandas object from the specified file path THIS IS AN EXPERIMENTAL LIBRARY and the storage format may not be stable until a future release. Parameters ---------- path_or_buf : string File path, ...
[ "def", "read_msgpack", "(", "path_or_buf", ",", "encoding", "=", "'utf-8'", ",", "iterator", "=", "False", ",", "*", "*", "kwargs", ")", ":", "path_or_buf", ",", "_", ",", "_", ",", "should_close", "=", "get_filepath_or_buffer", "(", "path_or_buf", ")", "i...
Load msgpack pandas object from the specified file path THIS IS AN EXPERIMENTAL LIBRARY and the storage format may not be stable until a future release. Parameters ---------- path_or_buf : string File path, BytesIO like or string encoding : Encoding for decoding msgpack str type iterat...
[ "Load", "msgpack", "pandas", "object", "from", "the", "specified", "file", "path" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/packers.py#L160-L219
20,431
pandas-dev/pandas
pandas/io/packers.py
dtype_for
def dtype_for(t): """ return my dtype mapping, whether number or name """ if t in dtype_dict: return dtype_dict[t] return np.typeDict.get(t, t)
python
def dtype_for(t): """ return my dtype mapping, whether number or name """ if t in dtype_dict: return dtype_dict[t] return np.typeDict.get(t, t)
[ "def", "dtype_for", "(", "t", ")", ":", "if", "t", "in", "dtype_dict", ":", "return", "dtype_dict", "[", "t", "]", "return", "np", ".", "typeDict", ".", "get", "(", "t", ",", "t", ")" ]
return my dtype mapping, whether number or name
[ "return", "my", "dtype", "mapping", "whether", "number", "or", "name" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/packers.py#L236-L240
20,432
pandas-dev/pandas
pandas/io/packers.py
c2f
def c2f(r, i, ctype_name): """ Convert strings to complex number instance with specified numpy type. """ ftype = c2f_dict[ctype_name] return np.typeDict[ctype_name](ftype(r) + 1j * ftype(i))
python
def c2f(r, i, ctype_name): """ Convert strings to complex number instance with specified numpy type. """ ftype = c2f_dict[ctype_name] return np.typeDict[ctype_name](ftype(r) + 1j * ftype(i))
[ "def", "c2f", "(", "r", ",", "i", ",", "ctype_name", ")", ":", "ftype", "=", "c2f_dict", "[", "ctype_name", "]", "return", "np", ".", "typeDict", "[", "ctype_name", "]", "(", "ftype", "(", "r", ")", "+", "1j", "*", "ftype", "(", "i", ")", ")" ]
Convert strings to complex number instance with specified numpy type.
[ "Convert", "strings", "to", "complex", "number", "instance", "with", "specified", "numpy", "type", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/packers.py#L252-L258
20,433
pandas-dev/pandas
pandas/io/packers.py
convert
def convert(values): """ convert the numpy values to a list """ dtype = values.dtype if is_categorical_dtype(values): return values elif is_object_dtype(dtype): return values.ravel().tolist() if needs_i8_conversion(dtype): values = values.view('i8') v = values.ravel()...
python
def convert(values): """ convert the numpy values to a list """ dtype = values.dtype if is_categorical_dtype(values): return values elif is_object_dtype(dtype): return values.ravel().tolist() if needs_i8_conversion(dtype): values = values.view('i8') v = values.ravel()...
[ "def", "convert", "(", "values", ")", ":", "dtype", "=", "values", ".", "dtype", "if", "is_categorical_dtype", "(", "values", ")", ":", "return", "values", "elif", "is_object_dtype", "(", "dtype", ")", ":", "return", "values", ".", "ravel", "(", ")", "."...
convert the numpy values to a list
[ "convert", "the", "numpy", "values", "to", "a", "list" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/packers.py#L261-L299
20,434
pandas-dev/pandas
pandas/io/packers.py
pack
def pack(o, default=encode, encoding='utf-8', unicode_errors='strict', use_single_float=False, autoreset=1, use_bin_type=1): """ Pack an object and return the packed bytes. """ return Packer(default=default, encoding=encoding, unicode_errors=unicode_errors, ...
python
def pack(o, default=encode, encoding='utf-8', unicode_errors='strict', use_single_float=False, autoreset=1, use_bin_type=1): """ Pack an object and return the packed bytes. """ return Packer(default=default, encoding=encoding, unicode_errors=unicode_errors, ...
[ "def", "pack", "(", "o", ",", "default", "=", "encode", ",", "encoding", "=", "'utf-8'", ",", "unicode_errors", "=", "'strict'", ",", "use_single_float", "=", "False", ",", "autoreset", "=", "1", ",", "use_bin_type", "=", "1", ")", ":", "return", "Packer...
Pack an object and return the packed bytes.
[ "Pack", "an", "object", "and", "return", "the", "packed", "bytes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/packers.py#L714-L725
20,435
pandas-dev/pandas
pandas/io/json/json.py
read_json
def read_json(path_or_buf=None, orient=None, typ='frame', dtype=None, convert_axes=None, convert_dates=True, keep_default_dates=True, numpy=False, precise_float=False, date_unit=None, encoding=None, lines=False, chunksize=None, compression='infer'): """ Convert a JSON s...
python
def read_json(path_or_buf=None, orient=None, typ='frame', dtype=None, convert_axes=None, convert_dates=True, keep_default_dates=True, numpy=False, precise_float=False, date_unit=None, encoding=None, lines=False, chunksize=None, compression='infer'): """ Convert a JSON s...
[ "def", "read_json", "(", "path_or_buf", "=", "None", ",", "orient", "=", "None", ",", "typ", "=", "'frame'", ",", "dtype", "=", "None", ",", "convert_axes", "=", "None", ",", "convert_dates", "=", "True", ",", "keep_default_dates", "=", "True", ",", "num...
Convert a JSON string to pandas object. Parameters ---------- path_or_buf : a valid JSON string or file-like, default: None The string could be a URL. Valid URL schemes include http, ftp, s3, gcs, and file. For file URLs, a host is expected. For instance, a local file could be ``fil...
[ "Convert", "a", "JSON", "string", "to", "pandas", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/json.py#L222-L450
20,436
pandas-dev/pandas
pandas/io/json/json.py
FrameWriter._format_axes
def _format_axes(self): """ Try to format axes if they are datelike. """ if not self.obj.index.is_unique and self.orient in ( 'index', 'columns'): raise ValueError("DataFrame index must be unique for orient=" "'{orient}'.".format(o...
python
def _format_axes(self): """ Try to format axes if they are datelike. """ if not self.obj.index.is_unique and self.orient in ( 'index', 'columns'): raise ValueError("DataFrame index must be unique for orient=" "'{orient}'.".format(o...
[ "def", "_format_axes", "(", "self", ")", ":", "if", "not", "self", ".", "obj", ".", "index", ".", "is_unique", "and", "self", ".", "orient", "in", "(", "'index'", ",", "'columns'", ")", ":", "raise", "ValueError", "(", "\"DataFrame index must be unique for o...
Try to format axes if they are datelike.
[ "Try", "to", "format", "axes", "if", "they", "are", "datelike", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/json.py#L138-L149
20,437
pandas-dev/pandas
pandas/io/json/json.py
JsonReader._combine_lines
def _combine_lines(self, lines): """ Combines a list of JSON objects into one JSON object. """ lines = filter(None, map(lambda x: x.strip(), lines)) return '[' + ','.join(lines) + ']'
python
def _combine_lines(self, lines): """ Combines a list of JSON objects into one JSON object. """ lines = filter(None, map(lambda x: x.strip(), lines)) return '[' + ','.join(lines) + ']'
[ "def", "_combine_lines", "(", "self", ",", "lines", ")", ":", "lines", "=", "filter", "(", "None", ",", "map", "(", "lambda", "x", ":", "x", ".", "strip", "(", ")", ",", "lines", ")", ")", "return", "'['", "+", "','", ".", "join", "(", "lines", ...
Combines a list of JSON objects into one JSON object.
[ "Combines", "a", "list", "of", "JSON", "objects", "into", "one", "JSON", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/json.py#L534-L539
20,438
pandas-dev/pandas
pandas/io/json/json.py
JsonReader.read
def read(self): """ Read the whole JSON input into a pandas object. """ if self.lines and self.chunksize: obj = concat(self) elif self.lines: data = to_str(self.data) obj = self._get_object_parser( self._combine_lines(data.spli...
python
def read(self): """ Read the whole JSON input into a pandas object. """ if self.lines and self.chunksize: obj = concat(self) elif self.lines: data = to_str(self.data) obj = self._get_object_parser( self._combine_lines(data.spli...
[ "def", "read", "(", "self", ")", ":", "if", "self", ".", "lines", "and", "self", ".", "chunksize", ":", "obj", "=", "concat", "(", "self", ")", "elif", "self", ".", "lines", ":", "data", "=", "to_str", "(", "self", ".", "data", ")", "obj", "=", ...
Read the whole JSON input into a pandas object.
[ "Read", "the", "whole", "JSON", "input", "into", "a", "pandas", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/json.py#L541-L556
20,439
pandas-dev/pandas
pandas/io/json/json.py
JsonReader._get_object_parser
def _get_object_parser(self, json): """ Parses a json document into a pandas object. """ typ = self.typ dtype = self.dtype kwargs = { "orient": self.orient, "dtype": self.dtype, "convert_axes": self.convert_axes, "convert_dates": self.c...
python
def _get_object_parser(self, json): """ Parses a json document into a pandas object. """ typ = self.typ dtype = self.dtype kwargs = { "orient": self.orient, "dtype": self.dtype, "convert_axes": self.convert_axes, "convert_dates": self.c...
[ "def", "_get_object_parser", "(", "self", ",", "json", ")", ":", "typ", "=", "self", ".", "typ", "dtype", "=", "self", ".", "dtype", "kwargs", "=", "{", "\"orient\"", ":", "self", ".", "orient", ",", "\"dtype\"", ":", "self", ".", "dtype", ",", "\"co...
Parses a json document into a pandas object.
[ "Parses", "a", "json", "document", "into", "a", "pandas", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/json.py#L558-L580
20,440
pandas-dev/pandas
pandas/io/json/json.py
Parser.check_keys_split
def check_keys_split(self, decoded): """ Checks that dict has only the appropriate keys for orient='split'. """ bad_keys = set(decoded.keys()).difference(set(self._split_keys)) if bad_keys: bad_keys = ", ".join(bad_keys) raise ValueError("JSON data had une...
python
def check_keys_split(self, decoded): """ Checks that dict has only the appropriate keys for orient='split'. """ bad_keys = set(decoded.keys()).difference(set(self._split_keys)) if bad_keys: bad_keys = ", ".join(bad_keys) raise ValueError("JSON data had une...
[ "def", "check_keys_split", "(", "self", ",", "decoded", ")", ":", "bad_keys", "=", "set", "(", "decoded", ".", "keys", "(", ")", ")", ".", "difference", "(", "set", "(", "self", ".", "_split_keys", ")", ")", "if", "bad_keys", ":", "bad_keys", "=", "\...
Checks that dict has only the appropriate keys for orient='split'.
[ "Checks", "that", "dict", "has", "only", "the", "appropriate", "keys", "for", "orient", "=", "split", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/json.py#L651-L659
20,441
pandas-dev/pandas
pandas/io/json/json.py
Parser._convert_axes
def _convert_axes(self): """ Try to convert axes. """ for axis in self.obj._AXIS_NUMBERS.keys(): new_axis, result = self._try_convert_data( axis, self.obj._get_axis(axis), use_dtypes=False, convert_dates=True) if result: ...
python
def _convert_axes(self): """ Try to convert axes. """ for axis in self.obj._AXIS_NUMBERS.keys(): new_axis, result = self._try_convert_data( axis, self.obj._get_axis(axis), use_dtypes=False, convert_dates=True) if result: ...
[ "def", "_convert_axes", "(", "self", ")", ":", "for", "axis", "in", "self", ".", "obj", ".", "_AXIS_NUMBERS", ".", "keys", "(", ")", ":", "new_axis", ",", "result", "=", "self", ".", "_try_convert_data", "(", "axis", ",", "self", ".", "obj", ".", "_g...
Try to convert axes.
[ "Try", "to", "convert", "axes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/json.py#L678-L687
20,442
pandas-dev/pandas
pandas/io/json/json.py
FrameParser._process_converter
def _process_converter(self, f, filt=None): """ Take a conversion function and possibly recreate the frame. """ if filt is None: filt = lambda col, c: True needs_new_obj = False new_obj = dict() for i, (col, c) in enumerate(self.obj.iteritems()): ...
python
def _process_converter(self, f, filt=None): """ Take a conversion function and possibly recreate the frame. """ if filt is None: filt = lambda col, c: True needs_new_obj = False new_obj = dict() for i, (col, c) in enumerate(self.obj.iteritems()): ...
[ "def", "_process_converter", "(", "self", ",", "f", ",", "filt", "=", "None", ")", ":", "if", "filt", "is", "None", ":", "filt", "=", "lambda", "col", ",", "c", ":", "True", "needs_new_obj", "=", "False", "new_obj", "=", "dict", "(", ")", "for", "i...
Take a conversion function and possibly recreate the frame.
[ "Take", "a", "conversion", "function", "and", "possibly", "recreate", "the", "frame", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/json.py#L904-L927
20,443
pandas-dev/pandas
pandas/io/formats/format.py
format_array
def format_array(values, formatter, float_format=None, na_rep='NaN', digits=None, space=None, justify='right', decimal='.', leading_space=None): """ Format an array for printing. Parameters ---------- values formatter float_format na_rep digits ...
python
def format_array(values, formatter, float_format=None, na_rep='NaN', digits=None, space=None, justify='right', decimal='.', leading_space=None): """ Format an array for printing. Parameters ---------- values formatter float_format na_rep digits ...
[ "def", "format_array", "(", "values", ",", "formatter", ",", "float_format", "=", "None", ",", "na_rep", "=", "'NaN'", ",", "digits", "=", "None", ",", "space", "=", "None", ",", "justify", "=", "'right'", ",", "decimal", "=", "'.'", ",", "leading_space"...
Format an array for printing. Parameters ---------- values formatter float_format na_rep digits space justify decimal leading_space : bool, optional Whether the array should be formatted with a leading space. When an array as a column of a Series or DataFrame...
[ "Format", "an", "array", "for", "printing", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L853-L912
20,444
pandas-dev/pandas
pandas/io/formats/format.py
format_percentiles
def format_percentiles(percentiles): """ Outputs rounded and formatted percentiles. Parameters ---------- percentiles : list-like, containing floats from interval [0,1] Returns ------- formatted : list of strings Notes ----- Rounding precision is chosen so that: (1) if any...
python
def format_percentiles(percentiles): """ Outputs rounded and formatted percentiles. Parameters ---------- percentiles : list-like, containing floats from interval [0,1] Returns ------- formatted : list of strings Notes ----- Rounding precision is chosen so that: (1) if any...
[ "def", "format_percentiles", "(", "percentiles", ")", ":", "percentiles", "=", "np", ".", "asarray", "(", "percentiles", ")", "# It checks for np.NaN as well", "with", "np", ".", "errstate", "(", "invalid", "=", "'ignore'", ")", ":", "if", "not", "is_numeric_dty...
Outputs rounded and formatted percentiles. Parameters ---------- percentiles : list-like, containing floats from interval [0,1] Returns ------- formatted : list of strings Notes ----- Rounding precision is chosen so that: (1) if any two elements of ``percentiles`` differ, they...
[ "Outputs", "rounded", "and", "formatted", "percentiles", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1208-L1268
20,445
pandas-dev/pandas
pandas/io/formats/format.py
_get_format_timedelta64
def _get_format_timedelta64(values, nat_rep='NaT', box=False): """ Return a formatter function for a range of timedeltas. These will all have the same format argument If box, then show the return in quotes """ values_int = values.astype(np.int64) consider_values = values_int != iNaT ...
python
def _get_format_timedelta64(values, nat_rep='NaT', box=False): """ Return a formatter function for a range of timedeltas. These will all have the same format argument If box, then show the return in quotes """ values_int = values.astype(np.int64) consider_values = values_int != iNaT ...
[ "def", "_get_format_timedelta64", "(", "values", ",", "nat_rep", "=", "'NaT'", ",", "box", "=", "False", ")", ":", "values_int", "=", "values", ".", "astype", "(", "np", ".", "int64", ")", "consider_values", "=", "values_int", "!=", "iNaT", "one_day_nanos", ...
Return a formatter function for a range of timedeltas. These will all have the same format argument If box, then show the return in quotes
[ "Return", "a", "formatter", "function", "for", "a", "range", "of", "timedeltas", ".", "These", "will", "all", "have", "the", "same", "format", "argument" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1360-L1396
20,446
pandas-dev/pandas
pandas/io/formats/format.py
_trim_zeros_complex
def _trim_zeros_complex(str_complexes, na_rep='NaN'): """ Separates the real and imaginary parts from the complex number, and executes the _trim_zeros_float method on each of those. """ def separate_and_trim(str_complex, na_rep): num_arr = str_complex.split('+') return (_trim_zeros_f...
python
def _trim_zeros_complex(str_complexes, na_rep='NaN'): """ Separates the real and imaginary parts from the complex number, and executes the _trim_zeros_float method on each of those. """ def separate_and_trim(str_complex, na_rep): num_arr = str_complex.split('+') return (_trim_zeros_f...
[ "def", "_trim_zeros_complex", "(", "str_complexes", ",", "na_rep", "=", "'NaN'", ")", ":", "def", "separate_and_trim", "(", "str_complex", ",", "na_rep", ")", ":", "num_arr", "=", "str_complex", ".", "split", "(", "'+'", ")", "return", "(", "_trim_zeros_float"...
Separates the real and imaginary parts from the complex number, and executes the _trim_zeros_float method on each of those.
[ "Separates", "the", "real", "and", "imaginary", "parts", "from", "the", "complex", "number", "and", "executes", "the", "_trim_zeros_float", "method", "on", "each", "of", "those", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1427-L1439
20,447
pandas-dev/pandas
pandas/io/formats/format.py
_trim_zeros_float
def _trim_zeros_float(str_floats, na_rep='NaN'): """ Trims zeros, leaving just one before the decimal points if need be. """ trimmed = str_floats def _is_number(x): return (x != na_rep and not x.endswith('inf')) def _cond(values): finite = [x for x in values if _is_number(x)] ...
python
def _trim_zeros_float(str_floats, na_rep='NaN'): """ Trims zeros, leaving just one before the decimal points if need be. """ trimmed = str_floats def _is_number(x): return (x != na_rep and not x.endswith('inf')) def _cond(values): finite = [x for x in values if _is_number(x)] ...
[ "def", "_trim_zeros_float", "(", "str_floats", ",", "na_rep", "=", "'NaN'", ")", ":", "trimmed", "=", "str_floats", "def", "_is_number", "(", "x", ")", ":", "return", "(", "x", "!=", "na_rep", "and", "not", "x", ".", "endswith", "(", "'inf'", ")", ")",...
Trims zeros, leaving just one before the decimal points if need be.
[ "Trims", "zeros", "leaving", "just", "one", "before", "the", "decimal", "points", "if", "need", "be", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1442-L1461
20,448
pandas-dev/pandas
pandas/io/formats/format.py
set_eng_float_format
def set_eng_float_format(accuracy=3, use_eng_prefix=False): """ Alter default behavior on how float is formatted in DataFrame. Format float in engineering format. By accuracy, we mean the number of decimal digits after the floating point. See also EngFormatter. """ set_option("display.floa...
python
def set_eng_float_format(accuracy=3, use_eng_prefix=False): """ Alter default behavior on how float is formatted in DataFrame. Format float in engineering format. By accuracy, we mean the number of decimal digits after the floating point. See also EngFormatter. """ set_option("display.floa...
[ "def", "set_eng_float_format", "(", "accuracy", "=", "3", ",", "use_eng_prefix", "=", "False", ")", ":", "set_option", "(", "\"display.float_format\"", ",", "EngFormatter", "(", "accuracy", ",", "use_eng_prefix", ")", ")", "set_option", "(", "\"display.column_space\...
Alter default behavior on how float is formatted in DataFrame. Format float in engineering format. By accuracy, we mean the number of decimal digits after the floating point. See also EngFormatter.
[ "Alter", "default", "behavior", "on", "how", "float", "is", "formatted", "in", "DataFrame", ".", "Format", "float", "in", "engineering", "format", ".", "By", "accuracy", "we", "mean", "the", "number", "of", "decimal", "digits", "after", "the", "floating", "p...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1570-L1580
20,449
pandas-dev/pandas
pandas/io/formats/format.py
get_level_lengths
def get_level_lengths(levels, sentinel=''): """For each index in each level the function returns lengths of indexes. Parameters ---------- levels : list of lists List of values on for level. sentinel : string, optional Value which states that no new index starts on there. Retur...
python
def get_level_lengths(levels, sentinel=''): """For each index in each level the function returns lengths of indexes. Parameters ---------- levels : list of lists List of values on for level. sentinel : string, optional Value which states that no new index starts on there. Retur...
[ "def", "get_level_lengths", "(", "levels", ",", "sentinel", "=", "''", ")", ":", "if", "len", "(", "levels", ")", "==", "0", ":", "return", "[", "]", "control", "=", "[", "True", "]", "*", "len", "(", "levels", "[", "0", "]", ")", "result", "=", ...
For each index in each level the function returns lengths of indexes. Parameters ---------- levels : list of lists List of values on for level. sentinel : string, optional Value which states that no new index starts on there. Returns ---------- Returns list of maps. For eac...
[ "For", "each", "index", "in", "each", "level", "the", "function", "returns", "lengths", "of", "indexes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1603-L1640
20,450
pandas-dev/pandas
pandas/io/formats/format.py
buffer_put_lines
def buffer_put_lines(buf, lines): """ Appends lines to a buffer. Parameters ---------- buf The buffer to write to lines The lines to append. """ if any(isinstance(x, str) for x in lines): lines = [str(x) for x in lines] buf.write('\n'.join(lines))
python
def buffer_put_lines(buf, lines): """ Appends lines to a buffer. Parameters ---------- buf The buffer to write to lines The lines to append. """ if any(isinstance(x, str) for x in lines): lines = [str(x) for x in lines] buf.write('\n'.join(lines))
[ "def", "buffer_put_lines", "(", "buf", ",", "lines", ")", ":", "if", "any", "(", "isinstance", "(", "x", ",", "str", ")", "for", "x", "in", "lines", ")", ":", "lines", "=", "[", "str", "(", "x", ")", "for", "x", "in", "lines", "]", "buf", ".", ...
Appends lines to a buffer. Parameters ---------- buf The buffer to write to lines The lines to append.
[ "Appends", "lines", "to", "a", "buffer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1643-L1656
20,451
pandas-dev/pandas
pandas/io/formats/format.py
EastAsianTextAdjustment.len
def len(self, text): """ Calculate display width considering unicode East Asian Width """ if not isinstance(text, str): return len(text) return sum(self._EAW_MAP.get(east_asian_width(c), self.ambiguous_width) for c in text)
python
def len(self, text): """ Calculate display width considering unicode East Asian Width """ if not isinstance(text, str): return len(text) return sum(self._EAW_MAP.get(east_asian_width(c), self.ambiguous_width) for c in text)
[ "def", "len", "(", "self", ",", "text", ")", ":", "if", "not", "isinstance", "(", "text", ",", "str", ")", ":", "return", "len", "(", "text", ")", "return", "sum", "(", "self", ".", "_EAW_MAP", ".", "get", "(", "east_asian_width", "(", "c", ")", ...
Calculate display width considering unicode East Asian Width
[ "Calculate", "display", "width", "considering", "unicode", "East", "Asian", "Width" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L322-L330
20,452
pandas-dev/pandas
pandas/io/formats/format.py
FloatArrayFormatter._value_formatter
def _value_formatter(self, float_format=None, threshold=None): """Returns a function to be applied on each value to format it """ # the float_format parameter supersedes self.float_format if float_format is None: float_format = self.float_format # we are going to co...
python
def _value_formatter(self, float_format=None, threshold=None): """Returns a function to be applied on each value to format it """ # the float_format parameter supersedes self.float_format if float_format is None: float_format = self.float_format # we are going to co...
[ "def", "_value_formatter", "(", "self", ",", "float_format", "=", "None", ",", "threshold", "=", "None", ")", ":", "# the float_format parameter supersedes self.float_format", "if", "float_format", "is", "None", ":", "float_format", "=", "self", ".", "float_format", ...
Returns a function to be applied on each value to format it
[ "Returns", "a", "function", "to", "be", "applied", "on", "each", "value", "to", "format", "it" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1015-L1054
20,453
pandas-dev/pandas
pandas/io/formats/format.py
FloatArrayFormatter.get_result_as_array
def get_result_as_array(self): """ Returns the float values converted into strings using the parameters given at initialisation, as a numpy array """ if self.formatter is not None: return np.array([self.formatter(x) for x in self.values]) if self.fixed_width...
python
def get_result_as_array(self): """ Returns the float values converted into strings using the parameters given at initialisation, as a numpy array """ if self.formatter is not None: return np.array([self.formatter(x) for x in self.values]) if self.fixed_width...
[ "def", "get_result_as_array", "(", "self", ")", ":", "if", "self", ".", "formatter", "is", "not", "None", ":", "return", "np", ".", "array", "(", "[", "self", ".", "formatter", "(", "x", ")", "for", "x", "in", "self", ".", "values", "]", ")", "if",...
Returns the float values converted into strings using the parameters given at initialisation, as a numpy array
[ "Returns", "the", "float", "values", "converted", "into", "strings", "using", "the", "parameters", "given", "at", "initialisation", "as", "a", "numpy", "array" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1056-L1141
20,454
pandas-dev/pandas
pandas/io/formats/format.py
Datetime64TZFormatter._format_strings
def _format_strings(self): """ we by definition have a TZ """ values = self.values.astype(object) is_dates_only = _is_dates_only(values) formatter = (self.formatter or _get_format_datetime64(is_dates_only, date_format=self...
python
def _format_strings(self): """ we by definition have a TZ """ values = self.values.astype(object) is_dates_only = _is_dates_only(values) formatter = (self.formatter or _get_format_datetime64(is_dates_only, date_format=self...
[ "def", "_format_strings", "(", "self", ")", ":", "values", "=", "self", ".", "values", ".", "astype", "(", "object", ")", "is_dates_only", "=", "_is_dates_only", "(", "values", ")", "formatter", "=", "(", "self", ".", "formatter", "or", "_get_format_datetime...
we by definition have a TZ
[ "we", "by", "definition", "have", "a", "TZ" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L1332-L1342
20,455
pandas-dev/pandas
pandas/core/indexes/interval.py
_get_interval_closed_bounds
def _get_interval_closed_bounds(interval): """ Given an Interval or IntervalIndex, return the corresponding interval with closed bounds. """ left, right = interval.left, interval.right if interval.open_left: left = _get_next_label(left) if interval.open_right: right = _get_pr...
python
def _get_interval_closed_bounds(interval): """ Given an Interval or IntervalIndex, return the corresponding interval with closed bounds. """ left, right = interval.left, interval.right if interval.open_left: left = _get_next_label(left) if interval.open_right: right = _get_pr...
[ "def", "_get_interval_closed_bounds", "(", "interval", ")", ":", "left", ",", "right", "=", "interval", ".", "left", ",", "interval", ".", "right", "if", "interval", ".", "open_left", ":", "left", "=", "_get_next_label", "(", "left", ")", "if", "interval", ...
Given an Interval or IntervalIndex, return the corresponding interval with closed bounds.
[ "Given", "an", "Interval", "or", "IntervalIndex", "return", "the", "corresponding", "interval", "with", "closed", "bounds", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/interval.py#L79-L89
20,456
pandas-dev/pandas
pandas/core/indexes/interval.py
interval_range
def interval_range(start=None, end=None, periods=None, freq=None, name=None, closed='right'): """ Return a fixed frequency IntervalIndex Parameters ---------- start : numeric or datetime-like, default None Left bound for generating intervals end : numeric or datetime-...
python
def interval_range(start=None, end=None, periods=None, freq=None, name=None, closed='right'): """ Return a fixed frequency IntervalIndex Parameters ---------- start : numeric or datetime-like, default None Left bound for generating intervals end : numeric or datetime-...
[ "def", "interval_range", "(", "start", "=", "None", ",", "end", "=", "None", ",", "periods", "=", "None", ",", "freq", "=", "None", ",", "name", "=", "None", ",", "closed", "=", "'right'", ")", ":", "start", "=", "com", ".", "maybe_box_datetimelike", ...
Return a fixed frequency IntervalIndex Parameters ---------- start : numeric or datetime-like, default None Left bound for generating intervals end : numeric or datetime-like, default None Right bound for generating intervals periods : integer, default None Number of periods...
[ "Return", "a", "fixed", "frequency", "IntervalIndex" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/interval.py#L1156-L1312
20,457
pandas-dev/pandas
pandas/io/formats/csvs.py
CSVFormatter.save
def save(self): """ Create the writer & save """ # GH21227 internal compression is not used when file-like passed. if self.compression and hasattr(self.path_or_buf, 'write'): msg = ("compression has no effect when passing file-like " "object as inpu...
python
def save(self): """ Create the writer & save """ # GH21227 internal compression is not used when file-like passed. if self.compression and hasattr(self.path_or_buf, 'write'): msg = ("compression has no effect when passing file-like " "object as inpu...
[ "def", "save", "(", "self", ")", ":", "# GH21227 internal compression is not used when file-like passed.", "if", "self", ".", "compression", "and", "hasattr", "(", "self", ".", "path_or_buf", ",", "'write'", ")", ":", "msg", "=", "(", "\"compression has no effect when...
Create the writer & save
[ "Create", "the", "writer", "&", "save" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/csvs.py#L125-L184
20,458
pandas-dev/pandas
pandas/core/accessor.py
delegate_names
def delegate_names(delegate, accessors, typ, overwrite=False): """ Add delegated names to a class using a class decorator. This provides an alternative usage to directly calling `_add_delegate_accessors` below a class definition. Parameters ---------- delegate : object the class to...
python
def delegate_names(delegate, accessors, typ, overwrite=False): """ Add delegated names to a class using a class decorator. This provides an alternative usage to directly calling `_add_delegate_accessors` below a class definition. Parameters ---------- delegate : object the class to...
[ "def", "delegate_names", "(", "delegate", ",", "accessors", ",", "typ", ",", "overwrite", "=", "False", ")", ":", "def", "add_delegate_accessors", "(", "cls", ")", ":", "cls", ".", "_add_delegate_accessors", "(", "delegate", ",", "accessors", ",", "typ", ","...
Add delegated names to a class using a class decorator. This provides an alternative usage to directly calling `_add_delegate_accessors` below a class definition. Parameters ---------- delegate : object the class to get methods/properties & doc-strings accessors : Sequence[str] ...
[ "Add", "delegated", "names", "to", "a", "class", "using", "a", "class", "decorator", ".", "This", "provides", "an", "alternative", "usage", "to", "directly", "calling", "_add_delegate_accessors", "below", "a", "class", "definition", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/accessor.py#L114-L146
20,459
pandas-dev/pandas
pandas/core/accessor.py
PandasDelegate._add_delegate_accessors
def _add_delegate_accessors(cls, delegate, accessors, typ, overwrite=False): """ Add accessors to cls from the delegate class. Parameters ---------- cls : the class to add the methods/properties to delegate : the class to get methods/prope...
python
def _add_delegate_accessors(cls, delegate, accessors, typ, overwrite=False): """ Add accessors to cls from the delegate class. Parameters ---------- cls : the class to add the methods/properties to delegate : the class to get methods/prope...
[ "def", "_add_delegate_accessors", "(", "cls", ",", "delegate", ",", "accessors", ",", "typ", ",", "overwrite", "=", "False", ")", ":", "def", "_create_delegator_property", "(", "name", ")", ":", "def", "_getter", "(", "self", ")", ":", "return", "self", "....
Add accessors to cls from the delegate class. Parameters ---------- cls : the class to add the methods/properties to delegate : the class to get methods/properties & doc-strings accessors : string list of accessors to add typ : 'property' or 'method' overwrite : ...
[ "Add", "accessors", "to", "cls", "from", "the", "delegate", "class", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/accessor.py#L63-L111
20,460
pandas-dev/pandas
pandas/core/computation/expressions.py
_can_use_numexpr
def _can_use_numexpr(op, op_str, a, b, dtype_check): """ return a boolean if we WILL be using numexpr """ if op_str is not None: # required min elements (otherwise we are adding overhead) if np.prod(a.shape) > _MIN_ELEMENTS: # check for dtype compatibility dtypes = set(...
python
def _can_use_numexpr(op, op_str, a, b, dtype_check): """ return a boolean if we WILL be using numexpr """ if op_str is not None: # required min elements (otherwise we are adding overhead) if np.prod(a.shape) > _MIN_ELEMENTS: # check for dtype compatibility dtypes = set(...
[ "def", "_can_use_numexpr", "(", "op", ",", "op_str", ",", "a", ",", "b", ",", "dtype_check", ")", ":", "if", "op_str", "is", "not", "None", ":", "# required min elements (otherwise we are adding overhead)", "if", "np", ".", "prod", "(", "a", ".", "shape", ")...
return a boolean if we WILL be using numexpr
[ "return", "a", "boolean", "if", "we", "WILL", "be", "using", "numexpr" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expressions.py#L72-L94
20,461
pandas-dev/pandas
pandas/core/computation/expressions.py
evaluate
def evaluate(op, op_str, a, b, use_numexpr=True, **eval_kwargs): """ evaluate and return the expression of the op on a and b Parameters ---------- op : the actual operand op_str: the string version of the op a : left operand b : right operand...
python
def evaluate(op, op_str, a, b, use_numexpr=True, **eval_kwargs): """ evaluate and return the expression of the op on a and b Parameters ---------- op : the actual operand op_str: the string version of the op a : left operand b : right operand...
[ "def", "evaluate", "(", "op", ",", "op_str", ",", "a", ",", "b", ",", "use_numexpr", "=", "True", ",", "*", "*", "eval_kwargs", ")", ":", "use_numexpr", "=", "use_numexpr", "and", "_bool_arith_check", "(", "op_str", ",", "a", ",", "b", ")", "if", "us...
evaluate and return the expression of the op on a and b Parameters ---------- op : the actual operand op_str: the string version of the op a : left operand b : right operand use_numexpr : whether to try to use numexpr (default True)
[ "evaluate", "and", "return", "the", "expression", "of", "the", "op", "on", "a", "and", "b" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expressions.py#L193-L210
20,462
pandas-dev/pandas
pandas/core/computation/expressions.py
where
def where(cond, a, b, use_numexpr=True): """ evaluate the where condition cond on a and b Parameters ---------- cond : a boolean array a : return if cond is True b : return if cond is False use_numexpr : whether to try to use numexpr (default True) """...
python
def where(cond, a, b, use_numexpr=True): """ evaluate the where condition cond on a and b Parameters ---------- cond : a boolean array a : return if cond is True b : return if cond is False use_numexpr : whether to try to use numexpr (default True) """...
[ "def", "where", "(", "cond", ",", "a", ",", "b", ",", "use_numexpr", "=", "True", ")", ":", "if", "use_numexpr", ":", "return", "_where", "(", "cond", ",", "a", ",", "b", ")", "return", "_where_standard", "(", "cond", ",", "a", ",", "b", ")" ]
evaluate the where condition cond on a and b Parameters ---------- cond : a boolean array a : return if cond is True b : return if cond is False use_numexpr : whether to try to use numexpr (default True)
[ "evaluate", "the", "where", "condition", "cond", "on", "a", "and", "b" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expressions.py#L213-L227
20,463
pandas-dev/pandas
pandas/io/feather_format.py
to_feather
def to_feather(df, path): """ Write a DataFrame to the feather-format Parameters ---------- df : DataFrame path : string file path, or file-like object """ path = _stringify_path(path) if not isinstance(df, DataFrame): raise ValueError("feather only support IO with DataFram...
python
def to_feather(df, path): """ Write a DataFrame to the feather-format Parameters ---------- df : DataFrame path : string file path, or file-like object """ path = _stringify_path(path) if not isinstance(df, DataFrame): raise ValueError("feather only support IO with DataFram...
[ "def", "to_feather", "(", "df", ",", "path", ")", ":", "path", "=", "_stringify_path", "(", "path", ")", "if", "not", "isinstance", "(", "df", ",", "DataFrame", ")", ":", "raise", "ValueError", "(", "\"feather only support IO with DataFrames\"", ")", "feather"...
Write a DataFrame to the feather-format Parameters ---------- df : DataFrame path : string file path, or file-like object
[ "Write", "a", "DataFrame", "to", "the", "feather", "-", "format" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/feather_format.py#L36-L82
20,464
pandas-dev/pandas
pandas/io/feather_format.py
read_feather
def read_feather(path, columns=None, use_threads=True): """ Load a feather-format object from the file path .. versionadded 0.20.0 Parameters ---------- path : string file path, or file-like object columns : sequence, default None If not provided, all columns are read .. v...
python
def read_feather(path, columns=None, use_threads=True): """ Load a feather-format object from the file path .. versionadded 0.20.0 Parameters ---------- path : string file path, or file-like object columns : sequence, default None If not provided, all columns are read .. v...
[ "def", "read_feather", "(", "path", ",", "columns", "=", "None", ",", "use_threads", "=", "True", ")", ":", "feather", ",", "pyarrow", "=", "_try_import", "(", ")", "path", "=", "_stringify_path", "(", "path", ")", "if", "LooseVersion", "(", "pyarrow", "...
Load a feather-format object from the file path .. versionadded 0.20.0 Parameters ---------- path : string file path, or file-like object columns : sequence, default None If not provided, all columns are read .. versionadded 0.24.0 nthreads : int, default 1 Number of C...
[ "Load", "a", "feather", "-", "format", "object", "from", "the", "file", "path" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/feather_format.py#L86-L125
20,465
pandas-dev/pandas
pandas/core/arrays/_ranges.py
generate_regular_range
def generate_regular_range(start, end, periods, freq): """ Generate a range of dates with the spans between dates described by the given `freq` DateOffset. Parameters ---------- start : Timestamp or None first point of produced date range end : Timestamp or None last point o...
python
def generate_regular_range(start, end, periods, freq): """ Generate a range of dates with the spans between dates described by the given `freq` DateOffset. Parameters ---------- start : Timestamp or None first point of produced date range end : Timestamp or None last point o...
[ "def", "generate_regular_range", "(", "start", ",", "end", ",", "periods", ",", "freq", ")", ":", "if", "isinstance", "(", "freq", ",", "Tick", ")", ":", "stride", "=", "freq", ".", "nanos", "if", "periods", "is", "None", ":", "b", "=", "Timestamp", ...
Generate a range of dates with the spans between dates described by the given `freq` DateOffset. Parameters ---------- start : Timestamp or None first point of produced date range end : Timestamp or None last point of produced date range periods : int number of periods i...
[ "Generate", "a", "range", "of", "dates", "with", "the", "spans", "between", "dates", "described", "by", "the", "given", "freq", "DateOffset", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/_ranges.py#L13-L79
20,466
pandas-dev/pandas
pandas/core/arrays/_ranges.py
_generate_range_overflow_safe
def _generate_range_overflow_safe(endpoint, periods, stride, side='start'): """ Calculate the second endpoint for passing to np.arange, checking to avoid an integer overflow. Catch OverflowError and re-raise as OutOfBoundsDatetime. Parameters ---------- endpoint : int nanosecond ti...
python
def _generate_range_overflow_safe(endpoint, periods, stride, side='start'): """ Calculate the second endpoint for passing to np.arange, checking to avoid an integer overflow. Catch OverflowError and re-raise as OutOfBoundsDatetime. Parameters ---------- endpoint : int nanosecond ti...
[ "def", "_generate_range_overflow_safe", "(", "endpoint", ",", "periods", ",", "stride", ",", "side", "=", "'start'", ")", ":", "# GH#14187 raise instead of incorrectly wrapping around", "assert", "side", "in", "[", "'start'", ",", "'end'", "]", "i64max", "=", "np", ...
Calculate the second endpoint for passing to np.arange, checking to avoid an integer overflow. Catch OverflowError and re-raise as OutOfBoundsDatetime. Parameters ---------- endpoint : int nanosecond timestamp of the known endpoint of the desired range periods : int number of p...
[ "Calculate", "the", "second", "endpoint", "for", "passing", "to", "np", ".", "arange", "checking", "to", "avoid", "an", "integer", "overflow", ".", "Catch", "OverflowError", "and", "re", "-", "raise", "as", "OutOfBoundsDatetime", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/_ranges.py#L82-L146
20,467
pandas-dev/pandas
pandas/_config/localization.py
set_locale
def set_locale(new_locale, lc_var=locale.LC_ALL): """ Context manager for temporarily setting a locale. Parameters ---------- new_locale : str or tuple A string of the form <language_country>.<encoding>. For example to set the current locale to US English with a UTF8 encoding, you w...
python
def set_locale(new_locale, lc_var=locale.LC_ALL): """ Context manager for temporarily setting a locale. Parameters ---------- new_locale : str or tuple A string of the form <language_country>.<encoding>. For example to set the current locale to US English with a UTF8 encoding, you w...
[ "def", "set_locale", "(", "new_locale", ",", "lc_var", "=", "locale", ".", "LC_ALL", ")", ":", "current_locale", "=", "locale", ".", "getlocale", "(", ")", "try", ":", "locale", ".", "setlocale", "(", "lc_var", ",", "new_locale", ")", "normalized_locale", ...
Context manager for temporarily setting a locale. Parameters ---------- new_locale : str or tuple A string of the form <language_country>.<encoding>. For example to set the current locale to US English with a UTF8 encoding, you would pass "en_US.UTF-8". lc_var : int, default `lo...
[ "Context", "manager", "for", "temporarily", "setting", "a", "locale", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/localization.py#L15-L44
20,468
pandas-dev/pandas
pandas/_config/localization.py
can_set_locale
def can_set_locale(lc, lc_var=locale.LC_ALL): """ Check to see if we can set a locale, and subsequently get the locale, without raising an Exception. Parameters ---------- lc : str The locale to attempt to set. lc_var : int, default `locale.LC_ALL` The category of the locale...
python
def can_set_locale(lc, lc_var=locale.LC_ALL): """ Check to see if we can set a locale, and subsequently get the locale, without raising an Exception. Parameters ---------- lc : str The locale to attempt to set. lc_var : int, default `locale.LC_ALL` The category of the locale...
[ "def", "can_set_locale", "(", "lc", ",", "lc_var", "=", "locale", ".", "LC_ALL", ")", ":", "try", ":", "with", "set_locale", "(", "lc", ",", "lc_var", "=", "lc_var", ")", ":", "pass", "except", "(", "ValueError", ",", "locale", ".", "Error", ")", ":"...
Check to see if we can set a locale, and subsequently get the locale, without raising an Exception. Parameters ---------- lc : str The locale to attempt to set. lc_var : int, default `locale.LC_ALL` The category of the locale being set. Returns ------- is_valid : bool ...
[ "Check", "to", "see", "if", "we", "can", "set", "a", "locale", "and", "subsequently", "get", "the", "locale", "without", "raising", "an", "Exception", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/localization.py#L47-L72
20,469
pandas-dev/pandas
pandas/_config/localization.py
_valid_locales
def _valid_locales(locales, normalize): """ Return a list of normalized locales that do not throw an ``Exception`` when set. Parameters ---------- locales : str A string where each locale is separated by a newline. normalize : bool Whether to call ``locale.normalize`` on eac...
python
def _valid_locales(locales, normalize): """ Return a list of normalized locales that do not throw an ``Exception`` when set. Parameters ---------- locales : str A string where each locale is separated by a newline. normalize : bool Whether to call ``locale.normalize`` on eac...
[ "def", "_valid_locales", "(", "locales", ",", "normalize", ")", ":", "if", "normalize", ":", "normalizer", "=", "lambda", "x", ":", "locale", ".", "normalize", "(", "x", ".", "strip", "(", ")", ")", "else", ":", "normalizer", "=", "lambda", "x", ":", ...
Return a list of normalized locales that do not throw an ``Exception`` when set. Parameters ---------- locales : str A string where each locale is separated by a newline. normalize : bool Whether to call ``locale.normalize`` on each locale. Returns ------- valid_locales...
[ "Return", "a", "list", "of", "normalized", "locales", "that", "do", "not", "throw", "an", "Exception", "when", "set", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/localization.py#L75-L97
20,470
pandas-dev/pandas
pandas/_config/localization.py
get_locales
def get_locales(prefix=None, normalize=True, locale_getter=_default_locale_getter): """ Get all the locales that are available on the system. Parameters ---------- prefix : str If not ``None`` then return only those locales with the prefix provided. For example to ge...
python
def get_locales(prefix=None, normalize=True, locale_getter=_default_locale_getter): """ Get all the locales that are available on the system. Parameters ---------- prefix : str If not ``None`` then return only those locales with the prefix provided. For example to ge...
[ "def", "get_locales", "(", "prefix", "=", "None", ",", "normalize", "=", "True", ",", "locale_getter", "=", "_default_locale_getter", ")", ":", "try", ":", "raw_locales", "=", "locale_getter", "(", ")", "except", "Exception", ":", "return", "None", "try", ":...
Get all the locales that are available on the system. Parameters ---------- prefix : str If not ``None`` then return only those locales with the prefix provided. For example to get all English language locales (those that start with ``"en"``), pass ``prefix="en"``. normalize : b...
[ "Get", "all", "the", "locales", "that", "are", "available", "on", "the", "system", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/localization.py#L109-L162
20,471
pandas-dev/pandas
pandas/core/dtypes/common.py
ensure_float
def ensure_float(arr): """ Ensure that an array object has a float dtype if possible. Parameters ---------- arr : array-like The array whose data type we want to enforce as float. Returns ------- float_arr : The original array cast to the float dtype if possible...
python
def ensure_float(arr): """ Ensure that an array object has a float dtype if possible. Parameters ---------- arr : array-like The array whose data type we want to enforce as float. Returns ------- float_arr : The original array cast to the float dtype if possible...
[ "def", "ensure_float", "(", "arr", ")", ":", "if", "issubclass", "(", "arr", ".", "dtype", ".", "type", ",", "(", "np", ".", "integer", ",", "np", ".", "bool_", ")", ")", ":", "arr", "=", "arr", ".", "astype", "(", "float", ")", "return", "arr" ]
Ensure that an array object has a float dtype if possible. Parameters ---------- arr : array-like The array whose data type we want to enforce as float. Returns ------- float_arr : The original array cast to the float dtype if possible. Otherwise, the original array is ...
[ "Ensure", "that", "an", "array", "object", "has", "a", "float", "dtype", "if", "possible", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L40-L57
20,472
pandas-dev/pandas
pandas/core/dtypes/common.py
ensure_int64_or_float64
def ensure_int64_or_float64(arr, copy=False): """ Ensure that an dtype array of some integer dtype has an int64 dtype if possible If it's not possible, potentially because of overflow, convert the array to float64 instead. Parameters ---------- arr : array-like The array whose...
python
def ensure_int64_or_float64(arr, copy=False): """ Ensure that an dtype array of some integer dtype has an int64 dtype if possible If it's not possible, potentially because of overflow, convert the array to float64 instead. Parameters ---------- arr : array-like The array whose...
[ "def", "ensure_int64_or_float64", "(", "arr", ",", "copy", "=", "False", ")", ":", "try", ":", "return", "arr", ".", "astype", "(", "'int64'", ",", "copy", "=", "copy", ",", "casting", "=", "'safe'", ")", "except", "TypeError", ":", "return", "arr", "....
Ensure that an dtype array of some integer dtype has an int64 dtype if possible If it's not possible, potentially because of overflow, convert the array to float64 instead. Parameters ---------- arr : array-like The array whose data type we want to enforce. copy: boolean ...
[ "Ensure", "that", "an", "dtype", "array", "of", "some", "integer", "dtype", "has", "an", "int64", "dtype", "if", "possible", "If", "it", "s", "not", "possible", "potentially", "because", "of", "overflow", "convert", "the", "array", "to", "float64", "instead"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L90-L114
20,473
pandas-dev/pandas
pandas/core/dtypes/common.py
classes_and_not_datetimelike
def classes_and_not_datetimelike(*klasses): """ evaluate if the tipo is a subclass of the klasses and not a datetimelike """ return lambda tipo: (issubclass(tipo, klasses) and not issubclass(tipo, (np.datetime64, np.timedelta64)))
python
def classes_and_not_datetimelike(*klasses): """ evaluate if the tipo is a subclass of the klasses and not a datetimelike """ return lambda tipo: (issubclass(tipo, klasses) and not issubclass(tipo, (np.datetime64, np.timedelta64)))
[ "def", "classes_and_not_datetimelike", "(", "*", "klasses", ")", ":", "return", "lambda", "tipo", ":", "(", "issubclass", "(", "tipo", ",", "klasses", ")", "and", "not", "issubclass", "(", "tipo", ",", "(", "np", ".", "datetime64", ",", "np", ".", "timed...
evaluate if the tipo is a subclass of the klasses and not a datetimelike
[ "evaluate", "if", "the", "tipo", "is", "a", "subclass", "of", "the", "klasses", "and", "not", "a", "datetimelike" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L122-L128
20,474
pandas-dev/pandas
pandas/core/dtypes/common.py
is_sparse
def is_sparse(arr): """ Check whether an array-like is a 1-D pandas sparse array. Check that the one-dimensional array-like is a pandas sparse array. Returns True if it is a pandas sparse array, not another type of sparse array. Parameters ---------- arr : array-like Array-like...
python
def is_sparse(arr): """ Check whether an array-like is a 1-D pandas sparse array. Check that the one-dimensional array-like is a pandas sparse array. Returns True if it is a pandas sparse array, not another type of sparse array. Parameters ---------- arr : array-like Array-like...
[ "def", "is_sparse", "(", "arr", ")", ":", "from", "pandas", ".", "core", ".", "arrays", ".", "sparse", "import", "SparseDtype", "dtype", "=", "getattr", "(", "arr", ",", "'dtype'", ",", "arr", ")", "return", "isinstance", "(", "dtype", ",", "SparseDtype"...
Check whether an array-like is a 1-D pandas sparse array. Check that the one-dimensional array-like is a pandas sparse array. Returns True if it is a pandas sparse array, not another type of sparse array. Parameters ---------- arr : array-like Array-like to check. Returns ----...
[ "Check", "whether", "an", "array", "-", "like", "is", "a", "1", "-", "D", "pandas", "sparse", "array", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L161-L220
20,475
pandas-dev/pandas
pandas/core/dtypes/common.py
is_scipy_sparse
def is_scipy_sparse(arr): """ Check whether an array-like is a scipy.sparse.spmatrix instance. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a scipy.sparse.spmatrix instance. Notes -----...
python
def is_scipy_sparse(arr): """ Check whether an array-like is a scipy.sparse.spmatrix instance. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a scipy.sparse.spmatrix instance. Notes -----...
[ "def", "is_scipy_sparse", "(", "arr", ")", ":", "global", "_is_scipy_sparse", "if", "_is_scipy_sparse", "is", "None", ":", "try", ":", "from", "scipy", ".", "sparse", "import", "issparse", "as", "_is_scipy_sparse", "except", "ImportError", ":", "_is_scipy_sparse",...
Check whether an array-like is a scipy.sparse.spmatrix instance. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a scipy.sparse.spmatrix instance. Notes ----- If scipy is not installed, this f...
[ "Check", "whether", "an", "array", "-", "like", "is", "a", "scipy", ".", "sparse", ".", "spmatrix", "instance", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L223-L260
20,476
pandas-dev/pandas
pandas/core/dtypes/common.py
is_offsetlike
def is_offsetlike(arr_or_obj): """ Check if obj or all elements of list-like is DateOffset Parameters ---------- arr_or_obj : object Returns ------- boolean Whether the object is a DateOffset or listlike of DatetOffsets Examples -------- >>> is_offsetlike(pd.DateOf...
python
def is_offsetlike(arr_or_obj): """ Check if obj or all elements of list-like is DateOffset Parameters ---------- arr_or_obj : object Returns ------- boolean Whether the object is a DateOffset or listlike of DatetOffsets Examples -------- >>> is_offsetlike(pd.DateOf...
[ "def", "is_offsetlike", "(", "arr_or_obj", ")", ":", "if", "isinstance", "(", "arr_or_obj", ",", "ABCDateOffset", ")", ":", "return", "True", "elif", "(", "is_list_like", "(", "arr_or_obj", ")", "and", "len", "(", "arr_or_obj", ")", "and", "is_object_dtype", ...
Check if obj or all elements of list-like is DateOffset Parameters ---------- arr_or_obj : object Returns ------- boolean Whether the object is a DateOffset or listlike of DatetOffsets Examples -------- >>> is_offsetlike(pd.DateOffset(days=1)) True >>> is_offsetlik...
[ "Check", "if", "obj", "or", "all", "elements", "of", "list", "-", "like", "is", "DateOffset" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L343-L372
20,477
pandas-dev/pandas
pandas/core/dtypes/common.py
is_period
def is_period(arr): """ Check whether an array-like is a periodical index. .. deprecated:: 0.24.0 Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a periodical index. Examples --------...
python
def is_period(arr): """ Check whether an array-like is a periodical index. .. deprecated:: 0.24.0 Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a periodical index. Examples --------...
[ "def", "is_period", "(", "arr", ")", ":", "warnings", ".", "warn", "(", "\"'is_period' is deprecated and will be removed in a future \"", "\"version. Use 'is_period_dtype' or is_period_arraylike' \"", "\"instead.\"", ",", "FutureWarning", ",", "stacklevel", "=", "2", ")", "r...
Check whether an array-like is a periodical index. .. deprecated:: 0.24.0 Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a periodical index. Examples -------- >>> is_period([1, 2, 3]) ...
[ "Check", "whether", "an", "array", "-", "like", "is", "a", "periodical", "index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L375-L405
20,478
pandas-dev/pandas
pandas/core/dtypes/common.py
is_string_dtype
def is_string_dtype(arr_or_dtype): """ Check whether the provided array or dtype is of the string dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of the string dtype. E...
python
def is_string_dtype(arr_or_dtype): """ Check whether the provided array or dtype is of the string dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of the string dtype. E...
[ "def", "is_string_dtype", "(", "arr_or_dtype", ")", ":", "# TODO: gh-15585: consider making the checks stricter.", "def", "condition", "(", "dtype", ")", ":", "return", "dtype", ".", "kind", "in", "(", "'O'", ",", "'S'", ",", "'U'", ")", "and", "not", "is_period...
Check whether the provided array or dtype is of the string dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of the string dtype. Examples -------- >>> is_string_dtype(st...
[ "Check", "whether", "the", "provided", "array", "or", "dtype", "is", "of", "the", "string", "dtype", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L611-L643
20,479
pandas-dev/pandas
pandas/core/dtypes/common.py
is_period_arraylike
def is_period_arraylike(arr): """ Check whether an array-like is a periodical array-like or PeriodIndex. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a periodical array-like or PeriodInd...
python
def is_period_arraylike(arr): """ Check whether an array-like is a periodical array-like or PeriodIndex. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a periodical array-like or PeriodInd...
[ "def", "is_period_arraylike", "(", "arr", ")", ":", "if", "isinstance", "(", "arr", ",", "(", "ABCPeriodIndex", ",", "ABCPeriodArray", ")", ")", ":", "return", "True", "elif", "isinstance", "(", "arr", ",", "(", "np", ".", "ndarray", ",", "ABCSeries", ")...
Check whether an array-like is a periodical array-like or PeriodIndex. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a periodical array-like or PeriodIndex instance. Examples -------- ...
[ "Check", "whether", "an", "array", "-", "like", "is", "a", "periodical", "array", "-", "like", "or", "PeriodIndex", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L646-L675
20,480
pandas-dev/pandas
pandas/core/dtypes/common.py
is_datetime_arraylike
def is_datetime_arraylike(arr): """ Check whether an array-like is a datetime array-like or DatetimeIndex. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a datetime array-like or DatetimeI...
python
def is_datetime_arraylike(arr): """ Check whether an array-like is a datetime array-like or DatetimeIndex. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a datetime array-like or DatetimeI...
[ "def", "is_datetime_arraylike", "(", "arr", ")", ":", "if", "isinstance", "(", "arr", ",", "ABCDatetimeIndex", ")", ":", "return", "True", "elif", "isinstance", "(", "arr", ",", "(", "np", ".", "ndarray", ",", "ABCSeries", ")", ")", ":", "return", "(", ...
Check whether an array-like is a datetime array-like or DatetimeIndex. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Whether or not the array-like is a datetime array-like or DatetimeIndex. Examples -------- >>> is_...
[ "Check", "whether", "an", "array", "-", "like", "is", "a", "datetime", "array", "-", "like", "or", "DatetimeIndex", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L678-L708
20,481
pandas-dev/pandas
pandas/core/dtypes/common.py
is_datetimelike
def is_datetimelike(arr): """ Check whether an array-like is a datetime-like array-like. Acceptable datetime-like objects are (but not limited to) datetime indices, periodic indices, and timedelta indices. Parameters ---------- arr : array-like The array-like to check. Returns...
python
def is_datetimelike(arr): """ Check whether an array-like is a datetime-like array-like. Acceptable datetime-like objects are (but not limited to) datetime indices, periodic indices, and timedelta indices. Parameters ---------- arr : array-like The array-like to check. Returns...
[ "def", "is_datetimelike", "(", "arr", ")", ":", "return", "(", "is_datetime64_dtype", "(", "arr", ")", "or", "is_datetime64tz_dtype", "(", "arr", ")", "or", "is_timedelta64_dtype", "(", "arr", ")", "or", "isinstance", "(", "arr", ",", "ABCPeriodIndex", ")", ...
Check whether an array-like is a datetime-like array-like. Acceptable datetime-like objects are (but not limited to) datetime indices, periodic indices, and timedelta indices. Parameters ---------- arr : array-like The array-like to check. Returns ------- boolean Wheth...
[ "Check", "whether", "an", "array", "-", "like", "is", "a", "datetime", "-", "like", "array", "-", "like", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L711-L753
20,482
pandas-dev/pandas
pandas/core/dtypes/common.py
is_dtype_equal
def is_dtype_equal(source, target): """ Check if two dtypes are equal. Parameters ---------- source : The first dtype to compare target : The second dtype to compare Returns ---------- boolean Whether or not the two dtypes are equal. Examples -------- >>> is_dt...
python
def is_dtype_equal(source, target): """ Check if two dtypes are equal. Parameters ---------- source : The first dtype to compare target : The second dtype to compare Returns ---------- boolean Whether or not the two dtypes are equal. Examples -------- >>> is_dt...
[ "def", "is_dtype_equal", "(", "source", ",", "target", ")", ":", "try", ":", "source", "=", "_get_dtype", "(", "source", ")", "target", "=", "_get_dtype", "(", "target", ")", "return", "source", "==", "target", "except", "(", "TypeError", ",", "AttributeEr...
Check if two dtypes are equal. Parameters ---------- source : The first dtype to compare target : The second dtype to compare Returns ---------- boolean Whether or not the two dtypes are equal. Examples -------- >>> is_dtype_equal(int, float) False >>> is_dtype...
[ "Check", "if", "two", "dtypes", "are", "equal", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L756-L792
20,483
pandas-dev/pandas
pandas/core/dtypes/common.py
is_dtype_union_equal
def is_dtype_union_equal(source, target): """ Check whether two arrays have compatible dtypes to do a union. numpy types are checked with ``is_dtype_equal``. Extension types are checked separately. Parameters ---------- source : The first dtype to compare target : The second dtype to co...
python
def is_dtype_union_equal(source, target): """ Check whether two arrays have compatible dtypes to do a union. numpy types are checked with ``is_dtype_equal``. Extension types are checked separately. Parameters ---------- source : The first dtype to compare target : The second dtype to co...
[ "def", "is_dtype_union_equal", "(", "source", ",", "target", ")", ":", "source", "=", "_get_dtype", "(", "source", ")", "target", "=", "_get_dtype", "(", "target", ")", "if", "is_categorical_dtype", "(", "source", ")", "and", "is_categorical_dtype", "(", "targ...
Check whether two arrays have compatible dtypes to do a union. numpy types are checked with ``is_dtype_equal``. Extension types are checked separately. Parameters ---------- source : The first dtype to compare target : The second dtype to compare Returns ---------- boolean ...
[ "Check", "whether", "two", "arrays", "have", "compatible", "dtypes", "to", "do", "a", "union", ".", "numpy", "types", "are", "checked", "with", "is_dtype_equal", ".", "Extension", "types", "are", "checked", "separately", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L795-L827
20,484
pandas-dev/pandas
pandas/core/dtypes/common.py
is_numeric_v_string_like
def is_numeric_v_string_like(a, b): """ Check if we are comparing a string-like object to a numeric ndarray. NumPy doesn't like to compare such objects, especially numeric arrays and scalar string-likes. Parameters ---------- a : array-like, scalar The first object to check. b ...
python
def is_numeric_v_string_like(a, b): """ Check if we are comparing a string-like object to a numeric ndarray. NumPy doesn't like to compare such objects, especially numeric arrays and scalar string-likes. Parameters ---------- a : array-like, scalar The first object to check. b ...
[ "def", "is_numeric_v_string_like", "(", "a", ",", "b", ")", ":", "is_a_array", "=", "isinstance", "(", "a", ",", "np", ".", "ndarray", ")", "is_b_array", "=", "isinstance", "(", "b", ",", "np", ".", "ndarray", ")", "is_a_numeric_array", "=", "is_a_array", ...
Check if we are comparing a string-like object to a numeric ndarray. NumPy doesn't like to compare such objects, especially numeric arrays and scalar string-likes. Parameters ---------- a : array-like, scalar The first object to check. b : array-like, scalar The second object t...
[ "Check", "if", "we", "are", "comparing", "a", "string", "-", "like", "object", "to", "a", "numeric", "ndarray", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1280-L1335
20,485
pandas-dev/pandas
pandas/core/dtypes/common.py
is_datetimelike_v_numeric
def is_datetimelike_v_numeric(a, b): """ Check if we are comparing a datetime-like object to a numeric object. By "numeric," we mean an object that is either of an int or float dtype. Parameters ---------- a : array-like, scalar The first object to check. b : array-like, scalar ...
python
def is_datetimelike_v_numeric(a, b): """ Check if we are comparing a datetime-like object to a numeric object. By "numeric," we mean an object that is either of an int or float dtype. Parameters ---------- a : array-like, scalar The first object to check. b : array-like, scalar ...
[ "def", "is_datetimelike_v_numeric", "(", "a", ",", "b", ")", ":", "if", "not", "hasattr", "(", "a", ",", "'dtype'", ")", ":", "a", "=", "np", ".", "asarray", "(", "a", ")", "if", "not", "hasattr", "(", "b", ",", "'dtype'", ")", ":", "b", "=", "...
Check if we are comparing a datetime-like object to a numeric object. By "numeric," we mean an object that is either of an int or float dtype. Parameters ---------- a : array-like, scalar The first object to check. b : array-like, scalar The second object to check. Returns ...
[ "Check", "if", "we", "are", "comparing", "a", "datetime", "-", "like", "object", "to", "a", "numeric", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1338-L1393
20,486
pandas-dev/pandas
pandas/core/dtypes/common.py
is_datetimelike_v_object
def is_datetimelike_v_object(a, b): """ Check if we are comparing a datetime-like object to an object instance. Parameters ---------- a : array-like, scalar The first object to check. b : array-like, scalar The second object to check. Returns ------- boolean ...
python
def is_datetimelike_v_object(a, b): """ Check if we are comparing a datetime-like object to an object instance. Parameters ---------- a : array-like, scalar The first object to check. b : array-like, scalar The second object to check. Returns ------- boolean ...
[ "def", "is_datetimelike_v_object", "(", "a", ",", "b", ")", ":", "if", "not", "hasattr", "(", "a", ",", "'dtype'", ")", ":", "a", "=", "np", ".", "asarray", "(", "a", ")", "if", "not", "hasattr", "(", "b", ",", "'dtype'", ")", ":", "b", "=", "n...
Check if we are comparing a datetime-like object to an object instance. Parameters ---------- a : array-like, scalar The first object to check. b : array-like, scalar The second object to check. Returns ------- boolean Whether we return a comparing a datetime-like t...
[ "Check", "if", "we", "are", "comparing", "a", "datetime", "-", "like", "object", "to", "an", "object", "instance", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1396-L1446
20,487
pandas-dev/pandas
pandas/core/dtypes/common.py
needs_i8_conversion
def needs_i8_conversion(arr_or_dtype): """ Check whether the array or dtype should be converted to int64. An array-like or dtype "needs" such a conversion if the array-like or dtype is of a datetime-like dtype Parameters ---------- arr_or_dtype : array-like The array or dtype to ch...
python
def needs_i8_conversion(arr_or_dtype): """ Check whether the array or dtype should be converted to int64. An array-like or dtype "needs" such a conversion if the array-like or dtype is of a datetime-like dtype Parameters ---------- arr_or_dtype : array-like The array or dtype to ch...
[ "def", "needs_i8_conversion", "(", "arr_or_dtype", ")", ":", "if", "arr_or_dtype", "is", "None", ":", "return", "False", "return", "(", "is_datetime_or_timedelta_dtype", "(", "arr_or_dtype", ")", "or", "is_datetime64tz_dtype", "(", "arr_or_dtype", ")", "or", "is_per...
Check whether the array or dtype should be converted to int64. An array-like or dtype "needs" such a conversion if the array-like or dtype is of a datetime-like dtype Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean W...
[ "Check", "whether", "the", "array", "or", "dtype", "should", "be", "converted", "to", "int64", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1449-L1488
20,488
pandas-dev/pandas
pandas/core/dtypes/common.py
is_bool_dtype
def is_bool_dtype(arr_or_dtype): """ Check whether the provided array or dtype is of a boolean dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of a boolean dtype. Notes...
python
def is_bool_dtype(arr_or_dtype): """ Check whether the provided array or dtype is of a boolean dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of a boolean dtype. Notes...
[ "def", "is_bool_dtype", "(", "arr_or_dtype", ")", ":", "if", "arr_or_dtype", "is", "None", ":", "return", "False", "try", ":", "dtype", "=", "_get_dtype", "(", "arr_or_dtype", ")", "except", "TypeError", ":", "return", "False", "if", "isinstance", "(", "arr_...
Check whether the provided array or dtype is of a boolean dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of a boolean dtype. Notes ----- An ExtensionArray is considere...
[ "Check", "whether", "the", "provided", "array", "or", "dtype", "is", "of", "a", "boolean", "dtype", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1600-L1663
20,489
pandas-dev/pandas
pandas/core/dtypes/common.py
is_extension_type
def is_extension_type(arr): """ Check whether an array-like is of a pandas extension class instance. Extension classes include categoricals, pandas sparse objects (i.e. classes represented within the pandas library and not ones external to it like scipy sparse matrices), and datetime-like arrays. ...
python
def is_extension_type(arr): """ Check whether an array-like is of a pandas extension class instance. Extension classes include categoricals, pandas sparse objects (i.e. classes represented within the pandas library and not ones external to it like scipy sparse matrices), and datetime-like arrays. ...
[ "def", "is_extension_type", "(", "arr", ")", ":", "if", "is_categorical", "(", "arr", ")", ":", "return", "True", "elif", "is_sparse", "(", "arr", ")", ":", "return", "True", "elif", "is_datetime64tz_dtype", "(", "arr", ")", ":", "return", "True", "return"...
Check whether an array-like is of a pandas extension class instance. Extension classes include categoricals, pandas sparse objects (i.e. classes represented within the pandas library and not ones external to it like scipy sparse matrices), and datetime-like arrays. Parameters ---------- arr : ...
[ "Check", "whether", "an", "array", "-", "like", "is", "of", "a", "pandas", "extension", "class", "instance", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1666-L1722
20,490
pandas-dev/pandas
pandas/core/dtypes/common.py
is_extension_array_dtype
def is_extension_array_dtype(arr_or_dtype): """ Check if an object is a pandas extension array type. See the :ref:`Use Guide <extending.extension-types>` for more. Parameters ---------- arr_or_dtype : object For array-like input, the ``.dtype`` attribute will be extracted. ...
python
def is_extension_array_dtype(arr_or_dtype): """ Check if an object is a pandas extension array type. See the :ref:`Use Guide <extending.extension-types>` for more. Parameters ---------- arr_or_dtype : object For array-like input, the ``.dtype`` attribute will be extracted. ...
[ "def", "is_extension_array_dtype", "(", "arr_or_dtype", ")", ":", "dtype", "=", "getattr", "(", "arr_or_dtype", ",", "'dtype'", ",", "arr_or_dtype", ")", "return", "(", "isinstance", "(", "dtype", ",", "ExtensionDtype", ")", "or", "registry", ".", "find", "(",...
Check if an object is a pandas extension array type. See the :ref:`Use Guide <extending.extension-types>` for more. Parameters ---------- arr_or_dtype : object For array-like input, the ``.dtype`` attribute will be extracted. Returns ------- bool Whether the `arr_o...
[ "Check", "if", "an", "object", "is", "a", "pandas", "extension", "array", "type", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1725-L1772
20,491
pandas-dev/pandas
pandas/core/dtypes/common.py
_get_dtype
def _get_dtype(arr_or_dtype): """ Get the dtype instance associated with an array or dtype object. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. Returns ------- obj_dtype : The extract dtype instance from the ...
python
def _get_dtype(arr_or_dtype): """ Get the dtype instance associated with an array or dtype object. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. Returns ------- obj_dtype : The extract dtype instance from the ...
[ "def", "_get_dtype", "(", "arr_or_dtype", ")", ":", "if", "arr_or_dtype", "is", "None", ":", "raise", "TypeError", "(", "\"Cannot deduce dtype from null object\"", ")", "# fastpath", "elif", "isinstance", "(", "arr_or_dtype", ",", "np", ".", "dtype", ")", ":", "...
Get the dtype instance associated with an array or dtype object. Parameters ---------- arr_or_dtype : array-like The array-like or dtype object whose dtype we want to extract. Returns ------- obj_dtype : The extract dtype instance from the passed in array or dtype o...
[ "Get", "the", "dtype", "instance", "associated", "with", "an", "array", "or", "dtype", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1833-L1866
20,492
pandas-dev/pandas
pandas/core/dtypes/common.py
infer_dtype_from_object
def infer_dtype_from_object(dtype): """ Get a numpy dtype.type-style object for a dtype object. This methods also includes handling of the datetime64[ns] and datetime64[ns, TZ] objects. If no dtype can be found, we return ``object``. Parameters ---------- dtype : dtype, type T...
python
def infer_dtype_from_object(dtype): """ Get a numpy dtype.type-style object for a dtype object. This methods also includes handling of the datetime64[ns] and datetime64[ns, TZ] objects. If no dtype can be found, we return ``object``. Parameters ---------- dtype : dtype, type T...
[ "def", "infer_dtype_from_object", "(", "dtype", ")", ":", "if", "isinstance", "(", "dtype", ",", "type", ")", "and", "issubclass", "(", "dtype", ",", "np", ".", "generic", ")", ":", "# Type object from a dtype", "return", "dtype", "elif", "isinstance", "(", ...
Get a numpy dtype.type-style object for a dtype object. This methods also includes handling of the datetime64[ns] and datetime64[ns, TZ] objects. If no dtype can be found, we return ``object``. Parameters ---------- dtype : dtype, type The dtype object whose numpy dtype.type-style ...
[ "Get", "a", "numpy", "dtype", ".", "type", "-", "style", "object", "for", "a", "dtype", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1916-L1977
20,493
pandas-dev/pandas
pandas/core/dtypes/common.py
_validate_date_like_dtype
def _validate_date_like_dtype(dtype): """ Check whether the dtype is a date-like dtype. Raises an error if invalid. Parameters ---------- dtype : dtype, type The dtype to check. Raises ------ TypeError : The dtype could not be casted to a date-like dtype. ValueError : The d...
python
def _validate_date_like_dtype(dtype): """ Check whether the dtype is a date-like dtype. Raises an error if invalid. Parameters ---------- dtype : dtype, type The dtype to check. Raises ------ TypeError : The dtype could not be casted to a date-like dtype. ValueError : The d...
[ "def", "_validate_date_like_dtype", "(", "dtype", ")", ":", "try", ":", "typ", "=", "np", ".", "datetime_data", "(", "dtype", ")", "[", "0", "]", "except", "ValueError", "as", "e", ":", "raise", "TypeError", "(", "'{error}'", ".", "format", "(", "error",...
Check whether the dtype is a date-like dtype. Raises an error if invalid. Parameters ---------- dtype : dtype, type The dtype to check. Raises ------ TypeError : The dtype could not be casted to a date-like dtype. ValueError : The dtype is an illegal date-like dtype (e.g. the ...
[ "Check", "whether", "the", "dtype", "is", "a", "date", "-", "like", "dtype", ".", "Raises", "an", "error", "if", "invalid", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1980-L2002
20,494
pandas-dev/pandas
pandas/core/dtypes/common.py
pandas_dtype
def pandas_dtype(dtype): """ Convert input into a pandas only dtype object or a numpy dtype object. Parameters ---------- dtype : object to be converted Returns ------- np.dtype or a pandas dtype Raises ------ TypeError if not a dtype """ # short-circuit if isi...
python
def pandas_dtype(dtype): """ Convert input into a pandas only dtype object or a numpy dtype object. Parameters ---------- dtype : object to be converted Returns ------- np.dtype or a pandas dtype Raises ------ TypeError if not a dtype """ # short-circuit if isi...
[ "def", "pandas_dtype", "(", "dtype", ")", ":", "# short-circuit", "if", "isinstance", "(", "dtype", ",", "np", ".", "ndarray", ")", ":", "return", "dtype", ".", "dtype", "elif", "isinstance", "(", "dtype", ",", "(", "np", ".", "dtype", ",", "PandasExtens...
Convert input into a pandas only dtype object or a numpy dtype object. Parameters ---------- dtype : object to be converted Returns ------- np.dtype or a pandas dtype Raises ------ TypeError if not a dtype
[ "Convert", "input", "into", "a", "pandas", "only", "dtype", "object", "or", "a", "numpy", "dtype", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L2005-L2055
20,495
pandas-dev/pandas
pandas/core/reshape/merge.py
_groupby_and_merge
def _groupby_and_merge(by, on, left, right, _merge_pieces, check_duplicates=True): """ groupby & merge; we are always performing a left-by type operation Parameters ---------- by: field to group on: duplicates field left: left frame right: right frame _merge_p...
python
def _groupby_and_merge(by, on, left, right, _merge_pieces, check_duplicates=True): """ groupby & merge; we are always performing a left-by type operation Parameters ---------- by: field to group on: duplicates field left: left frame right: right frame _merge_p...
[ "def", "_groupby_and_merge", "(", "by", ",", "on", ",", "left", ",", "right", ",", "_merge_pieces", ",", "check_duplicates", "=", "True", ")", ":", "pieces", "=", "[", "]", "if", "not", "isinstance", "(", "by", ",", "(", "list", ",", "tuple", ")", ")...
groupby & merge; we are always performing a left-by type operation Parameters ---------- by: field to group on: duplicates field left: left frame right: right frame _merge_pieces: function for merging check_duplicates: boolean, default True should we check & clean duplicates
[ "groupby", "&", "merge", ";", "we", "are", "always", "performing", "a", "left", "-", "by", "type", "operation" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L54-L128
20,496
pandas-dev/pandas
pandas/core/reshape/merge.py
merge_asof
def merge_asof(left, right, on=None, left_on=None, right_on=None, left_index=False, right_index=False, by=None, left_by=None, right_by=None, suffixes=('_x', '_y'), tolerance=None, allow_exact_matches=True, direction...
python
def merge_asof(left, right, on=None, left_on=None, right_on=None, left_index=False, right_index=False, by=None, left_by=None, right_by=None, suffixes=('_x', '_y'), tolerance=None, allow_exact_matches=True, direction...
[ "def", "merge_asof", "(", "left", ",", "right", ",", "on", "=", "None", ",", "left_on", "=", "None", ",", "right_on", "=", "None", ",", "left_index", "=", "False", ",", "right_index", "=", "False", ",", "by", "=", "None", ",", "left_by", "=", "None",...
Perform an asof merge. This is similar to a left-join except that we match on nearest key rather than equal keys. Both DataFrames must be sorted by the key. For each row in the left DataFrame: - A "backward" search selects the last row in the right DataFrame whose 'on' key is less than or e...
[ "Perform", "an", "asof", "merge", ".", "This", "is", "similar", "to", "a", "left", "-", "join", "except", "that", "we", "match", "on", "nearest", "key", "rather", "than", "equal", "keys", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L235-L467
20,497
pandas-dev/pandas
pandas/core/reshape/merge.py
_MergeOperation._maybe_restore_index_levels
def _maybe_restore_index_levels(self, result): """ Restore index levels specified as `on` parameters Here we check for cases where `self.left_on` and `self.right_on` pairs each reference an index level in their respective DataFrames. The joined columns corresponding to these pai...
python
def _maybe_restore_index_levels(self, result): """ Restore index levels specified as `on` parameters Here we check for cases where `self.left_on` and `self.right_on` pairs each reference an index level in their respective DataFrames. The joined columns corresponding to these pai...
[ "def", "_maybe_restore_index_levels", "(", "self", ",", "result", ")", ":", "names_to_restore", "=", "[", "]", "for", "name", ",", "left_key", ",", "right_key", "in", "zip", "(", "self", ".", "join_names", ",", "self", ".", "left_on", ",", "self", ".", "...
Restore index levels specified as `on` parameters Here we check for cases where `self.left_on` and `self.right_on` pairs each reference an index level in their respective DataFrames. The joined columns corresponding to these pairs are then restored to the index of `result`. **N...
[ "Restore", "index", "levels", "specified", "as", "on", "parameters" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L619-L650
20,498
pandas-dev/pandas
pandas/core/reshape/merge.py
_MergeOperation._create_join_index
def _create_join_index(self, index, other_index, indexer, other_indexer, how='left'): """ Create a join index by rearranging one index to match another Parameters ---------- index: Index being rearranged other_index: Index used to supply values...
python
def _create_join_index(self, index, other_index, indexer, other_indexer, how='left'): """ Create a join index by rearranging one index to match another Parameters ---------- index: Index being rearranged other_index: Index used to supply values...
[ "def", "_create_join_index", "(", "self", ",", "index", ",", "other_index", ",", "indexer", ",", "other_indexer", ",", "how", "=", "'left'", ")", ":", "join_index", "=", "index", ".", "take", "(", "indexer", ")", "if", "(", "self", ".", "how", "in", "(...
Create a join index by rearranging one index to match another Parameters ---------- index: Index being rearranged other_index: Index used to supply values not found in index indexer: how to rearrange index how: replacement is only necessary if indexer based on other_inde...
[ "Create", "a", "join", "index", "by", "rearranging", "one", "index", "to", "match", "another" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L790-L821
20,499
pandas-dev/pandas
pandas/core/dtypes/base.py
_DtypeOpsMixin.is_dtype
def is_dtype(cls, dtype): """Check if we match 'dtype'. Parameters ---------- dtype : object The object to check. Returns ------- is_dtype : bool Notes ----- The default implementation is True if 1. ``cls.construct_f...
python
def is_dtype(cls, dtype): """Check if we match 'dtype'. Parameters ---------- dtype : object The object to check. Returns ------- is_dtype : bool Notes ----- The default implementation is True if 1. ``cls.construct_f...
[ "def", "is_dtype", "(", "cls", ",", "dtype", ")", ":", "dtype", "=", "getattr", "(", "dtype", ",", "'dtype'", ",", "dtype", ")", "if", "isinstance", "(", "dtype", ",", "(", "ABCSeries", ",", "ABCIndexClass", ",", "ABCDataFrame", ",", "np", ".", "dtype"...
Check if we match 'dtype'. Parameters ---------- dtype : object The object to check. Returns ------- is_dtype : bool Notes ----- The default implementation is True if 1. ``cls.construct_from_string(dtype)`` is an instance ...
[ "Check", "if", "we", "match", "dtype", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/base.py#L75-L113