partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
ParserBase._extract_multi_indexer_columns
extract and return the names, index_names, col_names header is a list-of-lists returned from the parsers
pandas/io/parsers.py
def _extract_multi_indexer_columns(self, header, index_names, col_names, passed_names=False): """ extract and return the names, index_names, col_names header is a list-of-lists returned from the parsers """ if len(header) < 2: return header[...
def _extract_multi_indexer_columns(self, header, index_names, col_names, passed_names=False): """ extract and return the names, index_names, col_names header is a list-of-lists returned from the parsers """ if len(header) < 2: return header[...
[ "extract", "and", "return", "the", "names", "index_names", "col_names", "header", "is", "a", "list", "-", "of", "-", "lists", "returned", "from", "the", "parsers" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1451-L1504
[ "def", "_extract_multi_indexer_columns", "(", "self", ",", "header", ",", "index_names", ",", "col_names", ",", "passed_names", "=", "False", ")", ":", "if", "len", "(", "header", ")", "<", "2", ":", "return", "header", "[", "0", "]", ",", "index_names", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ParserBase._infer_types
Infer types of values, possibly casting Parameters ---------- values : ndarray na_values : set try_num_bool : bool, default try try to cast values to numeric (first preference) or boolean Returns: -------- converted : ndarray na_count ...
pandas/io/parsers.py
def _infer_types(self, values, na_values, try_num_bool=True): """ Infer types of values, possibly casting Parameters ---------- values : ndarray na_values : set try_num_bool : bool, default try try to cast values to numeric (first preference) or boolea...
def _infer_types(self, values, na_values, try_num_bool=True): """ Infer types of values, possibly casting Parameters ---------- values : ndarray na_values : set try_num_bool : bool, default try try to cast values to numeric (first preference) or boolea...
[ "Infer", "types", "of", "values", "possibly", "casting" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1719-L1764
[ "def", "_infer_types", "(", "self", ",", "values", ",", "na_values", ",", "try_num_bool", "=", "True", ")", ":", "na_count", "=", "0", "if", "issubclass", "(", "values", ".", "dtype", ".", "type", ",", "(", "np", ".", "number", ",", "np", ".", "bool_...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
ParserBase._cast_types
Cast values to specified type Parameters ---------- values : ndarray cast_type : string or np.dtype dtype to cast values to column : string column name - used only for error reporting Returns ------- converted : ndarray
pandas/io/parsers.py
def _cast_types(self, values, cast_type, column): """ Cast values to specified type Parameters ---------- values : ndarray cast_type : string or np.dtype dtype to cast values to column : string column name - used only for error reporting ...
def _cast_types(self, values, cast_type, column): """ Cast values to specified type Parameters ---------- values : ndarray cast_type : string or np.dtype dtype to cast values to column : string column name - used only for error reporting ...
[ "Cast", "values", "to", "specified", "type" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1766-L1821
[ "def", "_cast_types", "(", "self", ",", "values", ",", "cast_type", ",", "column", ")", ":", "if", "is_categorical_dtype", "(", "cast_type", ")", ":", "known_cats", "=", "(", "isinstance", "(", "cast_type", ",", "CategoricalDtype", ")", "and", "cast_type", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
CParserWrapper._set_noconvert_columns
Set the columns that should not undergo dtype conversions. Currently, any column that is involved with date parsing will not undergo such conversions.
pandas/io/parsers.py
def _set_noconvert_columns(self): """ Set the columns that should not undergo dtype conversions. Currently, any column that is involved with date parsing will not undergo such conversions. """ names = self.orig_names if self.usecols_dtype == 'integer': ...
def _set_noconvert_columns(self): """ Set the columns that should not undergo dtype conversions. Currently, any column that is involved with date parsing will not undergo such conversions. """ names = self.orig_names if self.usecols_dtype == 'integer': ...
[ "Set", "the", "columns", "that", "should", "not", "undergo", "dtype", "conversions", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1951-L2003
[ "def", "_set_noconvert_columns", "(", "self", ")", ":", "names", "=", "self", ".", "orig_names", "if", "self", ".", "usecols_dtype", "==", "'integer'", ":", "# A set of integers will be converted to a list in", "# the correct order every single time.", "usecols", "=", "li...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PythonParser._handle_usecols
Sets self._col_indices usecols_key is used if there are string usecols.
pandas/io/parsers.py
def _handle_usecols(self, columns, usecols_key): """ Sets self._col_indices usecols_key is used if there are string usecols. """ if self.usecols is not None: if callable(self.usecols): col_indices = _evaluate_usecols(self.usecols, usecols_key) ...
def _handle_usecols(self, columns, usecols_key): """ Sets self._col_indices usecols_key is used if there are string usecols. """ if self.usecols is not None: if callable(self.usecols): col_indices = _evaluate_usecols(self.usecols, usecols_key) ...
[ "Sets", "self", ".", "_col_indices" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2678-L2707
[ "def", "_handle_usecols", "(", "self", ",", "columns", ",", "usecols_key", ")", ":", "if", "self", ".", "usecols", "is", "not", "None", ":", "if", "callable", "(", "self", ".", "usecols", ")", ":", "col_indices", "=", "_evaluate_usecols", "(", "self", "....
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PythonParser._check_for_bom
Checks whether the file begins with the BOM character. If it does, remove it. In addition, if there is quoting in the field subsequent to the BOM, remove it as well because it technically takes place at the beginning of the name, not the middle of it.
pandas/io/parsers.py
def _check_for_bom(self, first_row): """ Checks whether the file begins with the BOM character. If it does, remove it. In addition, if there is quoting in the field subsequent to the BOM, remove it as well because it technically takes place at the beginning of the name, n...
def _check_for_bom(self, first_row): """ Checks whether the file begins with the BOM character. If it does, remove it. In addition, if there is quoting in the field subsequent to the BOM, remove it as well because it technically takes place at the beginning of the name, n...
[ "Checks", "whether", "the", "file", "begins", "with", "the", "BOM", "character", ".", "If", "it", "does", "remove", "it", ".", "In", "addition", "if", "there", "is", "quoting", "in", "the", "field", "subsequent", "to", "the", "BOM", "remove", "it", "as",...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2718-L2768
[ "def", "_check_for_bom", "(", "self", ",", "first_row", ")", ":", "# first_row will be a list, so we need to check", "# that that list is not empty before proceeding.", "if", "not", "first_row", ":", "return", "first_row", "# The first element of this row is the one that could have t...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PythonParser._alert_malformed
Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message to display. row_num : The row number where the parsing ...
pandas/io/parsers.py
def _alert_malformed(self, msg, row_num): """ Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message t...
def _alert_malformed(self, msg, row_num): """ Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message t...
[ "Alert", "a", "user", "about", "a", "malformed", "row", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2837-L2856
[ "def", "_alert_malformed", "(", "self", ",", "msg", ",", "row_num", ")", ":", "if", "self", ".", "error_bad_lines", ":", "raise", "ParserError", "(", "msg", ")", "elif", "self", ".", "warn_bad_lines", ":", "base", "=", "'Skipping line {row_num}: '", ".", "fo...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PythonParser._next_iter_line
Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- row_num : The row number of the line being parsed.
pandas/io/parsers.py
def _next_iter_line(self, row_num): """ Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- ...
def _next_iter_line(self, row_num): """ Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- ...
[ "Wrapper", "around", "iterating", "through", "self", ".", "data", "(", "CSV", "source", ")", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2858-L2892
[ "def", "_next_iter_line", "(", "self", ",", "row_num", ")", ":", "try", ":", "return", "next", "(", "self", ".", "data", ")", "except", "csv", ".", "Error", "as", "e", ":", "if", "self", ".", "warn_bad_lines", "or", "self", ".", "error_bad_lines", ":",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PythonParser._remove_empty_lines
Iterate through the lines and remove any that are either empty or contain only one whitespace value Parameters ---------- lines : array-like The array of lines that we are to filter. Returns ------- filtered_lines : array-like The same ar...
pandas/io/parsers.py
def _remove_empty_lines(self, lines): """ Iterate through the lines and remove any that are either empty or contain only one whitespace value Parameters ---------- lines : array-like The array of lines that we are to filter. Returns ------- ...
def _remove_empty_lines(self, lines): """ Iterate through the lines and remove any that are either empty or contain only one whitespace value Parameters ---------- lines : array-like The array of lines that we are to filter. Returns ------- ...
[ "Iterate", "through", "the", "lines", "and", "remove", "any", "that", "are", "either", "empty", "or", "contain", "only", "one", "whitespace", "value" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2912-L2934
[ "def", "_remove_empty_lines", "(", "self", ",", "lines", ")", ":", "ret", "=", "[", "]", "for", "l", "in", "lines", ":", "# Remove empty lines and lines with only one whitespace value", "if", "(", "len", "(", "l", ")", ">", "1", "or", "len", "(", "l", ")",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PythonParser._get_index_name
Try several cases to get lines: 0) There are headers on row 0 and row 1 and their total summed lengths equals the length of the next line. Treat row 0 as columns and row 1 as indices 1) Look for implicit index: there are more columns on row 1 than row 0. If this is true, assume ...
pandas/io/parsers.py
def _get_index_name(self, columns): """ Try several cases to get lines: 0) There are headers on row 0 and row 1 and their total summed lengths equals the length of the next line. Treat row 0 as columns and row 1 as indices 1) Look for implicit index: there are more colum...
def _get_index_name(self, columns): """ Try several cases to get lines: 0) There are headers on row 0 and row 1 and their total summed lengths equals the length of the next line. Treat row 0 as columns and row 1 as indices 1) Look for implicit index: there are more colum...
[ "Try", "several", "cases", "to", "get", "lines", ":" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2973-L3035
[ "def", "_get_index_name", "(", "self", ",", "columns", ")", ":", "orig_names", "=", "list", "(", "columns", ")", "columns", "=", "list", "(", "columns", ")", "try", ":", "line", "=", "self", ".", "_next_line", "(", ")", "except", "StopIteration", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FixedWidthReader.get_rows
Read rows from self.f, skipping as specified. We distinguish buffer_rows (the first <= infer_nrows lines) from the rows returned to detect_colspecs because it's simpler to leave the other locations with skiprows logic alone than to modify them to deal with the fact we skipped so...
pandas/io/parsers.py
def get_rows(self, infer_nrows, skiprows=None): """ Read rows from self.f, skipping as specified. We distinguish buffer_rows (the first <= infer_nrows lines) from the rows returned to detect_colspecs because it's simpler to leave the other locations with skiprows logic a...
def get_rows(self, infer_nrows, skiprows=None): """ Read rows from self.f, skipping as specified. We distinguish buffer_rows (the first <= infer_nrows lines) from the rows returned to detect_colspecs because it's simpler to leave the other locations with skiprows logic a...
[ "Read", "rows", "from", "self", ".", "f", "skipping", "as", "specified", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3535-L3571
[ "def", "get_rows", "(", "self", ",", "infer_nrows", ",", "skiprows", "=", "None", ")", ":", "if", "skiprows", "is", "None", ":", "skiprows", "=", "set", "(", ")", "buffer_rows", "=", "[", "]", "detect_rows", "=", "[", "]", "for", "i", ",", "row", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
linkcode_resolve
Determine the URL corresponding to Python object
doc/source/conf.py
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object """ if domain != 'py': return None modname = info['module'] fullname = info['fullname'] submod = sys.modules.get(modname) if submod is None: return None obj = submod for pa...
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object """ if domain != 'py': return None modname = info['module'] fullname = info['fullname'] submod = sys.modules.get(modname) if submod is None: return None obj = submod for pa...
[ "Determine", "the", "URL", "corresponding", "to", "Python", "object" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/source/conf.py#L629-L678
[ "def", "linkcode_resolve", "(", "domain", ",", "info", ")", ":", "if", "domain", "!=", "'py'", ":", "return", "None", "modname", "=", "info", "[", "'module'", "]", "fullname", "=", "info", "[", "'fullname'", "]", "submod", "=", "sys", ".", "modules", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
process_class_docstrings
For those classes for which we use :: :template: autosummary/class_without_autosummary.rst the documented attributes/methods have to be listed in the class docstring. However, if one of those lists is empty, we use 'None', which then generates warnings in sphinx / ugly html output. This "autodoc-p...
doc/source/conf.py
def process_class_docstrings(app, what, name, obj, options, lines): """ For those classes for which we use :: :template: autosummary/class_without_autosummary.rst the documented attributes/methods have to be listed in the class docstring. However, if one of those lists is empty, we use 'None', ...
def process_class_docstrings(app, what, name, obj, options, lines): """ For those classes for which we use :: :template: autosummary/class_without_autosummary.rst the documented attributes/methods have to be listed in the class docstring. However, if one of those lists is empty, we use 'None', ...
[ "For", "those", "classes", "for", "which", "we", "use", "::" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/source/conf.py#L688-L724
[ "def", "process_class_docstrings", "(", "app", ",", "what", ",", "name", ",", "obj", ",", "options", ",", "lines", ")", ":", "if", "what", "==", "\"class\"", ":", "joined", "=", "'\\n'", ".", "join", "(", "lines", ")", "templates", "=", "[", "\"\"\".. ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
pack
Pack object `o` and write it to `stream` See :class:`Packer` for options.
pandas/io/msgpack/__init__.py
def pack(o, stream, **kwargs): """ Pack object `o` and write it to `stream` See :class:`Packer` for options. """ packer = Packer(**kwargs) stream.write(packer.pack(o))
def pack(o, stream, **kwargs): """ Pack object `o` and write it to `stream` See :class:`Packer` for options. """ packer = Packer(**kwargs) stream.write(packer.pack(o))
[ "Pack", "object", "o", "and", "write", "it", "to", "stream" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/msgpack/__init__.py#L26-L33
[ "def", "pack", "(", "o", ",", "stream", ",", "*", "*", "kwargs", ")", ":", "packer", "=", "Packer", "(", "*", "*", "kwargs", ")", "stream", ".", "write", "(", "packer", ".", "pack", "(", "o", ")", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_mgr_concatenation_plan
Construct concatenation plan for given block manager and indexers. Parameters ---------- mgr : BlockManager indexers : dict of {axis: indexer} Returns ------- plan : list of (BlockPlacement, JoinUnit) tuples
pandas/core/internals/concat.py
def get_mgr_concatenation_plan(mgr, indexers): """ Construct concatenation plan for given block manager and indexers. Parameters ---------- mgr : BlockManager indexers : dict of {axis: indexer} Returns ------- plan : list of (BlockPlacement, JoinUnit) tuples """ # Calculat...
def get_mgr_concatenation_plan(mgr, indexers): """ Construct concatenation plan for given block manager and indexers. Parameters ---------- mgr : BlockManager indexers : dict of {axis: indexer} Returns ------- plan : list of (BlockPlacement, JoinUnit) tuples """ # Calculat...
[ "Construct", "concatenation", "plan", "for", "given", "block", "manager", "and", "indexers", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L21-L98
[ "def", "get_mgr_concatenation_plan", "(", "mgr", ",", "indexers", ")", ":", "# Calculate post-reindex shape , save for item axis which will be separate", "# for each block anyway.", "mgr_shape", "=", "list", "(", "mgr", ".", "shape", ")", "for", "ax", ",", "indexer", "in"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
concatenate_join_units
Concatenate values from several join units along selected axis.
pandas/core/internals/concat.py
def concatenate_join_units(join_units, concat_axis, copy): """ Concatenate values from several join units along selected axis. """ if concat_axis == 0 and len(join_units) > 1: # Concatenating join units along ax0 is handled in _merge_blocks. raise AssertionError("Concatenating join units...
def concatenate_join_units(join_units, concat_axis, copy): """ Concatenate values from several join units along selected axis. """ if concat_axis == 0 and len(join_units) > 1: # Concatenating join units along ax0 is handled in _merge_blocks. raise AssertionError("Concatenating join units...
[ "Concatenate", "values", "from", "several", "join", "units", "along", "selected", "axis", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L229-L257
[ "def", "concatenate_join_units", "(", "join_units", ",", "concat_axis", ",", "copy", ")", ":", "if", "concat_axis", "==", "0", "and", "len", "(", "join_units", ")", ">", "1", ":", "# Concatenating join units along ax0 is handled in _merge_blocks.", "raise", "Assertion...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_empty_dtype_and_na
Return dtype and N/A values to use when concatenating specified units. Returned N/A value may be None which means there was no casting involved. Returns ------- dtype na
pandas/core/internals/concat.py
def get_empty_dtype_and_na(join_units): """ Return dtype and N/A values to use when concatenating specified units. Returned N/A value may be None which means there was no casting involved. Returns ------- dtype na """ if len(join_units) == 1: blk = join_units[0].block ...
def get_empty_dtype_and_na(join_units): """ Return dtype and N/A values to use when concatenating specified units. Returned N/A value may be None which means there was no casting involved. Returns ------- dtype na """ if len(join_units) == 1: blk = join_units[0].block ...
[ "Return", "dtype", "and", "N", "/", "A", "values", "to", "use", "when", "concatenating", "specified", "units", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L260-L363
[ "def", "get_empty_dtype_and_na", "(", "join_units", ")", ":", "if", "len", "(", "join_units", ")", "==", "1", ":", "blk", "=", "join_units", "[", "0", "]", ".", "block", "if", "blk", "is", "None", ":", "return", "np", ".", "float64", ",", "np", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
is_uniform_join_units
Check if the join units consist of blocks of uniform type that can be concatenated using Block.concat_same_type instead of the generic concatenate_join_units (which uses `_concat._concat_compat`).
pandas/core/internals/concat.py
def is_uniform_join_units(join_units): """ Check if the join units consist of blocks of uniform type that can be concatenated using Block.concat_same_type instead of the generic concatenate_join_units (which uses `_concat._concat_compat`). """ return ( # all blocks need to have the same...
def is_uniform_join_units(join_units): """ Check if the join units consist of blocks of uniform type that can be concatenated using Block.concat_same_type instead of the generic concatenate_join_units (which uses `_concat._concat_compat`). """ return ( # all blocks need to have the same...
[ "Check", "if", "the", "join", "units", "consist", "of", "blocks", "of", "uniform", "type", "that", "can", "be", "concatenated", "using", "Block", ".", "concat_same_type", "instead", "of", "the", "generic", "concatenate_join_units", "(", "which", "uses", "_concat...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L366-L384
[ "def", "is_uniform_join_units", "(", "join_units", ")", ":", "return", "(", "# all blocks need to have the same type", "all", "(", "type", "(", "ju", ".", "block", ")", "is", "type", "(", "join_units", "[", "0", "]", ".", "block", ")", "for", "ju", "in", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
trim_join_unit
Reduce join_unit's shape along item axis to length. Extra items that didn't fit are returned as a separate block.
pandas/core/internals/concat.py
def trim_join_unit(join_unit, length): """ Reduce join_unit's shape along item axis to length. Extra items that didn't fit are returned as a separate block. """ if 0 not in join_unit.indexers: extra_indexers = join_unit.indexers if join_unit.block is None: extra_block ...
def trim_join_unit(join_unit, length): """ Reduce join_unit's shape along item axis to length. Extra items that didn't fit are returned as a separate block. """ if 0 not in join_unit.indexers: extra_indexers = join_unit.indexers if join_unit.block is None: extra_block ...
[ "Reduce", "join_unit", "s", "shape", "along", "item", "axis", "to", "length", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L395-L421
[ "def", "trim_join_unit", "(", "join_unit", ",", "length", ")", ":", "if", "0", "not", "in", "join_unit", ".", "indexers", ":", "extra_indexers", "=", "join_unit", ".", "indexers", "if", "join_unit", ".", "block", "is", "None", ":", "extra_block", "=", "Non...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
combine_concat_plans
Combine multiple concatenation plans into one. existing_plan is updated in-place.
pandas/core/internals/concat.py
def combine_concat_plans(plans, concat_axis): """ Combine multiple concatenation plans into one. existing_plan is updated in-place. """ if len(plans) == 1: for p in plans[0]: yield p[0], [p[1]] elif concat_axis == 0: offset = 0 for plan in plans: ...
def combine_concat_plans(plans, concat_axis): """ Combine multiple concatenation plans into one. existing_plan is updated in-place. """ if len(plans) == 1: for p in plans[0]: yield p[0], [p[1]] elif concat_axis == 0: offset = 0 for plan in plans: ...
[ "Combine", "multiple", "concatenation", "plans", "into", "one", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L424-L484
[ "def", "combine_concat_plans", "(", "plans", ",", "concat_axis", ")", ":", "if", "len", "(", "plans", ")", "==", "1", ":", "for", "p", "in", "plans", "[", "0", "]", ":", "yield", "p", "[", "0", "]", ",", "[", "p", "[", "1", "]", "]", "elif", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_Options.use
Temporarily set a parameter value using the with statement. Aliasing allowed.
pandas/plotting/_style.py
def use(self, key, value): """ Temporarily set a parameter value using the with statement. Aliasing allowed. """ old_value = self[key] try: self[key] = value yield self finally: self[key] = old_value
def use(self, key, value): """ Temporarily set a parameter value using the with statement. Aliasing allowed. """ old_value = self[key] try: self[key] = value yield self finally: self[key] = old_value
[ "Temporarily", "set", "a", "parameter", "value", "using", "the", "with", "statement", ".", "Aliasing", "allowed", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_style.py#L151-L161
[ "def", "use", "(", "self", ",", "key", ",", "value", ")", ":", "old_value", "=", "self", "[", "key", "]", "try", ":", "self", "[", "key", "]", "=", "value", "yield", "self", "finally", ":", "self", "[", "key", "]", "=", "old_value" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_stata_elapsed_date_to_datetime_vec
Convert from SIF to datetime. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series The Stata Internal Format date to convert to datetime according to fmt fmt : str The format to convert to. Can be, tc, td, tw, tm, tq, th, ty Returns Returns ------...
pandas/io/stata.py
def _stata_elapsed_date_to_datetime_vec(dates, fmt): """ Convert from SIF to datetime. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series The Stata Internal Format date to convert to datetime according to fmt fmt : str The format to convert to. Can be, t...
def _stata_elapsed_date_to_datetime_vec(dates, fmt): """ Convert from SIF to datetime. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series The Stata Internal Format date to convert to datetime according to fmt fmt : str The format to convert to. Can be, t...
[ "Convert", "from", "SIF", "to", "datetime", ".", "http", ":", "//", "www", ".", "stata", ".", "com", "/", "help", ".", "cgi?datetime" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L203-L364
[ "def", "_stata_elapsed_date_to_datetime_vec", "(", "dates", ",", "fmt", ")", ":", "MIN_YEAR", ",", "MAX_YEAR", "=", "Timestamp", ".", "min", ".", "year", ",", "Timestamp", ".", "max", ".", "year", "MAX_DAY_DELTA", "=", "(", "Timestamp", ".", "max", "-", "d...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_datetime_to_stata_elapsed_vec
Convert from datetime to SIF. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series Series or array containing datetime.datetime or datetime64[ns] to convert to the Stata Internal Format given by fmt fmt : str The format to convert to. Can be, tc, td, tw, t...
pandas/io/stata.py
def _datetime_to_stata_elapsed_vec(dates, fmt): """ Convert from datetime to SIF. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series Series or array containing datetime.datetime or datetime64[ns] to convert to the Stata Internal Format given by fmt fmt :...
def _datetime_to_stata_elapsed_vec(dates, fmt): """ Convert from datetime to SIF. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series Series or array containing datetime.datetime or datetime64[ns] to convert to the Stata Internal Format given by fmt fmt :...
[ "Convert", "from", "datetime", "to", "SIF", ".", "http", ":", "//", "www", ".", "stata", ".", "com", "/", "help", ".", "cgi?datetime" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L367-L461
[ "def", "_datetime_to_stata_elapsed_vec", "(", "dates", ",", "fmt", ")", ":", "index", "=", "dates", ".", "index", "NS_PER_DAY", "=", "24", "*", "3600", "*", "1000", "*", "1000", "*", "1000", "US_PER_DAY", "=", "NS_PER_DAY", "/", "1000", "def", "parse_dates...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_cast_to_stata_types
Checks the dtypes of the columns of a pandas DataFrame for compatibility with the data types and ranges supported by Stata, and converts if necessary. Parameters ---------- data : DataFrame The DataFrame to check and convert Notes ----- Numeric columns in Stata must be one of i...
pandas/io/stata.py
def _cast_to_stata_types(data): """Checks the dtypes of the columns of a pandas DataFrame for compatibility with the data types and ranges supported by Stata, and converts if necessary. Parameters ---------- data : DataFrame The DataFrame to check and convert Notes ----- Nu...
def _cast_to_stata_types(data): """Checks the dtypes of the columns of a pandas DataFrame for compatibility with the data types and ranges supported by Stata, and converts if necessary. Parameters ---------- data : DataFrame The DataFrame to check and convert Notes ----- Nu...
[ "Checks", "the", "dtypes", "of", "the", "columns", "of", "a", "pandas", "DataFrame", "for", "compatibility", "with", "the", "data", "types", "and", "ranges", "supported", "by", "Stata", "and", "converts", "if", "necessary", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L508-L592
[ "def", "_cast_to_stata_types", "(", "data", ")", ":", "ws", "=", "''", "# original, if small, if large", "conversion_data", "=", "(", "(", "np", ".", "bool", ",", "np", ".", "int8", ",", "np", ".", "int8", ")", ",", "(", "np", ".", "uint8"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_dtype_to_stata_type
Convert dtype types to stata types. Returns the byte of the given ordinal. See TYPE_MAP and comments for an explanation. This is also explained in the dta spec. 1 - 244 are strings of this length Pandas Stata 251 - for int8 byte 252 - for int16 int 253 - for ...
pandas/io/stata.py
def _dtype_to_stata_type(dtype, column): """ Convert dtype types to stata types. Returns the byte of the given ordinal. See TYPE_MAP and comments for an explanation. This is also explained in the dta spec. 1 - 244 are strings of this length Pandas Stata 251 - for int8...
def _dtype_to_stata_type(dtype, column): """ Convert dtype types to stata types. Returns the byte of the given ordinal. See TYPE_MAP and comments for an explanation. This is also explained in the dta spec. 1 - 244 are strings of this length Pandas Stata 251 - for int8...
[ "Convert", "dtype", "types", "to", "stata", "types", ".", "Returns", "the", "byte", "of", "the", "given", "ordinal", ".", "See", "TYPE_MAP", "and", "comments", "for", "an", "explanation", ".", "This", "is", "also", "explained", "in", "the", "dta", "spec", ...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1832-L1866
[ "def", "_dtype_to_stata_type", "(", "dtype", ",", "column", ")", ":", "# TODO: expand to handle datetime to integer conversion", "if", "dtype", ".", "type", "==", "np", ".", "object_", ":", "# try to coerce it to the biggest string", "# not memory efficient, what else could we"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_dtype_to_default_stata_fmt
Map numpy dtype to stata's default format for this type. Not terribly important since users can change this in Stata. Semantics are object -> "%DDs" where DD is the length of the string. If not a string, raise ValueError float64 -> "%10.0g" float32 -> "%9.0g" int64 -> "%9.0g" ...
pandas/io/stata.py
def _dtype_to_default_stata_fmt(dtype, column, dta_version=114, force_strl=False): """ Map numpy dtype to stata's default format for this type. Not terribly important since users can change this in Stata. Semantics are object -> "%DDs" where DD is the length of the stri...
def _dtype_to_default_stata_fmt(dtype, column, dta_version=114, force_strl=False): """ Map numpy dtype to stata's default format for this type. Not terribly important since users can change this in Stata. Semantics are object -> "%DDs" where DD is the length of the stri...
[ "Map", "numpy", "dtype", "to", "stata", "s", "default", "format", "for", "this", "type", ".", "Not", "terribly", "important", "since", "users", "can", "change", "this", "in", "Stata", ".", "Semantics", "are" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1869-L1922
[ "def", "_dtype_to_default_stata_fmt", "(", "dtype", ",", "column", ",", "dta_version", "=", "114", ",", "force_strl", "=", "False", ")", ":", "# TODO: Refactor to combine type with format", "# TODO: expand this to handle a default datetime format?", "if", "dta_version", "<", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_pad_bytes_new
Takes a bytes instance and pads it with null bytes until it's length chars.
pandas/io/stata.py
def _pad_bytes_new(name, length): """ Takes a bytes instance and pads it with null bytes until it's length chars. """ if isinstance(name, str): name = bytes(name, 'utf-8') return name + b'\x00' * (length - len(name))
def _pad_bytes_new(name, length): """ Takes a bytes instance and pads it with null bytes until it's length chars. """ if isinstance(name, str): name = bytes(name, 'utf-8') return name + b'\x00' * (length - len(name))
[ "Takes", "a", "bytes", "instance", "and", "pads", "it", "with", "null", "bytes", "until", "it", "s", "length", "chars", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2477-L2483
[ "def", "_pad_bytes_new", "(", "name", ",", "length", ")", ":", "if", "isinstance", "(", "name", ",", "str", ")", ":", "name", "=", "bytes", "(", "name", ",", "'utf-8'", ")", "return", "name", "+", "b'\\x00'", "*", "(", "length", "-", "len", "(", "n...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataValueLabel.generate_value_label
Parameters ---------- byteorder : str Byte order of the output encoding : str File encoding Returns ------- value_label : bytes Bytes containing the formatted value label
pandas/io/stata.py
def generate_value_label(self, byteorder, encoding): """ Parameters ---------- byteorder : str Byte order of the output encoding : str File encoding Returns ------- value_label : bytes Bytes containing the formatted val...
def generate_value_label(self, byteorder, encoding): """ Parameters ---------- byteorder : str Byte order of the output encoding : str File encoding Returns ------- value_label : bytes Bytes containing the formatted val...
[ "Parameters", "----------", "byteorder", ":", "str", "Byte", "order", "of", "the", "output", "encoding", ":", "str", "File", "encoding" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L662-L713
[ "def", "generate_value_label", "(", "self", ",", "byteorder", ",", "encoding", ")", ":", "self", ".", "_encoding", "=", "encoding", "bio", "=", "BytesIO", "(", ")", "null_string", "=", "'\\x00'", "null_byte", "=", "b'\\x00'", "# len", "bio", ".", "write", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataReader._setup_dtype
Map between numpy and state dtypes
pandas/io/stata.py
def _setup_dtype(self): """Map between numpy and state dtypes""" if self._dtype is not None: return self._dtype dtype = [] # Convert struct data types to numpy data type for i, typ in enumerate(self.typlist): if typ in self.NUMPY_TYPE_MAP: dtype....
def _setup_dtype(self): """Map between numpy and state dtypes""" if self._dtype is not None: return self._dtype dtype = [] # Convert struct data types to numpy data type for i, typ in enumerate(self.typlist): if typ in self.NUMPY_TYPE_MAP: dtype....
[ "Map", "between", "numpy", "and", "state", "dtypes" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1307-L1322
[ "def", "_setup_dtype", "(", "self", ")", ":", "if", "self", ".", "_dtype", "is", "not", "None", ":", "return", "self", ".", "_dtype", "dtype", "=", "[", "]", "# Convert struct data types to numpy data type", "for", "i", ",", "typ", "in", "enumerate", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataReader._do_convert_categoricals
Converts categorical columns to Categorical type.
pandas/io/stata.py
def _do_convert_categoricals(self, data, value_label_dict, lbllist, order_categoricals): """ Converts categorical columns to Categorical type. """ value_labels = list(value_label_dict.keys()) cat_converted_data = [] for col, label in zip(d...
def _do_convert_categoricals(self, data, value_label_dict, lbllist, order_categoricals): """ Converts categorical columns to Categorical type. """ value_labels = list(value_label_dict.keys()) cat_converted_data = [] for col, label in zip(d...
[ "Converts", "categorical", "columns", "to", "Categorical", "type", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1698-L1740
[ "def", "_do_convert_categoricals", "(", "self", ",", "data", ",", "value_label_dict", ",", "lbllist", ",", "order_categoricals", ")", ":", "value_labels", "=", "list", "(", "value_label_dict", ".", "keys", "(", ")", ")", "cat_converted_data", "=", "[", "]", "f...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter._write
Helper to call encode before writing to file for Python 3 compat.
pandas/io/stata.py
def _write(self, to_write): """ Helper to call encode before writing to file for Python 3 compat. """ self._file.write(to_write.encode(self._encoding or self._default_encoding))
def _write(self, to_write): """ Helper to call encode before writing to file for Python 3 compat. """ self._file.write(to_write.encode(self._encoding or self._default_encoding))
[ "Helper", "to", "call", "encode", "before", "writing", "to", "file", "for", "Python", "3", "compat", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2018-L2023
[ "def", "_write", "(", "self", ",", "to_write", ")", ":", "self", ".", "_file", ".", "write", "(", "to_write", ".", "encode", "(", "self", ".", "_encoding", "or", "self", ".", "_default_encoding", ")", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter._prepare_categoricals
Check for categorical columns, retain categorical information for Stata file and convert categorical data to int
pandas/io/stata.py
def _prepare_categoricals(self, data): """Check for categorical columns, retain categorical information for Stata file and convert categorical data to int""" is_cat = [is_categorical_dtype(data[col]) for col in data] self._is_col_cat = is_cat self._value_labels = [] if n...
def _prepare_categoricals(self, data): """Check for categorical columns, retain categorical information for Stata file and convert categorical data to int""" is_cat = [is_categorical_dtype(data[col]) for col in data] self._is_col_cat = is_cat self._value_labels = [] if n...
[ "Check", "for", "categorical", "columns", "retain", "categorical", "information", "for", "Stata", "file", "and", "convert", "categorical", "data", "to", "int" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2025-L2061
[ "def", "_prepare_categoricals", "(", "self", ",", "data", ")", ":", "is_cat", "=", "[", "is_categorical_dtype", "(", "data", "[", "col", "]", ")", "for", "col", "in", "data", "]", "self", ".", "_is_col_cat", "=", "is_cat", "self", ".", "_value_labels", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter._replace_nans
Checks floating point data columns for nans, and replaces these with the generic Stata for missing value (.)
pandas/io/stata.py
def _replace_nans(self, data): # return data """Checks floating point data columns for nans, and replaces these with the generic Stata for missing value (.)""" for c in data: dtype = data[c].dtype if dtype in (np.float32, np.float64): if dtype == n...
def _replace_nans(self, data): # return data """Checks floating point data columns for nans, and replaces these with the generic Stata for missing value (.)""" for c in data: dtype = data[c].dtype if dtype in (np.float32, np.float64): if dtype == n...
[ "Checks", "floating", "point", "data", "columns", "for", "nans", "and", "replaces", "these", "with", "the", "generic", "Stata", "for", "missing", "value", "(", ".", ")" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2063-L2076
[ "def", "_replace_nans", "(", "self", ",", "data", ")", ":", "# return data", "for", "c", "in", "data", ":", "dtype", "=", "data", "[", "c", "]", ".", "dtype", "if", "dtype", "in", "(", "np", ".", "float32", ",", "np", ".", "float64", ")", ":", "i...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter._check_column_names
Checks column names to ensure that they are valid Stata column names. This includes checks for: * Non-string names * Stata keywords * Variables that start with numbers * Variables with names that are too long When an illegal variable name is detected, it ...
pandas/io/stata.py
def _check_column_names(self, data): """ Checks column names to ensure that they are valid Stata column names. This includes checks for: * Non-string names * Stata keywords * Variables that start with numbers * Variables with names that are too lon...
def _check_column_names(self, data): """ Checks column names to ensure that they are valid Stata column names. This includes checks for: * Non-string names * Stata keywords * Variables that start with numbers * Variables with names that are too lon...
[ "Checks", "column", "names", "to", "ensure", "that", "they", "are", "valid", "Stata", "column", "names", ".", "This", "includes", "checks", "for", ":", "*", "Non", "-", "string", "names", "*", "Stata", "keywords", "*", "Variables", "that", "start", "with",...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2082-L2157
[ "def", "_check_column_names", "(", "self", ",", "data", ")", ":", "converted_names", "=", "{", "}", "columns", "=", "list", "(", "data", ".", "columns", ")", "original_columns", "=", "columns", "[", ":", "]", "duplicate_var_id", "=", "0", "for", "j", ","...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter._close
Close the file if it was created by the writer. If a buffer or file-like object was passed in, for example a GzipFile, then leave this file open for the caller to close. In either case, attempt to flush the file contents to ensure they are written to disk (if supported)
pandas/io/stata.py
def _close(self): """ Close the file if it was created by the writer. If a buffer or file-like object was passed in, for example a GzipFile, then leave this file open for the caller to close. In either case, attempt to flush the file contents to ensure they are written to disk ...
def _close(self): """ Close the file if it was created by the writer. If a buffer or file-like object was passed in, for example a GzipFile, then leave this file open for the caller to close. In either case, attempt to flush the file contents to ensure they are written to disk ...
[ "Close", "the", "file", "if", "it", "was", "created", "by", "the", "writer", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2249-L2264
[ "def", "_close", "(", "self", ")", ":", "# Some file-like objects might not support flush", "try", ":", "self", ".", "_file", ".", "flush", "(", ")", "except", "AttributeError", ":", "pass", "if", "self", ".", "_own_file", ":", "self", ".", "_file", ".", "cl...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataStrLWriter.generate_table
Generates the GSO lookup table for the DataFRame Returns ------- gso_table : OrderedDict Ordered dictionary using the string found as keys and their lookup position (v,o) as values gso_df : DataFrame DataFrame where strl columns have been converted to...
pandas/io/stata.py
def generate_table(self): """ Generates the GSO lookup table for the DataFRame Returns ------- gso_table : OrderedDict Ordered dictionary using the string found as keys and their lookup position (v,o) as values gso_df : DataFrame DataF...
def generate_table(self): """ Generates the GSO lookup table for the DataFRame Returns ------- gso_table : OrderedDict Ordered dictionary using the string found as keys and their lookup position (v,o) as values gso_df : DataFrame DataF...
[ "Generates", "the", "GSO", "lookup", "table", "for", "the", "DataFRame" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2546-L2596
[ "def", "generate_table", "(", "self", ")", ":", "gso_table", "=", "self", ".", "_gso_table", "gso_df", "=", "self", ".", "df", "columns", "=", "list", "(", "gso_df", ".", "columns", ")", "selected", "=", "gso_df", "[", "self", ".", "columns", "]", "col...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataStrLWriter.generate_blob
Generates the binary blob of GSOs that is written to the dta file. Parameters ---------- gso_table : OrderedDict Ordered dictionary (str, vo) Returns ------- gso : bytes Binary content of dta file to be placed between strl tags Notes ...
pandas/io/stata.py
def generate_blob(self, gso_table): """ Generates the binary blob of GSOs that is written to the dta file. Parameters ---------- gso_table : OrderedDict Ordered dictionary (str, vo) Returns ------- gso : bytes Binary content of dt...
def generate_blob(self, gso_table): """ Generates the binary blob of GSOs that is written to the dta file. Parameters ---------- gso_table : OrderedDict Ordered dictionary (str, vo) Returns ------- gso : bytes Binary content of dt...
[ "Generates", "the", "binary", "blob", "of", "GSOs", "that", "is", "written", "to", "the", "dta", "file", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2604-L2666
[ "def", "generate_blob", "(", "self", ",", "gso_table", ")", ":", "# Format information", "# Length includes null term", "# 117", "# GSOvvvvooootllllxxxxxxxxxxxxxxx...x", "# 3 u4 u4 u1 u4 string + null term", "#", "# 118, 119", "# GSOvvvvooooooootllllxxxxxxxxxxxxxxx...x", "# 3 u...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter117._tag
Surround val with <tag></tag>
pandas/io/stata.py
def _tag(val, tag): """Surround val with <tag></tag>""" if isinstance(val, str): val = bytes(val, 'utf-8') return (bytes('<' + tag + '>', 'utf-8') + val + bytes('</' + tag + '>', 'utf-8'))
def _tag(val, tag): """Surround val with <tag></tag>""" if isinstance(val, str): val = bytes(val, 'utf-8') return (bytes('<' + tag + '>', 'utf-8') + val + bytes('</' + tag + '>', 'utf-8'))
[ "Surround", "val", "with", "<tag", ">", "<", "/", "tag", ">" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2761-L2766
[ "def", "_tag", "(", "val", ",", "tag", ")", ":", "if", "isinstance", "(", "val", ",", "str", ")", ":", "val", "=", "bytes", "(", "val", ",", "'utf-8'", ")", "return", "(", "bytes", "(", "'<'", "+", "tag", "+", "'>'", ",", "'utf-8'", ")", "+", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter117._write_header
Write the file header
pandas/io/stata.py
def _write_header(self, data_label=None, time_stamp=None): """Write the file header""" byteorder = self._byteorder self._file.write(bytes('<stata_dta>', 'utf-8')) bio = BytesIO() # ds_format - 117 bio.write(self._tag(bytes('117', 'utf-8'), 'release')) # byteorder ...
def _write_header(self, data_label=None, time_stamp=None): """Write the file header""" byteorder = self._byteorder self._file.write(bytes('<stata_dta>', 'utf-8')) bio = BytesIO() # ds_format - 117 bio.write(self._tag(bytes('117', 'utf-8'), 'release')) # byteorder ...
[ "Write", "the", "file", "header" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2772-L2808
[ "def", "_write_header", "(", "self", ",", "data_label", "=", "None", ",", "time_stamp", "=", "None", ")", ":", "byteorder", "=", "self", ".", "_byteorder", "self", ".", "_file", ".", "write", "(", "bytes", "(", "'<stata_dta>'", ",", "'utf-8'", ")", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter117._write_map
Called twice during file write. The first populates the values in the map with 0s. The second call writes the final map locations when all blocks have been written.
pandas/io/stata.py
def _write_map(self): """Called twice during file write. The first populates the values in the map with 0s. The second call writes the final map locations when all blocks have been written.""" if self._map is None: self._map = OrderedDict((('stata_data', 0), ...
def _write_map(self): """Called twice during file write. The first populates the values in the map with 0s. The second call writes the final map locations when all blocks have been written.""" if self._map is None: self._map = OrderedDict((('stata_data', 0), ...
[ "Called", "twice", "during", "file", "write", ".", "The", "first", "populates", "the", "values", "in", "the", "map", "with", "0s", ".", "The", "second", "call", "writes", "the", "final", "map", "locations", "when", "all", "blocks", "have", "been", "written...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2810-L2835
[ "def", "_write_map", "(", "self", ")", ":", "if", "self", ".", "_map", "is", "None", ":", "self", ".", "_map", "=", "OrderedDict", "(", "(", "(", "'stata_data'", ",", "0", ")", ",", "(", "'map'", ",", "self", ".", "_file", ".", "tell", "(", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter117._update_strl_names
Update column names for conversion to strl if they might have been changed to comply with Stata naming rules
pandas/io/stata.py
def _update_strl_names(self): """Update column names for conversion to strl if they might have been changed to comply with Stata naming rules""" # Update convert_strl if names changed for orig, new in self._converted_names.items(): if orig in self._convert_strl: ...
def _update_strl_names(self): """Update column names for conversion to strl if they might have been changed to comply with Stata naming rules""" # Update convert_strl if names changed for orig, new in self._converted_names.items(): if orig in self._convert_strl: ...
[ "Update", "column", "names", "for", "conversion", "to", "strl", "if", "they", "might", "have", "been", "changed", "to", "comply", "with", "Stata", "naming", "rules" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2948-L2955
[ "def", "_update_strl_names", "(", "self", ")", ":", "# Update convert_strl if names changed", "for", "orig", ",", "new", "in", "self", ".", "_converted_names", ".", "items", "(", ")", ":", "if", "orig", "in", "self", ".", "_convert_strl", ":", "idx", "=", "s...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
StataWriter117._convert_strls
Convert columns to StrLs if either very large or in the convert_strl variable
pandas/io/stata.py
def _convert_strls(self, data): """Convert columns to StrLs if either very large or in the convert_strl variable""" convert_cols = [ col for i, col in enumerate(data) if self.typlist[i] == 32768 or col in self._convert_strl] if convert_cols: ssw = Sta...
def _convert_strls(self, data): """Convert columns to StrLs if either very large or in the convert_strl variable""" convert_cols = [ col for i, col in enumerate(data) if self.typlist[i] == 32768 or col in self._convert_strl] if convert_cols: ssw = Sta...
[ "Convert", "columns", "to", "StrLs", "if", "either", "very", "large", "or", "in", "the", "convert_strl", "variable" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2957-L2969
[ "def", "_convert_strls", "(", "self", ",", "data", ")", ":", "convert_cols", "=", "[", "col", "for", "i", ",", "col", "in", "enumerate", "(", "data", ")", "if", "self", ".", "typlist", "[", "i", "]", "==", "32768", "or", "col", "in", "self", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
register
Register Pandas Formatters and Converters with matplotlib This function modifies the global ``matplotlib.units.registry`` dictionary. Pandas adds custom converters for * pd.Timestamp * pd.Period * np.datetime64 * datetime.datetime * datetime.date * datetime.time See Also -----...
pandas/plotting/_converter.py
def register(explicit=True): """ Register Pandas Formatters and Converters with matplotlib This function modifies the global ``matplotlib.units.registry`` dictionary. Pandas adds custom converters for * pd.Timestamp * pd.Period * np.datetime64 * datetime.datetime * datetime.date ...
def register(explicit=True): """ Register Pandas Formatters and Converters with matplotlib This function modifies the global ``matplotlib.units.registry`` dictionary. Pandas adds custom converters for * pd.Timestamp * pd.Period * np.datetime64 * datetime.datetime * datetime.date ...
[ "Register", "Pandas", "Formatters", "and", "Converters", "with", "matplotlib" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L54-L84
[ "def", "register", "(", "explicit", "=", "True", ")", ":", "# Renamed in pandas.plotting.__init__", "global", "_WARN", "if", "explicit", ":", "_WARN", "=", "False", "pairs", "=", "get_pairs", "(", ")", "for", "type_", ",", "cls", "in", "pairs", ":", "convert...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
deregister
Remove pandas' formatters and converters Removes the custom converters added by :func:`register`. This attempts to set the state of the registry back to the state before pandas registered its own units. Converters for pandas' own types like Timestamp and Period are removed completely. Converters for ty...
pandas/plotting/_converter.py
def deregister(): """ Remove pandas' formatters and converters Removes the custom converters added by :func:`register`. This attempts to set the state of the registry back to the state before pandas registered its own units. Converters for pandas' own types like Timestamp and Period are removed...
def deregister(): """ Remove pandas' formatters and converters Removes the custom converters added by :func:`register`. This attempts to set the state of the registry back to the state before pandas registered its own units. Converters for pandas' own types like Timestamp and Period are removed...
[ "Remove", "pandas", "formatters", "and", "converters" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L87-L113
[ "def", "deregister", "(", ")", ":", "# Renamed in pandas.plotting.__init__", "for", "type_", ",", "cls", "in", "get_pairs", "(", ")", ":", "# We use type to catch our classes directly, no inheritance", "if", "type", "(", "units", ".", "registry", ".", "get", "(", "t...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_dt_to_float_ordinal
Convert :mod:`datetime` to the Gregorian date as UTC float days, preserving hours, minutes, seconds and microseconds. Return value is a :func:`float`.
pandas/plotting/_converter.py
def _dt_to_float_ordinal(dt): """ Convert :mod:`datetime` to the Gregorian date as UTC float days, preserving hours, minutes, seconds and microseconds. Return value is a :func:`float`. """ if (isinstance(dt, (np.ndarray, Index, ABCSeries) ) and is_datetime64_ns_dtype(dt)): ...
def _dt_to_float_ordinal(dt): """ Convert :mod:`datetime` to the Gregorian date as UTC float days, preserving hours, minutes, seconds and microseconds. Return value is a :func:`float`. """ if (isinstance(dt, (np.ndarray, Index, ABCSeries) ) and is_datetime64_ns_dtype(dt)): ...
[ "Convert", ":", "mod", ":", "datetime", "to", "the", "Gregorian", "date", "as", "UTC", "float", "days", "preserving", "hours", "minutes", "seconds", "and", "microseconds", ".", "Return", "value", "is", "a", ":", "func", ":", "float", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L269-L280
[ "def", "_dt_to_float_ordinal", "(", "dt", ")", ":", "if", "(", "isinstance", "(", "dt", ",", "(", "np", ".", "ndarray", ",", "Index", ",", "ABCSeries", ")", ")", "and", "is_datetime64_ns_dtype", "(", "dt", ")", ")", ":", "base", "=", "dates", ".", "e...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_default_annual_spacing
Returns a default spacing between consecutive ticks for annual data.
pandas/plotting/_converter.py
def _get_default_annual_spacing(nyears): """ Returns a default spacing between consecutive ticks for annual data. """ if nyears < 11: (min_spacing, maj_spacing) = (1, 1) elif nyears < 20: (min_spacing, maj_spacing) = (1, 2) elif nyears < 50: (min_spacing, maj_spacing) = (...
def _get_default_annual_spacing(nyears): """ Returns a default spacing between consecutive ticks for annual data. """ if nyears < 11: (min_spacing, maj_spacing) = (1, 1) elif nyears < 20: (min_spacing, maj_spacing) = (1, 2) elif nyears < 50: (min_spacing, maj_spacing) = (...
[ "Returns", "a", "default", "spacing", "between", "consecutive", "ticks", "for", "annual", "data", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L537-L556
[ "def", "_get_default_annual_spacing", "(", "nyears", ")", ":", "if", "nyears", "<", "11", ":", "(", "min_spacing", ",", "maj_spacing", ")", "=", "(", "1", ",", "1", ")", "elif", "nyears", "<", "20", ":", "(", "min_spacing", ",", "maj_spacing", ")", "="...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
period_break
Returns the indices where the given period changes. Parameters ---------- dates : PeriodIndex Array of intervals to monitor. period : string Name of the period to monitor.
pandas/plotting/_converter.py
def period_break(dates, period): """ Returns the indices where the given period changes. Parameters ---------- dates : PeriodIndex Array of intervals to monitor. period : string Name of the period to monitor. """ current = getattr(dates, period) previous = getattr(da...
def period_break(dates, period): """ Returns the indices where the given period changes. Parameters ---------- dates : PeriodIndex Array of intervals to monitor. period : string Name of the period to monitor. """ current = getattr(dates, period) previous = getattr(da...
[ "Returns", "the", "indices", "where", "the", "given", "period", "changes", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L559-L572
[ "def", "period_break", "(", "dates", ",", "period", ")", ":", "current", "=", "getattr", "(", "dates", ",", "period", ")", "previous", "=", "getattr", "(", "dates", "-", "1", "*", "dates", ".", "freq", ",", "period", ")", "return", "np", ".", "nonzer...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
has_level_label
Returns true if the ``label_flags`` indicate there is at least one label for this level. if the minimum view limit is not an exact integer, then the first tick label won't be shown, so we must adjust for that.
pandas/plotting/_converter.py
def has_level_label(label_flags, vmin): """ Returns true if the ``label_flags`` indicate there is at least one label for this level. if the minimum view limit is not an exact integer, then the first tick label won't be shown, so we must adjust for that. """ if label_flags.size == 0 or (labe...
def has_level_label(label_flags, vmin): """ Returns true if the ``label_flags`` indicate there is at least one label for this level. if the minimum view limit is not an exact integer, then the first tick label won't be shown, so we must adjust for that. """ if label_flags.size == 0 or (labe...
[ "Returns", "true", "if", "the", "label_flags", "indicate", "there", "is", "at", "least", "one", "label", "for", "this", "level", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L575-L588
[ "def", "has_level_label", "(", "label_flags", ",", "vmin", ")", ":", "if", "label_flags", ".", "size", "==", "0", "or", "(", "label_flags", ".", "size", "==", "1", "and", "label_flags", "[", "0", "]", "==", "0", "and", "vmin", "%", "1", ">", "0.0", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeConverter.axisinfo
Return the :class:`~matplotlib.units.AxisInfo` for *unit*. *unit* is a tzinfo instance or None. The *axis* argument is required but not used.
pandas/plotting/_converter.py
def axisinfo(unit, axis): """ Return the :class:`~matplotlib.units.AxisInfo` for *unit*. *unit* is a tzinfo instance or None. The *axis* argument is required but not used. """ tz = unit majloc = PandasAutoDateLocator(tz=tz) majfmt = PandasAutoDateFormatt...
def axisinfo(unit, axis): """ Return the :class:`~matplotlib.units.AxisInfo` for *unit*. *unit* is a tzinfo instance or None. The *axis* argument is required but not used. """ tz = unit majloc = PandasAutoDateLocator(tz=tz) majfmt = PandasAutoDateFormatt...
[ "Return", "the", ":", "class", ":", "~matplotlib", ".", "units", ".", "AxisInfo", "for", "*", "unit", "*", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L340-L355
[ "def", "axisinfo", "(", "unit", ",", "axis", ")", ":", "tz", "=", "unit", "majloc", "=", "PandasAutoDateLocator", "(", "tz", "=", "tz", ")", "majfmt", "=", "PandasAutoDateFormatter", "(", "majloc", ",", "tz", "=", "tz", ")", "datemin", "=", "pydt", "."...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
PandasAutoDateLocator.get_locator
Pick the best locator based on a distance.
pandas/plotting/_converter.py
def get_locator(self, dmin, dmax): 'Pick the best locator based on a distance.' _check_implicitly_registered() delta = relativedelta(dmax, dmin) num_days = (delta.years * 12.0 + delta.months) * 31.0 + delta.days num_sec = (delta.hours * 60.0 + delta.minutes) * 60.0 + delta.secon...
def get_locator(self, dmin, dmax): 'Pick the best locator based on a distance.' _check_implicitly_registered() delta = relativedelta(dmax, dmin) num_days = (delta.years * 12.0 + delta.months) * 31.0 + delta.days num_sec = (delta.hours * 60.0 + delta.minutes) * 60.0 + delta.secon...
[ "Pick", "the", "best", "locator", "based", "on", "a", "distance", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L369-L387
[ "def", "get_locator", "(", "self", ",", "dmin", ",", "dmax", ")", ":", "_check_implicitly_registered", "(", ")", "delta", "=", "relativedelta", "(", "dmax", ",", "dmin", ")", "num_days", "=", "(", "delta", ".", "years", "*", "12.0", "+", "delta", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
MilliSecondLocator.autoscale
Set the view limits to include the data range.
pandas/plotting/_converter.py
def autoscale(self): """ Set the view limits to include the data range. """ dmin, dmax = self.datalim_to_dt() if dmin > dmax: dmax, dmin = dmin, dmax # We need to cap at the endpoints of valid datetime # TODO(wesm): unused? # delta = relativ...
def autoscale(self): """ Set the view limits to include the data range. """ dmin, dmax = self.datalim_to_dt() if dmin > dmax: dmax, dmin = dmin, dmax # We need to cap at the endpoints of valid datetime # TODO(wesm): unused? # delta = relativ...
[ "Set", "the", "view", "limits", "to", "include", "the", "data", "range", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L478-L507
[ "def", "autoscale", "(", "self", ")", ":", "dmin", ",", "dmax", "=", "self", ".", "datalim_to_dt", "(", ")", "if", "dmin", ">", "dmax", ":", "dmax", ",", "dmin", "=", "dmin", ",", "dmax", "# We need to cap at the endpoints of valid datetime", "# TODO(wesm): un...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TimeSeries_DateLocator._get_default_locs
Returns the default locations of ticks.
pandas/plotting/_converter.py
def _get_default_locs(self, vmin, vmax): "Returns the default locations of ticks." if self.plot_obj.date_axis_info is None: self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) locator = self.plot_obj.date_axis_info if self.isminor: return np.compr...
def _get_default_locs(self, vmin, vmax): "Returns the default locations of ticks." if self.plot_obj.date_axis_info is None: self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) locator = self.plot_obj.date_axis_info if self.isminor: return np.compr...
[ "Returns", "the", "default", "locations", "of", "ticks", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1002-L1012
[ "def", "_get_default_locs", "(", "self", ",", "vmin", ",", "vmax", ")", ":", "if", "self", ".", "plot_obj", ".", "date_axis_info", "is", "None", ":", "self", ".", "plot_obj", ".", "date_axis_info", "=", "self", ".", "finder", "(", "vmin", ",", "vmax", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TimeSeries_DateLocator.autoscale
Sets the view limits to the nearest multiples of base that contain the data.
pandas/plotting/_converter.py
def autoscale(self): """ Sets the view limits to the nearest multiples of base that contain the data. """ # requires matplotlib >= 0.98.0 (vmin, vmax) = self.axis.get_data_interval() locs = self._get_default_locs(vmin, vmax) (vmin, vmax) = locs[[0, -1]] ...
def autoscale(self): """ Sets the view limits to the nearest multiples of base that contain the data. """ # requires matplotlib >= 0.98.0 (vmin, vmax) = self.axis.get_data_interval() locs = self._get_default_locs(vmin, vmax) (vmin, vmax) = locs[[0, -1]] ...
[ "Sets", "the", "view", "limits", "to", "the", "nearest", "multiples", "of", "base", "that", "contain", "the", "data", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1035-L1048
[ "def", "autoscale", "(", "self", ")", ":", "# requires matplotlib >= 0.98.0", "(", "vmin", ",", "vmax", ")", "=", "self", ".", "axis", ".", "get_data_interval", "(", ")", "locs", "=", "self", ".", "_get_default_locs", "(", "vmin", ",", "vmax", ")", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TimeSeries_DateFormatter._set_default_format
Returns the default ticks spacing.
pandas/plotting/_converter.py
def _set_default_format(self, vmin, vmax): "Returns the default ticks spacing." if self.plot_obj.date_axis_info is None: self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) info = self.plot_obj.date_axis_info if self.isminor: format = np.compress(i...
def _set_default_format(self, vmin, vmax): "Returns the default ticks spacing." if self.plot_obj.date_axis_info is None: self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) info = self.plot_obj.date_axis_info if self.isminor: format = np.compress(i...
[ "Returns", "the", "default", "ticks", "spacing", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1084-L1097
[ "def", "_set_default_format", "(", "self", ",", "vmin", ",", "vmax", ")", ":", "if", "self", ".", "plot_obj", ".", "date_axis_info", "is", "None", ":", "self", ".", "plot_obj", ".", "date_axis_info", "=", "self", ".", "finder", "(", "vmin", ",", "vmax", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
TimeSeries_DateFormatter.set_locs
Sets the locations of the ticks
pandas/plotting/_converter.py
def set_locs(self, locs): 'Sets the locations of the ticks' # don't actually use the locs. This is just needed to work with # matplotlib. Force to use vmin, vmax _check_implicitly_registered() self.locs = locs (vmin, vmax) = vi = tuple(self.axis.get_view_interval()) ...
def set_locs(self, locs): 'Sets the locations of the ticks' # don't actually use the locs. This is just needed to work with # matplotlib. Force to use vmin, vmax _check_implicitly_registered() self.locs = locs (vmin, vmax) = vi = tuple(self.axis.get_view_interval()) ...
[ "Sets", "the", "locations", "of", "the", "ticks" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1099-L1113
[ "def", "set_locs", "(", "self", ",", "locs", ")", ":", "# don't actually use the locs. This is just needed to work with", "# matplotlib. Force to use vmin, vmax", "_check_implicitly_registered", "(", ")", "self", ".", "locs", "=", "locs", "(", "vmin", ",", "vmax", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
set_default_names
Sets index names to 'index' for regular, or 'level_x' for Multi
pandas/io/json/table_schema.py
def set_default_names(data): """Sets index names to 'index' for regular, or 'level_x' for Multi""" if com._all_not_none(*data.index.names): nms = data.index.names if len(nms) == 1 and data.index.name == 'index': warnings.warn("Index name of 'index' is not round-trippable") el...
def set_default_names(data): """Sets index names to 'index' for regular, or 'level_x' for Multi""" if com._all_not_none(*data.index.names): nms = data.index.names if len(nms) == 1 and data.index.name == 'index': warnings.warn("Index name of 'index' is not round-trippable") el...
[ "Sets", "index", "names", "to", "index", "for", "regular", "or", "level_x", "for", "Multi" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L71-L89
[ "def", "set_default_names", "(", "data", ")", ":", "if", "com", ".", "_all_not_none", "(", "*", "data", ".", "index", ".", "names", ")", ":", "nms", "=", "data", ".", "index", ".", "names", "if", "len", "(", "nms", ")", "==", "1", "and", "data", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
convert_json_field_to_pandas_type
Converts a JSON field descriptor into its corresponding NumPy / pandas type Parameters ---------- field A JSON field descriptor Returns ------- dtype Raises ----- ValueError If the type of the provided field is unknown or currently unsupported Examples ---...
pandas/io/json/table_schema.py
def convert_json_field_to_pandas_type(field): """ Converts a JSON field descriptor into its corresponding NumPy / pandas type Parameters ---------- field A JSON field descriptor Returns ------- dtype Raises ----- ValueError If the type of the provided field...
def convert_json_field_to_pandas_type(field): """ Converts a JSON field descriptor into its corresponding NumPy / pandas type Parameters ---------- field A JSON field descriptor Returns ------- dtype Raises ----- ValueError If the type of the provided field...
[ "Converts", "a", "JSON", "field", "descriptor", "into", "its", "corresponding", "NumPy", "/", "pandas", "type" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L120-L180
[ "def", "convert_json_field_to_pandas_type", "(", "field", ")", ":", "typ", "=", "field", "[", "'type'", "]", "if", "typ", "==", "'string'", ":", "return", "'object'", "elif", "typ", "==", "'integer'", ":", "return", "'int64'", "elif", "typ", "==", "'number'"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
build_table_schema
Create a Table schema from ``data``. Parameters ---------- data : Series, DataFrame index : bool, default True Whether to include ``data.index`` in the schema. primary_key : bool or None, default True column names to designate as the primary key. The default `None` will set ...
pandas/io/json/table_schema.py
def build_table_schema(data, index=True, primary_key=None, version=True): """ Create a Table schema from ``data``. Parameters ---------- data : Series, DataFrame index : bool, default True Whether to include ``data.index`` in the schema. primary_key : bool or None, default True ...
def build_table_schema(data, index=True, primary_key=None, version=True): """ Create a Table schema from ``data``. Parameters ---------- data : Series, DataFrame index : bool, default True Whether to include ``data.index`` in the schema. primary_key : bool or None, default True ...
[ "Create", "a", "Table", "schema", "from", "data", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L183-L259
[ "def", "build_table_schema", "(", "data", ",", "index", "=", "True", ",", "primary_key", "=", "None", ",", "version", "=", "True", ")", ":", "if", "index", "is", "True", ":", "data", "=", "set_default_names", "(", "data", ")", "schema", "=", "{", "}", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
parse_table_schema
Builds a DataFrame from a given schema Parameters ---------- json : A JSON table schema precise_float : boolean Flag controlling precision when decoding string to double values, as dictated by ``read_json`` Returns ------- df : DataFrame Raises ------ N...
pandas/io/json/table_schema.py
def parse_table_schema(json, precise_float): """ Builds a DataFrame from a given schema Parameters ---------- json : A JSON table schema precise_float : boolean Flag controlling precision when decoding string to double values, as dictated by ``read_json`` Returns ...
def parse_table_schema(json, precise_float): """ Builds a DataFrame from a given schema Parameters ---------- json : A JSON table schema precise_float : boolean Flag controlling precision when decoding string to double values, as dictated by ``read_json`` Returns ...
[ "Builds", "a", "DataFrame", "from", "a", "given", "schema" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L262-L326
[ "def", "parse_table_schema", "(", "json", ",", "precise_float", ")", ":", "table", "=", "loads", "(", "json", ",", "precise_float", "=", "precise_float", ")", "col_order", "=", "[", "field", "[", "'name'", "]", "for", "field", "in", "table", "[", "'schema'...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_op_result_name
Find the appropriate name to pin to an operation result. This result should always be either an Index or a Series. Parameters ---------- left : {Series, Index} right : object Returns ------- name : object Usually a string
pandas/core/ops.py
def get_op_result_name(left, right): """ Find the appropriate name to pin to an operation result. This result should always be either an Index or a Series. Parameters ---------- left : {Series, Index} right : object Returns ------- name : object Usually a string ""...
def get_op_result_name(left, right): """ Find the appropriate name to pin to an operation result. This result should always be either an Index or a Series. Parameters ---------- left : {Series, Index} right : object Returns ------- name : object Usually a string ""...
[ "Find", "the", "appropriate", "name", "to", "pin", "to", "an", "operation", "result", ".", "This", "result", "should", "always", "be", "either", "an", "Index", "or", "a", "Series", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L38-L58
[ "def", "get_op_result_name", "(", "left", ",", "right", ")", ":", "# `left` is always a pd.Series when called from within ops", "if", "isinstance", "(", "right", ",", "(", "ABCSeries", ",", "pd", ".", "Index", ")", ")", ":", "name", "=", "_maybe_match_name", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_maybe_match_name
Try to find a name to attach to the result of an operation between a and b. If only one of these has a `name` attribute, return that name. Otherwise return a consensus name if they match of None if they have different names. Parameters ---------- a : object b : object Returns ---...
pandas/core/ops.py
def _maybe_match_name(a, b): """ Try to find a name to attach to the result of an operation between a and b. If only one of these has a `name` attribute, return that name. Otherwise return a consensus name if they match of None if they have different names. Parameters ---------- a : o...
def _maybe_match_name(a, b): """ Try to find a name to attach to the result of an operation between a and b. If only one of these has a `name` attribute, return that name. Otherwise return a consensus name if they match of None if they have different names. Parameters ---------- a : o...
[ "Try", "to", "find", "a", "name", "to", "attach", "to", "the", "result", "of", "an", "operation", "between", "a", "and", "b", ".", "If", "only", "one", "of", "these", "has", "a", "name", "attribute", "return", "that", "name", ".", "Otherwise", "return"...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L61-L93
[ "def", "_maybe_match_name", "(", "a", ",", "b", ")", ":", "a_has", "=", "hasattr", "(", "a", ",", "'name'", ")", "b_has", "=", "hasattr", "(", "b", ",", "'name'", ")", "if", "a_has", "and", "b_has", ":", "if", "a", ".", "name", "==", "b", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
maybe_upcast_for_op
Cast non-pandas objects to pandas types to unify behavior of arithmetic and comparison operations. Parameters ---------- obj: object Returns ------- out : object Notes ----- Be careful to call this *after* determining the `name` attribute to be attached to the result of th...
pandas/core/ops.py
def maybe_upcast_for_op(obj): """ Cast non-pandas objects to pandas types to unify behavior of arithmetic and comparison operations. Parameters ---------- obj: object Returns ------- out : object Notes ----- Be careful to call this *after* determining the `name` attrib...
def maybe_upcast_for_op(obj): """ Cast non-pandas objects to pandas types to unify behavior of arithmetic and comparison operations. Parameters ---------- obj: object Returns ------- out : object Notes ----- Be careful to call this *after* determining the `name` attrib...
[ "Cast", "non", "-", "pandas", "objects", "to", "pandas", "types", "to", "unify", "behavior", "of", "arithmetic", "and", "comparison", "operations", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L96-L131
[ "def", "maybe_upcast_for_op", "(", "obj", ")", ":", "if", "type", "(", "obj", ")", "is", "datetime", ".", "timedelta", ":", "# GH#22390 cast up to Timedelta to rely on Timedelta", "# implementation; otherwise operation against numeric-dtype", "# raises TypeError", "return", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
make_invalid_op
Return a binary method that always raises a TypeError. Parameters ---------- name : str Returns ------- invalid_op : function
pandas/core/ops.py
def make_invalid_op(name): """ Return a binary method that always raises a TypeError. Parameters ---------- name : str Returns ------- invalid_op : function """ def invalid_op(self, other=None): raise TypeError("cannot perform {name} with this index type: " ...
def make_invalid_op(name): """ Return a binary method that always raises a TypeError. Parameters ---------- name : str Returns ------- invalid_op : function """ def invalid_op(self, other=None): raise TypeError("cannot perform {name} with this index type: " ...
[ "Return", "a", "binary", "method", "that", "always", "raises", "a", "TypeError", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L195-L212
[ "def", "make_invalid_op", "(", "name", ")", ":", "def", "invalid_op", "(", "self", ",", "other", "=", "None", ")", ":", "raise", "TypeError", "(", "\"cannot perform {name} with this index type: \"", "\"{typ}\"", ".", "format", "(", "name", "=", "name", ",", "t...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_gen_eval_kwargs
Find the keyword arguments to pass to numexpr for the given operation. Parameters ---------- name : str Returns ------- eval_kwargs : dict Examples -------- >>> _gen_eval_kwargs("__add__") {} >>> _gen_eval_kwargs("rtruediv") {'reversed': True, 'truediv': True}
pandas/core/ops.py
def _gen_eval_kwargs(name): """ Find the keyword arguments to pass to numexpr for the given operation. Parameters ---------- name : str Returns ------- eval_kwargs : dict Examples -------- >>> _gen_eval_kwargs("__add__") {} >>> _gen_eval_kwargs("rtruediv") {'r...
def _gen_eval_kwargs(name): """ Find the keyword arguments to pass to numexpr for the given operation. Parameters ---------- name : str Returns ------- eval_kwargs : dict Examples -------- >>> _gen_eval_kwargs("__add__") {} >>> _gen_eval_kwargs("rtruediv") {'r...
[ "Find", "the", "keyword", "arguments", "to", "pass", "to", "numexpr", "for", "the", "given", "operation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L215-L253
[ "def", "_gen_eval_kwargs", "(", "name", ")", ":", "kwargs", "=", "{", "}", "# Series and Panel appear to only pass __add__, __radd__, ...", "# but DataFrame gets both these dunder names _and_ non-dunder names", "# add, radd, ...", "name", "=", "name", ".", "replace", "(", "'__'...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_gen_fill_zeros
Find the appropriate fill value to use when filling in undefined values in the results of the given operation caused by operating on (generally dividing by) zero. Parameters ---------- name : str Returns ------- fill_value : {None, np.nan, np.inf}
pandas/core/ops.py
def _gen_fill_zeros(name): """ Find the appropriate fill value to use when filling in undefined values in the results of the given operation caused by operating on (generally dividing by) zero. Parameters ---------- name : str Returns ------- fill_value : {None, np.nan, np.inf}...
def _gen_fill_zeros(name): """ Find the appropriate fill value to use when filling in undefined values in the results of the given operation caused by operating on (generally dividing by) zero. Parameters ---------- name : str Returns ------- fill_value : {None, np.nan, np.inf}...
[ "Find", "the", "appropriate", "fill", "value", "to", "use", "when", "filling", "in", "undefined", "values", "in", "the", "results", "of", "the", "given", "operation", "caused", "by", "operating", "on", "(", "generally", "dividing", "by", ")", "zero", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L256-L279
[ "def", "_gen_fill_zeros", "(", "name", ")", ":", "name", "=", "name", ".", "strip", "(", "'__'", ")", "if", "'div'", "in", "name", ":", "# truediv, floordiv, div, and reversed variants", "fill_value", "=", "np", ".", "inf", "elif", "'mod'", "in", "name", ":"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_opstr
Find the operation string, if any, to pass to numexpr for this operation. Parameters ---------- op : binary operator cls : class Returns ------- op_str : string or None
pandas/core/ops.py
def _get_opstr(op, cls): """ Find the operation string, if any, to pass to numexpr for this operation. Parameters ---------- op : binary operator cls : class Returns ------- op_str : string or None """ # numexpr is available for non-sparse classes subtyp = getattr(c...
def _get_opstr(op, cls): """ Find the operation string, if any, to pass to numexpr for this operation. Parameters ---------- op : binary operator cls : class Returns ------- op_str : string or None """ # numexpr is available for non-sparse classes subtyp = getattr(c...
[ "Find", "the", "operation", "string", "if", "any", "to", "pass", "to", "numexpr", "for", "this", "operation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L307-L356
[ "def", "_get_opstr", "(", "op", ",", "cls", ")", ":", "# numexpr is available for non-sparse classes", "subtyp", "=", "getattr", "(", "cls", ",", "'_subtyp'", ",", "''", ")", "use_numexpr", "=", "'sparse'", "not", "in", "subtyp", "if", "not", "use_numexpr", ":...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_op_name
Find the name to attach to this method according to conventions for special and non-special methods. Parameters ---------- op : binary operator special : bool Returns ------- op_name : str
pandas/core/ops.py
def _get_op_name(op, special): """ Find the name to attach to this method according to conventions for special and non-special methods. Parameters ---------- op : binary operator special : bool Returns ------- op_name : str """ opname = op.__name__.strip('_') if spe...
def _get_op_name(op, special): """ Find the name to attach to this method according to conventions for special and non-special methods. Parameters ---------- op : binary operator special : bool Returns ------- op_name : str """ opname = op.__name__.strip('_') if spe...
[ "Find", "the", "name", "to", "attach", "to", "this", "method", "according", "to", "conventions", "for", "special", "and", "non", "-", "special", "methods", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L359-L376
[ "def", "_get_op_name", "(", "op", ",", "special", ")", ":", "opname", "=", "op", ".", "__name__", ".", "strip", "(", "'_'", ")", "if", "special", ":", "opname", "=", "'__{opname}__'", ".", "format", "(", "opname", "=", "opname", ")", "return", "opname"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_make_flex_doc
Make the appropriate substitutions for the given operation and class-typ into either _flex_doc_SERIES or _flex_doc_FRAME to return the docstring to attach to a generated method. Parameters ---------- op_name : str {'__add__', '__sub__', ... '__eq__', '__ne__', ...} typ : str {series, 'dataframe...
pandas/core/ops.py
def _make_flex_doc(op_name, typ): """ Make the appropriate substitutions for the given operation and class-typ into either _flex_doc_SERIES or _flex_doc_FRAME to return the docstring to attach to a generated method. Parameters ---------- op_name : str {'__add__', '__sub__', ... '__eq__', '_...
def _make_flex_doc(op_name, typ): """ Make the appropriate substitutions for the given operation and class-typ into either _flex_doc_SERIES or _flex_doc_FRAME to return the docstring to attach to a generated method. Parameters ---------- op_name : str {'__add__', '__sub__', ... '__eq__', '_...
[ "Make", "the", "appropriate", "substitutions", "for", "the", "given", "operation", "and", "class", "-", "typ", "into", "either", "_flex_doc_SERIES", "or", "_flex_doc_FRAME", "to", "return", "the", "docstring", "to", "attach", "to", "a", "generated", "method", "....
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1029-L1082
[ "def", "_make_flex_doc", "(", "op_name", ",", "typ", ")", ":", "op_name", "=", "op_name", ".", "replace", "(", "'__'", ",", "''", ")", "op_desc", "=", "_op_descriptions", "[", "op_name", "]", "if", "op_desc", "[", "'reversed'", "]", ":", "equiv", "=", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
fill_binop
If a non-None fill_value is given, replace null entries in left and right with this value, but only in positions where _one_ of left/right is null, not both. Parameters ---------- left : array-like right : array-like fill_value : object Returns ------- left : array-like rig...
pandas/core/ops.py
def fill_binop(left, right, fill_value): """ If a non-None fill_value is given, replace null entries in left and right with this value, but only in positions where _one_ of left/right is null, not both. Parameters ---------- left : array-like right : array-like fill_value : object ...
def fill_binop(left, right, fill_value): """ If a non-None fill_value is given, replace null entries in left and right with this value, but only in positions where _one_ of left/right is null, not both. Parameters ---------- left : array-like right : array-like fill_value : object ...
[ "If", "a", "non", "-", "None", "fill_value", "is", "given", "replace", "null", "entries", "in", "left", "and", "right", "with", "this", "value", "but", "only", "in", "positions", "where", "_one_", "of", "left", "/", "right", "is", "null", "not", "both", ...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1088-L1120
[ "def", "fill_binop", "(", "left", ",", "right", ",", "fill_value", ")", ":", "# TODO: can we make a no-copy implementation?", "if", "fill_value", "is", "not", "None", ":", "left_mask", "=", "isna", "(", "left", ")", "right_mask", "=", "isna", "(", "right", ")"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
mask_cmp_op
Apply the function `op` to only non-null points in x and y. Parameters ---------- x : array-like y : array-like op : binary operation allowed_types : class or tuple of classes Returns ------- result : ndarray[bool]
pandas/core/ops.py
def mask_cmp_op(x, y, op, allowed_types): """ Apply the function `op` to only non-null points in x and y. Parameters ---------- x : array-like y : array-like op : binary operation allowed_types : class or tuple of classes Returns ------- result : ndarray[bool] """ #...
def mask_cmp_op(x, y, op, allowed_types): """ Apply the function `op` to only non-null points in x and y. Parameters ---------- x : array-like y : array-like op : binary operation allowed_types : class or tuple of classes Returns ------- result : ndarray[bool] """ #...
[ "Apply", "the", "function", "op", "to", "only", "non", "-", "null", "points", "in", "x", "and", "y", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1123-L1155
[ "def", "mask_cmp_op", "(", "x", ",", "y", ",", "op", ",", "allowed_types", ")", ":", "# TODO: Can we make the allowed_types arg unnecessary?", "xrav", "=", "x", ".", "ravel", "(", ")", "result", "=", "np", ".", "empty", "(", "x", ".", "size", ",", "dtype",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
masked_arith_op
If the given arithmetic operation fails, attempt it again on only the non-null elements of the input array(s). Parameters ---------- x : np.ndarray y : np.ndarray, Series, Index op : binary operator
pandas/core/ops.py
def masked_arith_op(x, y, op): """ If the given arithmetic operation fails, attempt it again on only the non-null elements of the input array(s). Parameters ---------- x : np.ndarray y : np.ndarray, Series, Index op : binary operator """ # For Series `x` is 1D so ravel() is a no...
def masked_arith_op(x, y, op): """ If the given arithmetic operation fails, attempt it again on only the non-null elements of the input array(s). Parameters ---------- x : np.ndarray y : np.ndarray, Series, Index op : binary operator """ # For Series `x` is 1D so ravel() is a no...
[ "If", "the", "given", "arithmetic", "operation", "fails", "attempt", "it", "again", "on", "only", "the", "non", "-", "null", "elements", "of", "the", "input", "array", "(", "s", ")", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1158-L1213
[ "def", "masked_arith_op", "(", "x", ",", "y", ",", "op", ")", ":", "# For Series `x` is 1D so ravel() is a no-op; calling it anyway makes", "# the logic valid for both Series and DataFrame ops.", "xrav", "=", "x", ".", "ravel", "(", ")", "assert", "isinstance", "(", "x", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
invalid_comparison
If a comparison has mismatched types and is not necessarily meaningful, follow python3 conventions by: - returning all-False for equality - returning all-True for inequality - raising TypeError otherwise Parameters ---------- left : array-like right : scalar, array-like ...
pandas/core/ops.py
def invalid_comparison(left, right, op): """ If a comparison has mismatched types and is not necessarily meaningful, follow python3 conventions by: - returning all-False for equality - returning all-True for inequality - raising TypeError otherwise Parameters ---------- ...
def invalid_comparison(left, right, op): """ If a comparison has mismatched types and is not necessarily meaningful, follow python3 conventions by: - returning all-False for equality - returning all-True for inequality - raising TypeError otherwise Parameters ---------- ...
[ "If", "a", "comparison", "has", "mismatched", "types", "and", "is", "not", "necessarily", "meaningful", "follow", "python3", "conventions", "by", ":" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1216-L1242
[ "def", "invalid_comparison", "(", "left", ",", "right", ",", "op", ")", ":", "if", "op", "is", "operator", ".", "eq", ":", "res_values", "=", "np", ".", "zeros", "(", "left", ".", "shape", ",", "dtype", "=", "bool", ")", "elif", "op", "is", "operat...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
should_series_dispatch
Identify cases where a DataFrame operation should dispatch to its Series counterpart. Parameters ---------- left : DataFrame right : DataFrame op : binary operator Returns ------- override : bool
pandas/core/ops.py
def should_series_dispatch(left, right, op): """ Identify cases where a DataFrame operation should dispatch to its Series counterpart. Parameters ---------- left : DataFrame right : DataFrame op : binary operator Returns ------- override : bool """ if left._is_mixed...
def should_series_dispatch(left, right, op): """ Identify cases where a DataFrame operation should dispatch to its Series counterpart. Parameters ---------- left : DataFrame right : DataFrame op : binary operator Returns ------- override : bool """ if left._is_mixed...
[ "Identify", "cases", "where", "a", "DataFrame", "operation", "should", "dispatch", "to", "its", "Series", "counterpart", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1248-L1282
[ "def", "should_series_dispatch", "(", "left", ",", "right", ",", "op", ")", ":", "if", "left", ".", "_is_mixed_type", "or", "right", ".", "_is_mixed_type", ":", "return", "True", "if", "not", "len", "(", "left", ".", "columns", ")", "or", "not", "len", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
dispatch_to_series
Evaluate the frame operation func(left, right) by evaluating column-by-column, dispatching to the Series implementation. Parameters ---------- left : DataFrame right : scalar or DataFrame func : arithmetic or comparison operator str_rep : str or None, default None axis : {None, 0, 1, "i...
pandas/core/ops.py
def dispatch_to_series(left, right, func, str_rep=None, axis=None): """ Evaluate the frame operation func(left, right) by evaluating column-by-column, dispatching to the Series implementation. Parameters ---------- left : DataFrame right : scalar or DataFrame func : arithmetic or compar...
def dispatch_to_series(left, right, func, str_rep=None, axis=None): """ Evaluate the frame operation func(left, right) by evaluating column-by-column, dispatching to the Series implementation. Parameters ---------- left : DataFrame right : scalar or DataFrame func : arithmetic or compar...
[ "Evaluate", "the", "frame", "operation", "func", "(", "left", "right", ")", "by", "evaluating", "column", "-", "by", "-", "column", "dispatching", "to", "the", "Series", "implementation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1285-L1346
[ "def", "dispatch_to_series", "(", "left", ",", "right", ",", "func", ",", "str_rep", "=", "None", ",", "axis", "=", "None", ")", ":", "# Note: we use iloc to access columns for compat with cases", "# with non-unique columns.", "import", "pandas", ".", "core", "....
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
dispatch_to_index_op
Wrap Series left in the given index_class to delegate the operation op to the index implementation. DatetimeIndex and TimedeltaIndex perform type checking, timezone handling, overflow checks, etc. Parameters ---------- op : binary operator (operator.add, operator.sub, ...) left : Series ri...
pandas/core/ops.py
def dispatch_to_index_op(op, left, right, index_class): """ Wrap Series left in the given index_class to delegate the operation op to the index implementation. DatetimeIndex and TimedeltaIndex perform type checking, timezone handling, overflow checks, etc. Parameters ---------- op : binary...
def dispatch_to_index_op(op, left, right, index_class): """ Wrap Series left in the given index_class to delegate the operation op to the index implementation. DatetimeIndex and TimedeltaIndex perform type checking, timezone handling, overflow checks, etc. Parameters ---------- op : binary...
[ "Wrap", "Series", "left", "in", "the", "given", "index_class", "to", "delegate", "the", "operation", "op", "to", "the", "index", "implementation", ".", "DatetimeIndex", "and", "TimedeltaIndex", "perform", "type", "checking", "timezone", "handling", "overflow", "ch...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1349-L1380
[ "def", "dispatch_to_index_op", "(", "op", ",", "left", ",", "right", ",", "index_class", ")", ":", "left_idx", "=", "index_class", "(", "left", ")", "# avoid accidentally allowing integer add/sub. For datetime64[tz] dtypes,", "# left_idx may inherit a freq from a cached Dateti...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
dispatch_to_extension_op
Assume that left or right is a Series backed by an ExtensionArray, apply the operator defined by op.
pandas/core/ops.py
def dispatch_to_extension_op(op, left, right): """ Assume that left or right is a Series backed by an ExtensionArray, apply the operator defined by op. """ # The op calls will raise TypeError if the op is not defined # on the ExtensionArray # unbox Series and Index to arrays if isinsta...
def dispatch_to_extension_op(op, left, right): """ Assume that left or right is a Series backed by an ExtensionArray, apply the operator defined by op. """ # The op calls will raise TypeError if the op is not defined # on the ExtensionArray # unbox Series and Index to arrays if isinsta...
[ "Assume", "that", "left", "or", "right", "is", "a", "Series", "backed", "by", "an", "ExtensionArray", "apply", "the", "operator", "defined", "by", "op", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1383-L1410
[ "def", "dispatch_to_extension_op", "(", "op", ",", "left", ",", "right", ")", ":", "# The op calls will raise TypeError if the op is not defined", "# on the ExtensionArray", "# unbox Series and Index to arrays", "if", "isinstance", "(", "left", ",", "(", "ABCSeries", ",", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_method_wrappers
Find the appropriate operation-wrappers to use when defining flex/special arithmetic, boolean, and comparison operations with the given class. Parameters ---------- cls : class Returns ------- arith_flex : function or None comp_flex : function or None arith_special : function c...
pandas/core/ops.py
def _get_method_wrappers(cls): """ Find the appropriate operation-wrappers to use when defining flex/special arithmetic, boolean, and comparison operations with the given class. Parameters ---------- cls : class Returns ------- arith_flex : function or None comp_flex : function...
def _get_method_wrappers(cls): """ Find the appropriate operation-wrappers to use when defining flex/special arithmetic, boolean, and comparison operations with the given class. Parameters ---------- cls : class Returns ------- arith_flex : function or None comp_flex : function...
[ "Find", "the", "appropriate", "operation", "-", "wrappers", "to", "use", "when", "defining", "flex", "/", "special", "arithmetic", "boolean", "and", "comparison", "operations", "with", "the", "given", "class", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1417-L1473
[ "def", "_get_method_wrappers", "(", "cls", ")", ":", "if", "issubclass", "(", "cls", ",", "ABCSparseSeries", ")", ":", "# Be sure to catch this before ABCSeries and ABCSparseArray,", "# as they will both come see SparseSeries as a subclass", "arith_flex", "=", "_flex_method_SERIE...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
add_special_arithmetic_methods
Adds the full suite of special arithmetic methods (``__add__``, ``__sub__``, etc.) to the class. Parameters ---------- cls : class special methods will be defined and pinned to this class
pandas/core/ops.py
def add_special_arithmetic_methods(cls): """ Adds the full suite of special arithmetic methods (``__add__``, ``__sub__``, etc.) to the class. Parameters ---------- cls : class special methods will be defined and pinned to this class """ _, _, arith_method, comp_method, bool_meth...
def add_special_arithmetic_methods(cls): """ Adds the full suite of special arithmetic methods (``__add__``, ``__sub__``, etc.) to the class. Parameters ---------- cls : class special methods will be defined and pinned to this class """ _, _, arith_method, comp_method, bool_meth...
[ "Adds", "the", "full", "suite", "of", "special", "arithmetic", "methods", "(", "__add__", "__sub__", "etc", ".", ")", "to", "the", "class", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1551-L1599
[ "def", "add_special_arithmetic_methods", "(", "cls", ")", ":", "_", ",", "_", ",", "arith_method", ",", "comp_method", ",", "bool_method", "=", "_get_method_wrappers", "(", "cls", ")", "new_methods", "=", "_create_methods", "(", "cls", ",", "arith_method", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
add_flex_arithmetic_methods
Adds the full suite of flex arithmetic methods (``pow``, ``mul``, ``add``) to the class. Parameters ---------- cls : class flex methods will be defined and pinned to this class
pandas/core/ops.py
def add_flex_arithmetic_methods(cls): """ Adds the full suite of flex arithmetic methods (``pow``, ``mul``, ``add``) to the class. Parameters ---------- cls : class flex methods will be defined and pinned to this class """ flex_arith_method, flex_comp_method, _, _, _ = _get_meth...
def add_flex_arithmetic_methods(cls): """ Adds the full suite of flex arithmetic methods (``pow``, ``mul``, ``add``) to the class. Parameters ---------- cls : class flex methods will be defined and pinned to this class """ flex_arith_method, flex_comp_method, _, _, _ = _get_meth...
[ "Adds", "the", "full", "suite", "of", "flex", "arithmetic", "methods", "(", "pow", "mul", "add", ")", "to", "the", "class", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1602-L1622
[ "def", "add_flex_arithmetic_methods", "(", "cls", ")", ":", "flex_arith_method", ",", "flex_comp_method", ",", "_", ",", "_", ",", "_", "=", "_get_method_wrappers", "(", "cls", ")", "new_methods", "=", "_create_methods", "(", "cls", ",", "flex_arith_method", ","...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_align_method_SERIES
align lhs and rhs Series
pandas/core/ops.py
def _align_method_SERIES(left, right, align_asobject=False): """ align lhs and rhs Series """ # ToDo: Different from _align_method_FRAME, list, tuple and ndarray # are not coerced here # because Series has inconsistencies described in #13637 if isinstance(right, ABCSeries): # avoid repeate...
def _align_method_SERIES(left, right, align_asobject=False): """ align lhs and rhs Series """ # ToDo: Different from _align_method_FRAME, list, tuple and ndarray # are not coerced here # because Series has inconsistencies described in #13637 if isinstance(right, ABCSeries): # avoid repeate...
[ "align", "lhs", "and", "rhs", "Series" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1628-L1646
[ "def", "_align_method_SERIES", "(", "left", ",", "right", ",", "align_asobject", "=", "False", ")", ":", "# ToDo: Different from _align_method_FRAME, list, tuple and ndarray", "# are not coerced here", "# because Series has inconsistencies described in #13637", "if", "isinstance", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_construct_result
If the raw op result has a non-None name (e.g. it is an Index object) and the name argument is None, then passing name to the constructor will not be enough; we still need to override the name attribute.
pandas/core/ops.py
def _construct_result(left, result, index, name, dtype=None): """ If the raw op result has a non-None name (e.g. it is an Index object) and the name argument is None, then passing name to the constructor will not be enough; we still need to override the name attribute. """ out = left._constructo...
def _construct_result(left, result, index, name, dtype=None): """ If the raw op result has a non-None name (e.g. it is an Index object) and the name argument is None, then passing name to the constructor will not be enough; we still need to override the name attribute. """ out = left._constructo...
[ "If", "the", "raw", "op", "result", "has", "a", "non", "-", "None", "name", "(", "e", ".", "g", ".", "it", "is", "an", "Index", "object", ")", "and", "the", "name", "argument", "is", "None", "then", "passing", "name", "to", "the", "constructor", "w...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1649-L1658
[ "def", "_construct_result", "(", "left", ",", "result", ",", "index", ",", "name", ",", "dtype", "=", "None", ")", ":", "out", "=", "left", ".", "_constructor", "(", "result", ",", "index", "=", "index", ",", "dtype", "=", "dtype", ")", "out", "=", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_construct_divmod_result
divmod returns a tuple of like indexed series instead of a single series.
pandas/core/ops.py
def _construct_divmod_result(left, result, index, name, dtype=None): """divmod returns a tuple of like indexed series instead of a single series. """ return ( _construct_result(left, result[0], index=index, name=name, dtype=dtype), _construct_result(left, result[1],...
def _construct_divmod_result(left, result, index, name, dtype=None): """divmod returns a tuple of like indexed series instead of a single series. """ return ( _construct_result(left, result[0], index=index, name=name, dtype=dtype), _construct_result(left, result[1],...
[ "divmod", "returns", "a", "tuple", "of", "like", "indexed", "series", "instead", "of", "a", "single", "series", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1661-L1669
[ "def", "_construct_divmod_result", "(", "left", ",", "result", ",", "index", ",", "name", ",", "dtype", "=", "None", ")", ":", "return", "(", "_construct_result", "(", "left", ",", "result", "[", "0", "]", ",", "index", "=", "index", ",", "name", "=", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_arith_method_SERIES
Wrapper function for Series arithmetic operations, to avoid code duplication.
pandas/core/ops.py
def _arith_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ str_rep = _get_opstr(op, cls) op_name = _get_op_name(op, special) eval_kwargs = _gen_eval_kwargs(op_name) fill_zeros = _gen_fill_zeros(op_name) construct_...
def _arith_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ str_rep = _get_opstr(op, cls) op_name = _get_op_name(op, special) eval_kwargs = _gen_eval_kwargs(op_name) fill_zeros = _gen_fill_zeros(op_name) construct_...
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1672-L1770
[ "def", "_arith_method_SERIES", "(", "cls", ",", "op", ",", "special", ")", ":", "str_rep", "=", "_get_opstr", "(", "op", ",", "cls", ")", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "eval_kwargs", "=", "_gen_eval_kwargs", "(", "op_name"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_comp_method_SERIES
Wrapper function for Series arithmetic operations, to avoid code duplication.
pandas/core/ops.py
def _comp_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) masker = _gen_eval_kwargs(op_name).get('masker', False) def na_op(x, y): # TODO: # should have guarantess on w...
def _comp_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) masker = _gen_eval_kwargs(op_name).get('masker', False) def na_op(x, y): # TODO: # should have guarantess on w...
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1789-L1959
[ "def", "_comp_method_SERIES", "(", "cls", ",", "op", ",", "special", ")", ":", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "masker", "=", "_gen_eval_kwargs", "(", "op_name", ")", ".", "get", "(", "'masker'", ",", "False", ")", "def", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_bool_method_SERIES
Wrapper function for Series arithmetic operations, to avoid code duplication.
pandas/core/ops.py
def _bool_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def na_op(x, y): try: result = op(x, y) except TypeError: assert not isinstance(y, (list, ...
def _bool_method_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def na_op(x, y): try: result = op(x, y) except TypeError: assert not isinstance(y, (list, ...
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1962-L2039
[ "def", "_bool_method_SERIES", "(", "cls", ",", "op", ",", "special", ")", ":", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "def", "na_op", "(", "x", ",", "y", ")", ":", "try", ":", "result", "=", "op", "(", "x", ",", "y", ")",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_combine_series_frame
Apply binary operator `func` to self, other using alignment and fill conventions determined by the fill_value, axis, and level kwargs. Parameters ---------- self : DataFrame other : Series func : binary operator fill_value : object, default None axis : {0, 1, 'columns', 'index', None}, ...
pandas/core/ops.py
def _combine_series_frame(self, other, func, fill_value=None, axis=None, level=None): """ Apply binary operator `func` to self, other using alignment and fill conventions determined by the fill_value, axis, and level kwargs. Parameters ---------- self : DataFrame o...
def _combine_series_frame(self, other, func, fill_value=None, axis=None, level=None): """ Apply binary operator `func` to self, other using alignment and fill conventions determined by the fill_value, axis, and level kwargs. Parameters ---------- self : DataFrame o...
[ "Apply", "binary", "operator", "func", "to", "self", "other", "using", "alignment", "and", "fill", "conventions", "determined", "by", "the", "fill_value", "axis", "and", "level", "kwargs", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2073-L2112
[ "def", "_combine_series_frame", "(", "self", ",", "other", ",", "func", ",", "fill_value", "=", "None", ",", "axis", "=", "None", ",", "level", "=", "None", ")", ":", "if", "fill_value", "is", "not", "None", ":", "raise", "NotImplementedError", "(", "\"f...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_align_method_FRAME
convert rhs to meet lhs dims if input is list, tuple or np.ndarray
pandas/core/ops.py
def _align_method_FRAME(left, right, axis): """ convert rhs to meet lhs dims if input is list, tuple or np.ndarray """ def to_series(right): msg = ('Unable to coerce to Series, length must be {req_len}: ' 'given {given_len}') if axis is not None and left._get_axis_name(axis) == '...
def _align_method_FRAME(left, right, axis): """ convert rhs to meet lhs dims if input is list, tuple or np.ndarray """ def to_series(right): msg = ('Unable to coerce to Series, length must be {req_len}: ' 'given {given_len}') if axis is not None and left._get_axis_name(axis) == '...
[ "convert", "rhs", "to", "meet", "lhs", "dims", "if", "input", "is", "list", "tuple", "or", "np", ".", "ndarray" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2115-L2169
[ "def", "_align_method_FRAME", "(", "left", ",", "right", ",", "axis", ")", ":", "def", "to_series", "(", "right", ")", ":", "msg", "=", "(", "'Unable to coerce to Series, length must be {req_len}: '", "'given {given_len}'", ")", "if", "axis", "is", "not", "None", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_cast_sparse_series_op
For SparseSeries operation, coerce to float64 if the result is expected to have NaN or inf values Parameters ---------- left : SparseArray right : SparseArray opname : str Returns ------- left : SparseArray right : SparseArray
pandas/core/ops.py
def _cast_sparse_series_op(left, right, opname): """ For SparseSeries operation, coerce to float64 if the result is expected to have NaN or inf values Parameters ---------- left : SparseArray right : SparseArray opname : str Returns ------- left : SparseArray right : Sp...
def _cast_sparse_series_op(left, right, opname): """ For SparseSeries operation, coerce to float64 if the result is expected to have NaN or inf values Parameters ---------- left : SparseArray right : SparseArray opname : str Returns ------- left : SparseArray right : Sp...
[ "For", "SparseSeries", "operation", "coerce", "to", "float64", "if", "the", "result", "is", "expected", "to", "have", "NaN", "or", "inf", "values" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2389-L2419
[ "def", "_cast_sparse_series_op", "(", "left", ",", "right", ",", "opname", ")", ":", "from", "pandas", ".", "core", ".", "sparse", ".", "api", "import", "SparseDtype", "opname", "=", "opname", ".", "strip", "(", "'_'", ")", "# TODO: This should be moved to the...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_arith_method_SPARSE_SERIES
Wrapper function for Series arithmetic operations, to avoid code duplication.
pandas/core/ops.py
def _arith_method_SPARSE_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def wrapper(self, other): if isinstance(other, ABCDataFrame): return NotImplemented elif isins...
def _arith_method_SPARSE_SERIES(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def wrapper(self, other): if isinstance(other, ABCDataFrame): return NotImplemented elif isins...
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2422-L2447
[ "def", "_arith_method_SPARSE_SERIES", "(", "cls", ",", "op", ",", "special", ")", ":", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "def", "wrapper", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "ABCDataF...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_arith_method_SPARSE_ARRAY
Wrapper function for Series arithmetic operations, to avoid code duplication.
pandas/core/ops.py
def _arith_method_SPARSE_ARRAY(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def wrapper(self, other): from pandas.core.arrays.sparse.array import ( SparseArray, _sparse_array_op, ...
def _arith_method_SPARSE_ARRAY(cls, op, special): """ Wrapper function for Series arithmetic operations, to avoid code duplication. """ op_name = _get_op_name(op, special) def wrapper(self, other): from pandas.core.arrays.sparse.array import ( SparseArray, _sparse_array_op, ...
[ "Wrapper", "function", "for", "Series", "arithmetic", "operations", "to", "avoid", "code", "duplication", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2461-L2491
[ "def", "_arith_method_SPARSE_ARRAY", "(", "cls", ",", "op", ",", "special", ")", ":", "op_name", "=", "_get_op_name", "(", "op", ",", "special", ")", "def", "wrapper", "(", "self", ",", "other", ")", ":", "from", "pandas", ".", "core", ".", "arrays", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_periods
If a `periods` argument is passed to the Datetime/Timedelta Array/Index constructor, cast it to an integer. Parameters ---------- periods : None, float, int Returns ------- periods : None or int Raises ------ TypeError if periods is None, float, or int
pandas/core/arrays/datetimelike.py
def validate_periods(periods): """ If a `periods` argument is passed to the Datetime/Timedelta Array/Index constructor, cast it to an integer. Parameters ---------- periods : None, float, int Returns ------- periods : None or int Raises ------ TypeError if peri...
def validate_periods(periods): """ If a `periods` argument is passed to the Datetime/Timedelta Array/Index constructor, cast it to an integer. Parameters ---------- periods : None, float, int Returns ------- periods : None or int Raises ------ TypeError if peri...
[ "If", "a", "periods", "argument", "is", "passed", "to", "the", "Datetime", "/", "Timedelta", "Array", "/", "Index", "constructor", "cast", "it", "to", "an", "integer", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1441-L1465
[ "def", "validate_periods", "(", "periods", ")", ":", "if", "periods", "is", "not", "None", ":", "if", "lib", ".", "is_float", "(", "periods", ")", ":", "periods", "=", "int", "(", "periods", ")", "elif", "not", "lib", ".", "is_integer", "(", "periods",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_endpoints
Check that the `closed` argument is among [None, "left", "right"] Parameters ---------- closed : {None, "left", "right"} Returns ------- left_closed : bool right_closed : bool Raises ------ ValueError : if argument is not among valid values
pandas/core/arrays/datetimelike.py
def validate_endpoints(closed): """ Check that the `closed` argument is among [None, "left", "right"] Parameters ---------- closed : {None, "left", "right"} Returns ------- left_closed : bool right_closed : bool Raises ------ ValueError : if argument is not among valid...
def validate_endpoints(closed): """ Check that the `closed` argument is among [None, "left", "right"] Parameters ---------- closed : {None, "left", "right"} Returns ------- left_closed : bool right_closed : bool Raises ------ ValueError : if argument is not among valid...
[ "Check", "that", "the", "closed", "argument", "is", "among", "[", "None", "left", "right", "]" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1468-L1498
[ "def", "validate_endpoints", "(", "closed", ")", ":", "left_closed", "=", "False", "right_closed", "=", "False", "if", "closed", "is", "None", ":", "left_closed", "=", "True", "right_closed", "=", "True", "elif", "closed", "==", "\"left\"", ":", "left_closed",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
validate_inferred_freq
If the user passes a freq and another freq is inferred from passed data, require that they match. Parameters ---------- freq : DateOffset or None inferred_freq : DateOffset or None freq_infer : bool Returns ------- freq : DateOffset or None freq_infer : bool Notes ----...
pandas/core/arrays/datetimelike.py
def validate_inferred_freq(freq, inferred_freq, freq_infer): """ If the user passes a freq and another freq is inferred from passed data, require that they match. Parameters ---------- freq : DateOffset or None inferred_freq : DateOffset or None freq_infer : bool Returns ------...
def validate_inferred_freq(freq, inferred_freq, freq_infer): """ If the user passes a freq and another freq is inferred from passed data, require that they match. Parameters ---------- freq : DateOffset or None inferred_freq : DateOffset or None freq_infer : bool Returns ------...
[ "If", "the", "user", "passes", "a", "freq", "and", "another", "freq", "is", "inferred", "from", "passed", "data", "require", "that", "they", "match", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1501-L1533
[ "def", "validate_inferred_freq", "(", "freq", ",", "inferred_freq", ",", "freq_infer", ")", ":", "if", "inferred_freq", "is", "not", "None", ":", "if", "freq", "is", "not", "None", "and", "freq", "!=", "inferred_freq", ":", "raise", "ValueError", "(", "'Infe...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
maybe_infer_freq
Comparing a DateOffset to the string "infer" raises, so we need to be careful about comparisons. Make a dummy variable `freq_infer` to signify the case where the given freq is "infer" and set freq to None to avoid comparison trouble later on. Parameters ---------- freq : {DateOffset, None, str...
pandas/core/arrays/datetimelike.py
def maybe_infer_freq(freq): """ Comparing a DateOffset to the string "infer" raises, so we need to be careful about comparisons. Make a dummy variable `freq_infer` to signify the case where the given freq is "infer" and set freq to None to avoid comparison trouble later on. Parameters ----...
def maybe_infer_freq(freq): """ Comparing a DateOffset to the string "infer" raises, so we need to be careful about comparisons. Make a dummy variable `freq_infer` to signify the case where the given freq is "infer" and set freq to None to avoid comparison trouble later on. Parameters ----...
[ "Comparing", "a", "DateOffset", "to", "the", "string", "infer", "raises", "so", "we", "need", "to", "be", "careful", "about", "comparisons", ".", "Make", "a", "dummy", "variable", "freq_infer", "to", "signify", "the", "case", "where", "the", "given", "freq",...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1536-L1560
[ "def", "maybe_infer_freq", "(", "freq", ")", ":", "freq_infer", "=", "False", "if", "not", "isinstance", "(", "freq", ",", "DateOffset", ")", ":", "# if a passed freq is None, don't infer automatically", "if", "freq", "!=", "'infer'", ":", "freq", "=", "frequencie...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_ensure_datetimelike_to_i8
Helper for coercing an input scalar or array to i8. Parameters ---------- other : 1d array to_utc : bool, default False If True, convert the values to UTC before extracting the i8 values If False, extract the i8 values directly. Returns ------- i8 1d array
pandas/core/arrays/datetimelike.py
def _ensure_datetimelike_to_i8(other, to_utc=False): """ Helper for coercing an input scalar or array to i8. Parameters ---------- other : 1d array to_utc : bool, default False If True, convert the values to UTC before extracting the i8 values If False, extract the i8 values dir...
def _ensure_datetimelike_to_i8(other, to_utc=False): """ Helper for coercing an input scalar or array to i8. Parameters ---------- other : 1d array to_utc : bool, default False If True, convert the values to UTC before extracting the i8 values If False, extract the i8 values dir...
[ "Helper", "for", "coercing", "an", "input", "scalar", "or", "array", "to", "i8", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1563-L1597
[ "def", "_ensure_datetimelike_to_i8", "(", "other", ",", "to_utc", "=", "False", ")", ":", "from", "pandas", "import", "Index", "from", "pandas", ".", "core", ".", "arrays", "import", "PeriodArray", "if", "lib", ".", "is_scalar", "(", "other", ")", "and", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
AttributesMixin._scalar_from_string
Construct a scalar type from a string. Parameters ---------- value : str Returns ------- Period, Timestamp, or Timedelta, or NaT Whatever the type of ``self._scalar_type`` is. Notes ----- This should call ``self._check_compatible_wit...
pandas/core/arrays/datetimelike.py
def _scalar_from_string( self, value: str, ) -> Union[Period, Timestamp, Timedelta, NaTType]: """ Construct a scalar type from a string. Parameters ---------- value : str Returns ------- Period, Timestamp, or Timedelta, or NaT...
def _scalar_from_string( self, value: str, ) -> Union[Period, Timestamp, Timedelta, NaTType]: """ Construct a scalar type from a string. Parameters ---------- value : str Returns ------- Period, Timestamp, or Timedelta, or NaT...
[ "Construct", "a", "scalar", "type", "from", "a", "string", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L68-L89
[ "def", "_scalar_from_string", "(", "self", ",", "value", ":", "str", ",", ")", "->", "Union", "[", "Period", ",", "Timestamp", ",", "Timedelta", ",", "NaTType", "]", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
AttributesMixin._unbox_scalar
Unbox the integer value of a scalar `value`. Parameters ---------- value : Union[Period, Timestamp, Timedelta] Returns ------- int Examples -------- >>> self._unbox_scalar(Timedelta('10s')) # DOCTEST: +SKIP 10000000000
pandas/core/arrays/datetimelike.py
def _unbox_scalar( self, value: Union[Period, Timestamp, Timedelta, NaTType], ) -> int: """ Unbox the integer value of a scalar `value`. Parameters ---------- value : Union[Period, Timestamp, Timedelta] Returns ------- int ...
def _unbox_scalar( self, value: Union[Period, Timestamp, Timedelta, NaTType], ) -> int: """ Unbox the integer value of a scalar `value`. Parameters ---------- value : Union[Period, Timestamp, Timedelta] Returns ------- int ...
[ "Unbox", "the", "integer", "value", "of", "a", "scalar", "value", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L91-L111
[ "def", "_unbox_scalar", "(", "self", ",", "value", ":", "Union", "[", "Period", ",", "Timestamp", ",", "Timedelta", ",", "NaTType", "]", ",", ")", "->", "int", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
AttributesMixin._check_compatible_with
Verify that `self` and `other` are compatible. * DatetimeArray verifies that the timezones (if any) match * PeriodArray verifies that the freq matches * Timedelta has no verification In each case, NaT is considered compatible. Parameters ---------- other ...
pandas/core/arrays/datetimelike.py
def _check_compatible_with( self, other: Union[Period, Timestamp, Timedelta, NaTType], ) -> None: """ Verify that `self` and `other` are compatible. * DatetimeArray verifies that the timezones (if any) match * PeriodArray verifies that the freq matches ...
def _check_compatible_with( self, other: Union[Period, Timestamp, Timedelta, NaTType], ) -> None: """ Verify that `self` and `other` are compatible. * DatetimeArray verifies that the timezones (if any) match * PeriodArray verifies that the freq matches ...
[ "Verify", "that", "self", "and", "other", "are", "compatible", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L113-L134
[ "def", "_check_compatible_with", "(", "self", ",", "other", ":", "Union", "[", "Period", ",", "Timestamp", ",", "Timedelta", ",", "NaTType", "]", ",", ")", "->", "None", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatelikeOps.strftime
Convert to Index using specified date_format. Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in `python string format doc <%(URL)s>`__. Parameters ...
pandas/core/arrays/datetimelike.py
def strftime(self, date_format): """ Convert to Index using specified date_format. Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in `python string for...
def strftime(self, date_format): """ Convert to Index using specified date_format. Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in `python string for...
[ "Convert", "to", "Index", "using", "specified", "date_format", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L144-L180
[ "def", "strftime", "(", "self", ",", "date_format", ")", ":", "from", "pandas", "import", "Index", "return", "Index", "(", "self", ".", "_format_native_types", "(", "date_format", "=", "date_format", ")", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DatetimeLikeArrayMixin.searchsorted
Find indices where elements should be inserted to maintain order. Find the indices into a sorted array `self` such that, if the corresponding elements in `value` were inserted before the indices, the order of `self` would be preserved. Parameters ---------- value : arra...
pandas/core/arrays/datetimelike.py
def searchsorted(self, value, side='left', sorter=None): """ Find indices where elements should be inserted to maintain order. Find the indices into a sorted array `self` such that, if the corresponding elements in `value` were inserted before the indices, the order of `self` wo...
def searchsorted(self, value, side='left', sorter=None): """ Find indices where elements should be inserted to maintain order. Find the indices into a sorted array `self` such that, if the corresponding elements in `value` were inserted before the indices, the order of `self` wo...
[ "Find", "indices", "where", "elements", "should", "be", "inserted", "to", "maintain", "order", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L627-L666
[ "def", "searchsorted", "(", "self", ",", "value", ",", "side", "=", "'left'", ",", "sorter", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=", "self", ".", "_scalar_from_string", "(", "value", ")", "if", "no...
9feb3ad92cc0397a04b665803a49299ee7aa1037