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,700
pandas-dev/pandas
pandas/core/frame.py
DataFrame.round
def round(self, decimals=0, *args, **kwargs): """ Round a DataFrame to a variable number of decimal places. Parameters ---------- decimals : int, dict, Series Number of decimal places to round each column to. If an int is given, round each column to the s...
python
def round(self, decimals=0, *args, **kwargs): """ Round a DataFrame to a variable number of decimal places. Parameters ---------- decimals : int, dict, Series Number of decimal places to round each column to. If an int is given, round each column to the s...
[ "def", "round", "(", "self", ",", "decimals", "=", "0", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "pandas", ".", "core", ".", "reshape", ".", "concat", "import", "concat", "def", "_dict_round", "(", "df", ",", "decimals", ")", ":...
Round a DataFrame to a variable number of decimal places. Parameters ---------- decimals : int, dict, Series Number of decimal places to round each column to. If an int is given, round each column to the same number of places. Otherwise dict and Series round ...
[ "Round", "a", "DataFrame", "to", "a", "variable", "number", "of", "decimal", "places", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L6917-L7028
19,701
pandas-dev/pandas
pandas/core/frame.py
DataFrame.corrwith
def corrwith(self, other, axis=0, drop=False, method='pearson'): """ Compute pairwise correlation between rows or columns of DataFrame with rows or columns of Series or DataFrame. DataFrames are first aligned along both axes before computing the correlations. Parameters ...
python
def corrwith(self, other, axis=0, drop=False, method='pearson'): """ Compute pairwise correlation between rows or columns of DataFrame with rows or columns of Series or DataFrame. DataFrames are first aligned along both axes before computing the correlations. Parameters ...
[ "def", "corrwith", "(", "self", ",", "other", ",", "axis", "=", "0", ",", "drop", "=", "False", ",", "method", "=", "'pearson'", ")", ":", "axis", "=", "self", ".", "_get_axis_number", "(", "axis", ")", "this", "=", "self", ".", "_get_numeric_data", ...
Compute pairwise correlation between rows or columns of DataFrame with rows or columns of Series or DataFrame. DataFrames are first aligned along both axes before computing the correlations. Parameters ---------- other : DataFrame, Series Object with which to comput...
[ "Compute", "pairwise", "correlation", "between", "rows", "or", "columns", "of", "DataFrame", "with", "rows", "or", "columns", "of", "Series", "or", "DataFrame", ".", "DataFrames", "are", "first", "aligned", "along", "both", "axes", "before", "computing", "the", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7228-L7314
19,702
pandas-dev/pandas
pandas/core/frame.py
DataFrame.count
def count(self, axis=0, level=None, numeric_only=False): """ Count non-NA cells for each column or row. The values `None`, `NaN`, `NaT`, and optionally `numpy.inf` (depending on `pandas.options.mode.use_inf_as_na`) are considered NA. Parameters ---------- axis :...
python
def count(self, axis=0, level=None, numeric_only=False): """ Count non-NA cells for each column or row. The values `None`, `NaN`, `NaT`, and optionally `numpy.inf` (depending on `pandas.options.mode.use_inf_as_na`) are considered NA. Parameters ---------- axis :...
[ "def", "count", "(", "self", ",", "axis", "=", "0", ",", "level", "=", "None", ",", "numeric_only", "=", "False", ")", ":", "axis", "=", "self", ".", "_get_axis_number", "(", "axis", ")", "if", "level", "is", "not", "None", ":", "return", "self", "...
Count non-NA cells for each column or row. The values `None`, `NaN`, `NaT`, and optionally `numpy.inf` (depending on `pandas.options.mode.use_inf_as_na`) are considered NA. Parameters ---------- axis : {0 or 'index', 1 or 'columns'}, default 0 If 0 or 'index' counts...
[ "Count", "non", "-", "NA", "cells", "for", "each", "column", "or", "row", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7319-L7419
19,703
pandas-dev/pandas
pandas/core/frame.py
DataFrame.nunique
def nunique(self, axis=0, dropna=True): """ Count distinct observations over requested axis. Return Series with number of distinct observations. Can ignore NaN values. .. versionadded:: 0.20.0 Parameters ---------- axis : {0 or 'index', 1 or 'columns'},...
python
def nunique(self, axis=0, dropna=True): """ Count distinct observations over requested axis. Return Series with number of distinct observations. Can ignore NaN values. .. versionadded:: 0.20.0 Parameters ---------- axis : {0 or 'index', 1 or 'columns'},...
[ "def", "nunique", "(", "self", ",", "axis", "=", "0", ",", "dropna", "=", "True", ")", ":", "return", "self", ".", "apply", "(", "Series", ".", "nunique", ",", "axis", "=", "axis", ",", "dropna", "=", "dropna", ")" ]
Count distinct observations over requested axis. Return Series with number of distinct observations. Can ignore NaN values. .. versionadded:: 0.20.0 Parameters ---------- axis : {0 or 'index', 1 or 'columns'}, default 0 The axis to use. 0 or 'index' for row...
[ "Count", "distinct", "observations", "over", "requested", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7565-L7605
19,704
pandas-dev/pandas
pandas/core/frame.py
DataFrame._get_agg_axis
def _get_agg_axis(self, axis_num): """ Let's be explicit about this. """ if axis_num == 0: return self.columns elif axis_num == 1: return self.index else: raise ValueError('Axis must be 0 or 1 (got %r)' % axis_num)
python
def _get_agg_axis(self, axis_num): """ Let's be explicit about this. """ if axis_num == 0: return self.columns elif axis_num == 1: return self.index else: raise ValueError('Axis must be 0 or 1 (got %r)' % axis_num)
[ "def", "_get_agg_axis", "(", "self", ",", "axis_num", ")", ":", "if", "axis_num", "==", "0", ":", "return", "self", ".", "columns", "elif", "axis_num", "==", "1", ":", "return", "self", ".", "index", "else", ":", "raise", "ValueError", "(", "'Axis must b...
Let's be explicit about this.
[ "Let", "s", "be", "explicit", "about", "this", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7681-L7690
19,705
pandas-dev/pandas
pandas/core/frame.py
DataFrame.quantile
def quantile(self, q=0.5, axis=0, numeric_only=True, interpolation='linear'): """ Return values at the given quantile over requested axis. Parameters ---------- q : float or array-like, default 0.5 (50% quantile) Value between 0 <= q <= 1, the quanti...
python
def quantile(self, q=0.5, axis=0, numeric_only=True, interpolation='linear'): """ Return values at the given quantile over requested axis. Parameters ---------- q : float or array-like, default 0.5 (50% quantile) Value between 0 <= q <= 1, the quanti...
[ "def", "quantile", "(", "self", ",", "q", "=", "0.5", ",", "axis", "=", "0", ",", "numeric_only", "=", "True", ",", "interpolation", "=", "'linear'", ")", ":", "self", ".", "_check_percentile", "(", "q", ")", "data", "=", "self", ".", "_get_numeric_dat...
Return values at the given quantile over requested axis. Parameters ---------- q : float or array-like, default 0.5 (50% quantile) Value between 0 <= q <= 1, the quantile(s) to compute. axis : {0, 1, 'index', 'columns'} (default 0) Equals 0 or 'index' for row-wis...
[ "Return", "values", "at", "the", "given", "quantile", "over", "requested", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7778-L7869
19,706
pandas-dev/pandas
pandas/core/frame.py
DataFrame.isin
def isin(self, values): """ Whether each element in the DataFrame is contained in values. Parameters ---------- values : iterable, Series, DataFrame or dict The result will only be true at a location if all the labels match. If `values` is a Series, that'...
python
def isin(self, values): """ Whether each element in the DataFrame is contained in values. Parameters ---------- values : iterable, Series, DataFrame or dict The result will only be true at a location if all the labels match. If `values` is a Series, that'...
[ "def", "isin", "(", "self", ",", "values", ")", ":", "if", "isinstance", "(", "values", ",", "dict", ")", ":", "from", "pandas", ".", "core", ".", "reshape", ".", "concat", "import", "concat", "values", "=", "collections", ".", "defaultdict", "(", "lis...
Whether each element in the DataFrame is contained in values. Parameters ---------- values : iterable, Series, DataFrame or dict The result will only be true at a location if all the labels match. If `values` is a Series, that's the index. If `values` is a di...
[ "Whether", "each", "element", "in", "the", "DataFrame", "is", "contained", "in", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7939-L8026
19,707
pandas-dev/pandas
pandas/core/arrays/integer.py
integer_array
def integer_array(values, dtype=None, copy=False): """ Infer and return an integer array of the values. Parameters ---------- values : 1D list-like dtype : dtype, optional dtype to coerce copy : boolean, default False Returns ------- IntegerArray Raises ------ ...
python
def integer_array(values, dtype=None, copy=False): """ Infer and return an integer array of the values. Parameters ---------- values : 1D list-like dtype : dtype, optional dtype to coerce copy : boolean, default False Returns ------- IntegerArray Raises ------ ...
[ "def", "integer_array", "(", "values", ",", "dtype", "=", "None", ",", "copy", "=", "False", ")", ":", "values", ",", "mask", "=", "coerce_to_array", "(", "values", ",", "dtype", "=", "dtype", ",", "copy", "=", "copy", ")", "return", "IntegerArray", "(...
Infer and return an integer array of the values. Parameters ---------- values : 1D list-like dtype : dtype, optional dtype to coerce copy : boolean, default False Returns ------- IntegerArray Raises ------ TypeError if incompatible types
[ "Infer", "and", "return", "an", "integer", "array", "of", "the", "values", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L92-L112
19,708
pandas-dev/pandas
pandas/core/arrays/integer.py
safe_cast
def safe_cast(values, dtype, copy): """ Safely cast the values to the dtype if they are equivalent, meaning floats must be equivalent to the ints. """ try: return values.astype(dtype, casting='safe', copy=copy) except TypeError: casted = values.astype(dtype, copy=copy) ...
python
def safe_cast(values, dtype, copy): """ Safely cast the values to the dtype if they are equivalent, meaning floats must be equivalent to the ints. """ try: return values.astype(dtype, casting='safe', copy=copy) except TypeError: casted = values.astype(dtype, copy=copy) ...
[ "def", "safe_cast", "(", "values", ",", "dtype", ",", "copy", ")", ":", "try", ":", "return", "values", ".", "astype", "(", "dtype", ",", "casting", "=", "'safe'", ",", "copy", "=", "copy", ")", "except", "TypeError", ":", "casted", "=", "values", "....
Safely cast the values to the dtype if they are equivalent, meaning floats must be equivalent to the ints.
[ "Safely", "cast", "the", "values", "to", "the", "dtype", "if", "they", "are", "equivalent", "meaning", "floats", "must", "be", "equivalent", "to", "the", "ints", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L115-L132
19,709
pandas-dev/pandas
pandas/core/arrays/integer.py
coerce_to_array
def coerce_to_array(values, dtype, mask=None, copy=False): """ Coerce the input values array to numpy arrays with a mask Parameters ---------- values : 1D list-like dtype : integer dtype mask : boolean 1D array, optional copy : boolean, default False if True, copy the input ...
python
def coerce_to_array(values, dtype, mask=None, copy=False): """ Coerce the input values array to numpy arrays with a mask Parameters ---------- values : 1D list-like dtype : integer dtype mask : boolean 1D array, optional copy : boolean, default False if True, copy the input ...
[ "def", "coerce_to_array", "(", "values", ",", "dtype", ",", "mask", "=", "None", ",", "copy", "=", "False", ")", ":", "# if values is integer numpy array, preserve it's dtype", "if", "dtype", "is", "None", "and", "hasattr", "(", "values", ",", "'dtype'", ")", ...
Coerce the input values array to numpy arrays with a mask Parameters ---------- values : 1D list-like dtype : integer dtype mask : boolean 1D array, optional copy : boolean, default False if True, copy the input Returns ------- tuple of (values, mask)
[ "Coerce", "the", "input", "values", "array", "to", "numpy", "arrays", "with", "a", "mask" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L135-L221
19,710
pandas-dev/pandas
pandas/core/arrays/integer.py
_IntegerDtype.construct_from_string
def construct_from_string(cls, string): """ Construction from a string, raise a TypeError if not possible """ if string == cls.name: return cls() raise TypeError("Cannot construct a '{}' from " "'{}'".format(cls, string))
python
def construct_from_string(cls, string): """ Construction from a string, raise a TypeError if not possible """ if string == cls.name: return cls() raise TypeError("Cannot construct a '{}' from " "'{}'".format(cls, string))
[ "def", "construct_from_string", "(", "cls", ",", "string", ")", ":", "if", "string", "==", "cls", ".", "name", ":", "return", "cls", "(", ")", "raise", "TypeError", "(", "\"Cannot construct a '{}' from \"", "\"'{}'\"", ".", "format", "(", "cls", ",", "string...
Construction from a string, raise a TypeError if not possible
[ "Construction", "from", "a", "string", "raise", "a", "TypeError", "if", "not", "possible" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L81-L89
19,711
pandas-dev/pandas
pandas/core/arrays/integer.py
IntegerArray._coerce_to_ndarray
def _coerce_to_ndarray(self): """ coerce to an ndarary of object dtype """ # TODO(jreback) make this better data = self._data.astype(object) data[self._mask] = self._na_value return data
python
def _coerce_to_ndarray(self): """ coerce to an ndarary of object dtype """ # TODO(jreback) make this better data = self._data.astype(object) data[self._mask] = self._na_value return data
[ "def", "_coerce_to_ndarray", "(", "self", ")", ":", "# TODO(jreback) make this better", "data", "=", "self", ".", "_data", ".", "astype", "(", "object", ")", "data", "[", "self", ".", "_mask", "]", "=", "self", ".", "_na_value", "return", "data" ]
coerce to an ndarary of object dtype
[ "coerce", "to", "an", "ndarary", "of", "object", "dtype" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L328-L336
19,712
pandas-dev/pandas
pandas/core/arrays/integer.py
IntegerArray.astype
def astype(self, dtype, copy=True): """ Cast to a NumPy array or IntegerArray with 'dtype'. Parameters ---------- dtype : str or dtype Typecode or data-type to which the array is cast. copy : bool, default True Whether to copy the data, even if no...
python
def astype(self, dtype, copy=True): """ Cast to a NumPy array or IntegerArray with 'dtype'. Parameters ---------- dtype : str or dtype Typecode or data-type to which the array is cast. copy : bool, default True Whether to copy the data, even if no...
[ "def", "astype", "(", "self", ",", "dtype", ",", "copy", "=", "True", ")", ":", "# if we are astyping to an existing IntegerDtype we can fastpath", "if", "isinstance", "(", "dtype", ",", "_IntegerDtype", ")", ":", "result", "=", "self", ".", "_data", ".", "astyp...
Cast to a NumPy array or IntegerArray with 'dtype'. Parameters ---------- dtype : str or dtype Typecode or data-type to which the array is cast. copy : bool, default True Whether to copy the data, even if not necessary. If False, a copy is made only i...
[ "Cast", "to", "a", "NumPy", "array", "or", "IntegerArray", "with", "dtype", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L420-L452
19,713
pandas-dev/pandas
pandas/core/arrays/integer.py
IntegerArray.value_counts
def value_counts(self, dropna=True): """ Returns a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : boolean, default True Don't include counts of NaN. Returns ...
python
def value_counts(self, dropna=True): """ Returns a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : boolean, default True Don't include counts of NaN. Returns ...
[ "def", "value_counts", "(", "self", ",", "dropna", "=", "True", ")", ":", "from", "pandas", "import", "Index", ",", "Series", "# compute counts on the data with no nans", "data", "=", "self", ".", "_data", "[", "~", "self", ".", "_mask", "]", "value_counts", ...
Returns a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : boolean, default True Don't include counts of NaN. Returns ------- counts : Series See Also...
[ "Returns", "a", "Series", "containing", "counts", "of", "each", "category", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L465-L509
19,714
pandas-dev/pandas
pandas/core/arrays/integer.py
IntegerArray._values_for_argsort
def _values_for_argsort(self) -> np.ndarray: """Return values for sorting. Returns ------- ndarray The transformed values should maintain the ordering between values within the array. See Also -------- ExtensionArray.argsort """ ...
python
def _values_for_argsort(self) -> np.ndarray: """Return values for sorting. Returns ------- ndarray The transformed values should maintain the ordering between values within the array. See Also -------- ExtensionArray.argsort """ ...
[ "def", "_values_for_argsort", "(", "self", ")", "->", "np", ".", "ndarray", ":", "data", "=", "self", ".", "_data", ".", "copy", "(", ")", "data", "[", "self", ".", "_mask", "]", "=", "data", ".", "min", "(", ")", "-", "1", "return", "data" ]
Return values for sorting. Returns ------- ndarray The transformed values should maintain the ordering between values within the array. See Also -------- ExtensionArray.argsort
[ "Return", "values", "for", "sorting", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/integer.py#L511-L526
19,715
pandas-dev/pandas
pandas/core/indexing.py
length_of_indexer
def length_of_indexer(indexer, target=None): """ return the length of a single non-tuple indexer which could be a slice """ if target is not None and isinstance(indexer, slice): target_len = len(target) start = indexer.start stop = indexer.stop step = indexer.step ...
python
def length_of_indexer(indexer, target=None): """ return the length of a single non-tuple indexer which could be a slice """ if target is not None and isinstance(indexer, slice): target_len = len(target) start = indexer.start stop = indexer.stop step = indexer.step ...
[ "def", "length_of_indexer", "(", "indexer", ",", "target", "=", "None", ")", ":", "if", "target", "is", "not", "None", "and", "isinstance", "(", "indexer", ",", "slice", ")", ":", "target_len", "=", "len", "(", "target", ")", "start", "=", "indexer", "...
return the length of a single non-tuple indexer which could be a slice
[ "return", "the", "length", "of", "a", "single", "non", "-", "tuple", "indexer", "which", "could", "be", "a", "slice" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2431-L2457
19,716
pandas-dev/pandas
pandas/core/indexing.py
convert_to_index_sliceable
def convert_to_index_sliceable(obj, key): """ if we are index sliceable, then return my slicer, otherwise return None """ idx = obj.index if isinstance(key, slice): return idx._convert_slice_indexer(key, kind='getitem') elif isinstance(key, str): # we are an actual column ...
python
def convert_to_index_sliceable(obj, key): """ if we are index sliceable, then return my slicer, otherwise return None """ idx = obj.index if isinstance(key, slice): return idx._convert_slice_indexer(key, kind='getitem') elif isinstance(key, str): # we are an actual column ...
[ "def", "convert_to_index_sliceable", "(", "obj", ",", "key", ")", ":", "idx", "=", "obj", ".", "index", "if", "isinstance", "(", "key", ",", "slice", ")", ":", "return", "idx", ".", "_convert_slice_indexer", "(", "key", ",", "kind", "=", "'getitem'", ")"...
if we are index sliceable, then return my slicer, otherwise return None
[ "if", "we", "are", "index", "sliceable", "then", "return", "my", "slicer", "otherwise", "return", "None" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2460-L2482
19,717
pandas-dev/pandas
pandas/core/indexing.py
check_setitem_lengths
def check_setitem_lengths(indexer, value, values): """ Validate that value and indexer are the same length. An special-case is allowed for when the indexer is a boolean array and the number of true values equals the length of ``value``. In this case, no exception is raised. Parameters ----...
python
def check_setitem_lengths(indexer, value, values): """ Validate that value and indexer are the same length. An special-case is allowed for when the indexer is a boolean array and the number of true values equals the length of ``value``. In this case, no exception is raised. Parameters ----...
[ "def", "check_setitem_lengths", "(", "indexer", ",", "value", ",", "values", ")", ":", "# boolean with truth values == len of the value is ok too", "if", "isinstance", "(", "indexer", ",", "(", "np", ".", "ndarray", ",", "list", ")", ")", ":", "if", "is_list_like"...
Validate that value and indexer are the same length. An special-case is allowed for when the indexer is a boolean array and the number of true values equals the length of ``value``. In this case, no exception is raised. Parameters ---------- indexer : sequence The key for the setitem ...
[ "Validate", "that", "value", "and", "indexer", "are", "the", "same", "length", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2511-L2552
19,718
pandas-dev/pandas
pandas/core/indexing.py
convert_missing_indexer
def convert_missing_indexer(indexer): """ reverse convert a missing indexer, which is a dict return the scalar indexer and a boolean indicating if we converted """ if isinstance(indexer, dict): # a missing key (but not a tuple indexer) indexer = indexer['key'] if isinstanc...
python
def convert_missing_indexer(indexer): """ reverse convert a missing indexer, which is a dict return the scalar indexer and a boolean indicating if we converted """ if isinstance(indexer, dict): # a missing key (but not a tuple indexer) indexer = indexer['key'] if isinstanc...
[ "def", "convert_missing_indexer", "(", "indexer", ")", ":", "if", "isinstance", "(", "indexer", ",", "dict", ")", ":", "# a missing key (but not a tuple indexer)", "indexer", "=", "indexer", "[", "'key'", "]", "if", "isinstance", "(", "indexer", ",", "bool", ")"...
reverse convert a missing indexer, which is a dict return the scalar indexer and a boolean indicating if we converted
[ "reverse", "convert", "a", "missing", "indexer", "which", "is", "a", "dict", "return", "the", "scalar", "indexer", "and", "a", "boolean", "indicating", "if", "we", "converted" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2555-L2570
19,719
pandas-dev/pandas
pandas/core/indexing.py
convert_from_missing_indexer_tuple
def convert_from_missing_indexer_tuple(indexer, axes): """ create a filtered indexer that doesn't have any missing indexers """ def get_indexer(_i, _idx): return (axes[_i].get_loc(_idx['key']) if isinstance(_idx, dict) else _idx) return tuple(get_indexer(_i, _idx) for _i, _...
python
def convert_from_missing_indexer_tuple(indexer, axes): """ create a filtered indexer that doesn't have any missing indexers """ def get_indexer(_i, _idx): return (axes[_i].get_loc(_idx['key']) if isinstance(_idx, dict) else _idx) return tuple(get_indexer(_i, _idx) for _i, _...
[ "def", "convert_from_missing_indexer_tuple", "(", "indexer", ",", "axes", ")", ":", "def", "get_indexer", "(", "_i", ",", "_idx", ")", ":", "return", "(", "axes", "[", "_i", "]", ".", "get_loc", "(", "_idx", "[", "'key'", "]", ")", "if", "isinstance", ...
create a filtered indexer that doesn't have any missing indexers
[ "create", "a", "filtered", "indexer", "that", "doesn", "t", "have", "any", "missing", "indexers" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2573-L2582
19,720
pandas-dev/pandas
pandas/core/indexing.py
maybe_convert_indices
def maybe_convert_indices(indices, n): """ Attempt to convert indices into valid, positive indices. If we have negative indices, translate to positive here. If we have indices that are out-of-bounds, raise an IndexError. Parameters ---------- indices : array-like The array of indic...
python
def maybe_convert_indices(indices, n): """ Attempt to convert indices into valid, positive indices. If we have negative indices, translate to positive here. If we have indices that are out-of-bounds, raise an IndexError. Parameters ---------- indices : array-like The array of indic...
[ "def", "maybe_convert_indices", "(", "indices", ",", "n", ")", ":", "if", "isinstance", "(", "indices", ",", "list", ")", ":", "indices", "=", "np", ".", "array", "(", "indices", ")", "if", "len", "(", "indices", ")", "==", "0", ":", "# If list is empt...
Attempt to convert indices into valid, positive indices. If we have negative indices, translate to positive here. If we have indices that are out-of-bounds, raise an IndexError. Parameters ---------- indices : array-like The array of indices that we are to convert. n : int The ...
[ "Attempt", "to", "convert", "indices", "into", "valid", "positive", "indices", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2585-L2626
19,721
pandas-dev/pandas
pandas/core/indexing.py
validate_indices
def validate_indices(indices, n): """ Perform bounds-checking for an indexer. -1 is allowed for indicating missing values. Parameters ---------- indices : ndarray n : int length of the array being indexed Raises ------ ValueError Examples -------- >>> vali...
python
def validate_indices(indices, n): """ Perform bounds-checking for an indexer. -1 is allowed for indicating missing values. Parameters ---------- indices : ndarray n : int length of the array being indexed Raises ------ ValueError Examples -------- >>> vali...
[ "def", "validate_indices", "(", "indices", ",", "n", ")", ":", "if", "len", "(", "indices", ")", ":", "min_idx", "=", "indices", ".", "min", "(", ")", "if", "min_idx", "<", "-", "1", ":", "msg", "=", "(", "\"'indices' contains values less than allowed ({} ...
Perform bounds-checking for an indexer. -1 is allowed for indicating missing values. Parameters ---------- indices : ndarray n : int length of the array being indexed Raises ------ ValueError Examples -------- >>> validate_indices([1, 2], 3) # OK >>> valid...
[ "Perform", "bounds", "-", "checking", "for", "an", "indexer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2629-L2667
19,722
pandas-dev/pandas
pandas/core/indexing.py
maybe_convert_ix
def maybe_convert_ix(*args): """ We likely want to take the cross-product """ ixify = True for arg in args: if not isinstance(arg, (np.ndarray, list, ABCSeries, Index)): ixify = False if ixify: return np.ix_(*args) else: return args
python
def maybe_convert_ix(*args): """ We likely want to take the cross-product """ ixify = True for arg in args: if not isinstance(arg, (np.ndarray, list, ABCSeries, Index)): ixify = False if ixify: return np.ix_(*args) else: return args
[ "def", "maybe_convert_ix", "(", "*", "args", ")", ":", "ixify", "=", "True", "for", "arg", "in", "args", ":", "if", "not", "isinstance", "(", "arg", ",", "(", "np", ".", "ndarray", ",", "list", ",", "ABCSeries", ",", "Index", ")", ")", ":", "ixify"...
We likely want to take the cross-product
[ "We", "likely", "want", "to", "take", "the", "cross", "-", "product" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2670-L2683
19,723
pandas-dev/pandas
pandas/core/indexing.py
_non_reducing_slice
def _non_reducing_slice(slice_): """ Ensurse that a slice doesn't reduce to a Series or Scalar. Any user-paseed `subset` should have this called on it to make sure we're always working with DataFrames. """ # default to column slice, like DataFrame # ['A', 'B'] -> IndexSlices[:, ['A', 'B']] ...
python
def _non_reducing_slice(slice_): """ Ensurse that a slice doesn't reduce to a Series or Scalar. Any user-paseed `subset` should have this called on it to make sure we're always working with DataFrames. """ # default to column slice, like DataFrame # ['A', 'B'] -> IndexSlices[:, ['A', 'B']] ...
[ "def", "_non_reducing_slice", "(", "slice_", ")", ":", "# default to column slice, like DataFrame", "# ['A', 'B'] -> IndexSlices[:, ['A', 'B']]", "kinds", "=", "(", "ABCSeries", ",", "np", ".", "ndarray", ",", "Index", ",", "list", ",", "str", ")", "if", "isinstance",...
Ensurse that a slice doesn't reduce to a Series or Scalar. Any user-paseed `subset` should have this called on it to make sure we're always working with DataFrames.
[ "Ensurse", "that", "a", "slice", "doesn", "t", "reduce", "to", "a", "Series", "or", "Scalar", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2734-L2762
19,724
pandas-dev/pandas
pandas/core/indexing.py
_maybe_numeric_slice
def _maybe_numeric_slice(df, slice_, include_bool=False): """ want nice defaults for background_gradient that don't break with non-numeric data. But if slice_ is passed go with that. """ if slice_ is None: dtypes = [np.number] if include_bool: dtypes.append(bool) ...
python
def _maybe_numeric_slice(df, slice_, include_bool=False): """ want nice defaults for background_gradient that don't break with non-numeric data. But if slice_ is passed go with that. """ if slice_ is None: dtypes = [np.number] if include_bool: dtypes.append(bool) ...
[ "def", "_maybe_numeric_slice", "(", "df", ",", "slice_", ",", "include_bool", "=", "False", ")", ":", "if", "slice_", "is", "None", ":", "dtypes", "=", "[", "np", ".", "number", "]", "if", "include_bool", ":", "dtypes", ".", "append", "(", "bool", ")",...
want nice defaults for background_gradient that don't break with non-numeric data. But if slice_ is passed go with that.
[ "want", "nice", "defaults", "for", "background_gradient", "that", "don", "t", "break", "with", "non", "-", "numeric", "data", ".", "But", "if", "slice_", "is", "passed", "go", "with", "that", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2765-L2775
19,725
pandas-dev/pandas
pandas/core/indexing.py
_NDFrameIndexer._has_valid_tuple
def _has_valid_tuple(self, key): """ check the key for valid keys across my indexer """ for i, k in enumerate(key): if i >= self.obj.ndim: raise IndexingError('Too many indexers') try: self._validate_key(k, i) except ValueError: ...
python
def _has_valid_tuple(self, key): """ check the key for valid keys across my indexer """ for i, k in enumerate(key): if i >= self.obj.ndim: raise IndexingError('Too many indexers') try: self._validate_key(k, i) except ValueError: ...
[ "def", "_has_valid_tuple", "(", "self", ",", "key", ")", ":", "for", "i", ",", "k", "in", "enumerate", "(", "key", ")", ":", "if", "i", ">=", "self", ".", "obj", ".", "ndim", ":", "raise", "IndexingError", "(", "'Too many indexers'", ")", "try", ":",...
check the key for valid keys across my indexer
[ "check", "the", "key", "for", "valid", "keys", "across", "my", "indexer" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L215-L225
19,726
pandas-dev/pandas
pandas/core/indexing.py
_NDFrameIndexer._has_valid_positional_setitem_indexer
def _has_valid_positional_setitem_indexer(self, indexer): """ validate that an positional indexer cannot enlarge its target will raise if needed, does not modify the indexer externally """ if isinstance(indexer, dict): raise IndexError("{0} cannot enlarge its target object" ...
python
def _has_valid_positional_setitem_indexer(self, indexer): """ validate that an positional indexer cannot enlarge its target will raise if needed, does not modify the indexer externally """ if isinstance(indexer, dict): raise IndexError("{0} cannot enlarge its target object" ...
[ "def", "_has_valid_positional_setitem_indexer", "(", "self", ",", "indexer", ")", ":", "if", "isinstance", "(", "indexer", ",", "dict", ")", ":", "raise", "IndexError", "(", "\"{0} cannot enlarge its target object\"", ".", "format", "(", "self", ".", "name", ")", ...
validate that an positional indexer cannot enlarge its target will raise if needed, does not modify the indexer externally
[ "validate", "that", "an", "positional", "indexer", "cannot", "enlarge", "its", "target", "will", "raise", "if", "needed", "does", "not", "modify", "the", "indexer", "externally" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L270-L295
19,727
pandas-dev/pandas
pandas/core/indexing.py
_NDFrameIndexer._multi_take_opportunity
def _multi_take_opportunity(self, tup): """ Check whether there is the possibility to use ``_multi_take``. Currently the limit is that all axes being indexed must be indexed with list-likes. Parameters ---------- tup : tuple Tuple of indexers, one per...
python
def _multi_take_opportunity(self, tup): """ Check whether there is the possibility to use ``_multi_take``. Currently the limit is that all axes being indexed must be indexed with list-likes. Parameters ---------- tup : tuple Tuple of indexers, one per...
[ "def", "_multi_take_opportunity", "(", "self", ",", "tup", ")", ":", "if", "not", "all", "(", "is_list_like_indexer", "(", "x", ")", "for", "x", "in", "tup", ")", ":", "return", "False", "# just too complicated", "if", "any", "(", "com", ".", "is_bool_inde...
Check whether there is the possibility to use ``_multi_take``. Currently the limit is that all axes being indexed must be indexed with list-likes. Parameters ---------- tup : tuple Tuple of indexers, one per axis Returns ------- boolean: Whet...
[ "Check", "whether", "there", "is", "the", "possibility", "to", "use", "_multi_take", ".", "Currently", "the", "limit", "is", "that", "all", "axes", "being", "indexed", "must", "be", "indexed", "with", "list", "-", "likes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L890-L912
19,728
pandas-dev/pandas
pandas/core/indexing.py
_NDFrameIndexer._multi_take
def _multi_take(self, tup): """ Create the indexers for the passed tuple of keys, and execute the take operation. This allows the take operation to be executed all at once - rather than once for each dimension - improving efficiency. Parameters ---------- tup : t...
python
def _multi_take(self, tup): """ Create the indexers for the passed tuple of keys, and execute the take operation. This allows the take operation to be executed all at once - rather than once for each dimension - improving efficiency. Parameters ---------- tup : t...
[ "def", "_multi_take", "(", "self", ",", "tup", ")", ":", "# GH 836", "o", "=", "self", ".", "obj", "d", "=", "{", "axis", ":", "self", ".", "_get_listlike_indexer", "(", "key", ",", "axis", ")", "for", "(", "key", ",", "axis", ")", "in", "zip", "...
Create the indexers for the passed tuple of keys, and execute the take operation. This allows the take operation to be executed all at once - rather than once for each dimension - improving efficiency. Parameters ---------- tup : tuple Tuple of indexers, one per axis...
[ "Create", "the", "indexers", "for", "the", "passed", "tuple", "of", "keys", "and", "execute", "the", "take", "operation", ".", "This", "allows", "the", "take", "operation", "to", "be", "executed", "all", "at", "once", "-", "rather", "than", "once", "for", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L914-L933
19,729
pandas-dev/pandas
pandas/core/indexing.py
_NDFrameIndexer._get_listlike_indexer
def _get_listlike_indexer(self, key, axis, raise_missing=False): """ Transform a list-like of keys into a new index and an indexer. Parameters ---------- key : list-like Target labels axis: int Dimension on which the indexing is being made ...
python
def _get_listlike_indexer(self, key, axis, raise_missing=False): """ Transform a list-like of keys into a new index and an indexer. Parameters ---------- key : list-like Target labels axis: int Dimension on which the indexing is being made ...
[ "def", "_get_listlike_indexer", "(", "self", ",", "key", ",", "axis", ",", "raise_missing", "=", "False", ")", ":", "o", "=", "self", ".", "obj", "ax", "=", "o", ".", "_get_axis", "(", "axis", ")", "# Have the index compute an indexer or return None", "# if it...
Transform a list-like of keys into a new index and an indexer. Parameters ---------- key : list-like Target labels axis: int Dimension on which the indexing is being made raise_missing: bool Whether to raise a KeyError if some labels are not f...
[ "Transform", "a", "list", "-", "like", "of", "keys", "into", "a", "new", "index", "and", "an", "indexer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1112-L1166
19,730
pandas-dev/pandas
pandas/core/indexing.py
_NDFrameIndexer._convert_to_indexer
def _convert_to_indexer(self, obj, axis=None, is_setter=False, raise_missing=False): """ Convert indexing key into something we can use to do actual fancy indexing on an ndarray Examples ix[:5] -> slice(0, 5) ix[[1,2,3]] -> [1,2,3] ix[...
python
def _convert_to_indexer(self, obj, axis=None, is_setter=False, raise_missing=False): """ Convert indexing key into something we can use to do actual fancy indexing on an ndarray Examples ix[:5] -> slice(0, 5) ix[[1,2,3]] -> [1,2,3] ix[...
[ "def", "_convert_to_indexer", "(", "self", ",", "obj", ",", "axis", "=", "None", ",", "is_setter", "=", "False", ",", "raise_missing", "=", "False", ")", ":", "if", "axis", "is", "None", ":", "axis", "=", "self", ".", "axis", "or", "0", "labels", "="...
Convert indexing key into something we can use to do actual fancy indexing on an ndarray Examples ix[:5] -> slice(0, 5) ix[[1,2,3]] -> [1,2,3] ix[['foo', 'bar', 'baz']] -> [i, j, k] (indices of foo, bar, baz) Going by Zen of Python? 'In the face of ambiguity, re...
[ "Convert", "indexing", "key", "into", "something", "we", "can", "use", "to", "do", "actual", "fancy", "indexing", "on", "an", "ndarray" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1275-L1366
19,731
pandas-dev/pandas
pandas/core/indexing.py
_LocationIndexer._get_slice_axis
def _get_slice_axis(self, slice_obj, axis=None): """ this is pretty simple as we just have to deal with labels """ if axis is None: axis = self.axis or 0 obj = self.obj if not need_slice(slice_obj): return obj.copy(deep=False) labels = obj._get_axis(axis...
python
def _get_slice_axis(self, slice_obj, axis=None): """ this is pretty simple as we just have to deal with labels """ if axis is None: axis = self.axis or 0 obj = self.obj if not need_slice(slice_obj): return obj.copy(deep=False) labels = obj._get_axis(axis...
[ "def", "_get_slice_axis", "(", "self", ",", "slice_obj", ",", "axis", "=", "None", ")", ":", "if", "axis", "is", "None", ":", "axis", "=", "self", ".", "axis", "or", "0", "obj", "=", "self", ".", "obj", "if", "not", "need_slice", "(", "slice_obj", ...
this is pretty simple as we just have to deal with labels
[ "this", "is", "pretty", "simple", "as", "we", "just", "have", "to", "deal", "with", "labels" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1526-L1542
19,732
pandas-dev/pandas
pandas/core/indexing.py
_iLocIndexer._validate_integer
def _validate_integer(self, key, axis): """ Check that 'key' is a valid position in the desired axis. Parameters ---------- key : int Requested position axis : int Desired axis Returns ------- None Raises ...
python
def _validate_integer(self, key, axis): """ Check that 'key' is a valid position in the desired axis. Parameters ---------- key : int Requested position axis : int Desired axis Returns ------- None Raises ...
[ "def", "_validate_integer", "(", "self", ",", "key", ",", "axis", ")", ":", "len_axis", "=", "len", "(", "self", ".", "obj", ".", "_get_axis", "(", "axis", ")", ")", "if", "key", ">=", "len_axis", "or", "key", "<", "-", "len_axis", ":", "raise", "I...
Check that 'key' is a valid position in the desired axis. Parameters ---------- key : int Requested position axis : int Desired axis Returns ------- None Raises ------ IndexError If 'key' is not a vali...
[ "Check", "that", "key", "is", "a", "valid", "position", "in", "the", "desired", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2125-L2148
19,733
pandas-dev/pandas
pandas/core/indexing.py
_iLocIndexer._get_list_axis
def _get_list_axis(self, key, axis=None): """ Return Series values by list or array of integers Parameters ---------- key : list-like positional indexer axis : int (can only be zero) Returns ------- Series object """ if axis is No...
python
def _get_list_axis(self, key, axis=None): """ Return Series values by list or array of integers Parameters ---------- key : list-like positional indexer axis : int (can only be zero) Returns ------- Series object """ if axis is No...
[ "def", "_get_list_axis", "(", "self", ",", "key", ",", "axis", "=", "None", ")", ":", "if", "axis", "is", "None", ":", "axis", "=", "self", ".", "axis", "or", "0", "try", ":", "return", "self", ".", "obj", ".", "_take", "(", "key", ",", "axis", ...
Return Series values by list or array of integers Parameters ---------- key : list-like positional indexer axis : int (can only be zero) Returns ------- Series object
[ "Return", "Series", "values", "by", "list", "or", "array", "of", "integers" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2193-L2212
19,734
pandas-dev/pandas
pandas/core/indexing.py
_iLocIndexer._convert_to_indexer
def _convert_to_indexer(self, obj, axis=None, is_setter=False): """ much simpler as we only have to deal with our valid types """ if axis is None: axis = self.axis or 0 # make need to convert a float key if isinstance(obj, slice): return self._convert_slice_index...
python
def _convert_to_indexer(self, obj, axis=None, is_setter=False): """ much simpler as we only have to deal with our valid types """ if axis is None: axis = self.axis or 0 # make need to convert a float key if isinstance(obj, slice): return self._convert_slice_index...
[ "def", "_convert_to_indexer", "(", "self", ",", "obj", ",", "axis", "=", "None", ",", "is_setter", "=", "False", ")", ":", "if", "axis", "is", "None", ":", "axis", "=", "self", ".", "axis", "or", "0", "# make need to convert a float key", "if", "isinstance...
much simpler as we only have to deal with our valid types
[ "much", "simpler", "as", "we", "only", "have", "to", "deal", "with", "our", "valid", "types" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2244-L2261
19,735
pandas-dev/pandas
pandas/core/sparse/frame.py
to_manager
def to_manager(sdf, columns, index): """ create and return the block manager from a dataframe of series, columns, index """ # from BlockManager perspective axes = [ensure_index(columns), ensure_index(index)] return create_block_manager_from_arrays( [sdf[c] for c in columns], columns, a...
python
def to_manager(sdf, columns, index): """ create and return the block manager from a dataframe of series, columns, index """ # from BlockManager perspective axes = [ensure_index(columns), ensure_index(index)] return create_block_manager_from_arrays( [sdf[c] for c in columns], columns, a...
[ "def", "to_manager", "(", "sdf", ",", "columns", ",", "index", ")", ":", "# from BlockManager perspective", "axes", "=", "[", "ensure_index", "(", "columns", ")", ",", "ensure_index", "(", "index", ")", "]", "return", "create_block_manager_from_arrays", "(", "["...
create and return the block manager from a dataframe of series, columns, index
[ "create", "and", "return", "the", "block", "manager", "from", "a", "dataframe", "of", "series", "columns", "index" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L951-L960
19,736
pandas-dev/pandas
pandas/core/sparse/frame.py
stack_sparse_frame
def stack_sparse_frame(frame): """ Only makes sense when fill_value is NaN """ lengths = [s.sp_index.npoints for _, s in frame.items()] nobs = sum(lengths) # this is pretty fast minor_codes = np.repeat(np.arange(len(frame.columns)), lengths) inds_to_concat = [] vals_to_concat = [] ...
python
def stack_sparse_frame(frame): """ Only makes sense when fill_value is NaN """ lengths = [s.sp_index.npoints for _, s in frame.items()] nobs = sum(lengths) # this is pretty fast minor_codes = np.repeat(np.arange(len(frame.columns)), lengths) inds_to_concat = [] vals_to_concat = [] ...
[ "def", "stack_sparse_frame", "(", "frame", ")", ":", "lengths", "=", "[", "s", ".", "sp_index", ".", "npoints", "for", "_", ",", "s", "in", "frame", ".", "items", "(", ")", "]", "nobs", "=", "sum", "(", "lengths", ")", "# this is pretty fast", "minor_c...
Only makes sense when fill_value is NaN
[ "Only", "makes", "sense", "when", "fill_value", "is", "NaN" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L963-L994
19,737
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame._init_matrix
def _init_matrix(self, data, index, columns, dtype=None): """ Init self from ndarray or list of lists. """ data = prep_ndarray(data, copy=False) index, columns = self._prep_index(data, index, columns) data = {idx: data[:, i] for i, idx in enumerate(columns)} retur...
python
def _init_matrix(self, data, index, columns, dtype=None): """ Init self from ndarray or list of lists. """ data = prep_ndarray(data, copy=False) index, columns = self._prep_index(data, index, columns) data = {idx: data[:, i] for i, idx in enumerate(columns)} retur...
[ "def", "_init_matrix", "(", "self", ",", "data", ",", "index", ",", "columns", ",", "dtype", "=", "None", ")", ":", "data", "=", "prep_ndarray", "(", "data", ",", "copy", "=", "False", ")", "index", ",", "columns", "=", "self", ".", "_prep_index", "(...
Init self from ndarray or list of lists.
[ "Init", "self", "from", "ndarray", "or", "list", "of", "lists", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L190-L197
19,738
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame._init_spmatrix
def _init_spmatrix(self, data, index, columns, dtype=None, fill_value=None): """ Init self from scipy.sparse matrix. """ index, columns = self._prep_index(data, index, columns) data = data.tocoo() N = len(index) # Construct a dict of Sparse...
python
def _init_spmatrix(self, data, index, columns, dtype=None, fill_value=None): """ Init self from scipy.sparse matrix. """ index, columns = self._prep_index(data, index, columns) data = data.tocoo() N = len(index) # Construct a dict of Sparse...
[ "def", "_init_spmatrix", "(", "self", ",", "data", ",", "index", ",", "columns", ",", "dtype", "=", "None", ",", "fill_value", "=", "None", ")", ":", "index", ",", "columns", "=", "self", ".", "_prep_index", "(", "data", ",", "index", ",", "columns", ...
Init self from scipy.sparse matrix.
[ "Init", "self", "from", "scipy", ".", "sparse", "matrix", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L199-L229
19,739
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame.to_coo
def to_coo(self): """ Return the contents of the frame as a sparse SciPy COO matrix. .. versionadded:: 0.20.0 Returns ------- coo_matrix : scipy.sparse.spmatrix If the caller is heterogeneous and contains booleans or objects, the result will be o...
python
def to_coo(self): """ Return the contents of the frame as a sparse SciPy COO matrix. .. versionadded:: 0.20.0 Returns ------- coo_matrix : scipy.sparse.spmatrix If the caller is heterogeneous and contains booleans or objects, the result will be o...
[ "def", "to_coo", "(", "self", ")", ":", "try", ":", "from", "scipy", ".", "sparse", "import", "coo_matrix", "except", "ImportError", ":", "raise", "ImportError", "(", "'Scipy is not installed'", ")", "dtype", "=", "find_common_type", "(", "self", ".", "dtypes"...
Return the contents of the frame as a sparse SciPy COO matrix. .. versionadded:: 0.20.0 Returns ------- coo_matrix : scipy.sparse.spmatrix If the caller is heterogeneous and contains booleans or objects, the result will be of dtype=object. See Notes. No...
[ "Return", "the", "contents", "of", "the", "frame", "as", "a", "sparse", "SciPy", "COO", "matrix", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L246-L288
19,740
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame._unpickle_sparse_frame_compat
def _unpickle_sparse_frame_compat(self, state): """ Original pickle format """ series, cols, idx, fv, kind = state if not isinstance(cols, Index): # pragma: no cover from pandas.io.pickle import _unpickle_array columns = _unpickle_array(cols) els...
python
def _unpickle_sparse_frame_compat(self, state): """ Original pickle format """ series, cols, idx, fv, kind = state if not isinstance(cols, Index): # pragma: no cover from pandas.io.pickle import _unpickle_array columns = _unpickle_array(cols) els...
[ "def", "_unpickle_sparse_frame_compat", "(", "self", ",", "state", ")", ":", "series", ",", "cols", ",", "idx", ",", "fv", ",", "kind", "=", "state", "if", "not", "isinstance", "(", "cols", ",", "Index", ")", ":", "# pragma: no cover", "from", "pandas", ...
Original pickle format
[ "Original", "pickle", "format" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L302-L327
19,741
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame.to_dense
def to_dense(self): """ Convert to dense DataFrame Returns ------- df : DataFrame """ data = {k: v.to_dense() for k, v in self.items()} return DataFrame(data, index=self.index, columns=self.columns)
python
def to_dense(self): """ Convert to dense DataFrame Returns ------- df : DataFrame """ data = {k: v.to_dense() for k, v in self.items()} return DataFrame(data, index=self.index, columns=self.columns)
[ "def", "to_dense", "(", "self", ")", ":", "data", "=", "{", "k", ":", "v", ".", "to_dense", "(", ")", "for", "k", ",", "v", "in", "self", ".", "items", "(", ")", "}", "return", "DataFrame", "(", "data", ",", "index", "=", "self", ".", "index", ...
Convert to dense DataFrame Returns ------- df : DataFrame
[ "Convert", "to", "dense", "DataFrame" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L329-L338
19,742
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame._apply_columns
def _apply_columns(self, func): """ Get new SparseDataFrame applying func to each columns """ new_data = {col: func(series) for col, series in self.items()} return self._constructor( data=new_data, index=self.index, columns=self.columns, ...
python
def _apply_columns(self, func): """ Get new SparseDataFrame applying func to each columns """ new_data = {col: func(series) for col, series in self.items()} return self._constructor( data=new_data, index=self.index, columns=self.columns, ...
[ "def", "_apply_columns", "(", "self", ",", "func", ")", ":", "new_data", "=", "{", "col", ":", "func", "(", "series", ")", "for", "col", ",", "series", "in", "self", ".", "items", "(", ")", "}", "return", "self", ".", "_constructor", "(", "data", "...
Get new SparseDataFrame applying func to each columns
[ "Get", "new", "SparseDataFrame", "applying", "func", "to", "each", "columns" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L340-L350
19,743
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame.copy
def copy(self, deep=True): """ Make a copy of this SparseDataFrame """ result = super().copy(deep=deep) result._default_fill_value = self._default_fill_value result._default_kind = self._default_kind return result
python
def copy(self, deep=True): """ Make a copy of this SparseDataFrame """ result = super().copy(deep=deep) result._default_fill_value = self._default_fill_value result._default_kind = self._default_kind return result
[ "def", "copy", "(", "self", ",", "deep", "=", "True", ")", ":", "result", "=", "super", "(", ")", ".", "copy", "(", "deep", "=", "deep", ")", "result", ".", "_default_fill_value", "=", "self", ".", "_default_fill_value", "result", ".", "_default_kind", ...
Make a copy of this SparseDataFrame
[ "Make", "a", "copy", "of", "this", "SparseDataFrame" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L355-L362
19,744
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame._sanitize_column
def _sanitize_column(self, key, value, **kwargs): """ Creates a new SparseArray from the input value. Parameters ---------- key : object value : scalar, Series, or array-like kwargs : dict Returns ------- sanitized_column : SparseArray ...
python
def _sanitize_column(self, key, value, **kwargs): """ Creates a new SparseArray from the input value. Parameters ---------- key : object value : scalar, Series, or array-like kwargs : dict Returns ------- sanitized_column : SparseArray ...
[ "def", "_sanitize_column", "(", "self", ",", "key", ",", "value", ",", "*", "*", "kwargs", ")", ":", "def", "sp_maker", "(", "x", ",", "index", "=", "None", ")", ":", "return", "SparseArray", "(", "x", ",", "index", "=", "index", ",", "fill_value", ...
Creates a new SparseArray from the input value. Parameters ---------- key : object value : scalar, Series, or array-like kwargs : dict Returns ------- sanitized_column : SparseArray
[ "Creates", "a", "new", "SparseArray", "from", "the", "input", "value", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L403-L448
19,745
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame.cumsum
def cumsum(self, axis=0, *args, **kwargs): """ Return SparseDataFrame of cumulative sums over requested axis. Parameters ---------- axis : {0, 1} 0 for row-wise, 1 for column-wise Returns ------- y : SparseDataFrame """ nv.val...
python
def cumsum(self, axis=0, *args, **kwargs): """ Return SparseDataFrame of cumulative sums over requested axis. Parameters ---------- axis : {0, 1} 0 for row-wise, 1 for column-wise Returns ------- y : SparseDataFrame """ nv.val...
[ "def", "cumsum", "(", "self", ",", "axis", "=", "0", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_cumsum", "(", "args", ",", "kwargs", ")", "if", "axis", "is", "None", ":", "axis", "=", "self", ".", "_stat_axis_number",...
Return SparseDataFrame of cumulative sums over requested axis. Parameters ---------- axis : {0, 1} 0 for row-wise, 1 for column-wise Returns ------- y : SparseDataFrame
[ "Return", "SparseDataFrame", "of", "cumulative", "sums", "over", "requested", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L828-L846
19,746
pandas-dev/pandas
pandas/core/sparse/frame.py
SparseDataFrame.apply
def apply(self, func, axis=0, broadcast=None, reduce=None, result_type=None): """ Analogous to DataFrame.apply, for SparseDataFrame Parameters ---------- func : function Function to apply to each column axis : {0, 1, 'index', 'columns'} ...
python
def apply(self, func, axis=0, broadcast=None, reduce=None, result_type=None): """ Analogous to DataFrame.apply, for SparseDataFrame Parameters ---------- func : function Function to apply to each column axis : {0, 1, 'index', 'columns'} ...
[ "def", "apply", "(", "self", ",", "func", ",", "axis", "=", "0", ",", "broadcast", "=", "None", ",", "reduce", "=", "None", ",", "result_type", "=", "None", ")", ":", "if", "not", "len", "(", "self", ".", "columns", ")", ":", "return", "self", "a...
Analogous to DataFrame.apply, for SparseDataFrame Parameters ---------- func : function Function to apply to each column axis : {0, 1, 'index', 'columns'} broadcast : bool, default False For aggregation functions, return object of same size with values ...
[ "Analogous", "to", "DataFrame", ".", "apply", "for", "SparseDataFrame" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L858-L931
19,747
pandas-dev/pandas
scripts/generate_pip_deps_from_conda.py
conda_package_to_pip
def conda_package_to_pip(package): """ Convert a conda package to its pip equivalent. In most cases they are the same, those are the exceptions: - Packages that should be excluded (in `EXCLUDE`) - Packages that should be renamed (in `RENAME`) - A package requiring a specific version, in conda i...
python
def conda_package_to_pip(package): """ Convert a conda package to its pip equivalent. In most cases they are the same, those are the exceptions: - Packages that should be excluded (in `EXCLUDE`) - Packages that should be renamed (in `RENAME`) - A package requiring a specific version, in conda i...
[ "def", "conda_package_to_pip", "(", "package", ")", ":", "if", "package", "in", "EXCLUDE", ":", "return", "package", "=", "re", ".", "sub", "(", "'(?<=[^<>])='", ",", "'=='", ",", "package", ")", ".", "strip", "(", ")", "for", "compare", "in", "(", "'<...
Convert a conda package to its pip equivalent. In most cases they are the same, those are the exceptions: - Packages that should be excluded (in `EXCLUDE`) - Packages that should be renamed (in `RENAME`) - A package requiring a specific version, in conda is defined with a single equal (e.g. ``pan...
[ "Convert", "a", "conda", "package", "to", "its", "pip", "equivalent", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/generate_pip_deps_from_conda.py#L26-L51
19,748
pandas-dev/pandas
pandas/core/dtypes/cast.py
maybe_convert_platform
def maybe_convert_platform(values): """ try to do platform conversion, allow ndarray or list here """ if isinstance(values, (list, tuple)): values = construct_1d_object_array_from_listlike(list(values)) if getattr(values, 'dtype', None) == np.object_: if hasattr(values, '_values'): ...
python
def maybe_convert_platform(values): """ try to do platform conversion, allow ndarray or list here """ if isinstance(values, (list, tuple)): values = construct_1d_object_array_from_listlike(list(values)) if getattr(values, 'dtype', None) == np.object_: if hasattr(values, '_values'): ...
[ "def", "maybe_convert_platform", "(", "values", ")", ":", "if", "isinstance", "(", "values", ",", "(", "list", ",", "tuple", ")", ")", ":", "values", "=", "construct_1d_object_array_from_listlike", "(", "list", "(", "values", ")", ")", "if", "getattr", "(", ...
try to do platform conversion, allow ndarray or list here
[ "try", "to", "do", "platform", "conversion", "allow", "ndarray", "or", "list", "here" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L35-L45
19,749
pandas-dev/pandas
pandas/core/dtypes/cast.py
maybe_upcast_putmask
def maybe_upcast_putmask(result, mask, other): """ A safe version of putmask that potentially upcasts the result. The result is replaced with the first N elements of other, where N is the number of True values in mask. If the length of other is shorter than N, other will be repeated. Parameters...
python
def maybe_upcast_putmask(result, mask, other): """ A safe version of putmask that potentially upcasts the result. The result is replaced with the first N elements of other, where N is the number of True values in mask. If the length of other is shorter than N, other will be repeated. Parameters...
[ "def", "maybe_upcast_putmask", "(", "result", ",", "mask", ",", "other", ")", ":", "if", "not", "isinstance", "(", "result", ",", "np", ".", "ndarray", ")", ":", "raise", "ValueError", "(", "\"The result input must be a ndarray.\"", ")", "if", "mask", ".", "...
A safe version of putmask that potentially upcasts the result. The result is replaced with the first N elements of other, where N is the number of True values in mask. If the length of other is shorter than N, other will be repeated. Parameters ---------- result : ndarray The destinatio...
[ "A", "safe", "version", "of", "putmask", "that", "potentially", "upcasts", "the", "result", ".", "The", "result", "is", "replaced", "with", "the", "first", "N", "elements", "of", "other", "where", "N", "is", "the", "number", "of", "True", "values", "in", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L170-L265
19,750
pandas-dev/pandas
pandas/core/dtypes/cast.py
infer_dtype_from
def infer_dtype_from(val, pandas_dtype=False): """ interpret the dtype from a scalar or array. This is a convenience routines to infer dtype from a scalar or an array Parameters ---------- pandas_dtype : bool, default False whether to infer dtype including pandas extension types. ...
python
def infer_dtype_from(val, pandas_dtype=False): """ interpret the dtype from a scalar or array. This is a convenience routines to infer dtype from a scalar or an array Parameters ---------- pandas_dtype : bool, default False whether to infer dtype including pandas extension types. ...
[ "def", "infer_dtype_from", "(", "val", ",", "pandas_dtype", "=", "False", ")", ":", "if", "is_scalar", "(", "val", ")", ":", "return", "infer_dtype_from_scalar", "(", "val", ",", "pandas_dtype", "=", "pandas_dtype", ")", "return", "infer_dtype_from_array", "(", ...
interpret the dtype from a scalar or array. This is a convenience routines to infer dtype from a scalar or an array Parameters ---------- pandas_dtype : bool, default False whether to infer dtype including pandas extension types. If False, scalar/array belongs to pandas extension types ...
[ "interpret", "the", "dtype", "from", "a", "scalar", "or", "array", ".", "This", "is", "a", "convenience", "routines", "to", "infer", "dtype", "from", "a", "scalar", "or", "an", "array" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L337-L351
19,751
pandas-dev/pandas
pandas/core/dtypes/cast.py
infer_dtype_from_scalar
def infer_dtype_from_scalar(val, pandas_dtype=False): """ interpret the dtype from a scalar Parameters ---------- pandas_dtype : bool, default False whether to infer dtype including pandas extension types. If False, scalar belongs to pandas extension types is inferred as obj...
python
def infer_dtype_from_scalar(val, pandas_dtype=False): """ interpret the dtype from a scalar Parameters ---------- pandas_dtype : bool, default False whether to infer dtype including pandas extension types. If False, scalar belongs to pandas extension types is inferred as obj...
[ "def", "infer_dtype_from_scalar", "(", "val", ",", "pandas_dtype", "=", "False", ")", ":", "dtype", "=", "np", ".", "object_", "# a 1-element ndarray", "if", "isinstance", "(", "val", ",", "np", ".", "ndarray", ")", ":", "msg", "=", "\"invalid ndarray passed t...
interpret the dtype from a scalar Parameters ---------- pandas_dtype : bool, default False whether to infer dtype including pandas extension types. If False, scalar belongs to pandas extension types is inferred as object
[ "interpret", "the", "dtype", "from", "a", "scalar" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L354-L426
19,752
pandas-dev/pandas
pandas/core/dtypes/cast.py
infer_dtype_from_array
def infer_dtype_from_array(arr, pandas_dtype=False): """ infer the dtype from a scalar or array Parameters ---------- arr : scalar or array pandas_dtype : bool, default False whether to infer dtype including pandas extension types. If False, array belongs to pandas extension typ...
python
def infer_dtype_from_array(arr, pandas_dtype=False): """ infer the dtype from a scalar or array Parameters ---------- arr : scalar or array pandas_dtype : bool, default False whether to infer dtype including pandas extension types. If False, array belongs to pandas extension typ...
[ "def", "infer_dtype_from_array", "(", "arr", ",", "pandas_dtype", "=", "False", ")", ":", "if", "isinstance", "(", "arr", ",", "np", ".", "ndarray", ")", ":", "return", "arr", ".", "dtype", ",", "arr", "if", "not", "is_list_like", "(", "arr", ")", ":",...
infer the dtype from a scalar or array Parameters ---------- arr : scalar or array pandas_dtype : bool, default False whether to infer dtype including pandas extension types. If False, array belongs to pandas extension types is inferred as object Returns ------- tup...
[ "infer", "the", "dtype", "from", "a", "scalar", "or", "array" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L429-L483
19,753
pandas-dev/pandas
pandas/core/dtypes/cast.py
maybe_infer_dtype_type
def maybe_infer_dtype_type(element): """Try to infer an object's dtype, for use in arithmetic ops Uses `element.dtype` if that's available. Objects implementing the iterator protocol are cast to a NumPy array, and from there the array's type is used. Parameters ---------- element : object ...
python
def maybe_infer_dtype_type(element): """Try to infer an object's dtype, for use in arithmetic ops Uses `element.dtype` if that's available. Objects implementing the iterator protocol are cast to a NumPy array, and from there the array's type is used. Parameters ---------- element : object ...
[ "def", "maybe_infer_dtype_type", "(", "element", ")", ":", "tipo", "=", "None", "if", "hasattr", "(", "element", ",", "'dtype'", ")", ":", "tipo", "=", "element", ".", "dtype", "elif", "is_list_like", "(", "element", ")", ":", "element", "=", "np", ".", ...
Try to infer an object's dtype, for use in arithmetic ops Uses `element.dtype` if that's available. Objects implementing the iterator protocol are cast to a NumPy array, and from there the array's type is used. Parameters ---------- element : object Possibly has a `.dtype` attribute, a...
[ "Try", "to", "infer", "an", "object", "s", "dtype", "for", "use", "in", "arithmetic", "ops" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L486-L516
19,754
pandas-dev/pandas
pandas/core/dtypes/cast.py
maybe_upcast
def maybe_upcast(values, fill_value=np.nan, dtype=None, copy=False): """ provide explicit type promotion and coercion Parameters ---------- values : the ndarray that we want to maybe upcast fill_value : what we want to fill with dtype : if None, then use the dtype of the values, else coerce to ...
python
def maybe_upcast(values, fill_value=np.nan, dtype=None, copy=False): """ provide explicit type promotion and coercion Parameters ---------- values : the ndarray that we want to maybe upcast fill_value : what we want to fill with dtype : if None, then use the dtype of the values, else coerce to ...
[ "def", "maybe_upcast", "(", "values", ",", "fill_value", "=", "np", ".", "nan", ",", "dtype", "=", "None", ",", "copy", "=", "False", ")", ":", "if", "is_extension_type", "(", "values", ")", ":", "if", "copy", ":", "values", "=", "values", ".", "copy...
provide explicit type promotion and coercion Parameters ---------- values : the ndarray that we want to maybe upcast fill_value : what we want to fill with dtype : if None, then use the dtype of the values, else coerce to this type copy : if True always make a copy even if no upcast is required
[ "provide", "explicit", "type", "promotion", "and", "coercion" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L519-L542
19,755
pandas-dev/pandas
pandas/core/dtypes/cast.py
coerce_indexer_dtype
def coerce_indexer_dtype(indexer, categories): """ coerce the indexer input array to the smallest dtype possible """ length = len(categories) if length < _int8_max: return ensure_int8(indexer) elif length < _int16_max: return ensure_int16(indexer) elif length < _int32_max: re...
python
def coerce_indexer_dtype(indexer, categories): """ coerce the indexer input array to the smallest dtype possible """ length = len(categories) if length < _int8_max: return ensure_int8(indexer) elif length < _int16_max: return ensure_int16(indexer) elif length < _int32_max: re...
[ "def", "coerce_indexer_dtype", "(", "indexer", ",", "categories", ")", ":", "length", "=", "len", "(", "categories", ")", "if", "length", "<", "_int8_max", ":", "return", "ensure_int8", "(", "indexer", ")", "elif", "length", "<", "_int16_max", ":", "return",...
coerce the indexer input array to the smallest dtype possible
[ "coerce", "the", "indexer", "input", "array", "to", "the", "smallest", "dtype", "possible" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L565-L574
19,756
pandas-dev/pandas
pandas/core/dtypes/cast.py
coerce_to_dtypes
def coerce_to_dtypes(result, dtypes): """ given a dtypes and a result set, coerce the result elements to the dtypes """ if len(result) != len(dtypes): raise AssertionError("_coerce_to_dtypes requires equal len arrays") def conv(r, dtype): try: if isna(r): ...
python
def coerce_to_dtypes(result, dtypes): """ given a dtypes and a result set, coerce the result elements to the dtypes """ if len(result) != len(dtypes): raise AssertionError("_coerce_to_dtypes requires equal len arrays") def conv(r, dtype): try: if isna(r): ...
[ "def", "coerce_to_dtypes", "(", "result", ",", "dtypes", ")", ":", "if", "len", "(", "result", ")", "!=", "len", "(", "dtypes", ")", ":", "raise", "AssertionError", "(", "\"_coerce_to_dtypes requires equal len arrays\"", ")", "def", "conv", "(", "r", ",", "d...
given a dtypes and a result set, coerce the result elements to the dtypes
[ "given", "a", "dtypes", "and", "a", "result", "set", "coerce", "the", "result", "elements", "to", "the", "dtypes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L577-L607
19,757
pandas-dev/pandas
pandas/core/dtypes/cast.py
find_common_type
def find_common_type(types): """ Find a common data type among the given dtypes. Parameters ---------- types : list of dtypes Returns ------- pandas extension or numpy dtype See Also -------- numpy.find_common_type """ if len(types) == 0: raise ValueError...
python
def find_common_type(types): """ Find a common data type among the given dtypes. Parameters ---------- types : list of dtypes Returns ------- pandas extension or numpy dtype See Also -------- numpy.find_common_type """ if len(types) == 0: raise ValueError...
[ "def", "find_common_type", "(", "types", ")", ":", "if", "len", "(", "types", ")", "==", "0", ":", "raise", "ValueError", "(", "'no types given'", ")", "first", "=", "types", "[", "0", "]", "# workaround for find_common_type([np.dtype('datetime64[ns]')] * 2)", "# ...
Find a common data type among the given dtypes. Parameters ---------- types : list of dtypes Returns ------- pandas extension or numpy dtype See Also -------- numpy.find_common_type
[ "Find", "a", "common", "data", "type", "among", "the", "given", "dtypes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1083-L1129
19,758
pandas-dev/pandas
pandas/core/dtypes/cast.py
cast_scalar_to_array
def cast_scalar_to_array(shape, value, dtype=None): """ create np.ndarray of specified shape and dtype, filled with values Parameters ---------- shape : tuple value : scalar value dtype : np.dtype, optional dtype to coerce Returns ------- ndarray of shape, filled with v...
python
def cast_scalar_to_array(shape, value, dtype=None): """ create np.ndarray of specified shape and dtype, filled with values Parameters ---------- shape : tuple value : scalar value dtype : np.dtype, optional dtype to coerce Returns ------- ndarray of shape, filled with v...
[ "def", "cast_scalar_to_array", "(", "shape", ",", "value", ",", "dtype", "=", "None", ")", ":", "if", "dtype", "is", "None", ":", "dtype", ",", "fill_value", "=", "infer_dtype_from_scalar", "(", "value", ")", "else", ":", "fill_value", "=", "value", "value...
create np.ndarray of specified shape and dtype, filled with values Parameters ---------- shape : tuple value : scalar value dtype : np.dtype, optional dtype to coerce Returns ------- ndarray of shape, filled with value, of specified / inferred dtype
[ "create", "np", ".", "ndarray", "of", "specified", "shape", "and", "dtype", "filled", "with", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1132-L1157
19,759
pandas-dev/pandas
pandas/core/dtypes/cast.py
construct_1d_object_array_from_listlike
def construct_1d_object_array_from_listlike(values): """ Transform any list-like object in a 1-dimensional numpy array of object dtype. Parameters ---------- values : any iterable which has a len() Raises ------ TypeError * If `values` does not have a len() Returns ...
python
def construct_1d_object_array_from_listlike(values): """ Transform any list-like object in a 1-dimensional numpy array of object dtype. Parameters ---------- values : any iterable which has a len() Raises ------ TypeError * If `values` does not have a len() Returns ...
[ "def", "construct_1d_object_array_from_listlike", "(", "values", ")", ":", "# numpy will try to interpret nested lists as further dimensions, hence", "# making a 1D array that contains list-likes is a bit tricky:", "result", "=", "np", ".", "empty", "(", "len", "(", "values", ")", ...
Transform any list-like object in a 1-dimensional numpy array of object dtype. Parameters ---------- values : any iterable which has a len() Raises ------ TypeError * If `values` does not have a len() Returns ------- 1-dimensional numpy array of dtype object
[ "Transform", "any", "list", "-", "like", "object", "in", "a", "1", "-", "dimensional", "numpy", "array", "of", "object", "dtype", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1202-L1224
19,760
pandas-dev/pandas
pandas/core/dtypes/cast.py
construct_1d_ndarray_preserving_na
def construct_1d_ndarray_preserving_na(values, dtype=None, copy=False): """ Construct a new ndarray, coercing `values` to `dtype`, preserving NA. Parameters ---------- values : Sequence dtype : numpy.dtype, optional copy : bool, default False Note that copies may still be made with ...
python
def construct_1d_ndarray_preserving_na(values, dtype=None, copy=False): """ Construct a new ndarray, coercing `values` to `dtype`, preserving NA. Parameters ---------- values : Sequence dtype : numpy.dtype, optional copy : bool, default False Note that copies may still be made with ...
[ "def", "construct_1d_ndarray_preserving_na", "(", "values", ",", "dtype", "=", "None", ",", "copy", "=", "False", ")", ":", "subarr", "=", "np", ".", "array", "(", "values", ",", "dtype", "=", "dtype", ",", "copy", "=", "copy", ")", "if", "dtype", "is"...
Construct a new ndarray, coercing `values` to `dtype`, preserving NA. Parameters ---------- values : Sequence dtype : numpy.dtype, optional copy : bool, default False Note that copies may still be made with ``copy=False`` if casting is required. Returns ------- arr : nd...
[ "Construct", "a", "new", "ndarray", "coercing", "values", "to", "dtype", "preserving", "NA", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/cast.py#L1227-L1266
19,761
pandas-dev/pandas
pandas/plotting/_core.py
scatter_plot
def scatter_plot(data, x, y, by=None, ax=None, figsize=None, grid=False, **kwargs): """ Make a scatter plot from two DataFrame columns Parameters ---------- data : DataFrame x : Column name for the x-axis values y : Column name for the y-axis values ax : Matplotlib axis...
python
def scatter_plot(data, x, y, by=None, ax=None, figsize=None, grid=False, **kwargs): """ Make a scatter plot from two DataFrame columns Parameters ---------- data : DataFrame x : Column name for the x-axis values y : Column name for the y-axis values ax : Matplotlib axis...
[ "def", "scatter_plot", "(", "data", ",", "x", ",", "y", ",", "by", "=", "None", ",", "ax", "=", "None", ",", "figsize", "=", "None", ",", "grid", "=", "False", ",", "*", "*", "kwargs", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt",...
Make a scatter plot from two DataFrame columns Parameters ---------- data : DataFrame x : Column name for the x-axis values y : Column name for the y-axis values ax : Matplotlib axis object figsize : A tuple (width, height) in inches grid : Setting this to True will show the grid kw...
[ "Make", "a", "scatter", "plot", "from", "two", "DataFrame", "columns" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2284-L2328
19,762
pandas-dev/pandas
pandas/plotting/_core.py
hist_frame
def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None, ax=None, sharex=False, sharey=False, figsize=None, layout=None, bins=10, **kwds): """ Make a histogram of the DataFrame's. A `histogram`_ is a representation of the di...
python
def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None, ax=None, sharex=False, sharey=False, figsize=None, layout=None, bins=10, **kwds): """ Make a histogram of the DataFrame's. A `histogram`_ is a representation of the di...
[ "def", "hist_frame", "(", "data", ",", "column", "=", "None", ",", "by", "=", "None", ",", "grid", "=", "True", ",", "xlabelsize", "=", "None", ",", "xrot", "=", "None", ",", "ylabelsize", "=", "None", ",", "yrot", "=", "None", ",", "ax", "=", "N...
Make a histogram of the DataFrame's. A `histogram`_ is a representation of the distribution of data. This function calls :meth:`matplotlib.pyplot.hist`, on each series in the DataFrame, resulting in one histogram per column. .. _histogram: https://en.wikipedia.org/wiki/Histogram Parameters --...
[ "Make", "a", "histogram", "of", "the", "DataFrame", "s", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2331-L2443
19,763
pandas-dev/pandas
pandas/plotting/_core.py
hist_series
def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None, figsize=None, bins=10, **kwds): """ Draw histogram of the input series using matplotlib. Parameters ---------- by : object, optional If passed, then use...
python
def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None, figsize=None, bins=10, **kwds): """ Draw histogram of the input series using matplotlib. Parameters ---------- by : object, optional If passed, then use...
[ "def", "hist_series", "(", "self", ",", "by", "=", "None", ",", "ax", "=", "None", ",", "grid", "=", "True", ",", "xlabelsize", "=", "None", ",", "xrot", "=", "None", ",", "ylabelsize", "=", "None", ",", "yrot", "=", "None", ",", "figsize", "=", ...
Draw histogram of the input series using matplotlib. Parameters ---------- by : object, optional If passed, then used to form histograms for separate groups ax : matplotlib axis object If not passed, uses gca() grid : bool, default True Whether to show axis grid lines xl...
[ "Draw", "histogram", "of", "the", "input", "series", "using", "matplotlib", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2446-L2521
19,764
pandas-dev/pandas
pandas/plotting/_core.py
boxplot_frame_groupby
def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None, rot=0, grid=True, ax=None, figsize=None, layout=None, sharex=False, sharey=True, **kwds): """ Make box plots from DataFrameGroupBy data. Parameters ---------- grouped : ...
python
def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None, rot=0, grid=True, ax=None, figsize=None, layout=None, sharex=False, sharey=True, **kwds): """ Make box plots from DataFrameGroupBy data. Parameters ---------- grouped : ...
[ "def", "boxplot_frame_groupby", "(", "grouped", ",", "subplots", "=", "True", ",", "column", "=", "None", ",", "fontsize", "=", "None", ",", "rot", "=", "0", ",", "grid", "=", "True", ",", "ax", "=", "None", ",", "figsize", "=", "None", ",", "layout"...
Make box plots from DataFrameGroupBy data. Parameters ---------- grouped : Grouped DataFrame subplots : bool * ``False`` - no subplots will be used * ``True`` - create a subplot for each group column : column name or list of names, or vector Can be any valid input to groupby...
[ "Make", "box", "plots", "from", "DataFrameGroupBy", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2570-L2653
19,765
pandas-dev/pandas
pandas/plotting/_core.py
MPLPlot._has_plotted_object
def _has_plotted_object(self, ax): """check whether ax has data""" return (len(ax.lines) != 0 or len(ax.artists) != 0 or len(ax.containers) != 0)
python
def _has_plotted_object(self, ax): """check whether ax has data""" return (len(ax.lines) != 0 or len(ax.artists) != 0 or len(ax.containers) != 0)
[ "def", "_has_plotted_object", "(", "self", ",", "ax", ")", ":", "return", "(", "len", "(", "ax", ".", "lines", ")", "!=", "0", "or", "len", "(", "ax", ".", "artists", ")", "!=", "0", "or", "len", "(", "ax", ".", "containers", ")", "!=", "0", ")...
check whether ax has data
[ "check", "whether", "ax", "has", "data" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L260-L264
19,766
pandas-dev/pandas
pandas/plotting/_core.py
MPLPlot.result
def result(self): """ Return result axes """ if self.subplots: if self.layout is not None and not is_list_like(self.ax): return self.axes.reshape(*self.layout) else: return self.axes else: sec_true = isinstance(s...
python
def result(self): """ Return result axes """ if self.subplots: if self.layout is not None and not is_list_like(self.ax): return self.axes.reshape(*self.layout) else: return self.axes else: sec_true = isinstance(s...
[ "def", "result", "(", "self", ")", ":", "if", "self", ".", "subplots", ":", "if", "self", ".", "layout", "is", "not", "None", "and", "not", "is_list_like", "(", "self", ".", "ax", ")", ":", "return", "self", ".", "axes", ".", "reshape", "(", "*", ...
Return result axes
[ "Return", "result", "axes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L336-L353
19,767
pandas-dev/pandas
pandas/plotting/_core.py
MPLPlot._post_plot_logic_common
def _post_plot_logic_common(self, ax, data): """Common post process for each axes""" def get_label(i): try: return pprint_thing(data.index[i]) except Exception: return '' if self.orientation == 'vertical' or self.orientation is None: ...
python
def _post_plot_logic_common(self, ax, data): """Common post process for each axes""" def get_label(i): try: return pprint_thing(data.index[i]) except Exception: return '' if self.orientation == 'vertical' or self.orientation is None: ...
[ "def", "_post_plot_logic_common", "(", "self", ",", "ax", ",", "data", ")", ":", "def", "get_label", "(", "i", ")", ":", "try", ":", "return", "pprint_thing", "(", "data", ".", "index", "[", "i", "]", ")", "except", "Exception", ":", "return", "''", ...
Common post process for each axes
[ "Common", "post", "process", "for", "each", "axes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L402-L435
19,768
pandas-dev/pandas
pandas/plotting/_core.py
MPLPlot._adorn_subplots
def _adorn_subplots(self): """Common post process unrelated to data""" if len(self.axes) > 0: all_axes = self._get_subplots() nrows, ncols = self._get_axes_layout() _handle_shared_axes(axarr=all_axes, nplots=len(all_axes), naxes=nrows *...
python
def _adorn_subplots(self): """Common post process unrelated to data""" if len(self.axes) > 0: all_axes = self._get_subplots() nrows, ncols = self._get_axes_layout() _handle_shared_axes(axarr=all_axes, nplots=len(all_axes), naxes=nrows *...
[ "def", "_adorn_subplots", "(", "self", ")", ":", "if", "len", "(", "self", ".", "axes", ")", ">", "0", ":", "all_axes", "=", "self", ".", "_get_subplots", "(", ")", "nrows", ",", "ncols", "=", "self", ".", "_get_axes_layout", "(", ")", "_handle_shared_...
Common post process unrelated to data
[ "Common", "post", "process", "unrelated", "to", "data" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L441-L487
19,769
pandas-dev/pandas
pandas/plotting/_core.py
MPLPlot._apply_style_colors
def _apply_style_colors(self, colors, kwds, col_num, label): """ Manage style and color based on column number and its label. Returns tuple of appropriate style and kwds which "color" may be added. """ style = None if self.style is not None: if isinstance(self...
python
def _apply_style_colors(self, colors, kwds, col_num, label): """ Manage style and color based on column number and its label. Returns tuple of appropriate style and kwds which "color" may be added. """ style = None if self.style is not None: if isinstance(self...
[ "def", "_apply_style_colors", "(", "self", ",", "colors", ",", "kwds", ",", "col_num", ",", "label", ")", ":", "style", "=", "None", "if", "self", ".", "style", "is", "not", "None", ":", "if", "isinstance", "(", "self", ".", "style", ",", "list", ")"...
Manage style and color based on column number and its label. Returns tuple of appropriate style and kwds which "color" may be added.
[ "Manage", "style", "and", "color", "based", "on", "column", "number", "and", "its", "label", ".", "Returns", "tuple", "of", "appropriate", "style", "and", "kwds", "which", "color", "may", "be", "added", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L672-L693
19,770
pandas-dev/pandas
pandas/plotting/_core.py
FramePlotMethods.line
def line(self, x=None, y=None, **kwds): """ Plot DataFrame columns as lines. This function is useful to plot lines using DataFrame's values as coordinates. Parameters ---------- x : int or str, optional Columns to use for the horizontal axis. ...
python
def line(self, x=None, y=None, **kwds): """ Plot DataFrame columns as lines. This function is useful to plot lines using DataFrame's values as coordinates. Parameters ---------- x : int or str, optional Columns to use for the horizontal axis. ...
[ "def", "line", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'line'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "*", "*", "kwds", ")" ]
Plot DataFrame columns as lines. This function is useful to plot lines using DataFrame's values as coordinates. Parameters ---------- x : int or str, optional Columns to use for the horizontal axis. Either the location or the label of the columns to be u...
[ "Plot", "DataFrame", "columns", "as", "lines", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2970-L3031
19,771
pandas-dev/pandas
pandas/plotting/_core.py
FramePlotMethods.bar
def bar(self, x=None, y=None, **kwds): """ Vertical bar plot. A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the pl...
python
def bar(self, x=None, y=None, **kwds): """ Vertical bar plot. A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the pl...
[ "def", "bar", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'bar'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "*", "*", "kwds", ")" ]
Vertical bar plot. A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the plot shows the specific categories being compared, and the ...
[ "Vertical", "bar", "plot", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3033-L3116
19,772
pandas-dev/pandas
pandas/plotting/_core.py
FramePlotMethods.barh
def barh(self, x=None, y=None, **kwds): """ Make a horizontal bar plot. A horizontal bar plot is a plot that presents quantitative data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One ...
python
def barh(self, x=None, y=None, **kwds): """ Make a horizontal bar plot. A horizontal bar plot is a plot that presents quantitative data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One ...
[ "def", "barh", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'barh'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "*", "*", "kwds", ")" ]
Make a horizontal bar plot. A horizontal bar plot is a plot that presents quantitative data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the plot shows the specific categories being...
[ "Make", "a", "horizontal", "bar", "plot", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3118-L3196
19,773
pandas-dev/pandas
pandas/plotting/_core.py
FramePlotMethods.hist
def hist(self, by=None, bins=10, **kwds): """ Draw one histogram of the DataFrame's columns. A histogram is a representation of the distribution of data. This function groups the values of all given Series in the DataFrame into bins and draws all bins in one :class:`matplotlib.a...
python
def hist(self, by=None, bins=10, **kwds): """ Draw one histogram of the DataFrame's columns. A histogram is a representation of the distribution of data. This function groups the values of all given Series in the DataFrame into bins and draws all bins in one :class:`matplotlib.a...
[ "def", "hist", "(", "self", ",", "by", "=", "None", ",", "bins", "=", "10", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'hist'", ",", "by", "=", "by", ",", "bins", "=", "bins", ",", "*", "*", "kwds", ")" ]
Draw one histogram of the DataFrame's columns. A histogram is a representation of the distribution of data. This function groups the values of all given Series in the DataFrame into bins and draws all bins in one :class:`matplotlib.axes.Axes`. This is useful when the DataFrame's Series ...
[ "Draw", "one", "histogram", "of", "the", "DataFrame", "s", "columns", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3248-L3293
19,774
pandas-dev/pandas
pandas/plotting/_core.py
FramePlotMethods.area
def area(self, x=None, y=None, **kwds): """ Draw a stacked area plot. An area plot displays quantitative data visually. This function wraps the matplotlib area function. Parameters ---------- x : label or position, optional Coordinates for the X axis...
python
def area(self, x=None, y=None, **kwds): """ Draw a stacked area plot. An area plot displays quantitative data visually. This function wraps the matplotlib area function. Parameters ---------- x : label or position, optional Coordinates for the X axis...
[ "def", "area", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'area'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "*", "*", "kwds", ")" ]
Draw a stacked area plot. An area plot displays quantitative data visually. This function wraps the matplotlib area function. Parameters ---------- x : label or position, optional Coordinates for the X axis. By default uses the index. y : label or position, ...
[ "Draw", "a", "stacked", "area", "plot", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3341-L3412
19,775
pandas-dev/pandas
pandas/plotting/_core.py
FramePlotMethods.scatter
def scatter(self, x, y, s=None, c=None, **kwds): """ Create a scatter plot with varying marker point size and color. The coordinates of each point are defined by two dataframe columns and filled circles are used to represent each point. This kind of plot is useful to see complex...
python
def scatter(self, x, y, s=None, c=None, **kwds): """ Create a scatter plot with varying marker point size and color. The coordinates of each point are defined by two dataframe columns and filled circles are used to represent each point. This kind of plot is useful to see complex...
[ "def", "scatter", "(", "self", ",", "x", ",", "y", ",", "s", "=", "None", ",", "c", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'scatter'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "c", "=", "c",...
Create a scatter plot with varying marker point size and color. The coordinates of each point are defined by two dataframe columns and filled circles are used to represent each point. This kind of plot is useful to see complex correlations between two variables. Points could be for inst...
[ "Create", "a", "scatter", "plot", "with", "varying", "marker", "point", "size", "and", "color", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3463-L3542
19,776
pandas-dev/pandas
pandas/plotting/_core.py
FramePlotMethods.hexbin
def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwds): """ Generate a hexagonal binning plot. Generate a hexagonal binning plot of `x` versus `y`. If `C` is `None` (the default), this is a histogram of the number of occurrences of the obser...
python
def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwds): """ Generate a hexagonal binning plot. Generate a hexagonal binning plot of `x` versus `y`. If `C` is `None` (the default), this is a histogram of the number of occurrences of the obser...
[ "def", "hexbin", "(", "self", ",", "x", ",", "y", ",", "C", "=", "None", ",", "reduce_C_function", "=", "None", ",", "gridsize", "=", "None", ",", "*", "*", "kwds", ")", ":", "if", "reduce_C_function", "is", "not", "None", ":", "kwds", "[", "'reduc...
Generate a hexagonal binning plot. Generate a hexagonal binning plot of `x` versus `y`. If `C` is `None` (the default), this is a histogram of the number of occurrences of the observations at ``(x[i], y[i])``. If `C` is specified, specifies values at given coordinates ``(x[i], ...
[ "Generate", "a", "hexagonal", "binning", "plot", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3544-L3631
19,777
pandas-dev/pandas
pandas/core/indexes/api.py
_get_combined_index
def _get_combined_index(indexes, intersect=False, sort=False): """ Return the union or intersection of indexes. Parameters ---------- indexes : list of Index or list objects When intersect=True, do not accept list of lists. intersect : bool, default False If True, calculate the ...
python
def _get_combined_index(indexes, intersect=False, sort=False): """ Return the union or intersection of indexes. Parameters ---------- indexes : list of Index or list objects When intersect=True, do not accept list of lists. intersect : bool, default False If True, calculate the ...
[ "def", "_get_combined_index", "(", "indexes", ",", "intersect", "=", "False", ",", "sort", "=", "False", ")", ":", "# TODO: handle index names!", "indexes", "=", "_get_distinct_objs", "(", "indexes", ")", "if", "len", "(", "indexes", ")", "==", "0", ":", "in...
Return the union or intersection of indexes. Parameters ---------- indexes : list of Index or list objects When intersect=True, do not accept list of lists. intersect : bool, default False If True, calculate the intersection between indexes. Otherwise, calculate the union. s...
[ "Return", "the", "union", "or", "intersection", "of", "indexes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L87-L125
19,778
pandas-dev/pandas
pandas/core/indexes/api.py
_union_indexes
def _union_indexes(indexes, sort=True): """ Return the union of indexes. The behavior of sort and names is not consistent. Parameters ---------- indexes : list of Index or list objects sort : bool, default True Whether the result index should come out sorted or not. Returns ...
python
def _union_indexes(indexes, sort=True): """ Return the union of indexes. The behavior of sort and names is not consistent. Parameters ---------- indexes : list of Index or list objects sort : bool, default True Whether the result index should come out sorted or not. Returns ...
[ "def", "_union_indexes", "(", "indexes", ",", "sort", "=", "True", ")", ":", "if", "len", "(", "indexes", ")", "==", "0", ":", "raise", "AssertionError", "(", "'Must have at least 1 Index to union'", ")", "if", "len", "(", "indexes", ")", "==", "1", ":", ...
Return the union of indexes. The behavior of sort and names is not consistent. Parameters ---------- indexes : list of Index or list objects sort : bool, default True Whether the result index should come out sorted or not. Returns ------- Index
[ "Return", "the", "union", "of", "indexes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L128-L202
19,779
pandas-dev/pandas
pandas/core/indexes/api.py
_sanitize_and_check
def _sanitize_and_check(indexes): """ Verify the type of indexes and convert lists to Index. Cases: - [list, list, ...]: Return ([list, list, ...], 'list') - [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...]) Lists are sorted and converted to Index. - [Index, Index, .....
python
def _sanitize_and_check(indexes): """ Verify the type of indexes and convert lists to Index. Cases: - [list, list, ...]: Return ([list, list, ...], 'list') - [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...]) Lists are sorted and converted to Index. - [Index, Index, .....
[ "def", "_sanitize_and_check", "(", "indexes", ")", ":", "kinds", "=", "list", "(", "{", "type", "(", "index", ")", "for", "index", "in", "indexes", "}", ")", "if", "list", "in", "kinds", ":", "if", "len", "(", "kinds", ")", ">", "1", ":", "indexes"...
Verify the type of indexes and convert lists to Index. Cases: - [list, list, ...]: Return ([list, list, ...], 'list') - [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...]) Lists are sorted and converted to Index. - [Index, Index, ...]: Return ([Index, Index, ...], TYPE) ...
[ "Verify", "the", "type", "of", "indexes", "and", "convert", "lists", "to", "Index", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L205-L240
19,780
pandas-dev/pandas
pandas/core/indexes/api.py
_get_consensus_names
def _get_consensus_names(indexes): """ Give a consensus 'names' to indexes. If there's exactly one non-empty 'names', return this, otherwise, return empty. Parameters ---------- indexes : list of Index objects Returns ------- list A list representing the consensus 'nam...
python
def _get_consensus_names(indexes): """ Give a consensus 'names' to indexes. If there's exactly one non-empty 'names', return this, otherwise, return empty. Parameters ---------- indexes : list of Index objects Returns ------- list A list representing the consensus 'nam...
[ "def", "_get_consensus_names", "(", "indexes", ")", ":", "# find the non-none names, need to tupleify to make", "# the set hashable, then reverse on return", "consensus_names", "=", "{", "tuple", "(", "i", ".", "names", ")", "for", "i", "in", "indexes", "if", "com", "."...
Give a consensus 'names' to indexes. If there's exactly one non-empty 'names', return this, otherwise, return empty. Parameters ---------- indexes : list of Index objects Returns ------- list A list representing the consensus 'names' found.
[ "Give", "a", "consensus", "names", "to", "indexes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L243-L266
19,781
pandas-dev/pandas
pandas/core/indexes/api.py
_all_indexes_same
def _all_indexes_same(indexes): """ Determine if all indexes contain the same elements. Parameters ---------- indexes : list of Index objects Returns ------- bool True if all indexes contain the same elements, False otherwise. """ first = indexes[0] for index in ind...
python
def _all_indexes_same(indexes): """ Determine if all indexes contain the same elements. Parameters ---------- indexes : list of Index objects Returns ------- bool True if all indexes contain the same elements, False otherwise. """ first = indexes[0] for index in ind...
[ "def", "_all_indexes_same", "(", "indexes", ")", ":", "first", "=", "indexes", "[", "0", "]", "for", "index", "in", "indexes", "[", "1", ":", "]", ":", "if", "not", "first", ".", "equals", "(", "index", ")", ":", "return", "False", "return", "True" ]
Determine if all indexes contain the same elements. Parameters ---------- indexes : list of Index objects Returns ------- bool True if all indexes contain the same elements, False otherwise.
[ "Determine", "if", "all", "indexes", "contain", "the", "same", "elements", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L269-L286
19,782
pandas-dev/pandas
pandas/io/sql.py
_convert_params
def _convert_params(sql, params): """Convert SQL and params args to DBAPI2.0 compliant format.""" args = [sql] if params is not None: if hasattr(params, 'keys'): # test if params is a mapping args += [params] else: args += [list(params)] return args
python
def _convert_params(sql, params): """Convert SQL and params args to DBAPI2.0 compliant format.""" args = [sql] if params is not None: if hasattr(params, 'keys'): # test if params is a mapping args += [params] else: args += [list(params)] return args
[ "def", "_convert_params", "(", "sql", ",", "params", ")", ":", "args", "=", "[", "sql", "]", "if", "params", "is", "not", "None", ":", "if", "hasattr", "(", "params", ",", "'keys'", ")", ":", "# test if params is a mapping", "args", "+=", "[", "params", ...
Convert SQL and params args to DBAPI2.0 compliant format.
[ "Convert", "SQL", "and", "params", "args", "to", "DBAPI2", ".", "0", "compliant", "format", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L57-L65
19,783
pandas-dev/pandas
pandas/io/sql.py
_process_parse_dates_argument
def _process_parse_dates_argument(parse_dates): """Process parse_dates argument for read_sql functions""" # handle non-list entries for parse_dates gracefully if parse_dates is True or parse_dates is None or parse_dates is False: parse_dates = [] elif not hasattr(parse_dates, '__iter__'): ...
python
def _process_parse_dates_argument(parse_dates): """Process parse_dates argument for read_sql functions""" # handle non-list entries for parse_dates gracefully if parse_dates is True or parse_dates is None or parse_dates is False: parse_dates = [] elif not hasattr(parse_dates, '__iter__'): ...
[ "def", "_process_parse_dates_argument", "(", "parse_dates", ")", ":", "# handle non-list entries for parse_dates gracefully", "if", "parse_dates", "is", "True", "or", "parse_dates", "is", "None", "or", "parse_dates", "is", "False", ":", "parse_dates", "=", "[", "]", "...
Process parse_dates argument for read_sql functions
[ "Process", "parse_dates", "argument", "for", "read_sql", "functions" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L68-L76
19,784
pandas-dev/pandas
pandas/io/sql.py
_parse_date_columns
def _parse_date_columns(data_frame, parse_dates): """ Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns. """ parse_dates = _process_parse_dates_argument(parse_dates) # we want to coerce datetime64_tz dtypes for now to UTC # we could ...
python
def _parse_date_columns(data_frame, parse_dates): """ Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns. """ parse_dates = _process_parse_dates_argument(parse_dates) # we want to coerce datetime64_tz dtypes for now to UTC # we could ...
[ "def", "_parse_date_columns", "(", "data_frame", ",", "parse_dates", ")", ":", "parse_dates", "=", "_process_parse_dates_argument", "(", "parse_dates", ")", "# we want to coerce datetime64_tz dtypes for now to UTC", "# we could in theory do a 'nice' conversion from a FixedOffset tz", ...
Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns.
[ "Force", "non", "-", "datetime", "columns", "to", "be", "read", "as", "such", ".", "Supports", "both", "string", "formatted", "and", "integer", "timestamp", "columns", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L98-L116
19,785
pandas-dev/pandas
pandas/io/sql.py
_wrap_result
def _wrap_result(data, columns, index_col=None, coerce_float=True, parse_dates=None): """Wrap result set of query in a DataFrame.""" frame = DataFrame.from_records(data, columns=columns, coerce_float=coerce_float) frame = _parse_date_columns(frame, parse...
python
def _wrap_result(data, columns, index_col=None, coerce_float=True, parse_dates=None): """Wrap result set of query in a DataFrame.""" frame = DataFrame.from_records(data, columns=columns, coerce_float=coerce_float) frame = _parse_date_columns(frame, parse...
[ "def", "_wrap_result", "(", "data", ",", "columns", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ")", ":", "frame", "=", "DataFrame", ".", "from_records", "(", "data", ",", "columns", "=", "columns", "...
Wrap result set of query in a DataFrame.
[ "Wrap", "result", "set", "of", "query", "in", "a", "DataFrame", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L119-L131
19,786
pandas-dev/pandas
pandas/io/sql.py
execute
def execute(sql, con, cur=None, params=None): """ Execute the given SQL query using the provided connection object. Parameters ---------- sql : string SQL query to be executed. con : SQLAlchemy connectable(engine/connection) or sqlite3 connection Using SQLAlchemy makes it possib...
python
def execute(sql, con, cur=None, params=None): """ Execute the given SQL query using the provided connection object. Parameters ---------- sql : string SQL query to be executed. con : SQLAlchemy connectable(engine/connection) or sqlite3 connection Using SQLAlchemy makes it possib...
[ "def", "execute", "(", "sql", ",", "con", ",", "cur", "=", "None", ",", "params", "=", "None", ")", ":", "if", "cur", "is", "None", ":", "pandas_sql", "=", "pandasSQL_builder", "(", "con", ")", "else", ":", "pandas_sql", "=", "pandasSQL_builder", "(", ...
Execute the given SQL query using the provided connection object. Parameters ---------- sql : string SQL query to be executed. con : SQLAlchemy connectable(engine/connection) or sqlite3 connection Using SQLAlchemy makes it possible to use any DB supported by the library. ...
[ "Execute", "the", "given", "SQL", "query", "using", "the", "provided", "connection", "object", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L134-L159
19,787
pandas-dev/pandas
pandas/io/sql.py
has_table
def has_table(table_name, con, schema=None): """ Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table. con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported ...
python
def has_table(table_name, con, schema=None): """ Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table. con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported ...
[ "def", "has_table", "(", "table_name", ",", "con", ",", "schema", "=", "None", ")", ":", "pandas_sql", "=", "pandasSQL_builder", "(", "con", ",", "schema", "=", "schema", ")", "return", "pandas_sql", ".", "has_table", "(", "table_name", ")" ]
Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table. con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only...
[ "Check", "if", "DataBase", "has", "named", "table", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L454-L475
19,788
pandas-dev/pandas
pandas/io/sql.py
pandasSQL_builder
def pandasSQL_builder(con, schema=None, meta=None, is_cursor=False): """ Convenience function to return the correct PandasSQL subclass based on the provided parameters. """ # When support for DBAPI connections is removed, # is_cursor should not be necessary. con = _engi...
python
def pandasSQL_builder(con, schema=None, meta=None, is_cursor=False): """ Convenience function to return the correct PandasSQL subclass based on the provided parameters. """ # When support for DBAPI connections is removed, # is_cursor should not be necessary. con = _engi...
[ "def", "pandasSQL_builder", "(", "con", ",", "schema", "=", "None", ",", "meta", "=", "None", ",", "is_cursor", "=", "False", ")", ":", "# When support for DBAPI connections is removed,", "# is_cursor should not be necessary.", "con", "=", "_engine_builder", "(", "con...
Convenience function to return the correct PandasSQL subclass based on the provided parameters.
[ "Convenience", "function", "to", "return", "the", "correct", "PandasSQL", "subclass", "based", "on", "the", "provided", "parameters", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L499-L513
19,789
pandas-dev/pandas
pandas/io/sql.py
get_schema
def get_schema(frame, name, keys=None, con=None, dtype=None): """ Get the SQL db table schema for the given frame. Parameters ---------- frame : DataFrame name : string name of SQL table keys : string or sequence, default: None columns to use a primary key con: an open S...
python
def get_schema(frame, name, keys=None, con=None, dtype=None): """ Get the SQL db table schema for the given frame. Parameters ---------- frame : DataFrame name : string name of SQL table keys : string or sequence, default: None columns to use a primary key con: an open S...
[ "def", "get_schema", "(", "frame", ",", "name", ",", "keys", "=", "None", ",", "con", "=", "None", ",", "dtype", "=", "None", ")", ":", "pandas_sql", "=", "pandasSQL_builder", "(", "con", "=", "con", ")", "return", "pandas_sql", ".", "_create_sql_schema"...
Get the SQL db table schema for the given frame. Parameters ---------- frame : DataFrame name : string name of SQL table keys : string or sequence, default: None columns to use a primary key con: an open SQL database connection object or a SQLAlchemy connectable Using SQ...
[ "Get", "the", "SQL", "db", "table", "schema", "for", "the", "given", "frame", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1564-L1586
19,790
pandas-dev/pandas
pandas/io/sql.py
SQLTable._execute_insert
def _execute_insert(self, conn, keys, data_iter): """Execute SQL statement inserting data Parameters ---------- conn : sqlalchemy.engine.Engine or sqlalchemy.engine.Connection keys : list of str Column names data_iter : generator of list Each item c...
python
def _execute_insert(self, conn, keys, data_iter): """Execute SQL statement inserting data Parameters ---------- conn : sqlalchemy.engine.Engine or sqlalchemy.engine.Connection keys : list of str Column names data_iter : generator of list Each item c...
[ "def", "_execute_insert", "(", "self", ",", "conn", ",", "keys", ",", "data_iter", ")", ":", "data", "=", "[", "dict", "(", "zip", "(", "keys", ",", "row", ")", ")", "for", "row", "in", "data_iter", "]", "conn", ".", "execute", "(", "self", ".", ...
Execute SQL statement inserting data Parameters ---------- conn : sqlalchemy.engine.Engine or sqlalchemy.engine.Connection keys : list of str Column names data_iter : generator of list Each item contains a list of values to be inserted
[ "Execute", "SQL", "statement", "inserting", "data" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L578-L590
19,791
pandas-dev/pandas
pandas/io/sql.py
SQLTable._query_iterator
def _query_iterator(self, result, chunksize, columns, coerce_float=True, parse_dates=None): """Return generator through chunked result set.""" while True: data = result.fetchmany(chunksize) if not data: break else: ...
python
def _query_iterator(self, result, chunksize, columns, coerce_float=True, parse_dates=None): """Return generator through chunked result set.""" while True: data = result.fetchmany(chunksize) if not data: break else: ...
[ "def", "_query_iterator", "(", "self", ",", "result", ",", "chunksize", ",", "columns", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ")", ":", "while", "True", ":", "data", "=", "result", ".", "fetchmany", "(", "chunksize", ")", "if...
Return generator through chunked result set.
[ "Return", "generator", "through", "chunked", "result", "set", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L679-L696
19,792
pandas-dev/pandas
pandas/io/sql.py
SQLTable._harmonize_columns
def _harmonize_columns(self, parse_dates=None): """ Make the DataFrame's column types align with the SQL table column types. Need to work around limited NA value support. Floats are always fine, ints must always be floats if there are Null values. Booleans are hard becaus...
python
def _harmonize_columns(self, parse_dates=None): """ Make the DataFrame's column types align with the SQL table column types. Need to work around limited NA value support. Floats are always fine, ints must always be floats if there are Null values. Booleans are hard becaus...
[ "def", "_harmonize_columns", "(", "self", ",", "parse_dates", "=", "None", ")", ":", "parse_dates", "=", "_process_parse_dates_argument", "(", "parse_dates", ")", "for", "sql_col", "in", "self", ".", "table", ".", "columns", ":", "col_name", "=", "sql_col", "....
Make the DataFrame's column types align with the SQL table column types. Need to work around limited NA value support. Floats are always fine, ints must always be floats if there are Null values. Booleans are hard because converting bool column with None replaces all Nones with f...
[ "Make", "the", "DataFrame", "s", "column", "types", "align", "with", "the", "SQL", "table", "column", "types", ".", "Need", "to", "work", "around", "limited", "NA", "value", "support", ".", "Floats", "are", "always", "fine", "ints", "must", "always", "be",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L803-L851
19,793
pandas-dev/pandas
pandas/io/sql.py
SQLiteTable._create_table_setup
def _create_table_setup(self): """ Return a list of SQL statements that creates a table reflecting the structure of a DataFrame. The first entry will be a CREATE TABLE statement while the rest will be CREATE INDEX statements. """ column_names_and_types = self._get_column...
python
def _create_table_setup(self): """ Return a list of SQL statements that creates a table reflecting the structure of a DataFrame. The first entry will be a CREATE TABLE statement while the rest will be CREATE INDEX statements. """ column_names_and_types = self._get_column...
[ "def", "_create_table_setup", "(", "self", ")", ":", "column_names_and_types", "=", "self", ".", "_get_column_names_and_types", "(", "self", ".", "_sql_type_name", ")", "pat", "=", "re", ".", "compile", "(", "r'\\s+'", ")", "column_names", "=", "[", "col_name", ...
Return a list of SQL statements that creates a table reflecting the structure of a DataFrame. The first entry will be a CREATE TABLE statement while the rest will be CREATE INDEX statements.
[ "Return", "a", "list", "of", "SQL", "statements", "that", "creates", "a", "table", "reflecting", "the", "structure", "of", "a", "DataFrame", ".", "The", "first", "entry", "will", "be", "a", "CREATE", "TABLE", "statement", "while", "the", "rest", "will", "b...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1311-L1353
19,794
pandas-dev/pandas
pandas/core/arrays/categorical.py
_maybe_to_categorical
def _maybe_to_categorical(array): """ Coerce to a categorical if a series is given. Internal use ONLY. """ if isinstance(array, (ABCSeries, ABCCategoricalIndex)): return array._values elif isinstance(array, np.ndarray): return Categorical(array) return array
python
def _maybe_to_categorical(array): """ Coerce to a categorical if a series is given. Internal use ONLY. """ if isinstance(array, (ABCSeries, ABCCategoricalIndex)): return array._values elif isinstance(array, np.ndarray): return Categorical(array) return array
[ "def", "_maybe_to_categorical", "(", "array", ")", ":", "if", "isinstance", "(", "array", ",", "(", "ABCSeries", ",", "ABCCategoricalIndex", ")", ")", ":", "return", "array", ".", "_values", "elif", "isinstance", "(", "array", ",", "np", ".", "ndarray", ")...
Coerce to a categorical if a series is given. Internal use ONLY.
[ "Coerce", "to", "a", "categorical", "if", "a", "series", "is", "given", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L131-L141
19,795
pandas-dev/pandas
pandas/core/arrays/categorical.py
contains
def contains(cat, key, container): """ Helper for membership check for ``key`` in ``cat``. This is a helper method for :method:`__contains__` and :class:`CategoricalIndex.__contains__`. Returns True if ``key`` is in ``cat.categories`` and the location of ``key`` in ``categories`` is in ``conta...
python
def contains(cat, key, container): """ Helper for membership check for ``key`` in ``cat``. This is a helper method for :method:`__contains__` and :class:`CategoricalIndex.__contains__`. Returns True if ``key`` is in ``cat.categories`` and the location of ``key`` in ``categories`` is in ``conta...
[ "def", "contains", "(", "cat", ",", "key", ",", "container", ")", ":", "hash", "(", "key", ")", "# get location of key in categories.", "# If a KeyError, the key isn't in categories, so logically", "# can't be in container either.", "try", ":", "loc", "=", "cat", ".", ...
Helper for membership check for ``key`` in ``cat``. This is a helper method for :method:`__contains__` and :class:`CategoricalIndex.__contains__`. Returns True if ``key`` is in ``cat.categories`` and the location of ``key`` in ``categories`` is in ``container``. Parameters ---------- cat ...
[ "Helper", "for", "membership", "check", "for", "key", "in", "cat", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L144-L192
19,796
pandas-dev/pandas
pandas/core/arrays/categorical.py
_get_codes_for_values
def _get_codes_for_values(values, categories): """ utility routine to turn values into codes given the specified categories """ from pandas.core.algorithms import _get_data_algo, _hashtables dtype_equal = is_dtype_equal(values.dtype, categories.dtype) if dtype_equal: # To prevent errone...
python
def _get_codes_for_values(values, categories): """ utility routine to turn values into codes given the specified categories """ from pandas.core.algorithms import _get_data_algo, _hashtables dtype_equal = is_dtype_equal(values.dtype, categories.dtype) if dtype_equal: # To prevent errone...
[ "def", "_get_codes_for_values", "(", "values", ",", "categories", ")", ":", "from", "pandas", ".", "core", ".", "algorithms", "import", "_get_data_algo", ",", "_hashtables", "dtype_equal", "=", "is_dtype_equal", "(", "values", ".", "dtype", ",", "categories", "....
utility routine to turn values into codes given the specified categories
[ "utility", "routine", "to", "turn", "values", "into", "codes", "given", "the", "specified", "categories" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2549-L2582
19,797
pandas-dev/pandas
pandas/core/arrays/categorical.py
_recode_for_categories
def _recode_for_categories(codes, old_categories, new_categories): """ Convert a set of codes for to a new set of categories Parameters ---------- codes : array old_categories, new_categories : Index Returns ------- new_codes : array Examples -------- >>> old_cat = pd....
python
def _recode_for_categories(codes, old_categories, new_categories): """ Convert a set of codes for to a new set of categories Parameters ---------- codes : array old_categories, new_categories : Index Returns ------- new_codes : array Examples -------- >>> old_cat = pd....
[ "def", "_recode_for_categories", "(", "codes", ",", "old_categories", ",", "new_categories", ")", ":", "from", "pandas", ".", "core", ".", "algorithms", "import", "take_1d", "if", "len", "(", "old_categories", ")", "==", "0", ":", "# All null anyway, so just retai...
Convert a set of codes for to a new set of categories Parameters ---------- codes : array old_categories, new_categories : Index Returns ------- new_codes : array Examples -------- >>> old_cat = pd.Index(['b', 'a', 'c']) >>> new_cat = pd.Index(['a', 'b']) >>> codes = n...
[ "Convert", "a", "set", "of", "codes", "for", "to", "a", "new", "set", "of", "categories" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2585-L2617
19,798
pandas-dev/pandas
pandas/core/arrays/categorical.py
_factorize_from_iterable
def _factorize_from_iterable(values): """ Factorize an input `values` into `categories` and `codes`. Preserves categorical dtype in `categories`. *This is an internal function* Parameters ---------- values : list-like Returns ------- codes : ndarray categories : Index ...
python
def _factorize_from_iterable(values): """ Factorize an input `values` into `categories` and `codes`. Preserves categorical dtype in `categories`. *This is an internal function* Parameters ---------- values : list-like Returns ------- codes : ndarray categories : Index ...
[ "def", "_factorize_from_iterable", "(", "values", ")", ":", "from", "pandas", ".", "core", ".", "indexes", ".", "category", "import", "CategoricalIndex", "if", "not", "is_list_like", "(", "values", ")", ":", "raise", "TypeError", "(", "\"Input must be list-like\""...
Factorize an input `values` into `categories` and `codes`. Preserves categorical dtype in `categories`. *This is an internal function* Parameters ---------- values : list-like Returns ------- codes : ndarray categories : Index If `values` has a categorical dtype, then `cat...
[ "Factorize", "an", "input", "values", "into", "categories", "and", "codes", ".", "Preserves", "categorical", "dtype", "in", "categories", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2635-L2670
19,799
pandas-dev/pandas
pandas/core/arrays/categorical.py
_factorize_from_iterables
def _factorize_from_iterables(iterables): """ A higher-level wrapper over `_factorize_from_iterable`. *This is an internal function* Parameters ---------- iterables : list-like of list-likes Returns ------- codes_list : list of ndarrays categories_list : list of Indexes N...
python
def _factorize_from_iterables(iterables): """ A higher-level wrapper over `_factorize_from_iterable`. *This is an internal function* Parameters ---------- iterables : list-like of list-likes Returns ------- codes_list : list of ndarrays categories_list : list of Indexes N...
[ "def", "_factorize_from_iterables", "(", "iterables", ")", ":", "if", "len", "(", "iterables", ")", "==", "0", ":", "# For consistency, it should return a list of 2 lists.", "return", "[", "[", "]", ",", "[", "]", "]", "return", "map", "(", "list", ",", "lzip"...
A higher-level wrapper over `_factorize_from_iterable`. *This is an internal function* Parameters ---------- iterables : list-like of list-likes Returns ------- codes_list : list of ndarrays categories_list : list of Indexes Notes ----- See `_factorize_from_iterable` for ...
[ "A", "higher", "-", "level", "wrapper", "over", "_factorize_from_iterable", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2673-L2695