id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
19,900
pandas-dev/pandas
pandas/io/parsers.py
_validate_names
def _validate_names(names): """ Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ---...
python
def _validate_names(names): """ Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ---...
[ "def", "_validate_names", "(", "names", ")", ":", "if", "names", "is", "not", "None", ":", "if", "len", "(", "names", ")", "!=", "len", "(", "set", "(", "names", ")", ")", ":", "msg", "=", "(", "\"Duplicate names specified. This \"", "\"will raise an error...
Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ------- names : array-like or None ...
[ "Check", "if", "the", "names", "parameter", "contains", "duplicates", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L379-L402
19,901
pandas-dev/pandas
pandas/io/parsers.py
_read
def _read(filepath_or_buffer: FilePathOrBuffer, kwds): """Generic reader of line files.""" encoding = kwds.get('encoding', None) if encoding is not None: encoding = re.sub('_', '-', encoding).lower() kwds['encoding'] = encoding compression = kwds.get('compression', 'infer') compress...
python
def _read(filepath_or_buffer: FilePathOrBuffer, kwds): """Generic reader of line files.""" encoding = kwds.get('encoding', None) if encoding is not None: encoding = re.sub('_', '-', encoding).lower() kwds['encoding'] = encoding compression = kwds.get('compression', 'infer') compress...
[ "def", "_read", "(", "filepath_or_buffer", ":", "FilePathOrBuffer", ",", "kwds", ")", ":", "encoding", "=", "kwds", ".", "get", "(", "'encoding'", ",", "None", ")", "if", "encoding", "is", "not", "None", ":", "encoding", "=", "re", ".", "sub", "(", "'_...
Generic reader of line files.
[ "Generic", "reader", "of", "line", "files", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L405-L452
19,902
pandas-dev/pandas
pandas/io/parsers.py
read_fwf
def read_fwf(filepath_or_buffer: FilePathOrBuffer, colspecs='infer', widths=None, infer_nrows=100, **kwds): r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. ...
python
def read_fwf(filepath_or_buffer: FilePathOrBuffer, colspecs='infer', widths=None, infer_nrows=100, **kwds): r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. ...
[ "def", "read_fwf", "(", "filepath_or_buffer", ":", "FilePathOrBuffer", ",", "colspecs", "=", "'infer'", ",", "widths", "=", "None", ",", "infer_nrows", "=", "100", ",", "*", "*", "kwds", ")", ":", "# Check input arguments.", "if", "colspecs", "is", "None", "...
r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. Additional help can be found in the `online docs for IO Tools <http://pandas.pydata.org/pandas-docs/stable/io.html>`_. Parameters ---------- filepat...
[ "r", "Read", "a", "table", "of", "fixed", "-", "width", "formatted", "lines", "into", "DataFrame", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L735-L813
19,903
pandas-dev/pandas
pandas/io/parsers.py
_is_potential_multi_index
def _is_potential_multi_index(columns): """ Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not co...
python
def _is_potential_multi_index(columns): """ Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not co...
[ "def", "_is_potential_multi_index", "(", "columns", ")", ":", "return", "(", "len", "(", "columns", ")", "and", "not", "isinstance", "(", "columns", ",", "MultiIndex", ")", "and", "all", "(", "isinstance", "(", "c", ",", "tuple", ")", "for", "c", "in", ...
Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not columns could become a MultiIndex
[ "Check", "whether", "or", "not", "the", "columns", "parameter", "could", "be", "converted", "into", "a", "MultiIndex", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1190-L1205
19,904
pandas-dev/pandas
pandas/io/parsers.py
_evaluate_usecols
def _evaluate_usecols(usecols, names): """ Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'. """ if callable(usecols): ...
python
def _evaluate_usecols(usecols, names): """ Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'. """ if callable(usecols): ...
[ "def", "_evaluate_usecols", "(", "usecols", ",", "names", ")", ":", "if", "callable", "(", "usecols", ")", ":", "return", "{", "i", "for", "i", ",", "name", "in", "enumerate", "(", "names", ")", "if", "usecols", "(", "name", ")", "}", "return", "usec...
Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'.
[ "Check", "whether", "or", "not", "the", "usecols", "parameter", "is", "a", "callable", ".", "If", "so", "enumerates", "the", "names", "parameter", "and", "returns", "a", "set", "of", "indices", "for", "each", "entry", "in", "names", "that", "evaluates", "t...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1208-L1218
19,905
pandas-dev/pandas
pandas/io/parsers.py
_validate_usecols_names
def _validate_usecols_names(usecols, names): """ Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. nam...
python
def _validate_usecols_names(usecols, names): """ Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. nam...
[ "def", "_validate_usecols_names", "(", "usecols", ",", "names", ")", ":", "missing", "=", "[", "c", "for", "c", "in", "usecols", "if", "c", "not", "in", "names", "]", "if", "len", "(", "missing", ")", ">", "0", ":", "raise", "ValueError", "(", "\"Use...
Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. names : iterable of names The column names to check ...
[ "Validates", "that", "all", "usecols", "are", "present", "in", "a", "given", "list", "of", "names", ".", "If", "not", "raise", "a", "ValueError", "that", "shows", "what", "usecols", "are", "missing", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1221-L1250
19,906
pandas-dev/pandas
pandas/io/parsers.py
_validate_usecols_arg
def _validate_usecols_arg(usecols): """ Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- useco...
python
def _validate_usecols_arg(usecols): """ Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- useco...
[ "def", "_validate_usecols_arg", "(", "usecols", ")", ":", "msg", "=", "(", "\"'usecols' must either be list-like of all strings, all unicode, \"", "\"all integers or a callable.\"", ")", "if", "usecols", "is", "not", "None", ":", "if", "callable", "(", "usecols", ")", "...
Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- usecols : list-like, callable, or None List o...
[ "Validate", "the", "usecols", "parameter", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1284-L1330
19,907
pandas-dev/pandas
pandas/io/parsers.py
_validate_parse_dates_arg
def _validate_parse_dates_arg(parse_dates): """ Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case. """ msg = ("Only booleans, lists, and " "dictionaries are accepted " "for the 'parse_dates' parameter") if...
python
def _validate_parse_dates_arg(parse_dates): """ Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case. """ msg = ("Only booleans, lists, and " "dictionaries are accepted " "for the 'parse_dates' parameter") if...
[ "def", "_validate_parse_dates_arg", "(", "parse_dates", ")", ":", "msg", "=", "(", "\"Only booleans, lists, and \"", "\"dictionaries are accepted \"", "\"for the 'parse_dates' parameter\"", ")", "if", "parse_dates", "is", "not", "None", ":", "if", "is_scalar", "(", "parse...
Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case.
[ "Check", "whether", "or", "not", "the", "parse_dates", "parameter", "is", "a", "non", "-", "boolean", "scalar", ".", "Raises", "a", "ValueError", "if", "that", "is", "the", "case", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1333-L1351
19,908
pandas-dev/pandas
pandas/io/parsers.py
_stringify_na_values
def _stringify_na_values(na_values): """ return a stringified and numeric for these values """ result = [] for x in na_values: result.append(str(x)) result.append(x) try: v = float(x) # we are like 999 here if v == int(v): v = int(...
python
def _stringify_na_values(na_values): """ return a stringified and numeric for these values """ result = [] for x in na_values: result.append(str(x)) result.append(x) try: v = float(x) # we are like 999 here if v == int(v): v = int(...
[ "def", "_stringify_na_values", "(", "na_values", ")", ":", "result", "=", "[", "]", "for", "x", "in", "na_values", ":", "result", ".", "append", "(", "str", "(", "x", ")", ")", "result", ".", "append", "(", "x", ")", "try", ":", "v", "=", "float", ...
return a stringified and numeric for these values
[ "return", "a", "stringified", "and", "numeric", "for", "these", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3425-L3447
19,909
pandas-dev/pandas
pandas/io/parsers.py
_get_na_values
def _get_na_values(col, na_values, na_fvalues, keep_default_na): """ Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict ...
python
def _get_na_values(col, na_values, na_fvalues, keep_default_na): """ Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict ...
[ "def", "_get_na_values", "(", "col", ",", "na_values", ",", "na_fvalues", ",", "keep_default_na", ")", ":", "if", "isinstance", "(", "na_values", ",", "dict", ")", ":", "if", "col", "in", "na_values", ":", "return", "na_values", "[", "col", "]", ",", "na...
Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict The object listing the NaN values as floats. keep_default_na : bool ...
[ "Get", "the", "NaN", "values", "for", "a", "given", "column", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3450-L3483
19,910
pandas-dev/pandas
pandas/io/parsers.py
ParserBase._extract_multi_indexer_columns
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[...
python
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", ")", ":", "if", "len", "(", "header", ")", "<", "2", ":", "return", "header", "[", "0", "]", ",", "index_names", ...
extract and return the names, index_names, col_names header is a list-of-lists returned from the parsers
[ "extract", "and", "return", "the", "names", "index_names", "col_names", "header", "is", "a", "list", "-", "of", "-", "lists", "returned", "from", "the", "parsers" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1451-L1504
19,911
pandas-dev/pandas
pandas/io/parsers.py
ParserBase._infer_types
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...
python
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", ")", ":", "na_count", "=", "0", "if", "issubclass", "(", "values", ".", "dtype", ".", "type", ",", "(", "np", ".", "number", ",", "np", ".", "bool_...
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 ...
[ "Infer", "types", "of", "values", "possibly", "casting" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1719-L1764
19,912
pandas-dev/pandas
pandas/io/parsers.py
ParserBase._cast_types
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 ...
python
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", ")", ":", "if", "is_categorical_dtype", "(", "cast_type", ")", ":", "known_cats", "=", "(", "isinstance", "(", "cast_type", ",", "CategoricalDtype", ")", "and", "cast_type", "...
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
[ "Cast", "values", "to", "specified", "type" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1766-L1821
19,913
pandas-dev/pandas
pandas/io/parsers.py
CParserWrapper._set_noconvert_columns
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': ...
python
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", ")", ":", "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...
Set the columns that should not undergo dtype conversions. Currently, any column that is involved with date parsing will not undergo such conversions.
[ "Set", "the", "columns", "that", "should", "not", "undergo", "dtype", "conversions", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1951-L2003
19,914
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._handle_usecols
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) ...
python
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", ")", ":", "if", "self", ".", "usecols", "is", "not", "None", ":", "if", "callable", "(", "self", ".", "usecols", ")", ":", "col_indices", "=", "_evaluate_usecols", "(", "self", "....
Sets self._col_indices usecols_key is used if there are string usecols.
[ "Sets", "self", ".", "_col_indices" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2678-L2707
19,915
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._check_for_bom
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...
python
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", ")", ":", "# 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...
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.
[ "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",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2718-L2768
19,916
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._alert_malformed
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...
python
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", ")", ":", "if", "self", ".", "error_bad_lines", ":", "raise", "ParserError", "(", "msg", ")", "elif", "self", ".", "warn_bad_lines", ":", "base", "=", "'Skipping line {row_num}: '", ".", "fo...
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 ...
[ "Alert", "a", "user", "about", "a", "malformed", "row", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2837-L2856
19,917
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._remove_empty_lines
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 ------- ...
python
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", ")", ":", "ret", "=", "[", "]", "for", "l", "in", "lines", ":", "# Remove empty lines and lines with only one whitespace value", "if", "(", "len", "(", "l", ")", ">", "1", "or", "len", "(", "l", ")",...
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...
[ "Iterate", "through", "the", "lines", "and", "remove", "any", "that", "are", "either", "empty", "or", "contain", "only", "one", "whitespace", "value" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2912-L2934
19,918
pandas-dev/pandas
pandas/io/parsers.py
FixedWidthReader.get_rows
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...
python
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", ")", ":", "if", "skiprows", "is", "None", ":", "skiprows", "=", "set", "(", ")", "buffer_rows", "=", "[", "]", "detect_rows", "=", "[", "]", "for", "i", ",", "row", "...
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...
[ "Read", "rows", "from", "self", ".", "f", "skipping", "as", "specified", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3535-L3571
19,919
pandas-dev/pandas
pandas/io/msgpack/__init__.py
pack
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))
python
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", ")", ":", "packer", "=", "Packer", "(", "*", "*", "kwargs", ")", "stream", ".", "write", "(", "packer", ".", "pack", "(", "o", ")", ")" ]
Pack object `o` and write it to `stream` See :class:`Packer` for options.
[ "Pack", "object", "o", "and", "write", "it", "to", "stream" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/msgpack/__init__.py#L26-L33
19,920
pandas-dev/pandas
pandas/core/internals/concat.py
get_mgr_concatenation_plan
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...
python
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", ")", ":", "# 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"...
Construct concatenation plan for given block manager and indexers. Parameters ---------- mgr : BlockManager indexers : dict of {axis: indexer} Returns ------- plan : list of (BlockPlacement, JoinUnit) tuples
[ "Construct", "concatenation", "plan", "for", "given", "block", "manager", "and", "indexers", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L21-L98
19,921
pandas-dev/pandas
pandas/core/internals/concat.py
concatenate_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...
python
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", ")", ":", "if", "concat_axis", "==", "0", "and", "len", "(", "join_units", ")", ">", "1", ":", "# Concatenating join units along ax0 is handled in _merge_blocks.", "raise", "Assertion...
Concatenate values from several join units along selected axis.
[ "Concatenate", "values", "from", "several", "join", "units", "along", "selected", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L229-L257
19,922
pandas-dev/pandas
pandas/core/internals/concat.py
trim_join_unit
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 ...
python
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", ")", ":", "if", "0", "not", "in", "join_unit", ".", "indexers", ":", "extra_indexers", "=", "join_unit", ".", "indexers", "if", "join_unit", ".", "block", "is", "None", ":", "extra_block", "=", "Non...
Reduce join_unit's shape along item axis to length. Extra items that didn't fit are returned as a separate block.
[ "Reduce", "join_unit", "s", "shape", "along", "item", "axis", "to", "length", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L395-L421
19,923
pandas-dev/pandas
pandas/core/internals/concat.py
combine_concat_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: ...
python
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", ")", ":", "if", "len", "(", "plans", ")", "==", "1", ":", "for", "p", "in", "plans", "[", "0", "]", ":", "yield", "p", "[", "0", "]", ",", "[", "p", "[", "1", "]", "]", "elif", ...
Combine multiple concatenation plans into one. existing_plan is updated in-place.
[ "Combine", "multiple", "concatenation", "plans", "into", "one", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L424-L484
19,924
pandas-dev/pandas
pandas/plotting/_style.py
_Options.use
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
python
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", ")", ":", "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.
[ "Temporarily", "set", "a", "parameter", "value", "using", "the", "with", "statement", ".", "Aliasing", "allowed", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_style.py#L151-L161
19,925
pandas-dev/pandas
pandas/io/stata.py
_dtype_to_stata_type
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...
python
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", ")", ":", "# 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"...
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 ...
[ "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", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1832-L1866
19,926
pandas-dev/pandas
pandas/io/stata.py
_dtype_to_default_stata_fmt
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...
python
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", ")", ":", "# TODO: Refactor to combine type with format", "# TODO: expand this to handle a default datetime format?", "if", "dta_version", "<", ...
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" ...
[ "Map", "numpy", "dtype", "to", "stata", "s", "default", "format", "for", "this", "type", ".", "Not", "terribly", "important", "since", "users", "can", "change", "this", "in", "Stata", ".", "Semantics", "are" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1869-L1922
19,927
pandas-dev/pandas
pandas/io/stata.py
_pad_bytes_new
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))
python
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", ")", ":", "if", "isinstance", "(", "name", ",", "str", ")", ":", "name", "=", "bytes", "(", "name", ",", "'utf-8'", ")", "return", "name", "+", "b'\\x00'", "*", "(", "length", "-", "len", "(", "n...
Takes a bytes instance and pads it with null bytes until it's length chars.
[ "Takes", "a", "bytes", "instance", "and", "pads", "it", "with", "null", "bytes", "until", "it", "s", "length", "chars", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2477-L2483
19,928
pandas-dev/pandas
pandas/io/stata.py
StataReader._setup_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....
python
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", ")", ":", "if", "self", ".", "_dtype", "is", "not", "None", ":", "return", "self", ".", "_dtype", "dtype", "=", "[", "]", "# Convert struct data types to numpy data type", "for", "i", ",", "typ", "in", "enumerate", "(", ...
Map between numpy and state dtypes
[ "Map", "between", "numpy", "and", "state", "dtypes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1307-L1322
19,929
pandas-dev/pandas
pandas/io/stata.py
StataWriter._write
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))
python
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", ")", ":", "self", ".", "_file", ".", "write", "(", "to_write", ".", "encode", "(", "self", ".", "_encoding", "or", "self", ".", "_default_encoding", ")", ")" ]
Helper to call encode before writing to file for Python 3 compat.
[ "Helper", "to", "call", "encode", "before", "writing", "to", "file", "for", "Python", "3", "compat", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2018-L2023
19,930
pandas-dev/pandas
pandas/io/stata.py
StataWriter._prepare_categoricals
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...
python
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", ")", ":", "is_cat", "=", "[", "is_categorical_dtype", "(", "data", "[", "col", "]", ")", "for", "col", "in", "data", "]", "self", ".", "_is_col_cat", "=", "is_cat", "self", ".", "_value_labels", "...
Check for categorical columns, retain categorical information for Stata file and convert categorical data to int
[ "Check", "for", "categorical", "columns", "retain", "categorical", "information", "for", "Stata", "file", "and", "convert", "categorical", "data", "to", "int" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2025-L2061
19,931
pandas-dev/pandas
pandas/io/stata.py
StataWriter._close
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 ...
python
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", ")", ":", "# Some file-like objects might not support flush", "try", ":", "self", ".", "_file", ".", "flush", "(", ")", "except", "AttributeError", ":", "pass", "if", "self", ".", "_own_file", ":", "self", ".", "_file", ".", "cl...
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)
[ "Close", "the", "file", "if", "it", "was", "created", "by", "the", "writer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2249-L2264
19,932
pandas-dev/pandas
pandas/io/stata.py
StataStrLWriter.generate_table
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...
python
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", ")", ":", "gso_table", "=", "self", ".", "_gso_table", "gso_df", "=", "self", ".", "df", "columns", "=", "list", "(", "gso_df", ".", "columns", ")", "selected", "=", "gso_df", "[", "self", ".", "columns", "]", "col...
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...
[ "Generates", "the", "GSO", "lookup", "table", "for", "the", "DataFRame" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2546-L2596
19,933
pandas-dev/pandas
pandas/io/stata.py
StataStrLWriter.generate_blob
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...
python
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", ")", ":", "# Format information", "# Length includes null term", "# 117", "# GSOvvvvooootllllxxxxxxxxxxxxxxx...x", "# 3 u4 u4 u1 u4 string + null term", "#", "# 118, 119", "# GSOvvvvooooooootllllxxxxxxxxxxxxxxx...x", "# 3 u...
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 ...
[ "Generates", "the", "binary", "blob", "of", "GSOs", "that", "is", "written", "to", "the", "dta", "file", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2604-L2666
19,934
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._write_header
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 ...
python
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", ")", ":", "byteorder", "=", "self", ".", "_byteorder", "self", ".", "_file", ".", "write", "(", "bytes", "(", "'<stata_dta>'", ",", "'utf-8'", ")", ")", ...
Write the file header
[ "Write", "the", "file", "header" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2772-L2808
19,935
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._write_map
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), ...
python
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", ")", ":", "if", "self", ".", "_map", "is", "None", ":", "self", ".", "_map", "=", "OrderedDict", "(", "(", "(", "'stata_data'", ",", "0", ")", ",", "(", "'map'", ",", "self", ".", "_file", ".", "tell", "(", ")", ...
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.
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2810-L2835
19,936
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._update_strl_names
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: ...
python
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 convert_strl if names changed", "for", "orig", ",", "new", "in", "self", ".", "_converted_names", ".", "items", "(", ")", ":", "if", "orig", "in", "self", ".", "_convert_strl", ":", "idx", "=", "s...
Update column names for conversion to strl if they might have been changed to comply with Stata naming rules
[ "Update", "column", "names", "for", "conversion", "to", "strl", "if", "they", "might", "have", "been", "changed", "to", "comply", "with", "Stata", "naming", "rules" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2948-L2955
19,937
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._convert_strls
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...
python
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_cols", "=", "[", "col", "for", "i", ",", "col", "in", "enumerate", "(", "data", ")", "if", "self", ".", "typlist", "[", "i", "]", "==", "32768", "or", "col", "in", "self", ".", ...
Convert columns to StrLs if either very large or in the convert_strl variable
[ "Convert", "columns", "to", "StrLs", "if", "either", "very", "large", "or", "in", "the", "convert_strl", "variable" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2957-L2969
19,938
pandas-dev/pandas
pandas/plotting/_converter.py
register
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 ...
python
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", ")", ":", "# Renamed in pandas.plotting.__init__", "global", "_WARN", "if", "explicit", ":", "_WARN", "=", "False", "pairs", "=", "get_pairs", "(", ")", "for", "type_", ",", "cls", "in", "pairs", ":", "convert...
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 -----...
[ "Register", "Pandas", "Formatters", "and", "Converters", "with", "matplotlib" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L54-L84
19,939
pandas-dev/pandas
pandas/plotting/_converter.py
deregister
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...
python
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", "(", ")", ":", "# 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...
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...
[ "Remove", "pandas", "formatters", "and", "converters" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L87-L113
19,940
pandas-dev/pandas
pandas/plotting/_converter.py
_get_default_annual_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) = (...
python
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", ")", ":", "if", "nyears", "<", "11", ":", "(", "min_spacing", ",", "maj_spacing", ")", "=", "(", "1", ",", "1", ")", "elif", "nyears", "<", "20", ":", "(", "min_spacing", ",", "maj_spacing", ")", "="...
Returns a default spacing between consecutive ticks for annual data.
[ "Returns", "a", "default", "spacing", "between", "consecutive", "ticks", "for", "annual", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L537-L556
19,941
pandas-dev/pandas
pandas/plotting/_converter.py
period_break
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...
python
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", ")", ":", "current", "=", "getattr", "(", "dates", ",", "period", ")", "previous", "=", "getattr", "(", "dates", "-", "1", "*", "dates", ".", "freq", ",", "period", ")", "return", "np", ".", "nonzer...
Returns the indices where the given period changes. Parameters ---------- dates : PeriodIndex Array of intervals to monitor. period : string Name of the period to monitor.
[ "Returns", "the", "indices", "where", "the", "given", "period", "changes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L559-L572
19,942
pandas-dev/pandas
pandas/plotting/_converter.py
has_level_label
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...
python
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", ")", ":", "if", "label_flags", ".", "size", "==", "0", "or", "(", "label_flags", ".", "size", "==", "1", "and", "label_flags", "[", "0", "]", "==", "0", "and", "vmin", "%", "1", ">", "0.0", ...
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.
[ "Returns", "true", "if", "the", "label_flags", "indicate", "there", "is", "at", "least", "one", "label", "for", "this", "level", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L575-L588
19,943
pandas-dev/pandas
pandas/plotting/_converter.py
PandasAutoDateLocator.get_locator
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...
python
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", ")", ":", "_check_implicitly_registered", "(", ")", "delta", "=", "relativedelta", "(", "dmax", ",", "dmin", ")", "num_days", "=", "(", "delta", ".", "years", "*", "12.0", "+", "delta", ".", ...
Pick the best locator based on a distance.
[ "Pick", "the", "best", "locator", "based", "on", "a", "distance", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L369-L387
19,944
pandas-dev/pandas
pandas/plotting/_converter.py
MilliSecondLocator.autoscale
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...
python
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", ")", ":", "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...
Set the view limits to include the data range.
[ "Set", "the", "view", "limits", "to", "include", "the", "data", "range", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L478-L507
19,945
pandas-dev/pandas
pandas/plotting/_converter.py
TimeSeries_DateLocator._get_default_locs
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...
python
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", ")", ":", "if", "self", ".", "plot_obj", ".", "date_axis_info", "is", "None", ":", "self", ".", "plot_obj", ".", "date_axis_info", "=", "self", ".", "finder", "(", "vmin", ",", "vmax", ...
Returns the default locations of ticks.
[ "Returns", "the", "default", "locations", "of", "ticks", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1002-L1012
19,946
pandas-dev/pandas
pandas/plotting/_converter.py
TimeSeries_DateLocator.autoscale
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]] ...
python
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", ")", ":", "# requires matplotlib >= 0.98.0", "(", "vmin", ",", "vmax", ")", "=", "self", ".", "axis", ".", "get_data_interval", "(", ")", "locs", "=", "self", ".", "_get_default_locs", "(", "vmin", ",", "vmax", ")", "(", ...
Sets the view limits to the nearest multiples of base that contain the data.
[ "Sets", "the", "view", "limits", "to", "the", "nearest", "multiples", "of", "base", "that", "contain", "the", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1035-L1048
19,947
pandas-dev/pandas
pandas/plotting/_converter.py
TimeSeries_DateFormatter._set_default_format
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...
python
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", ")", ":", "if", "self", ".", "plot_obj", ".", "date_axis_info", "is", "None", ":", "self", ".", "plot_obj", ".", "date_axis_info", "=", "self", ".", "finder", "(", "vmin", ",", "vmax", ...
Returns the default ticks spacing.
[ "Returns", "the", "default", "ticks", "spacing", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1084-L1097
19,948
pandas-dev/pandas
pandas/plotting/_converter.py
TimeSeries_DateFormatter.set_locs
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()) ...
python
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", ")", ":", "# 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", ")", ...
Sets the locations of the ticks
[ "Sets", "the", "locations", "of", "the", "ticks" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1099-L1113
19,949
pandas-dev/pandas
pandas/io/json/table_schema.py
build_table_schema
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 ...
python
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", ")", ":", "if", "index", "is", "True", ":", "data", "=", "set_default_names", "(", "data", ")", "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 ...
[ "Create", "a", "Table", "schema", "from", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L183-L259
19,950
pandas-dev/pandas
pandas/io/json/table_schema.py
parse_table_schema
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 ...
python
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", ")", ":", "table", "=", "loads", "(", "json", ",", "precise_float", "=", "precise_float", ")", "col_order", "=", "[", "field", "[", "'name'", "]", "for", "field", "in", "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...
[ "Builds", "a", "DataFrame", "from", "a", "given", "schema" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L262-L326
19,951
pandas-dev/pandas
pandas/core/ops.py
get_op_result_name
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 ""...
python
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", ")", ":", "# `left` is always a pd.Series when called from within ops", "if", "isinstance", "(", "right", ",", "(", "ABCSeries", ",", "pd", ".", "Index", ")", ")", ":", "name", "=", "_maybe_match_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
[ "Find", "the", "appropriate", "name", "to", "pin", "to", "an", "operation", "result", ".", "This", "result", "should", "always", "be", "either", "an", "Index", "or", "a", "Series", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L38-L58
19,952
pandas-dev/pandas
pandas/core/ops.py
_maybe_match_name
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...
python
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", ")", ":", "a_has", "=", "hasattr", "(", "a", ",", "'name'", ")", "b_has", "=", "hasattr", "(", "b", ",", "'name'", ")", "if", "a_has", "and", "b_has", ":", "if", "a", ".", "name", "==", "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 : object b : object Returns ---...
[ "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"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L61-L93
19,953
pandas-dev/pandas
pandas/core/ops.py
maybe_upcast_for_op
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...
python
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", ")", ":", "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", ...
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...
[ "Cast", "non", "-", "pandas", "objects", "to", "pandas", "types", "to", "unify", "behavior", "of", "arithmetic", "and", "comparison", "operations", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L96-L131
19,954
pandas-dev/pandas
pandas/core/ops.py
make_invalid_op
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: " ...
python
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", ")", ":", "def", "invalid_op", "(", "self", ",", "other", "=", "None", ")", ":", "raise", "TypeError", "(", "\"cannot perform {name} with this index type: \"", "\"{typ}\"", ".", "format", "(", "name", "=", "name", ",", "t...
Return a binary method that always raises a TypeError. Parameters ---------- name : str Returns ------- invalid_op : function
[ "Return", "a", "binary", "method", "that", "always", "raises", "a", "TypeError", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L195-L212
19,955
pandas-dev/pandas
pandas/core/ops.py
_gen_eval_kwargs
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...
python
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", ")", ":", "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", "(", "'__'...
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}
[ "Find", "the", "keyword", "arguments", "to", "pass", "to", "numexpr", "for", "the", "given", "operation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L215-L253
19,956
pandas-dev/pandas
pandas/core/ops.py
_get_opstr
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...
python
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", ")", ":", "# numexpr is available for non-sparse classes", "subtyp", "=", "getattr", "(", "cls", ",", "'_subtyp'", ",", "''", ")", "use_numexpr", "=", "'sparse'", "not", "in", "subtyp", "if", "not", "use_numexpr", ":...
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
[ "Find", "the", "operation", "string", "if", "any", "to", "pass", "to", "numexpr", "for", "this", "operation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L307-L356
19,957
pandas-dev/pandas
pandas/core/ops.py
_get_op_name
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...
python
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", ")", ":", "opname", "=", "op", ".", "__name__", ".", "strip", "(", "'_'", ")", "if", "special", ":", "opname", "=", "'__{opname}__'", ".", "format", "(", "opname", "=", "opname", ")", "return", "opname"...
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
[ "Find", "the", "name", "to", "attach", "to", "this", "method", "according", "to", "conventions", "for", "special", "and", "non", "-", "special", "methods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L359-L376
19,958
pandas-dev/pandas
pandas/core/ops.py
_make_flex_doc
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__', '_...
python
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", ")", ":", "op_name", "=", "op_name", ".", "replace", "(", "'__'", ",", "''", ")", "op_desc", "=", "_op_descriptions", "[", "op_name", "]", "if", "op_desc", "[", "'reversed'", "]", ":", "equiv", "=", ...
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...
[ "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", "....
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1029-L1082
19,959
pandas-dev/pandas
pandas/core/ops.py
mask_cmp_op
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] """ #...
python
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", ")", ":", "# TODO: Can we make the allowed_types arg unnecessary?", "xrav", "=", "x", ".", "ravel", "(", ")", "result", "=", "np", ".", "empty", "(", "x", ".", "size", ",", "dtype",...
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", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1123-L1155
19,960
pandas-dev/pandas
pandas/core/ops.py
should_series_dispatch
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...
python
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", ")", ":", "if", "left", ".", "_is_mixed_type", "or", "right", ".", "_is_mixed_type", ":", "return", "True", "if", "not", "len", "(", "left", ".", "columns", ")", "or", "not", "len", ...
Identify cases where a DataFrame operation should dispatch to its Series counterpart. Parameters ---------- left : DataFrame right : DataFrame op : binary operator Returns ------- override : bool
[ "Identify", "cases", "where", "a", "DataFrame", "operation", "should", "dispatch", "to", "its", "Series", "counterpart", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1248-L1282
19,961
pandas-dev/pandas
pandas/core/ops.py
dispatch_to_index_op
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...
python
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", ")", ":", "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...
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...
[ "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...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1349-L1380
19,962
pandas-dev/pandas
pandas/core/ops.py
dispatch_to_extension_op
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...
python
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", ")", ":", "# 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", ",", "...
Assume that left or right is a Series backed by an ExtensionArray, apply the operator defined by op.
[ "Assume", "that", "left", "or", "right", "is", "a", "Series", "backed", "by", "an", "ExtensionArray", "apply", "the", "operator", "defined", "by", "op", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1383-L1410
19,963
pandas-dev/pandas
pandas/core/ops.py
_align_method_SERIES
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...
python
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", ")", ":", "# ToDo: Different from _align_method_FRAME, list, tuple and ndarray", "# are not coerced here", "# because Series has inconsistencies described in #13637", "if", "isinstance", ...
align lhs and rhs Series
[ "align", "lhs", "and", "rhs", "Series" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1628-L1646
19,964
pandas-dev/pandas
pandas/core/ops.py
_construct_divmod_result
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],...
python
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", ")", ":", "return", "(", "_construct_result", "(", "left", ",", "result", "[", "0", "]", ",", "index", "=", "index", ",", "name", "=", ...
divmod returns a tuple of like indexed series instead of a single series.
[ "divmod", "returns", "a", "tuple", "of", "like", "indexed", "series", "instead", "of", "a", "single", "series", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1661-L1669
19,965
pandas-dev/pandas
pandas/core/ops.py
_combine_series_frame
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...
python
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", ")", ":", "if", "fill_value", "is", "not", "None", ":", "raise", "NotImplementedError", "(", "\"f...
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}, ...
[ "Apply", "binary", "operator", "func", "to", "self", "other", "using", "alignment", "and", "fill", "conventions", "determined", "by", "the", "fill_value", "axis", "and", "level", "kwargs", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2073-L2112
19,966
pandas-dev/pandas
pandas/core/ops.py
_align_method_FRAME
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) == '...
python
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", ")", ":", "def", "to_series", "(", "right", ")", ":", "msg", "=", "(", "'Unable to coerce to Series, length must be {req_len}: '", "'given {given_len}'", ")", "if", "axis", "is", "not", "None", ...
convert rhs to meet lhs dims if input is list, tuple or np.ndarray
[ "convert", "rhs", "to", "meet", "lhs", "dims", "if", "input", "is", "list", "tuple", "or", "np", ".", "ndarray" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2115-L2169
19,967
pandas-dev/pandas
pandas/core/ops.py
_cast_sparse_series_op
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...
python
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", ")", ":", "from", "pandas", ".", "core", ".", "sparse", ".", "api", "import", "SparseDtype", "opname", "=", "opname", ".", "strip", "(", "'_'", ")", "# TODO: This should be moved to the...
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
[ "For", "SparseSeries", "operation", "coerce", "to", "float64", "if", "the", "result", "is", "expected", "to", "have", "NaN", "or", "inf", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L2389-L2419
19,968
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
validate_inferred_freq
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 ------...
python
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", "inferred_freq", "is", "not", "None", ":", "if", "freq", "is", "not", "None", "and", "freq", "!=", "inferred_freq", ":", "raise", "ValueError", "(", "'Infe...
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 ----...
[ "If", "the", "user", "passes", "a", "freq", "and", "another", "freq", "is", "inferred", "from", "passed", "data", "require", "that", "they", "match", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1501-L1533
19,969
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
maybe_infer_freq
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 ----...
python
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", ")", ":", "freq_infer", "=", "False", "if", "not", "isinstance", "(", "freq", ",", "DateOffset", ")", ":", "# if a passed freq is None, don't infer automatically", "if", "freq", "!=", "'infer'", ":", "freq", "=", "frequencie...
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...
[ "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",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1536-L1560
19,970
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
_ensure_datetimelike_to_i8
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...
python
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", ")", ":", "from", "pandas", "import", "Index", "from", "pandas", ".", "core", ".", "arrays", "import", "PeriodArray", "if", "lib", ".", "is_scalar", "(", "other", ")", "and", "...
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
[ "Helper", "for", "coercing", "an", "input", "scalar", "or", "array", "to", "i8", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1563-L1597
19,971
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
AttributesMixin._scalar_from_string
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...
python
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", "]", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
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...
[ "Construct", "a", "scalar", "type", "from", "a", "string", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L68-L89
19,972
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
AttributesMixin._unbox_scalar
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 ...
python
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", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
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
[ "Unbox", "the", "integer", "value", "of", "a", "scalar", "value", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L91-L111
19,973
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
AttributesMixin._check_compatible_with
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 ...
python
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", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
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 ...
[ "Verify", "that", "self", "and", "other", "are", "compatible", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L113-L134
19,974
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatelikeOps.strftime
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...
python
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", ")", ":", "from", "pandas", "import", "Index", "return", "Index", "(", "self", ".", "_format_native_types", "(", "date_format", "=", "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 format doc <%(URL)s>`__. Parameters ...
[ "Convert", "to", "Index", "using", "specified", "date_format", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L144-L180
19,975
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin.repeat
def repeat(self, repeats, *args, **kwargs): """ Repeat elements of an array. See Also -------- numpy.ndarray.repeat """ nv.validate_repeat(args, kwargs) values = self._data.repeat(repeats) return type(self)(values.view('i8'), dtype=self.dtype)
python
def repeat(self, repeats, *args, **kwargs): """ Repeat elements of an array. See Also -------- numpy.ndarray.repeat """ nv.validate_repeat(args, kwargs) values = self._data.repeat(repeats) return type(self)(values.view('i8'), dtype=self.dtype)
[ "def", "repeat", "(", "self", ",", "repeats", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_repeat", "(", "args", ",", "kwargs", ")", "values", "=", "self", ".", "_data", ".", "repeat", "(", "repeats", ")", "return", "ty...
Repeat elements of an array. See Also -------- numpy.ndarray.repeat
[ "Repeat", "elements", "of", "an", "array", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L668-L678
19,976
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._add_delta
def _add_delta(self, other): """ Add a timedelta-like, Tick or TimedeltaIndex-like object to self, yielding an int64 numpy array Parameters ---------- delta : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
python
def _add_delta(self, other): """ Add a timedelta-like, Tick or TimedeltaIndex-like object to self, yielding an int64 numpy array Parameters ---------- delta : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
[ "def", "_add_delta", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "(", "Tick", ",", "timedelta", ",", "np", ".", "timedelta64", ")", ")", ":", "new_values", "=", "self", ".", "_add_timedeltalike_scalar", "(", "other", ")", ...
Add a timedelta-like, Tick or TimedeltaIndex-like object to self, yielding an int64 numpy array Parameters ---------- delta : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ------- result : ndarray[int64] ...
[ "Add", "a", "timedelta", "-", "like", "Tick", "or", "TimedeltaIndex", "-", "like", "object", "to", "self", "yielding", "an", "int64", "numpy", "array" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L942-L967
19,977
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._add_timedeltalike_scalar
def _add_timedeltalike_scalar(self, other): """ Add a delta of a timedeltalike return the i8 result view """ if isna(other): # i.e np.timedelta64("NaT"), not recognized by delta_to_nanoseconds new_values = np.empty(len(self), dtype='i8') new_va...
python
def _add_timedeltalike_scalar(self, other): """ Add a delta of a timedeltalike return the i8 result view """ if isna(other): # i.e np.timedelta64("NaT"), not recognized by delta_to_nanoseconds new_values = np.empty(len(self), dtype='i8') new_va...
[ "def", "_add_timedeltalike_scalar", "(", "self", ",", "other", ")", ":", "if", "isna", "(", "other", ")", ":", "# i.e np.timedelta64(\"NaT\"), not recognized by delta_to_nanoseconds", "new_values", "=", "np", ".", "empty", "(", "len", "(", "self", ")", ",", "dtype...
Add a delta of a timedeltalike return the i8 result view
[ "Add", "a", "delta", "of", "a", "timedeltalike", "return", "the", "i8", "result", "view" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L969-L984
19,978
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._add_delta_tdi
def _add_delta_tdi(self, other): """ Add a delta of a TimedeltaIndex return the i8 result view """ if len(self) != len(other): raise ValueError("cannot add indices of unequal length") if isinstance(other, np.ndarray): # ndarray[timedelta64]; wrap ...
python
def _add_delta_tdi(self, other): """ Add a delta of a TimedeltaIndex return the i8 result view """ if len(self) != len(other): raise ValueError("cannot add indices of unequal length") if isinstance(other, np.ndarray): # ndarray[timedelta64]; wrap ...
[ "def", "_add_delta_tdi", "(", "self", ",", "other", ")", ":", "if", "len", "(", "self", ")", "!=", "len", "(", "other", ")", ":", "raise", "ValueError", "(", "\"cannot add indices of unequal length\"", ")", "if", "isinstance", "(", "other", ",", "np", ".",...
Add a delta of a TimedeltaIndex return the i8 result view
[ "Add", "a", "delta", "of", "a", "TimedeltaIndex", "return", "the", "i8", "result", "view" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L986-L1007
19,979
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._add_nat
def _add_nat(self): """ Add pd.NaT to self """ if is_period_dtype(self): raise TypeError('Cannot add {cls} and {typ}' .format(cls=type(self).__name__, typ=type(NaT).__name__)) # GH#19124 pd.NaT is treate...
python
def _add_nat(self): """ Add pd.NaT to self """ if is_period_dtype(self): raise TypeError('Cannot add {cls} and {typ}' .format(cls=type(self).__name__, typ=type(NaT).__name__)) # GH#19124 pd.NaT is treate...
[ "def", "_add_nat", "(", "self", ")", ":", "if", "is_period_dtype", "(", "self", ")", ":", "raise", "TypeError", "(", "'Cannot add {cls} and {typ}'", ".", "format", "(", "cls", "=", "type", "(", "self", ")", ".", "__name__", ",", "typ", "=", "type", "(", ...
Add pd.NaT to self
[ "Add", "pd", ".", "NaT", "to", "self" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1009-L1022
19,980
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._sub_nat
def _sub_nat(self): """ Subtract pd.NaT from self """ # GH#19124 Timedelta - datetime is not in general well-defined. # We make an exception for pd.NaT, which in this case quacks # like a timedelta. # For datetime64 dtypes by convention we treat NaT as a datetime,...
python
def _sub_nat(self): """ Subtract pd.NaT from self """ # GH#19124 Timedelta - datetime is not in general well-defined. # We make an exception for pd.NaT, which in this case quacks # like a timedelta. # For datetime64 dtypes by convention we treat NaT as a datetime,...
[ "def", "_sub_nat", "(", "self", ")", ":", "# GH#19124 Timedelta - datetime is not in general well-defined.", "# We make an exception for pd.NaT, which in this case quacks", "# like a timedelta.", "# For datetime64 dtypes by convention we treat NaT as a datetime, so", "# this subtraction returns ...
Subtract pd.NaT from self
[ "Subtract", "pd", ".", "NaT", "from", "self" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1024-L1036
19,981
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._addsub_int_array
def _addsub_int_array(self, other, op): """ Add or subtract array-like of integers equivalent to applying `_time_shift` pointwise. Parameters ---------- other : Index, ExtensionArray, np.ndarray integer-dtype op : {operator.add, operator.sub} ...
python
def _addsub_int_array(self, other, op): """ Add or subtract array-like of integers equivalent to applying `_time_shift` pointwise. Parameters ---------- other : Index, ExtensionArray, np.ndarray integer-dtype op : {operator.add, operator.sub} ...
[ "def", "_addsub_int_array", "(", "self", ",", "other", ",", "op", ")", ":", "# _addsub_int_array is overriden by PeriodArray", "assert", "not", "is_period_dtype", "(", "self", ")", "assert", "op", "in", "[", "operator", ".", "add", ",", "operator", ".", "sub", ...
Add or subtract array-like of integers equivalent to applying `_time_shift` pointwise. Parameters ---------- other : Index, ExtensionArray, np.ndarray integer-dtype op : {operator.add, operator.sub} Returns ------- result : same class as self
[ "Add", "or", "subtract", "array", "-", "like", "of", "integers", "equivalent", "to", "applying", "_time_shift", "pointwise", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1077-L1108
19,982
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._addsub_offset_array
def _addsub_offset_array(self, other, op): """ Add or subtract array-like of DateOffset objects Parameters ---------- other : Index, np.ndarray object-dtype containing pd.DateOffset objects op : {operator.add, operator.sub} Returns ------- ...
python
def _addsub_offset_array(self, other, op): """ Add or subtract array-like of DateOffset objects Parameters ---------- other : Index, np.ndarray object-dtype containing pd.DateOffset objects op : {operator.add, operator.sub} Returns ------- ...
[ "def", "_addsub_offset_array", "(", "self", ",", "other", ",", "op", ")", ":", "assert", "op", "in", "[", "operator", ".", "add", ",", "operator", ".", "sub", "]", "if", "len", "(", "other", ")", "==", "1", ":", "return", "op", "(", "self", ",", ...
Add or subtract array-like of DateOffset objects Parameters ---------- other : Index, np.ndarray object-dtype containing pd.DateOffset objects op : {operator.add, operator.sub} Returns ------- result : same class as self
[ "Add", "or", "subtract", "array", "-", "like", "of", "DateOffset", "objects" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1110-L1139
19,983
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin._ensure_localized
def _ensure_localized(self, arg, ambiguous='raise', nonexistent='raise', from_utc=False): """ Ensure that we are re-localized. This is for compat as we can then call this on all datetimelike arrays generally (ignored for Period/Timedelta) Parameters ...
python
def _ensure_localized(self, arg, ambiguous='raise', nonexistent='raise', from_utc=False): """ Ensure that we are re-localized. This is for compat as we can then call this on all datetimelike arrays generally (ignored for Period/Timedelta) Parameters ...
[ "def", "_ensure_localized", "(", "self", ",", "arg", ",", "ambiguous", "=", "'raise'", ",", "nonexistent", "=", "'raise'", ",", "from_utc", "=", "False", ")", ":", "# reconvert to local tz", "tz", "=", "getattr", "(", "self", ",", "'tz'", ",", "None", ")",...
Ensure that we are re-localized. This is for compat as we can then call this on all datetimelike arrays generally (ignored for Period/Timedelta) Parameters ---------- arg : Union[DatetimeLikeArray, DatetimeIndexOpsMixin, ndarray] ambiguous : str, bool, or bool-ndarray, ...
[ "Ensure", "that", "we", "are", "re", "-", "localized", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1340-L1373
19,984
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin.min
def min(self, axis=None, skipna=True, *args, **kwargs): """ Return the minimum value of the Array or minimum along an axis. See Also -------- numpy.ndarray.min Index.min : Return the minimum value in an Index. Series.min : Return the minimum value in a Se...
python
def min(self, axis=None, skipna=True, *args, **kwargs): """ Return the minimum value of the Array or minimum along an axis. See Also -------- numpy.ndarray.min Index.min : Return the minimum value in an Index. Series.min : Return the minimum value in a Se...
[ "def", "min", "(", "self", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_min", "(", "args", ",", "kwargs", ")", "nv", ".", "validate_minmax_axis", "(", "axis", ")", ...
Return the minimum value of the Array or minimum along an axis. See Also -------- numpy.ndarray.min Index.min : Return the minimum value in an Index. Series.min : Return the minimum value in a Series.
[ "Return", "the", "minimum", "value", "of", "the", "Array", "or", "minimum", "along", "an", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1385-L1403
19,985
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
DatetimeLikeArrayMixin.max
def max(self, axis=None, skipna=True, *args, **kwargs): """ Return the maximum value of the Array or maximum along an axis. See Also -------- numpy.ndarray.max Index.max : Return the maximum value in an Index. Series.max : Return the maximum value in a Se...
python
def max(self, axis=None, skipna=True, *args, **kwargs): """ Return the maximum value of the Array or maximum along an axis. See Also -------- numpy.ndarray.max Index.max : Return the maximum value in an Index. Series.max : Return the maximum value in a Se...
[ "def", "max", "(", "self", ",", "axis", "=", "None", ",", "skipna", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO: skipna is broken with max.", "# See https://github.com/pandas-dev/pandas/issues/24265", "nv", ".", "validate_max", "(", ...
Return the maximum value of the Array or maximum along an axis. See Also -------- numpy.ndarray.max Index.max : Return the maximum value in an Index. Series.max : Return the maximum value in a Series.
[ "Return", "the", "maximum", "value", "of", "the", "Array", "or", "maximum", "along", "an", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L1405-L1435
19,986
pandas-dev/pandas
pandas/core/arrays/period.py
_period_array_cmp
def _period_array_cmp(cls, op): """ Wrap comparison operations to convert Period-like to PeriodDtype """ opname = '__{name}__'.format(name=op.__name__) nat_result = opname == '__ne__' def wrapper(self, other): op = getattr(self.asi8, opname) if isinstance(other, (ABCDataFrame, ...
python
def _period_array_cmp(cls, op): """ Wrap comparison operations to convert Period-like to PeriodDtype """ opname = '__{name}__'.format(name=op.__name__) nat_result = opname == '__ne__' def wrapper(self, other): op = getattr(self.asi8, opname) if isinstance(other, (ABCDataFrame, ...
[ "def", "_period_array_cmp", "(", "cls", ",", "op", ")", ":", "opname", "=", "'__{name}__'", ".", "format", "(", "name", "=", "op", ".", "__name__", ")", "nat_result", "=", "opname", "==", "'__ne__'", "def", "wrapper", "(", "self", ",", "other", ")", ":...
Wrap comparison operations to convert Period-like to PeriodDtype
[ "Wrap", "comparison", "operations", "to", "convert", "Period", "-", "like", "to", "PeriodDtype" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L44-L86
19,987
pandas-dev/pandas
pandas/core/arrays/period.py
_raise_on_incompatible
def _raise_on_incompatible(left, right): """ Helper function to render a consistent error message when raising IncompatibleFrequency. Parameters ---------- left : PeriodArray right : DateOffset, Period, ndarray, or timedelta-like Raises ------ IncompatibleFrequency """ ...
python
def _raise_on_incompatible(left, right): """ Helper function to render a consistent error message when raising IncompatibleFrequency. Parameters ---------- left : PeriodArray right : DateOffset, Period, ndarray, or timedelta-like Raises ------ IncompatibleFrequency """ ...
[ "def", "_raise_on_incompatible", "(", "left", ",", "right", ")", ":", "# GH#24283 error message format depends on whether right is scalar", "if", "isinstance", "(", "right", ",", "np", ".", "ndarray", ")", ":", "other_freq", "=", "None", "elif", "isinstance", "(", "...
Helper function to render a consistent error message when raising IncompatibleFrequency. Parameters ---------- left : PeriodArray right : DateOffset, Period, ndarray, or timedelta-like Raises ------ IncompatibleFrequency
[ "Helper", "function", "to", "render", "a", "consistent", "error", "message", "when", "raising", "IncompatibleFrequency", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L681-L706
19,988
pandas-dev/pandas
pandas/core/arrays/period.py
period_array
def period_array( data: Sequence[Optional[Period]], freq: Optional[Tick] = None, copy: bool = False, ) -> PeriodArray: """ Construct a new PeriodArray from a sequence of Period scalars. Parameters ---------- data : Sequence of Period objects A sequence of Period obje...
python
def period_array( data: Sequence[Optional[Period]], freq: Optional[Tick] = None, copy: bool = False, ) -> PeriodArray: """ Construct a new PeriodArray from a sequence of Period scalars. Parameters ---------- data : Sequence of Period objects A sequence of Period obje...
[ "def", "period_array", "(", "data", ":", "Sequence", "[", "Optional", "[", "Period", "]", "]", ",", "freq", ":", "Optional", "[", "Tick", "]", "=", "None", ",", "copy", ":", "bool", "=", "False", ",", ")", "->", "PeriodArray", ":", "if", "is_datetime...
Construct a new PeriodArray from a sequence of Period scalars. Parameters ---------- data : Sequence of Period objects A sequence of Period objects. These are required to all have the same ``freq.`` Missing values can be indicated by ``None`` or ``pandas.NaT``. freq : str, Tick,...
[ "Construct", "a", "new", "PeriodArray", "from", "a", "sequence", "of", "Period", "scalars", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L712-L791
19,989
pandas-dev/pandas
pandas/core/arrays/period.py
validate_dtype_freq
def validate_dtype_freq(dtype, freq): """ If both a dtype and a freq are available, ensure they match. If only dtype is available, extract the implied freq. Parameters ---------- dtype : dtype freq : DateOffset or None Returns ------- freq : DateOffset Raises ------ ...
python
def validate_dtype_freq(dtype, freq): """ If both a dtype and a freq are available, ensure they match. If only dtype is available, extract the implied freq. Parameters ---------- dtype : dtype freq : DateOffset or None Returns ------- freq : DateOffset Raises ------ ...
[ "def", "validate_dtype_freq", "(", "dtype", ",", "freq", ")", ":", "if", "freq", "is", "not", "None", ":", "freq", "=", "frequencies", ".", "to_offset", "(", "freq", ")", "if", "dtype", "is", "not", "None", ":", "dtype", "=", "pandas_dtype", "(", "dtyp...
If both a dtype and a freq are available, ensure they match. If only dtype is available, extract the implied freq. Parameters ---------- dtype : dtype freq : DateOffset or None Returns ------- freq : DateOffset Raises ------ ValueError : non-period dtype IncompatibleF...
[ "If", "both", "a", "dtype", "and", "a", "freq", "are", "available", "ensure", "they", "match", ".", "If", "only", "dtype", "is", "available", "extract", "the", "implied", "freq", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L794-L825
19,990
pandas-dev/pandas
pandas/core/arrays/period.py
dt64arr_to_periodarr
def dt64arr_to_periodarr(data, freq, tz=None): """ Convert an datetime-like array to values Period ordinals. Parameters ---------- data : Union[Series[datetime64[ns]], DatetimeIndex, ndarray[datetime64ns]] freq : Optional[Union[str, Tick]] Must match the `freq` on the `data` if `data` i...
python
def dt64arr_to_periodarr(data, freq, tz=None): """ Convert an datetime-like array to values Period ordinals. Parameters ---------- data : Union[Series[datetime64[ns]], DatetimeIndex, ndarray[datetime64ns]] freq : Optional[Union[str, Tick]] Must match the `freq` on the `data` if `data` i...
[ "def", "dt64arr_to_periodarr", "(", "data", ",", "freq", ",", "tz", "=", "None", ")", ":", "if", "data", ".", "dtype", "!=", "np", ".", "dtype", "(", "'M8[ns]'", ")", ":", "raise", "ValueError", "(", "'Wrong dtype: {dtype}'", ".", "format", "(", "dtype",...
Convert an datetime-like array to values Period ordinals. Parameters ---------- data : Union[Series[datetime64[ns]], DatetimeIndex, ndarray[datetime64ns]] freq : Optional[Union[str, Tick]] Must match the `freq` on the `data` if `data` is a DatetimeIndex or Series. tz : Optional[tzin...
[ "Convert", "an", "datetime", "-", "like", "array", "to", "values", "Period", "ordinals", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L828-L863
19,991
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._from_datetime64
def _from_datetime64(cls, data, freq, tz=None): """ Construct a PeriodArray from a datetime64 array Parameters ---------- data : ndarray[datetime64[ns], datetime64[ns, tz]] freq : str or Tick tz : tzinfo, optional Returns ------- PeriodAr...
python
def _from_datetime64(cls, data, freq, tz=None): """ Construct a PeriodArray from a datetime64 array Parameters ---------- data : ndarray[datetime64[ns], datetime64[ns, tz]] freq : str or Tick tz : tzinfo, optional Returns ------- PeriodAr...
[ "def", "_from_datetime64", "(", "cls", ",", "data", ",", "freq", ",", "tz", "=", "None", ")", ":", "data", ",", "freq", "=", "dt64arr_to_periodarr", "(", "data", ",", "freq", ",", "tz", ")", "return", "cls", "(", "data", ",", "freq", "=", "freq", "...
Construct a PeriodArray from a datetime64 array Parameters ---------- data : ndarray[datetime64[ns], datetime64[ns, tz]] freq : str or Tick tz : tzinfo, optional Returns ------- PeriodArray[freq]
[ "Construct", "a", "PeriodArray", "from", "a", "datetime64", "array" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L211-L226
19,992
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._format_native_types
def _format_native_types(self, na_rep='NaT', date_format=None, **kwargs): """ actually format my specific types """ values = self.astype(object) if date_format: formatter = lambda dt: dt.strftime(date_format) else: formatter = lambda dt: '%s' % dt...
python
def _format_native_types(self, na_rep='NaT', date_format=None, **kwargs): """ actually format my specific types """ values = self.astype(object) if date_format: formatter = lambda dt: dt.strftime(date_format) else: formatter = lambda dt: '%s' % dt...
[ "def", "_format_native_types", "(", "self", ",", "na_rep", "=", "'NaT'", ",", "date_format", "=", "None", ",", "*", "*", "kwargs", ")", ":", "values", "=", "self", ".", "astype", "(", "object", ")", "if", "date_format", ":", "formatter", "=", "lambda", ...
actually format my specific types
[ "actually", "format", "my", "specific", "types" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L477-L496
19,993
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._add_delta
def _add_delta(self, other): """ Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new PeriodArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
python
def _add_delta(self, other): """ Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new PeriodArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ...
[ "def", "_add_delta", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "self", ".", "freq", ",", "Tick", ")", ":", "# We cannot add timedelta-like to non-tick PeriodArray", "_raise_on_incompatible", "(", "self", ",", "other", ")", "new_ordinals"...
Add a timedelta-like, Tick, or TimedeltaIndex-like object to self, yielding a new PeriodArray Parameters ---------- other : {timedelta, np.timedelta64, Tick, TimedeltaIndex, ndarray[timedelta64]} Returns ------- result : PeriodArray
[ "Add", "a", "timedelta", "-", "like", "Tick", "or", "TimedeltaIndex", "-", "like", "object", "to", "self", "yielding", "a", "new", "PeriodArray" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L604-L623
19,994
pandas-dev/pandas
pandas/core/arrays/period.py
PeriodArray._check_timedeltalike_freq_compat
def _check_timedeltalike_freq_compat(self, other): """ Arithmetic operations with timedelta-like scalars or array `other` are only valid if `other` is an integer multiple of `self.freq`. If the operation is valid, find that integer multiple. Otherwise, raise because the operatio...
python
def _check_timedeltalike_freq_compat(self, other): """ Arithmetic operations with timedelta-like scalars or array `other` are only valid if `other` is an integer multiple of `self.freq`. If the operation is valid, find that integer multiple. Otherwise, raise because the operatio...
[ "def", "_check_timedeltalike_freq_compat", "(", "self", ",", "other", ")", ":", "assert", "isinstance", "(", "self", ".", "freq", ",", "Tick", ")", "# checked by calling function", "own_offset", "=", "frequencies", ".", "to_offset", "(", "self", ".", "freq", "."...
Arithmetic operations with timedelta-like scalars or array `other` are only valid if `other` is an integer multiple of `self.freq`. If the operation is valid, find that integer multiple. Otherwise, raise because the operation is invalid. Parameters ---------- other : ti...
[ "Arithmetic", "operations", "with", "timedelta", "-", "like", "scalars", "or", "array", "other", "are", "only", "valid", "if", "other", "is", "an", "integer", "multiple", "of", "self", ".", "freq", ".", "If", "the", "operation", "is", "valid", "find", "tha...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/period.py#L625-L672
19,995
pandas-dev/pandas
pandas/core/dtypes/missing.py
_isna_old
def _isna_old(obj): """Detect missing values. Treat None, NaN, INF, -INF as null. Parameters ---------- arr: ndarray or object value Returns ------- boolean ndarray or boolean """ if is_scalar(obj): return libmissing.checknull_old(obj) # hack (for now) because MI regist...
python
def _isna_old(obj): """Detect missing values. Treat None, NaN, INF, -INF as null. Parameters ---------- arr: ndarray or object value Returns ------- boolean ndarray or boolean """ if is_scalar(obj): return libmissing.checknull_old(obj) # hack (for now) because MI regist...
[ "def", "_isna_old", "(", "obj", ")", ":", "if", "is_scalar", "(", "obj", ")", ":", "return", "libmissing", ".", "checknull_old", "(", "obj", ")", "# hack (for now) because MI registers as ndarray", "elif", "isinstance", "(", "obj", ",", "ABCMultiIndex", ")", ":"...
Detect missing values. Treat None, NaN, INF, -INF as null. Parameters ---------- arr: ndarray or object value Returns ------- boolean ndarray or boolean
[ "Detect", "missing", "values", ".", "Treat", "None", "NaN", "INF", "-", "INF", "as", "null", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L126-L151
19,996
pandas-dev/pandas
pandas/core/dtypes/missing.py
_maybe_fill
def _maybe_fill(arr, fill_value=np.nan): """ if we have a compatible fill_value and arr dtype, then fill """ if _isna_compat(arr, fill_value): arr.fill(fill_value) return arr
python
def _maybe_fill(arr, fill_value=np.nan): """ if we have a compatible fill_value and arr dtype, then fill """ if _isna_compat(arr, fill_value): arr.fill(fill_value) return arr
[ "def", "_maybe_fill", "(", "arr", ",", "fill_value", "=", "np", ".", "nan", ")", ":", "if", "_isna_compat", "(", "arr", ",", "fill_value", ")", ":", "arr", ".", "fill", "(", "fill_value", ")", "return", "arr" ]
if we have a compatible fill_value and arr dtype, then fill
[ "if", "we", "have", "a", "compatible", "fill_value", "and", "arr", "dtype", "then", "fill" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L470-L476
19,997
pandas-dev/pandas
pandas/core/dtypes/missing.py
na_value_for_dtype
def na_value_for_dtype(dtype, compat=True): """ Return a dtype compat na value Parameters ---------- dtype : string / dtype compat : boolean, default True Returns ------- np.dtype or a pandas dtype Examples -------- >>> na_value_for_dtype(np.dtype('int64')) 0 >...
python
def na_value_for_dtype(dtype, compat=True): """ Return a dtype compat na value Parameters ---------- dtype : string / dtype compat : boolean, default True Returns ------- np.dtype or a pandas dtype Examples -------- >>> na_value_for_dtype(np.dtype('int64')) 0 >...
[ "def", "na_value_for_dtype", "(", "dtype", ",", "compat", "=", "True", ")", ":", "dtype", "=", "pandas_dtype", "(", "dtype", ")", "if", "is_extension_array_dtype", "(", "dtype", ")", ":", "return", "dtype", ".", "na_value", "if", "(", "is_datetime64_dtype", ...
Return a dtype compat na value Parameters ---------- dtype : string / dtype compat : boolean, default True Returns ------- np.dtype or a pandas dtype Examples -------- >>> na_value_for_dtype(np.dtype('int64')) 0 >>> na_value_for_dtype(np.dtype('int64'), compat=False) ...
[ "Return", "a", "dtype", "compat", "na", "value" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L479-L520
19,998
pandas-dev/pandas
pandas/plotting/_tools.py
table
def table(ax, data, rowLabels=None, colLabels=None, **kwargs): """ Helper function to convert DataFrame and Series to matplotlib.table Parameters ---------- ax : Matplotlib axes object data : DataFrame or Series data for table contents kwargs : keywords, optional keyword arg...
python
def table(ax, data, rowLabels=None, colLabels=None, **kwargs): """ Helper function to convert DataFrame and Series to matplotlib.table Parameters ---------- ax : Matplotlib axes object data : DataFrame or Series data for table contents kwargs : keywords, optional keyword arg...
[ "def", "table", "(", "ax", ",", "data", ",", "rowLabels", "=", "None", ",", "colLabels", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "data", ",", "ABCSeries", ")", ":", "data", "=", "data", ".", "to_frame", "(", ")", ...
Helper function to convert DataFrame and Series to matplotlib.table Parameters ---------- ax : Matplotlib axes object data : DataFrame or Series data for table contents kwargs : keywords, optional keyword arguments which passed to matplotlib.table.table. If `rowLabels` or `c...
[ "Helper", "function", "to", "convert", "DataFrame", "and", "Series", "to", "matplotlib", ".", "table" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_tools.py#L23-L60
19,999
pandas-dev/pandas
pandas/plotting/_tools.py
_subplots
def _subplots(naxes=None, sharex=False, sharey=False, squeeze=True, subplot_kw=None, ax=None, layout=None, layout_type='box', **fig_kw): """Create a figure with a set of subplots already made. This utility wrapper makes it convenient to create common layouts of subplots, includi...
python
def _subplots(naxes=None, sharex=False, sharey=False, squeeze=True, subplot_kw=None, ax=None, layout=None, layout_type='box', **fig_kw): """Create a figure with a set of subplots already made. This utility wrapper makes it convenient to create common layouts of subplots, includi...
[ "def", "_subplots", "(", "naxes", "=", "None", ",", "sharex", "=", "False", ",", "sharey", "=", "False", ",", "squeeze", "=", "True", ",", "subplot_kw", "=", "None", ",", "ax", "=", "None", ",", "layout", "=", "None", ",", "layout_type", "=", "'box'"...
Create a figure with a set of subplots already made. This utility wrapper makes it convenient to create common layouts of subplots, including the enclosing figure object, in a single call. Keyword arguments: naxes : int Number of required axes. Exceeded axes are set invisible. Default is ...
[ "Create", "a", "figure", "with", "a", "set", "of", "subplots", "already", "made", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_tools.py#L110-L271