repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pandas-dev/pandas | pandas/core/arrays/_ranges.py | _generate_range_overflow_safe_signed | def _generate_range_overflow_safe_signed(endpoint, periods, stride, side):
"""
A special case for _generate_range_overflow_safe where `periods * stride`
can be calculated without overflowing int64 bounds.
"""
assert side in ['start', 'end']
if side == 'end':
stride *= -1
with np.err... | python | def _generate_range_overflow_safe_signed(endpoint, periods, stride, side):
"""
A special case for _generate_range_overflow_safe where `periods * stride`
can be calculated without overflowing int64 bounds.
"""
assert side in ['start', 'end']
if side == 'end':
stride *= -1
with np.err... | [
"def",
"_generate_range_overflow_safe_signed",
"(",
"endpoint",
",",
"periods",
",",
"stride",
",",
"side",
")",
":",
"assert",
"side",
"in",
"[",
"'start'",
",",
"'end'",
"]",
"if",
"side",
"==",
"'end'",
":",
"stride",
"*=",
"-",
"1",
"with",
"np",
"."... | A special case for _generate_range_overflow_safe where `periods * stride`
can be calculated without overflowing int64 bounds. | [
"A",
"special",
"case",
"for",
"_generate_range_overflow_safe",
"where",
"periods",
"*",
"stride",
"can",
"be",
"calculated",
"without",
"overflowing",
"int64",
"bounds",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/_ranges.py#L149-L187 | train |
pandas-dev/pandas | pandas/_config/localization.py | set_locale | def set_locale(new_locale, lc_var=locale.LC_ALL):
"""
Context manager for temporarily setting a locale.
Parameters
----------
new_locale : str or tuple
A string of the form <language_country>.<encoding>. For example to set
the current locale to US English with a UTF8 encoding, you w... | python | def set_locale(new_locale, lc_var=locale.LC_ALL):
"""
Context manager for temporarily setting a locale.
Parameters
----------
new_locale : str or tuple
A string of the form <language_country>.<encoding>. For example to set
the current locale to US English with a UTF8 encoding, you w... | [
"def",
"set_locale",
"(",
"new_locale",
",",
"lc_var",
"=",
"locale",
".",
"LC_ALL",
")",
":",
"current_locale",
"=",
"locale",
".",
"getlocale",
"(",
")",
"try",
":",
"locale",
".",
"setlocale",
"(",
"lc_var",
",",
"new_locale",
")",
"normalized_locale",
... | Context manager for temporarily setting a locale.
Parameters
----------
new_locale : str or tuple
A string of the form <language_country>.<encoding>. For example to set
the current locale to US English with a UTF8 encoding, you would pass
"en_US.UTF-8".
lc_var : int, default `lo... | [
"Context",
"manager",
"for",
"temporarily",
"setting",
"a",
"locale",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/localization.py#L15-L44 | train |
pandas-dev/pandas | pandas/_config/localization.py | can_set_locale | def can_set_locale(lc, lc_var=locale.LC_ALL):
"""
Check to see if we can set a locale, and subsequently get the locale,
without raising an Exception.
Parameters
----------
lc : str
The locale to attempt to set.
lc_var : int, default `locale.LC_ALL`
The category of the locale... | python | def can_set_locale(lc, lc_var=locale.LC_ALL):
"""
Check to see if we can set a locale, and subsequently get the locale,
without raising an Exception.
Parameters
----------
lc : str
The locale to attempt to set.
lc_var : int, default `locale.LC_ALL`
The category of the locale... | [
"def",
"can_set_locale",
"(",
"lc",
",",
"lc_var",
"=",
"locale",
".",
"LC_ALL",
")",
":",
"try",
":",
"with",
"set_locale",
"(",
"lc",
",",
"lc_var",
"=",
"lc_var",
")",
":",
"pass",
"except",
"(",
"ValueError",
",",
"locale",
".",
"Error",
")",
":"... | Check to see if we can set a locale, and subsequently get the locale,
without raising an Exception.
Parameters
----------
lc : str
The locale to attempt to set.
lc_var : int, default `locale.LC_ALL`
The category of the locale being set.
Returns
-------
is_valid : bool
... | [
"Check",
"to",
"see",
"if",
"we",
"can",
"set",
"a",
"locale",
"and",
"subsequently",
"get",
"the",
"locale",
"without",
"raising",
"an",
"Exception",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/localization.py#L47-L72 | train |
pandas-dev/pandas | pandas/_config/localization.py | _valid_locales | def _valid_locales(locales, normalize):
"""
Return a list of normalized locales that do not throw an ``Exception``
when set.
Parameters
----------
locales : str
A string where each locale is separated by a newline.
normalize : bool
Whether to call ``locale.normalize`` on eac... | python | def _valid_locales(locales, normalize):
"""
Return a list of normalized locales that do not throw an ``Exception``
when set.
Parameters
----------
locales : str
A string where each locale is separated by a newline.
normalize : bool
Whether to call ``locale.normalize`` on eac... | [
"def",
"_valid_locales",
"(",
"locales",
",",
"normalize",
")",
":",
"if",
"normalize",
":",
"normalizer",
"=",
"lambda",
"x",
":",
"locale",
".",
"normalize",
"(",
"x",
".",
"strip",
"(",
")",
")",
"else",
":",
"normalizer",
"=",
"lambda",
"x",
":",
... | Return a list of normalized locales that do not throw an ``Exception``
when set.
Parameters
----------
locales : str
A string where each locale is separated by a newline.
normalize : bool
Whether to call ``locale.normalize`` on each locale.
Returns
-------
valid_locales... | [
"Return",
"a",
"list",
"of",
"normalized",
"locales",
"that",
"do",
"not",
"throw",
"an",
"Exception",
"when",
"set",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/localization.py#L75-L97 | train |
pandas-dev/pandas | pandas/_config/localization.py | get_locales | def get_locales(prefix=None, normalize=True,
locale_getter=_default_locale_getter):
"""
Get all the locales that are available on the system.
Parameters
----------
prefix : str
If not ``None`` then return only those locales with the prefix
provided. For example to ge... | python | def get_locales(prefix=None, normalize=True,
locale_getter=_default_locale_getter):
"""
Get all the locales that are available on the system.
Parameters
----------
prefix : str
If not ``None`` then return only those locales with the prefix
provided. For example to ge... | [
"def",
"get_locales",
"(",
"prefix",
"=",
"None",
",",
"normalize",
"=",
"True",
",",
"locale_getter",
"=",
"_default_locale_getter",
")",
":",
"try",
":",
"raw_locales",
"=",
"locale_getter",
"(",
")",
"except",
"Exception",
":",
"return",
"None",
"try",
":... | Get all the locales that are available on the system.
Parameters
----------
prefix : str
If not ``None`` then return only those locales with the prefix
provided. For example to get all English language locales (those that
start with ``"en"``), pass ``prefix="en"``.
normalize : b... | [
"Get",
"all",
"the",
"locales",
"that",
"are",
"available",
"on",
"the",
"system",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/_config/localization.py#L109-L162 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | ensure_float | def ensure_float(arr):
"""
Ensure that an array object has a float dtype if possible.
Parameters
----------
arr : array-like
The array whose data type we want to enforce as float.
Returns
-------
float_arr : The original array cast to the float dtype if
possible... | python | def ensure_float(arr):
"""
Ensure that an array object has a float dtype if possible.
Parameters
----------
arr : array-like
The array whose data type we want to enforce as float.
Returns
-------
float_arr : The original array cast to the float dtype if
possible... | [
"def",
"ensure_float",
"(",
"arr",
")",
":",
"if",
"issubclass",
"(",
"arr",
".",
"dtype",
".",
"type",
",",
"(",
"np",
".",
"integer",
",",
"np",
".",
"bool_",
")",
")",
":",
"arr",
"=",
"arr",
".",
"astype",
"(",
"float",
")",
"return",
"arr"
] | Ensure that an array object has a float dtype if possible.
Parameters
----------
arr : array-like
The array whose data type we want to enforce as float.
Returns
-------
float_arr : The original array cast to the float dtype if
possible. Otherwise, the original array is ... | [
"Ensure",
"that",
"an",
"array",
"object",
"has",
"a",
"float",
"dtype",
"if",
"possible",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L40-L57 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | ensure_categorical | def ensure_categorical(arr):
"""
Ensure that an array-like object is a Categorical (if not already).
Parameters
----------
arr : array-like
The array that we want to convert into a Categorical.
Returns
-------
cat_arr : The original array cast as a Categorical. If it already
... | python | def ensure_categorical(arr):
"""
Ensure that an array-like object is a Categorical (if not already).
Parameters
----------
arr : array-like
The array that we want to convert into a Categorical.
Returns
-------
cat_arr : The original array cast as a Categorical. If it already
... | [
"def",
"ensure_categorical",
"(",
"arr",
")",
":",
"if",
"not",
"is_categorical",
"(",
"arr",
")",
":",
"from",
"pandas",
"import",
"Categorical",
"arr",
"=",
"Categorical",
"(",
"arr",
")",
"return",
"arr"
] | Ensure that an array-like object is a Categorical (if not already).
Parameters
----------
arr : array-like
The array that we want to convert into a Categorical.
Returns
-------
cat_arr : The original array cast as a Categorical. If it already
is a Categorical, we return a... | [
"Ensure",
"that",
"an",
"array",
"-",
"like",
"object",
"is",
"a",
"Categorical",
"(",
"if",
"not",
"already",
")",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L69-L87 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | ensure_int64_or_float64 | def ensure_int64_or_float64(arr, copy=False):
"""
Ensure that an dtype array of some integer dtype
has an int64 dtype if possible
If it's not possible, potentially because of overflow,
convert the array to float64 instead.
Parameters
----------
arr : array-like
The array whose... | python | def ensure_int64_or_float64(arr, copy=False):
"""
Ensure that an dtype array of some integer dtype
has an int64 dtype if possible
If it's not possible, potentially because of overflow,
convert the array to float64 instead.
Parameters
----------
arr : array-like
The array whose... | [
"def",
"ensure_int64_or_float64",
"(",
"arr",
",",
"copy",
"=",
"False",
")",
":",
"try",
":",
"return",
"arr",
".",
"astype",
"(",
"'int64'",
",",
"copy",
"=",
"copy",
",",
"casting",
"=",
"'safe'",
")",
"except",
"TypeError",
":",
"return",
"arr",
".... | Ensure that an dtype array of some integer dtype
has an int64 dtype if possible
If it's not possible, potentially because of overflow,
convert the array to float64 instead.
Parameters
----------
arr : array-like
The array whose data type we want to enforce.
copy: boolean
... | [
"Ensure",
"that",
"an",
"dtype",
"array",
"of",
"some",
"integer",
"dtype",
"has",
"an",
"int64",
"dtype",
"if",
"possible",
"If",
"it",
"s",
"not",
"possible",
"potentially",
"because",
"of",
"overflow",
"convert",
"the",
"array",
"to",
"float64",
"instead"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L90-L114 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | classes_and_not_datetimelike | def classes_and_not_datetimelike(*klasses):
"""
evaluate if the tipo is a subclass of the klasses
and not a datetimelike
"""
return lambda tipo: (issubclass(tipo, klasses) and
not issubclass(tipo, (np.datetime64, np.timedelta64))) | python | def classes_and_not_datetimelike(*klasses):
"""
evaluate if the tipo is a subclass of the klasses
and not a datetimelike
"""
return lambda tipo: (issubclass(tipo, klasses) and
not issubclass(tipo, (np.datetime64, np.timedelta64))) | [
"def",
"classes_and_not_datetimelike",
"(",
"*",
"klasses",
")",
":",
"return",
"lambda",
"tipo",
":",
"(",
"issubclass",
"(",
"tipo",
",",
"klasses",
")",
"and",
"not",
"issubclass",
"(",
"tipo",
",",
"(",
"np",
".",
"datetime64",
",",
"np",
".",
"timed... | evaluate if the tipo is a subclass of the klasses
and not a datetimelike | [
"evaluate",
"if",
"the",
"tipo",
"is",
"a",
"subclass",
"of",
"the",
"klasses",
"and",
"not",
"a",
"datetimelike"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L122-L128 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_sparse | def is_sparse(arr):
"""
Check whether an array-like is a 1-D pandas sparse array.
Check that the one-dimensional array-like is a pandas sparse array.
Returns True if it is a pandas sparse array, not another type of
sparse array.
Parameters
----------
arr : array-like
Array-like... | python | def is_sparse(arr):
"""
Check whether an array-like is a 1-D pandas sparse array.
Check that the one-dimensional array-like is a pandas sparse array.
Returns True if it is a pandas sparse array, not another type of
sparse array.
Parameters
----------
arr : array-like
Array-like... | [
"def",
"is_sparse",
"(",
"arr",
")",
":",
"from",
"pandas",
".",
"core",
".",
"arrays",
".",
"sparse",
"import",
"SparseDtype",
"dtype",
"=",
"getattr",
"(",
"arr",
",",
"'dtype'",
",",
"arr",
")",
"return",
"isinstance",
"(",
"dtype",
",",
"SparseDtype"... | Check whether an array-like is a 1-D pandas sparse array.
Check that the one-dimensional array-like is a pandas sparse array.
Returns True if it is a pandas sparse array, not another type of
sparse array.
Parameters
----------
arr : array-like
Array-like to check.
Returns
----... | [
"Check",
"whether",
"an",
"array",
"-",
"like",
"is",
"a",
"1",
"-",
"D",
"pandas",
"sparse",
"array",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L161-L220 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_scipy_sparse | def is_scipy_sparse(arr):
"""
Check whether an array-like is a scipy.sparse.spmatrix instance.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a scipy.sparse.spmatrix instance.
Notes
-----... | python | def is_scipy_sparse(arr):
"""
Check whether an array-like is a scipy.sparse.spmatrix instance.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a scipy.sparse.spmatrix instance.
Notes
-----... | [
"def",
"is_scipy_sparse",
"(",
"arr",
")",
":",
"global",
"_is_scipy_sparse",
"if",
"_is_scipy_sparse",
"is",
"None",
":",
"try",
":",
"from",
"scipy",
".",
"sparse",
"import",
"issparse",
"as",
"_is_scipy_sparse",
"except",
"ImportError",
":",
"_is_scipy_sparse",... | Check whether an array-like is a scipy.sparse.spmatrix instance.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a scipy.sparse.spmatrix instance.
Notes
-----
If scipy is not installed, this f... | [
"Check",
"whether",
"an",
"array",
"-",
"like",
"is",
"a",
"scipy",
".",
"sparse",
".",
"spmatrix",
"instance",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L223-L260 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_offsetlike | def is_offsetlike(arr_or_obj):
"""
Check if obj or all elements of list-like is DateOffset
Parameters
----------
arr_or_obj : object
Returns
-------
boolean
Whether the object is a DateOffset or listlike of DatetOffsets
Examples
--------
>>> is_offsetlike(pd.DateOf... | python | def is_offsetlike(arr_or_obj):
"""
Check if obj or all elements of list-like is DateOffset
Parameters
----------
arr_or_obj : object
Returns
-------
boolean
Whether the object is a DateOffset or listlike of DatetOffsets
Examples
--------
>>> is_offsetlike(pd.DateOf... | [
"def",
"is_offsetlike",
"(",
"arr_or_obj",
")",
":",
"if",
"isinstance",
"(",
"arr_or_obj",
",",
"ABCDateOffset",
")",
":",
"return",
"True",
"elif",
"(",
"is_list_like",
"(",
"arr_or_obj",
")",
"and",
"len",
"(",
"arr_or_obj",
")",
"and",
"is_object_dtype",
... | Check if obj or all elements of list-like is DateOffset
Parameters
----------
arr_or_obj : object
Returns
-------
boolean
Whether the object is a DateOffset or listlike of DatetOffsets
Examples
--------
>>> is_offsetlike(pd.DateOffset(days=1))
True
>>> is_offsetlik... | [
"Check",
"if",
"obj",
"or",
"all",
"elements",
"of",
"list",
"-",
"like",
"is",
"DateOffset"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L343-L372 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_period | def is_period(arr):
"""
Check whether an array-like is a periodical index.
.. deprecated:: 0.24.0
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a periodical index.
Examples
--------... | python | def is_period(arr):
"""
Check whether an array-like is a periodical index.
.. deprecated:: 0.24.0
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a periodical index.
Examples
--------... | [
"def",
"is_period",
"(",
"arr",
")",
":",
"warnings",
".",
"warn",
"(",
"\"'is_period' is deprecated and will be removed in a future \"",
"\"version. Use 'is_period_dtype' or is_period_arraylike' \"",
"\"instead.\"",
",",
"FutureWarning",
",",
"stacklevel",
"=",
"2",
")",
"r... | Check whether an array-like is a periodical index.
.. deprecated:: 0.24.0
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a periodical index.
Examples
--------
>>> is_period([1, 2, 3])
... | [
"Check",
"whether",
"an",
"array",
"-",
"like",
"is",
"a",
"periodical",
"index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L375-L405 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_string_dtype | def is_string_dtype(arr_or_dtype):
"""
Check whether the provided array or dtype is of the string dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of the string dtype.
E... | python | def is_string_dtype(arr_or_dtype):
"""
Check whether the provided array or dtype is of the string dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of the string dtype.
E... | [
"def",
"is_string_dtype",
"(",
"arr_or_dtype",
")",
":",
"# TODO: gh-15585: consider making the checks stricter.",
"def",
"condition",
"(",
"dtype",
")",
":",
"return",
"dtype",
".",
"kind",
"in",
"(",
"'O'",
",",
"'S'",
",",
"'U'",
")",
"and",
"not",
"is_period... | Check whether the provided array or dtype is of the string dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of the string dtype.
Examples
--------
>>> is_string_dtype(st... | [
"Check",
"whether",
"the",
"provided",
"array",
"or",
"dtype",
"is",
"of",
"the",
"string",
"dtype",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L611-L643 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_period_arraylike | def is_period_arraylike(arr):
"""
Check whether an array-like is a periodical array-like or PeriodIndex.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a periodical array-like or
PeriodInd... | python | def is_period_arraylike(arr):
"""
Check whether an array-like is a periodical array-like or PeriodIndex.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a periodical array-like or
PeriodInd... | [
"def",
"is_period_arraylike",
"(",
"arr",
")",
":",
"if",
"isinstance",
"(",
"arr",
",",
"(",
"ABCPeriodIndex",
",",
"ABCPeriodArray",
")",
")",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"arr",
",",
"(",
"np",
".",
"ndarray",
",",
"ABCSeries",
")... | Check whether an array-like is a periodical array-like or PeriodIndex.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a periodical array-like or
PeriodIndex instance.
Examples
--------
... | [
"Check",
"whether",
"an",
"array",
"-",
"like",
"is",
"a",
"periodical",
"array",
"-",
"like",
"or",
"PeriodIndex",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L646-L675 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_datetime_arraylike | def is_datetime_arraylike(arr):
"""
Check whether an array-like is a datetime array-like or DatetimeIndex.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a datetime array-like or
DatetimeI... | python | def is_datetime_arraylike(arr):
"""
Check whether an array-like is a datetime array-like or DatetimeIndex.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a datetime array-like or
DatetimeI... | [
"def",
"is_datetime_arraylike",
"(",
"arr",
")",
":",
"if",
"isinstance",
"(",
"arr",
",",
"ABCDatetimeIndex",
")",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"arr",
",",
"(",
"np",
".",
"ndarray",
",",
"ABCSeries",
")",
")",
":",
"return",
"(",
... | Check whether an array-like is a datetime array-like or DatetimeIndex.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a datetime array-like or
DatetimeIndex.
Examples
--------
>>> is_... | [
"Check",
"whether",
"an",
"array",
"-",
"like",
"is",
"a",
"datetime",
"array",
"-",
"like",
"or",
"DatetimeIndex",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L678-L708 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_datetimelike | def is_datetimelike(arr):
"""
Check whether an array-like is a datetime-like array-like.
Acceptable datetime-like objects are (but not limited to) datetime
indices, periodic indices, and timedelta indices.
Parameters
----------
arr : array-like
The array-like to check.
Returns... | python | def is_datetimelike(arr):
"""
Check whether an array-like is a datetime-like array-like.
Acceptable datetime-like objects are (but not limited to) datetime
indices, periodic indices, and timedelta indices.
Parameters
----------
arr : array-like
The array-like to check.
Returns... | [
"def",
"is_datetimelike",
"(",
"arr",
")",
":",
"return",
"(",
"is_datetime64_dtype",
"(",
"arr",
")",
"or",
"is_datetime64tz_dtype",
"(",
"arr",
")",
"or",
"is_timedelta64_dtype",
"(",
"arr",
")",
"or",
"isinstance",
"(",
"arr",
",",
"ABCPeriodIndex",
")",
... | Check whether an array-like is a datetime-like array-like.
Acceptable datetime-like objects are (but not limited to) datetime
indices, periodic indices, and timedelta indices.
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Wheth... | [
"Check",
"whether",
"an",
"array",
"-",
"like",
"is",
"a",
"datetime",
"-",
"like",
"array",
"-",
"like",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L711-L753 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_dtype_equal | def is_dtype_equal(source, target):
"""
Check if two dtypes are equal.
Parameters
----------
source : The first dtype to compare
target : The second dtype to compare
Returns
----------
boolean
Whether or not the two dtypes are equal.
Examples
--------
>>> is_dt... | python | def is_dtype_equal(source, target):
"""
Check if two dtypes are equal.
Parameters
----------
source : The first dtype to compare
target : The second dtype to compare
Returns
----------
boolean
Whether or not the two dtypes are equal.
Examples
--------
>>> is_dt... | [
"def",
"is_dtype_equal",
"(",
"source",
",",
"target",
")",
":",
"try",
":",
"source",
"=",
"_get_dtype",
"(",
"source",
")",
"target",
"=",
"_get_dtype",
"(",
"target",
")",
"return",
"source",
"==",
"target",
"except",
"(",
"TypeError",
",",
"AttributeEr... | Check if two dtypes are equal.
Parameters
----------
source : The first dtype to compare
target : The second dtype to compare
Returns
----------
boolean
Whether or not the two dtypes are equal.
Examples
--------
>>> is_dtype_equal(int, float)
False
>>> is_dtype... | [
"Check",
"if",
"two",
"dtypes",
"are",
"equal",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L756-L792 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_dtype_union_equal | def is_dtype_union_equal(source, target):
"""
Check whether two arrays have compatible dtypes to do a union.
numpy types are checked with ``is_dtype_equal``. Extension types are
checked separately.
Parameters
----------
source : The first dtype to compare
target : The second dtype to co... | python | def is_dtype_union_equal(source, target):
"""
Check whether two arrays have compatible dtypes to do a union.
numpy types are checked with ``is_dtype_equal``. Extension types are
checked separately.
Parameters
----------
source : The first dtype to compare
target : The second dtype to co... | [
"def",
"is_dtype_union_equal",
"(",
"source",
",",
"target",
")",
":",
"source",
"=",
"_get_dtype",
"(",
"source",
")",
"target",
"=",
"_get_dtype",
"(",
"target",
")",
"if",
"is_categorical_dtype",
"(",
"source",
")",
"and",
"is_categorical_dtype",
"(",
"targ... | Check whether two arrays have compatible dtypes to do a union.
numpy types are checked with ``is_dtype_equal``. Extension types are
checked separately.
Parameters
----------
source : The first dtype to compare
target : The second dtype to compare
Returns
----------
boolean
... | [
"Check",
"whether",
"two",
"arrays",
"have",
"compatible",
"dtypes",
"to",
"do",
"a",
"union",
".",
"numpy",
"types",
"are",
"checked",
"with",
"is_dtype_equal",
".",
"Extension",
"types",
"are",
"checked",
"separately",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L795-L827 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_datetime64_ns_dtype | def is_datetime64_ns_dtype(arr_or_dtype):
"""
Check whether the provided array or dtype is of the datetime64[ns] dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of the datet... | python | def is_datetime64_ns_dtype(arr_or_dtype):
"""
Check whether the provided array or dtype is of the datetime64[ns] dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of the datet... | [
"def",
"is_datetime64_ns_dtype",
"(",
"arr_or_dtype",
")",
":",
"if",
"arr_or_dtype",
"is",
"None",
":",
"return",
"False",
"try",
":",
"tipo",
"=",
"_get_dtype",
"(",
"arr_or_dtype",
")",
"except",
"TypeError",
":",
"if",
"is_datetime64tz_dtype",
"(",
"arr_or_d... | Check whether the provided array or dtype is of the datetime64[ns] dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of the datetime64[ns] dtype.
Examples
--------
>>> is... | [
"Check",
"whether",
"the",
"provided",
"array",
"or",
"dtype",
"is",
"of",
"the",
"datetime64",
"[",
"ns",
"]",
"dtype",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1135-L1182 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_numeric_v_string_like | def is_numeric_v_string_like(a, b):
"""
Check if we are comparing a string-like object to a numeric ndarray.
NumPy doesn't like to compare such objects, especially numeric arrays
and scalar string-likes.
Parameters
----------
a : array-like, scalar
The first object to check.
b ... | python | def is_numeric_v_string_like(a, b):
"""
Check if we are comparing a string-like object to a numeric ndarray.
NumPy doesn't like to compare such objects, especially numeric arrays
and scalar string-likes.
Parameters
----------
a : array-like, scalar
The first object to check.
b ... | [
"def",
"is_numeric_v_string_like",
"(",
"a",
",",
"b",
")",
":",
"is_a_array",
"=",
"isinstance",
"(",
"a",
",",
"np",
".",
"ndarray",
")",
"is_b_array",
"=",
"isinstance",
"(",
"b",
",",
"np",
".",
"ndarray",
")",
"is_a_numeric_array",
"=",
"is_a_array",
... | Check if we are comparing a string-like object to a numeric ndarray.
NumPy doesn't like to compare such objects, especially numeric arrays
and scalar string-likes.
Parameters
----------
a : array-like, scalar
The first object to check.
b : array-like, scalar
The second object t... | [
"Check",
"if",
"we",
"are",
"comparing",
"a",
"string",
"-",
"like",
"object",
"to",
"a",
"numeric",
"ndarray",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1280-L1335 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_datetimelike_v_numeric | def is_datetimelike_v_numeric(a, b):
"""
Check if we are comparing a datetime-like object to a numeric object.
By "numeric," we mean an object that is either of an int or float dtype.
Parameters
----------
a : array-like, scalar
The first object to check.
b : array-like, scalar
... | python | def is_datetimelike_v_numeric(a, b):
"""
Check if we are comparing a datetime-like object to a numeric object.
By "numeric," we mean an object that is either of an int or float dtype.
Parameters
----------
a : array-like, scalar
The first object to check.
b : array-like, scalar
... | [
"def",
"is_datetimelike_v_numeric",
"(",
"a",
",",
"b",
")",
":",
"if",
"not",
"hasattr",
"(",
"a",
",",
"'dtype'",
")",
":",
"a",
"=",
"np",
".",
"asarray",
"(",
"a",
")",
"if",
"not",
"hasattr",
"(",
"b",
",",
"'dtype'",
")",
":",
"b",
"=",
"... | Check if we are comparing a datetime-like object to a numeric object.
By "numeric," we mean an object that is either of an int or float dtype.
Parameters
----------
a : array-like, scalar
The first object to check.
b : array-like, scalar
The second object to check.
Returns
... | [
"Check",
"if",
"we",
"are",
"comparing",
"a",
"datetime",
"-",
"like",
"object",
"to",
"a",
"numeric",
"object",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1338-L1393 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_datetimelike_v_object | def is_datetimelike_v_object(a, b):
"""
Check if we are comparing a datetime-like object to an object instance.
Parameters
----------
a : array-like, scalar
The first object to check.
b : array-like, scalar
The second object to check.
Returns
-------
boolean
... | python | def is_datetimelike_v_object(a, b):
"""
Check if we are comparing a datetime-like object to an object instance.
Parameters
----------
a : array-like, scalar
The first object to check.
b : array-like, scalar
The second object to check.
Returns
-------
boolean
... | [
"def",
"is_datetimelike_v_object",
"(",
"a",
",",
"b",
")",
":",
"if",
"not",
"hasattr",
"(",
"a",
",",
"'dtype'",
")",
":",
"a",
"=",
"np",
".",
"asarray",
"(",
"a",
")",
"if",
"not",
"hasattr",
"(",
"b",
",",
"'dtype'",
")",
":",
"b",
"=",
"n... | Check if we are comparing a datetime-like object to an object instance.
Parameters
----------
a : array-like, scalar
The first object to check.
b : array-like, scalar
The second object to check.
Returns
-------
boolean
Whether we return a comparing a datetime-like t... | [
"Check",
"if",
"we",
"are",
"comparing",
"a",
"datetime",
"-",
"like",
"object",
"to",
"an",
"object",
"instance",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1396-L1446 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | needs_i8_conversion | def needs_i8_conversion(arr_or_dtype):
"""
Check whether the array or dtype should be converted to int64.
An array-like or dtype "needs" such a conversion if the array-like
or dtype is of a datetime-like dtype
Parameters
----------
arr_or_dtype : array-like
The array or dtype to ch... | python | def needs_i8_conversion(arr_or_dtype):
"""
Check whether the array or dtype should be converted to int64.
An array-like or dtype "needs" such a conversion if the array-like
or dtype is of a datetime-like dtype
Parameters
----------
arr_or_dtype : array-like
The array or dtype to ch... | [
"def",
"needs_i8_conversion",
"(",
"arr_or_dtype",
")",
":",
"if",
"arr_or_dtype",
"is",
"None",
":",
"return",
"False",
"return",
"(",
"is_datetime_or_timedelta_dtype",
"(",
"arr_or_dtype",
")",
"or",
"is_datetime64tz_dtype",
"(",
"arr_or_dtype",
")",
"or",
"is_per... | Check whether the array or dtype should be converted to int64.
An array-like or dtype "needs" such a conversion if the array-like
or dtype is of a datetime-like dtype
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
W... | [
"Check",
"whether",
"the",
"array",
"or",
"dtype",
"should",
"be",
"converted",
"to",
"int64",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1449-L1488 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_bool_dtype | def is_bool_dtype(arr_or_dtype):
"""
Check whether the provided array or dtype is of a boolean dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of a boolean dtype.
Notes... | python | def is_bool_dtype(arr_or_dtype):
"""
Check whether the provided array or dtype is of a boolean dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of a boolean dtype.
Notes... | [
"def",
"is_bool_dtype",
"(",
"arr_or_dtype",
")",
":",
"if",
"arr_or_dtype",
"is",
"None",
":",
"return",
"False",
"try",
":",
"dtype",
"=",
"_get_dtype",
"(",
"arr_or_dtype",
")",
"except",
"TypeError",
":",
"return",
"False",
"if",
"isinstance",
"(",
"arr_... | Check whether the provided array or dtype is of a boolean dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of a boolean dtype.
Notes
-----
An ExtensionArray is considere... | [
"Check",
"whether",
"the",
"provided",
"array",
"or",
"dtype",
"is",
"of",
"a",
"boolean",
"dtype",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1600-L1663 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_extension_type | def is_extension_type(arr):
"""
Check whether an array-like is of a pandas extension class instance.
Extension classes include categoricals, pandas sparse objects (i.e.
classes represented within the pandas library and not ones external
to it like scipy sparse matrices), and datetime-like arrays.
... | python | def is_extension_type(arr):
"""
Check whether an array-like is of a pandas extension class instance.
Extension classes include categoricals, pandas sparse objects (i.e.
classes represented within the pandas library and not ones external
to it like scipy sparse matrices), and datetime-like arrays.
... | [
"def",
"is_extension_type",
"(",
"arr",
")",
":",
"if",
"is_categorical",
"(",
"arr",
")",
":",
"return",
"True",
"elif",
"is_sparse",
"(",
"arr",
")",
":",
"return",
"True",
"elif",
"is_datetime64tz_dtype",
"(",
"arr",
")",
":",
"return",
"True",
"return"... | Check whether an array-like is of a pandas extension class instance.
Extension classes include categoricals, pandas sparse objects (i.e.
classes represented within the pandas library and not ones external
to it like scipy sparse matrices), and datetime-like arrays.
Parameters
----------
arr : ... | [
"Check",
"whether",
"an",
"array",
"-",
"like",
"is",
"of",
"a",
"pandas",
"extension",
"class",
"instance",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1666-L1722 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | is_extension_array_dtype | def is_extension_array_dtype(arr_or_dtype):
"""
Check if an object is a pandas extension array type.
See the :ref:`Use Guide <extending.extension-types>` for more.
Parameters
----------
arr_or_dtype : object
For array-like input, the ``.dtype`` attribute will
be extracted.
... | python | def is_extension_array_dtype(arr_or_dtype):
"""
Check if an object is a pandas extension array type.
See the :ref:`Use Guide <extending.extension-types>` for more.
Parameters
----------
arr_or_dtype : object
For array-like input, the ``.dtype`` attribute will
be extracted.
... | [
"def",
"is_extension_array_dtype",
"(",
"arr_or_dtype",
")",
":",
"dtype",
"=",
"getattr",
"(",
"arr_or_dtype",
",",
"'dtype'",
",",
"arr_or_dtype",
")",
"return",
"(",
"isinstance",
"(",
"dtype",
",",
"ExtensionDtype",
")",
"or",
"registry",
".",
"find",
"(",... | Check if an object is a pandas extension array type.
See the :ref:`Use Guide <extending.extension-types>` for more.
Parameters
----------
arr_or_dtype : object
For array-like input, the ``.dtype`` attribute will
be extracted.
Returns
-------
bool
Whether the `arr_o... | [
"Check",
"if",
"an",
"object",
"is",
"a",
"pandas",
"extension",
"array",
"type",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1725-L1772 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | _is_dtype | def _is_dtype(arr_or_dtype, condition):
"""
Return a boolean if the condition is satisfied for the arr_or_dtype.
Parameters
----------
arr_or_dtype : array-like, str, np.dtype, or ExtensionArrayType
The array-like or dtype object whose dtype we want to extract.
condition : callable[Unio... | python | def _is_dtype(arr_or_dtype, condition):
"""
Return a boolean if the condition is satisfied for the arr_or_dtype.
Parameters
----------
arr_or_dtype : array-like, str, np.dtype, or ExtensionArrayType
The array-like or dtype object whose dtype we want to extract.
condition : callable[Unio... | [
"def",
"_is_dtype",
"(",
"arr_or_dtype",
",",
"condition",
")",
":",
"if",
"arr_or_dtype",
"is",
"None",
":",
"return",
"False",
"try",
":",
"dtype",
"=",
"_get_dtype",
"(",
"arr_or_dtype",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
",",
"UnicodeEnc... | Return a boolean if the condition is satisfied for the arr_or_dtype.
Parameters
----------
arr_or_dtype : array-like, str, np.dtype, or ExtensionArrayType
The array-like or dtype object whose dtype we want to extract.
condition : callable[Union[np.dtype, ExtensionDtype]]
Returns
------... | [
"Return",
"a",
"boolean",
"if",
"the",
"condition",
"is",
"satisfied",
"for",
"the",
"arr_or_dtype",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1808-L1830 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | _get_dtype | def _get_dtype(arr_or_dtype):
"""
Get the dtype instance associated with an array
or dtype object.
Parameters
----------
arr_or_dtype : array-like
The array-like or dtype object whose dtype we want to extract.
Returns
-------
obj_dtype : The extract dtype instance from the
... | python | def _get_dtype(arr_or_dtype):
"""
Get the dtype instance associated with an array
or dtype object.
Parameters
----------
arr_or_dtype : array-like
The array-like or dtype object whose dtype we want to extract.
Returns
-------
obj_dtype : The extract dtype instance from the
... | [
"def",
"_get_dtype",
"(",
"arr_or_dtype",
")",
":",
"if",
"arr_or_dtype",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"Cannot deduce dtype from null object\"",
")",
"# fastpath",
"elif",
"isinstance",
"(",
"arr_or_dtype",
",",
"np",
".",
"dtype",
")",
":",
"... | Get the dtype instance associated with an array
or dtype object.
Parameters
----------
arr_or_dtype : array-like
The array-like or dtype object whose dtype we want to extract.
Returns
-------
obj_dtype : The extract dtype instance from the
passed in array or dtype o... | [
"Get",
"the",
"dtype",
"instance",
"associated",
"with",
"an",
"array",
"or",
"dtype",
"object",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1833-L1866 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | _is_dtype_type | def _is_dtype_type(arr_or_dtype, condition):
"""
Return a boolean if the condition is satisfied for the arr_or_dtype.
Parameters
----------
arr_or_dtype : array-like
The array-like or dtype object whose dtype we want to extract.
condition : callable[Union[np.dtype, ExtensionDtypeType]]
... | python | def _is_dtype_type(arr_or_dtype, condition):
"""
Return a boolean if the condition is satisfied for the arr_or_dtype.
Parameters
----------
arr_or_dtype : array-like
The array-like or dtype object whose dtype we want to extract.
condition : callable[Union[np.dtype, ExtensionDtypeType]]
... | [
"def",
"_is_dtype_type",
"(",
"arr_or_dtype",
",",
"condition",
")",
":",
"if",
"arr_or_dtype",
"is",
"None",
":",
"return",
"condition",
"(",
"type",
"(",
"None",
")",
")",
"# fastpath",
"if",
"isinstance",
"(",
"arr_or_dtype",
",",
"np",
".",
"dtype",
")... | Return a boolean if the condition is satisfied for the arr_or_dtype.
Parameters
----------
arr_or_dtype : array-like
The array-like or dtype object whose dtype we want to extract.
condition : callable[Union[np.dtype, ExtensionDtypeType]]
Returns
-------
bool : if the condition is s... | [
"Return",
"a",
"boolean",
"if",
"the",
"condition",
"is",
"satisfied",
"for",
"the",
"arr_or_dtype",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1869-L1913 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | infer_dtype_from_object | def infer_dtype_from_object(dtype):
"""
Get a numpy dtype.type-style object for a dtype object.
This methods also includes handling of the datetime64[ns] and
datetime64[ns, TZ] objects.
If no dtype can be found, we return ``object``.
Parameters
----------
dtype : dtype, type
T... | python | def infer_dtype_from_object(dtype):
"""
Get a numpy dtype.type-style object for a dtype object.
This methods also includes handling of the datetime64[ns] and
datetime64[ns, TZ] objects.
If no dtype can be found, we return ``object``.
Parameters
----------
dtype : dtype, type
T... | [
"def",
"infer_dtype_from_object",
"(",
"dtype",
")",
":",
"if",
"isinstance",
"(",
"dtype",
",",
"type",
")",
"and",
"issubclass",
"(",
"dtype",
",",
"np",
".",
"generic",
")",
":",
"# Type object from a dtype",
"return",
"dtype",
"elif",
"isinstance",
"(",
... | Get a numpy dtype.type-style object for a dtype object.
This methods also includes handling of the datetime64[ns] and
datetime64[ns, TZ] objects.
If no dtype can be found, we return ``object``.
Parameters
----------
dtype : dtype, type
The dtype object whose numpy dtype.type-style
... | [
"Get",
"a",
"numpy",
"dtype",
".",
"type",
"-",
"style",
"object",
"for",
"a",
"dtype",
"object",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1916-L1977 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | _validate_date_like_dtype | def _validate_date_like_dtype(dtype):
"""
Check whether the dtype is a date-like dtype. Raises an error if invalid.
Parameters
----------
dtype : dtype, type
The dtype to check.
Raises
------
TypeError : The dtype could not be casted to a date-like dtype.
ValueError : The d... | python | def _validate_date_like_dtype(dtype):
"""
Check whether the dtype is a date-like dtype. Raises an error if invalid.
Parameters
----------
dtype : dtype, type
The dtype to check.
Raises
------
TypeError : The dtype could not be casted to a date-like dtype.
ValueError : The d... | [
"def",
"_validate_date_like_dtype",
"(",
"dtype",
")",
":",
"try",
":",
"typ",
"=",
"np",
".",
"datetime_data",
"(",
"dtype",
")",
"[",
"0",
"]",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"TypeError",
"(",
"'{error}'",
".",
"format",
"(",
"error",... | Check whether the dtype is a date-like dtype. Raises an error if invalid.
Parameters
----------
dtype : dtype, type
The dtype to check.
Raises
------
TypeError : The dtype could not be casted to a date-like dtype.
ValueError : The dtype is an illegal date-like dtype (e.g. the
... | [
"Check",
"whether",
"the",
"dtype",
"is",
"a",
"date",
"-",
"like",
"dtype",
".",
"Raises",
"an",
"error",
"if",
"invalid",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1980-L2002 | train |
pandas-dev/pandas | pandas/core/dtypes/common.py | pandas_dtype | def pandas_dtype(dtype):
"""
Convert input into a pandas only dtype object or a numpy dtype object.
Parameters
----------
dtype : object to be converted
Returns
-------
np.dtype or a pandas dtype
Raises
------
TypeError if not a dtype
"""
# short-circuit
if isi... | python | def pandas_dtype(dtype):
"""
Convert input into a pandas only dtype object or a numpy dtype object.
Parameters
----------
dtype : object to be converted
Returns
-------
np.dtype or a pandas dtype
Raises
------
TypeError if not a dtype
"""
# short-circuit
if isi... | [
"def",
"pandas_dtype",
"(",
"dtype",
")",
":",
"# short-circuit",
"if",
"isinstance",
"(",
"dtype",
",",
"np",
".",
"ndarray",
")",
":",
"return",
"dtype",
".",
"dtype",
"elif",
"isinstance",
"(",
"dtype",
",",
"(",
"np",
".",
"dtype",
",",
"PandasExtens... | Convert input into a pandas only dtype object or a numpy dtype object.
Parameters
----------
dtype : object to be converted
Returns
-------
np.dtype or a pandas dtype
Raises
------
TypeError if not a dtype | [
"Convert",
"input",
"into",
"a",
"pandas",
"only",
"dtype",
"object",
"or",
"a",
"numpy",
"dtype",
"object",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L2005-L2055 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | _groupby_and_merge | def _groupby_and_merge(by, on, left, right, _merge_pieces,
check_duplicates=True):
"""
groupby & merge; we are always performing a left-by type operation
Parameters
----------
by: field to group
on: duplicates field
left: left frame
right: right frame
_merge_p... | python | def _groupby_and_merge(by, on, left, right, _merge_pieces,
check_duplicates=True):
"""
groupby & merge; we are always performing a left-by type operation
Parameters
----------
by: field to group
on: duplicates field
left: left frame
right: right frame
_merge_p... | [
"def",
"_groupby_and_merge",
"(",
"by",
",",
"on",
",",
"left",
",",
"right",
",",
"_merge_pieces",
",",
"check_duplicates",
"=",
"True",
")",
":",
"pieces",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"by",
",",
"(",
"list",
",",
"tuple",
")",
")... | groupby & merge; we are always performing a left-by type operation
Parameters
----------
by: field to group
on: duplicates field
left: left frame
right: right frame
_merge_pieces: function for merging
check_duplicates: boolean, default True
should we check & clean duplicates | [
"groupby",
"&",
"merge",
";",
"we",
"are",
"always",
"performing",
"a",
"left",
"-",
"by",
"type",
"operation"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L54-L128 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | merge_ordered | def merge_ordered(left, right, on=None,
left_on=None, right_on=None,
left_by=None, right_by=None,
fill_method=None, suffixes=('_x', '_y'),
how='outer'):
"""Perform merge with optional filling/interpolation designed for ordered
data like tim... | python | def merge_ordered(left, right, on=None,
left_on=None, right_on=None,
left_by=None, right_by=None,
fill_method=None, suffixes=('_x', '_y'),
how='outer'):
"""Perform merge with optional filling/interpolation designed for ordered
data like tim... | [
"def",
"merge_ordered",
"(",
"left",
",",
"right",
",",
"on",
"=",
"None",
",",
"left_on",
"=",
"None",
",",
"right_on",
"=",
"None",
",",
"left_by",
"=",
"None",
",",
"right_by",
"=",
"None",
",",
"fill_method",
"=",
"None",
",",
"suffixes",
"=",
"(... | Perform merge with optional filling/interpolation designed for ordered
data like time series data. Optionally perform group-wise merge (see
examples)
Parameters
----------
left : DataFrame
right : DataFrame
on : label or list
Field names to join on. Must be found in both DataFrames.... | [
"Perform",
"merge",
"with",
"optional",
"filling",
"/",
"interpolation",
"designed",
"for",
"ordered",
"data",
"like",
"time",
"series",
"data",
".",
"Optionally",
"perform",
"group",
"-",
"wise",
"merge",
"(",
"see",
"examples",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L131-L232 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | merge_asof | def merge_asof(left, right, on=None,
left_on=None, right_on=None,
left_index=False, right_index=False,
by=None, left_by=None, right_by=None,
suffixes=('_x', '_y'),
tolerance=None,
allow_exact_matches=True,
direction... | python | def merge_asof(left, right, on=None,
left_on=None, right_on=None,
left_index=False, right_index=False,
by=None, left_by=None, right_by=None,
suffixes=('_x', '_y'),
tolerance=None,
allow_exact_matches=True,
direction... | [
"def",
"merge_asof",
"(",
"left",
",",
"right",
",",
"on",
"=",
"None",
",",
"left_on",
"=",
"None",
",",
"right_on",
"=",
"None",
",",
"left_index",
"=",
"False",
",",
"right_index",
"=",
"False",
",",
"by",
"=",
"None",
",",
"left_by",
"=",
"None",... | Perform an asof merge. This is similar to a left-join except that we
match on nearest key rather than equal keys.
Both DataFrames must be sorted by the key.
For each row in the left DataFrame:
- A "backward" search selects the last row in the right DataFrame whose
'on' key is less than or e... | [
"Perform",
"an",
"asof",
"merge",
".",
"This",
"is",
"similar",
"to",
"a",
"left",
"-",
"join",
"except",
"that",
"we",
"match",
"on",
"nearest",
"key",
"rather",
"than",
"equal",
"keys",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L235-L467 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | _restore_dropped_levels_multijoin | def _restore_dropped_levels_multijoin(left, right, dropped_level_names,
join_index, lindexer, rindexer):
"""
*this is an internal non-public method*
Returns the levels, labels and names of a multi-index to multi-index join.
Depending on the type of join, this metho... | python | def _restore_dropped_levels_multijoin(left, right, dropped_level_names,
join_index, lindexer, rindexer):
"""
*this is an internal non-public method*
Returns the levels, labels and names of a multi-index to multi-index join.
Depending on the type of join, this metho... | [
"def",
"_restore_dropped_levels_multijoin",
"(",
"left",
",",
"right",
",",
"dropped_level_names",
",",
"join_index",
",",
"lindexer",
",",
"rindexer",
")",
":",
"def",
"_convert_to_mulitindex",
"(",
"index",
")",
":",
"if",
"isinstance",
"(",
"index",
",",
"Mul... | *this is an internal non-public method*
Returns the levels, labels and names of a multi-index to multi-index join.
Depending on the type of join, this method restores the appropriate
dropped levels of the joined multi-index.
The method relies on lidx, rindexer which hold the index positions of
left... | [
"*",
"this",
"is",
"an",
"internal",
"non",
"-",
"public",
"method",
"*"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L1195-L1281 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | _MergeOperation._maybe_restore_index_levels | def _maybe_restore_index_levels(self, result):
"""
Restore index levels specified as `on` parameters
Here we check for cases where `self.left_on` and `self.right_on` pairs
each reference an index level in their respective DataFrames. The
joined columns corresponding to these pai... | python | def _maybe_restore_index_levels(self, result):
"""
Restore index levels specified as `on` parameters
Here we check for cases where `self.left_on` and `self.right_on` pairs
each reference an index level in their respective DataFrames. The
joined columns corresponding to these pai... | [
"def",
"_maybe_restore_index_levels",
"(",
"self",
",",
"result",
")",
":",
"names_to_restore",
"=",
"[",
"]",
"for",
"name",
",",
"left_key",
",",
"right_key",
"in",
"zip",
"(",
"self",
".",
"join_names",
",",
"self",
".",
"left_on",
",",
"self",
".",
"... | Restore index levels specified as `on` parameters
Here we check for cases where `self.left_on` and `self.right_on` pairs
each reference an index level in their respective DataFrames. The
joined columns corresponding to these pairs are then restored to the
index of `result`.
**N... | [
"Restore",
"index",
"levels",
"specified",
"as",
"on",
"parameters"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L619-L650 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | _MergeOperation._get_join_indexers | def _get_join_indexers(self):
""" return the join indexers """
return _get_join_indexers(self.left_join_keys,
self.right_join_keys,
sort=self.sort,
how=self.how) | python | def _get_join_indexers(self):
""" return the join indexers """
return _get_join_indexers(self.left_join_keys,
self.right_join_keys,
sort=self.sort,
how=self.how) | [
"def",
"_get_join_indexers",
"(",
"self",
")",
":",
"return",
"_get_join_indexers",
"(",
"self",
".",
"left_join_keys",
",",
"self",
".",
"right_join_keys",
",",
"sort",
"=",
"self",
".",
"sort",
",",
"how",
"=",
"self",
".",
"how",
")"
] | return the join indexers | [
"return",
"the",
"join",
"indexers"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L735-L740 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | _MergeOperation._create_join_index | def _create_join_index(self, index, other_index, indexer,
other_indexer, how='left'):
"""
Create a join index by rearranging one index to match another
Parameters
----------
index: Index being rearranged
other_index: Index used to supply values... | python | def _create_join_index(self, index, other_index, indexer,
other_indexer, how='left'):
"""
Create a join index by rearranging one index to match another
Parameters
----------
index: Index being rearranged
other_index: Index used to supply values... | [
"def",
"_create_join_index",
"(",
"self",
",",
"index",
",",
"other_index",
",",
"indexer",
",",
"other_indexer",
",",
"how",
"=",
"'left'",
")",
":",
"join_index",
"=",
"index",
".",
"take",
"(",
"indexer",
")",
"if",
"(",
"self",
".",
"how",
"in",
"(... | Create a join index by rearranging one index to match another
Parameters
----------
index: Index being rearranged
other_index: Index used to supply values not found in index
indexer: how to rearrange index
how: replacement is only necessary if indexer based on other_inde... | [
"Create",
"a",
"join",
"index",
"by",
"rearranging",
"one",
"index",
"to",
"match",
"another"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L790-L821 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | _MergeOperation._get_merge_keys | def _get_merge_keys(self):
"""
Note: has side effects (copy/delete key columns)
Parameters
----------
left
right
on
Returns
-------
left_keys, right_keys
"""
left_keys = []
right_keys = []
join_names = []
... | python | def _get_merge_keys(self):
"""
Note: has side effects (copy/delete key columns)
Parameters
----------
left
right
on
Returns
-------
left_keys, right_keys
"""
left_keys = []
right_keys = []
join_names = []
... | [
"def",
"_get_merge_keys",
"(",
"self",
")",
":",
"left_keys",
"=",
"[",
"]",
"right_keys",
"=",
"[",
"]",
"join_names",
"=",
"[",
"]",
"right_drop",
"=",
"[",
"]",
"left_drop",
"=",
"[",
"]",
"left",
",",
"right",
"=",
"self",
".",
"left",
",",
"se... | Note: has side effects (copy/delete key columns)
Parameters
----------
left
right
on
Returns
-------
left_keys, right_keys | [
"Note",
":",
"has",
"side",
"effects",
"(",
"copy",
"/",
"delete",
"key",
"columns",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L823-L933 | train |
pandas-dev/pandas | pandas/core/reshape/merge.py | _AsOfMerge._get_join_indexers | def _get_join_indexers(self):
""" return the join indexers """
def flip(xs):
""" unlike np.transpose, this returns an array of tuples """
labels = list(string.ascii_lowercase[:len(xs)])
dtypes = [x.dtype for x in xs]
labeled_dtypes = list(zip(labels, dtyp... | python | def _get_join_indexers(self):
""" return the join indexers """
def flip(xs):
""" unlike np.transpose, this returns an array of tuples """
labels = list(string.ascii_lowercase[:len(xs)])
dtypes = [x.dtype for x in xs]
labeled_dtypes = list(zip(labels, dtyp... | [
"def",
"_get_join_indexers",
"(",
"self",
")",
":",
"def",
"flip",
"(",
"xs",
")",
":",
"\"\"\" unlike np.transpose, this returns an array of tuples \"\"\"",
"labels",
"=",
"list",
"(",
"string",
".",
"ascii_lowercase",
"[",
":",
"len",
"(",
"xs",
")",
"]",
")",... | return the join indexers | [
"return",
"the",
"join",
"indexers"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/merge.py#L1495-L1573 | train |
pandas-dev/pandas | pandas/core/dtypes/base.py | _DtypeOpsMixin.is_dtype | def is_dtype(cls, dtype):
"""Check if we match 'dtype'.
Parameters
----------
dtype : object
The object to check.
Returns
-------
is_dtype : bool
Notes
-----
The default implementation is True if
1. ``cls.construct_f... | python | def is_dtype(cls, dtype):
"""Check if we match 'dtype'.
Parameters
----------
dtype : object
The object to check.
Returns
-------
is_dtype : bool
Notes
-----
The default implementation is True if
1. ``cls.construct_f... | [
"def",
"is_dtype",
"(",
"cls",
",",
"dtype",
")",
":",
"dtype",
"=",
"getattr",
"(",
"dtype",
",",
"'dtype'",
",",
"dtype",
")",
"if",
"isinstance",
"(",
"dtype",
",",
"(",
"ABCSeries",
",",
"ABCIndexClass",
",",
"ABCDataFrame",
",",
"np",
".",
"dtype"... | Check if we match 'dtype'.
Parameters
----------
dtype : object
The object to check.
Returns
-------
is_dtype : bool
Notes
-----
The default implementation is True if
1. ``cls.construct_from_string(dtype)`` is an instance
... | [
"Check",
"if",
"we",
"match",
"dtype",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/base.py#L75-L113 | train |
pandas-dev/pandas | pandas/core/strings.py | cat_core | def cat_core(list_of_columns, sep):
"""
Auxiliary function for :meth:`str.cat`
Parameters
----------
list_of_columns : list of numpy arrays
List of arrays to be concatenated with sep;
these arrays may not contain NaNs!
sep : string
The separator string for concatenating ... | python | def cat_core(list_of_columns, sep):
"""
Auxiliary function for :meth:`str.cat`
Parameters
----------
list_of_columns : list of numpy arrays
List of arrays to be concatenated with sep;
these arrays may not contain NaNs!
sep : string
The separator string for concatenating ... | [
"def",
"cat_core",
"(",
"list_of_columns",
",",
"sep",
")",
":",
"list_with_sep",
"=",
"[",
"sep",
"]",
"*",
"(",
"2",
"*",
"len",
"(",
"list_of_columns",
")",
"-",
"1",
")",
"list_with_sep",
"[",
":",
":",
"2",
"]",
"=",
"list_of_columns",
"return",
... | Auxiliary function for :meth:`str.cat`
Parameters
----------
list_of_columns : list of numpy arrays
List of arrays to be concatenated with sep;
these arrays may not contain NaNs!
sep : string
The separator string for concatenating the columns
Returns
-------
nd.arra... | [
"Auxiliary",
"function",
"for",
":",
"meth",
":",
"str",
".",
"cat"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L33-L52 | train |
pandas-dev/pandas | pandas/core/strings.py | str_count | def str_count(arr, pat, flags=0):
"""
Count occurrences of pattern in each string of the Series/Index.
This function is used to count the number of times a particular regex
pattern is repeated in each of the string elements of the
:class:`~pandas.Series`.
Parameters
----------
pat : st... | python | def str_count(arr, pat, flags=0):
"""
Count occurrences of pattern in each string of the Series/Index.
This function is used to count the number of times a particular regex
pattern is repeated in each of the string elements of the
:class:`~pandas.Series`.
Parameters
----------
pat : st... | [
"def",
"str_count",
"(",
"arr",
",",
"pat",
",",
"flags",
"=",
"0",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"pat",
",",
"flags",
"=",
"flags",
")",
"f",
"=",
"lambda",
"x",
":",
"len",
"(",
"regex",
".",
"findall",
"(",
"x",
")",
"... | Count occurrences of pattern in each string of the Series/Index.
This function is used to count the number of times a particular regex
pattern is repeated in each of the string elements of the
:class:`~pandas.Series`.
Parameters
----------
pat : str
Valid regular expression.
flags ... | [
"Count",
"occurrences",
"of",
"pattern",
"in",
"each",
"string",
"of",
"the",
"Series",
"/",
"Index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L98-L164 | train |
pandas-dev/pandas | pandas/core/strings.py | str_contains | def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True):
"""
Test if pattern or regex is contained within a string of a Series or Index.
Return boolean Series or Index based on whether a given pattern or regex is
contained within a string of a Series or Index.
Parameters
--------... | python | def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True):
"""
Test if pattern or regex is contained within a string of a Series or Index.
Return boolean Series or Index based on whether a given pattern or regex is
contained within a string of a Series or Index.
Parameters
--------... | [
"def",
"str_contains",
"(",
"arr",
",",
"pat",
",",
"case",
"=",
"True",
",",
"flags",
"=",
"0",
",",
"na",
"=",
"np",
".",
"nan",
",",
"regex",
"=",
"True",
")",
":",
"if",
"regex",
":",
"if",
"not",
"case",
":",
"flags",
"|=",
"re",
".",
"I... | Test if pattern or regex is contained within a string of a Series or Index.
Return boolean Series or Index based on whether a given pattern or regex is
contained within a string of a Series or Index.
Parameters
----------
pat : str
Character sequence or regular expression.
case : bool,... | [
"Test",
"if",
"pattern",
"or",
"regex",
"is",
"contained",
"within",
"a",
"string",
"of",
"a",
"Series",
"or",
"Index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L167-L310 | train |
pandas-dev/pandas | pandas/core/strings.py | str_startswith | def str_startswith(arr, pat, na=np.nan):
"""
Test if the start of each string element matches a pattern.
Equivalent to :meth:`str.startswith`.
Parameters
----------
pat : str
Character sequence. Regular expressions are not accepted.
na : object, default NaN
Object shown if ... | python | def str_startswith(arr, pat, na=np.nan):
"""
Test if the start of each string element matches a pattern.
Equivalent to :meth:`str.startswith`.
Parameters
----------
pat : str
Character sequence. Regular expressions are not accepted.
na : object, default NaN
Object shown if ... | [
"def",
"str_startswith",
"(",
"arr",
",",
"pat",
",",
"na",
"=",
"np",
".",
"nan",
")",
":",
"f",
"=",
"lambda",
"x",
":",
"x",
".",
"startswith",
"(",
"pat",
")",
"return",
"_na_map",
"(",
"f",
",",
"arr",
",",
"na",
",",
"dtype",
"=",
"bool",... | Test if the start of each string element matches a pattern.
Equivalent to :meth:`str.startswith`.
Parameters
----------
pat : str
Character sequence. Regular expressions are not accepted.
na : object, default NaN
Object shown if element tested is not a string.
Returns
----... | [
"Test",
"if",
"the",
"start",
"of",
"each",
"string",
"element",
"matches",
"a",
"pattern",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L313-L365 | train |
pandas-dev/pandas | pandas/core/strings.py | str_endswith | def str_endswith(arr, pat, na=np.nan):
"""
Test if the end of each string element matches a pattern.
Equivalent to :meth:`str.endswith`.
Parameters
----------
pat : str
Character sequence. Regular expressions are not accepted.
na : object, default NaN
Object shown if elemen... | python | def str_endswith(arr, pat, na=np.nan):
"""
Test if the end of each string element matches a pattern.
Equivalent to :meth:`str.endswith`.
Parameters
----------
pat : str
Character sequence. Regular expressions are not accepted.
na : object, default NaN
Object shown if elemen... | [
"def",
"str_endswith",
"(",
"arr",
",",
"pat",
",",
"na",
"=",
"np",
".",
"nan",
")",
":",
"f",
"=",
"lambda",
"x",
":",
"x",
".",
"endswith",
"(",
"pat",
")",
"return",
"_na_map",
"(",
"f",
",",
"arr",
",",
"na",
",",
"dtype",
"=",
"bool",
"... | Test if the end of each string element matches a pattern.
Equivalent to :meth:`str.endswith`.
Parameters
----------
pat : str
Character sequence. Regular expressions are not accepted.
na : object, default NaN
Object shown if element tested is not a string.
Returns
-------
... | [
"Test",
"if",
"the",
"end",
"of",
"each",
"string",
"element",
"matches",
"a",
"pattern",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L368-L420 | train |
pandas-dev/pandas | pandas/core/strings.py | str_replace | def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):
r"""
Replace occurrences of pattern/regex in the Series/Index with
some other string. Equivalent to :meth:`str.replace` or
:func:`re.sub`.
Parameters
----------
pat : str or compiled regex
String can be a charact... | python | def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):
r"""
Replace occurrences of pattern/regex in the Series/Index with
some other string. Equivalent to :meth:`str.replace` or
:func:`re.sub`.
Parameters
----------
pat : str or compiled regex
String can be a charact... | [
"def",
"str_replace",
"(",
"arr",
",",
"pat",
",",
"repl",
",",
"n",
"=",
"-",
"1",
",",
"case",
"=",
"None",
",",
"flags",
"=",
"0",
",",
"regex",
"=",
"True",
")",
":",
"# Check whether repl is valid (GH 13438, GH 15055)",
"if",
"not",
"(",
"is_string_... | r"""
Replace occurrences of pattern/regex in the Series/Index with
some other string. Equivalent to :meth:`str.replace` or
:func:`re.sub`.
Parameters
----------
pat : str or compiled regex
String can be a character sequence or regular expression.
.. versionadded:: 0.20.0
... | [
"r",
"Replace",
"occurrences",
"of",
"pattern",
"/",
"regex",
"in",
"the",
"Series",
"/",
"Index",
"with",
"some",
"other",
"string",
".",
"Equivalent",
"to",
":",
"meth",
":",
"str",
".",
"replace",
"or",
":",
"func",
":",
"re",
".",
"sub",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L423-L578 | train |
pandas-dev/pandas | pandas/core/strings.py | str_repeat | def str_repeat(arr, repeats):
"""
Duplicate each string in the Series or Index.
Parameters
----------
repeats : int or sequence of int
Same value for all (int) or different value per (sequence).
Returns
-------
Series or Index of object
Series or Index of repeated strin... | python | def str_repeat(arr, repeats):
"""
Duplicate each string in the Series or Index.
Parameters
----------
repeats : int or sequence of int
Same value for all (int) or different value per (sequence).
Returns
-------
Series or Index of object
Series or Index of repeated strin... | [
"def",
"str_repeat",
"(",
"arr",
",",
"repeats",
")",
":",
"if",
"is_scalar",
"(",
"repeats",
")",
":",
"def",
"scalar_rep",
"(",
"x",
")",
":",
"try",
":",
"return",
"bytes",
".",
"__mul__",
"(",
"x",
",",
"repeats",
")",
"except",
"TypeError",
":",... | Duplicate each string in the Series or Index.
Parameters
----------
repeats : int or sequence of int
Same value for all (int) or different value per (sequence).
Returns
-------
Series or Index of object
Series or Index of repeated string objects specified by
input param... | [
"Duplicate",
"each",
"string",
"in",
"the",
"Series",
"or",
"Index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L581-L639 | train |
pandas-dev/pandas | pandas/core/strings.py | str_match | def str_match(arr, pat, case=True, flags=0, na=np.nan):
"""
Determine if each string matches a regular expression.
Parameters
----------
pat : str
Character sequence or regular expression.
case : bool, default True
If True, case sensitive.
flags : int, default 0 (no flags)
... | python | def str_match(arr, pat, case=True, flags=0, na=np.nan):
"""
Determine if each string matches a regular expression.
Parameters
----------
pat : str
Character sequence or regular expression.
case : bool, default True
If True, case sensitive.
flags : int, default 0 (no flags)
... | [
"def",
"str_match",
"(",
"arr",
",",
"pat",
",",
"case",
"=",
"True",
",",
"flags",
"=",
"0",
",",
"na",
"=",
"np",
".",
"nan",
")",
":",
"if",
"not",
"case",
":",
"flags",
"|=",
"re",
".",
"IGNORECASE",
"regex",
"=",
"re",
".",
"compile",
"(",... | Determine if each string matches a regular expression.
Parameters
----------
pat : str
Character sequence or regular expression.
case : bool, default True
If True, case sensitive.
flags : int, default 0 (no flags)
re module flags, e.g. re.IGNORECASE.
na : default NaN
... | [
"Determine",
"if",
"each",
"string",
"matches",
"a",
"regular",
"expression",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L642-L675 | train |
pandas-dev/pandas | pandas/core/strings.py | _groups_or_na_fun | def _groups_or_na_fun(regex):
"""Used in both extract_noexpand and extract_frame"""
if regex.groups == 0:
raise ValueError("pattern contains no capture groups")
empty_row = [np.nan] * regex.groups
def f(x):
if not isinstance(x, str):
return empty_row
m = regex.search... | python | def _groups_or_na_fun(regex):
"""Used in both extract_noexpand and extract_frame"""
if regex.groups == 0:
raise ValueError("pattern contains no capture groups")
empty_row = [np.nan] * regex.groups
def f(x):
if not isinstance(x, str):
return empty_row
m = regex.search... | [
"def",
"_groups_or_na_fun",
"(",
"regex",
")",
":",
"if",
"regex",
".",
"groups",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"pattern contains no capture groups\"",
")",
"empty_row",
"=",
"[",
"np",
".",
"nan",
"]",
"*",
"regex",
".",
"groups",
"def",
"... | Used in both extract_noexpand and extract_frame | [
"Used",
"in",
"both",
"extract_noexpand",
"and",
"extract_frame"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L685-L699 | train |
pandas-dev/pandas | pandas/core/strings.py | _str_extract_noexpand | def _str_extract_noexpand(arr, pat, flags=0):
"""
Find groups in each string in the Series using passed regular
expression. This function is called from
str_extract(expand=False), and can return Series, DataFrame, or
Index.
"""
from pandas import DataFrame, Index
regex = re.compile(pat... | python | def _str_extract_noexpand(arr, pat, flags=0):
"""
Find groups in each string in the Series using passed regular
expression. This function is called from
str_extract(expand=False), and can return Series, DataFrame, or
Index.
"""
from pandas import DataFrame, Index
regex = re.compile(pat... | [
"def",
"_str_extract_noexpand",
"(",
"arr",
",",
"pat",
",",
"flags",
"=",
"0",
")",
":",
"from",
"pandas",
"import",
"DataFrame",
",",
"Index",
"regex",
"=",
"re",
".",
"compile",
"(",
"pat",
",",
"flags",
"=",
"flags",
")",
"groups_or_na",
"=",
"_gro... | Find groups in each string in the Series using passed regular
expression. This function is called from
str_extract(expand=False), and can return Series, DataFrame, or
Index. | [
"Find",
"groups",
"in",
"each",
"string",
"in",
"the",
"Series",
"using",
"passed",
"regular",
"expression",
".",
"This",
"function",
"is",
"called",
"from",
"str_extract",
"(",
"expand",
"=",
"False",
")",
"and",
"can",
"return",
"Series",
"DataFrame",
"or"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L702-L732 | train |
pandas-dev/pandas | pandas/core/strings.py | _str_extract_frame | def _str_extract_frame(arr, pat, flags=0):
"""
For each subject string in the Series, extract groups from the
first match of regular expression pat. This function is called from
str_extract(expand=True), and always returns a DataFrame.
"""
from pandas import DataFrame
regex = re.compile(pa... | python | def _str_extract_frame(arr, pat, flags=0):
"""
For each subject string in the Series, extract groups from the
first match of regular expression pat. This function is called from
str_extract(expand=True), and always returns a DataFrame.
"""
from pandas import DataFrame
regex = re.compile(pa... | [
"def",
"_str_extract_frame",
"(",
"arr",
",",
"pat",
",",
"flags",
"=",
"0",
")",
":",
"from",
"pandas",
"import",
"DataFrame",
"regex",
"=",
"re",
".",
"compile",
"(",
"pat",
",",
"flags",
"=",
"flags",
")",
"groups_or_na",
"=",
"_groups_or_na_fun",
"("... | For each subject string in the Series, extract groups from the
first match of regular expression pat. This function is called from
str_extract(expand=True), and always returns a DataFrame. | [
"For",
"each",
"subject",
"string",
"in",
"the",
"Series",
"extract",
"groups",
"from",
"the",
"first",
"match",
"of",
"regular",
"expression",
"pat",
".",
"This",
"function",
"is",
"called",
"from",
"str_extract",
"(",
"expand",
"=",
"True",
")",
"and",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L735-L759 | train |
pandas-dev/pandas | pandas/core/strings.py | str_extract | def str_extract(arr, pat, flags=0, expand=True):
r"""
Extract capture groups in the regex `pat` as columns in a DataFrame.
For each subject string in the Series, extract groups from the
first match of regular expression `pat`.
Parameters
----------
pat : str
Regular expression patt... | python | def str_extract(arr, pat, flags=0, expand=True):
r"""
Extract capture groups in the regex `pat` as columns in a DataFrame.
For each subject string in the Series, extract groups from the
first match of regular expression `pat`.
Parameters
----------
pat : str
Regular expression patt... | [
"def",
"str_extract",
"(",
"arr",
",",
"pat",
",",
"flags",
"=",
"0",
",",
"expand",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"expand",
",",
"bool",
")",
":",
"raise",
"ValueError",
"(",
"\"expand must be True or False\"",
")",
"if",
"expan... | r"""
Extract capture groups in the regex `pat` as columns in a DataFrame.
For each subject string in the Series, extract groups from the
first match of regular expression `pat`.
Parameters
----------
pat : str
Regular expression pattern with capturing groups.
flags : int, default 0... | [
"r",
"Extract",
"capture",
"groups",
"in",
"the",
"regex",
"pat",
"as",
"columns",
"in",
"a",
"DataFrame",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L762-L851 | train |
pandas-dev/pandas | pandas/core/strings.py | str_extractall | def str_extractall(arr, pat, flags=0):
r"""
For each subject string in the Series, extract groups from all
matches of regular expression pat. When each subject string in the
Series has exactly one match, extractall(pat).xs(0, level='match')
is the same as extract(pat).
.. versionadded:: 0.18.0
... | python | def str_extractall(arr, pat, flags=0):
r"""
For each subject string in the Series, extract groups from all
matches of regular expression pat. When each subject string in the
Series has exactly one match, extractall(pat).xs(0, level='match')
is the same as extract(pat).
.. versionadded:: 0.18.0
... | [
"def",
"str_extractall",
"(",
"arr",
",",
"pat",
",",
"flags",
"=",
"0",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"pat",
",",
"flags",
"=",
"flags",
")",
"# the regex must contain capture groups.",
"if",
"regex",
".",
"groups",
"==",
"0",
":",
... | r"""
For each subject string in the Series, extract groups from all
matches of regular expression pat. When each subject string in the
Series has exactly one match, extractall(pat).xs(0, level='match')
is the same as extract(pat).
.. versionadded:: 0.18.0
Parameters
----------
pat : st... | [
"r",
"For",
"each",
"subject",
"string",
"in",
"the",
"Series",
"extract",
"groups",
"from",
"all",
"matches",
"of",
"regular",
"expression",
"pat",
".",
"When",
"each",
"subject",
"string",
"in",
"the",
"Series",
"has",
"exactly",
"one",
"match",
"extractal... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L854-L964 | train |
pandas-dev/pandas | pandas/core/strings.py | str_get_dummies | def str_get_dummies(arr, sep='|'):
"""
Split each string in the Series by sep and return a DataFrame
of dummy/indicator variables.
Parameters
----------
sep : str, default "|"
String to split on.
Returns
-------
DataFrame
Dummy variables corresponding to values of t... | python | def str_get_dummies(arr, sep='|'):
"""
Split each string in the Series by sep and return a DataFrame
of dummy/indicator variables.
Parameters
----------
sep : str, default "|"
String to split on.
Returns
-------
DataFrame
Dummy variables corresponding to values of t... | [
"def",
"str_get_dummies",
"(",
"arr",
",",
"sep",
"=",
"'|'",
")",
":",
"arr",
"=",
"arr",
".",
"fillna",
"(",
"''",
")",
"try",
":",
"arr",
"=",
"sep",
"+",
"arr",
"+",
"sep",
"except",
"TypeError",
":",
"arr",
"=",
"sep",
"+",
"arr",
".",
"as... | Split each string in the Series by sep and return a DataFrame
of dummy/indicator variables.
Parameters
----------
sep : str, default "|"
String to split on.
Returns
-------
DataFrame
Dummy variables corresponding to values of the Series.
See Also
--------
get_d... | [
"Split",
"each",
"string",
"in",
"the",
"Series",
"by",
"sep",
"and",
"return",
"a",
"DataFrame",
"of",
"dummy",
"/",
"indicator",
"variables",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L967-L1017 | train |
pandas-dev/pandas | pandas/core/strings.py | str_findall | def str_findall(arr, pat, flags=0):
"""
Find all occurrences of pattern or regular expression in the Series/Index.
Equivalent to applying :func:`re.findall` to all the elements in the
Series/Index.
Parameters
----------
pat : str
Pattern or regular expression.
flags : int, defa... | python | def str_findall(arr, pat, flags=0):
"""
Find all occurrences of pattern or regular expression in the Series/Index.
Equivalent to applying :func:`re.findall` to all the elements in the
Series/Index.
Parameters
----------
pat : str
Pattern or regular expression.
flags : int, defa... | [
"def",
"str_findall",
"(",
"arr",
",",
"pat",
",",
"flags",
"=",
"0",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"pat",
",",
"flags",
"=",
"flags",
")",
"return",
"_na_map",
"(",
"regex",
".",
"findall",
",",
"arr",
")"
] | Find all occurrences of pattern or regular expression in the Series/Index.
Equivalent to applying :func:`re.findall` to all the elements in the
Series/Index.
Parameters
----------
pat : str
Pattern or regular expression.
flags : int, default 0
Flags from ``re`` module, e.g. `re... | [
"Find",
"all",
"occurrences",
"of",
"pattern",
"or",
"regular",
"expression",
"in",
"the",
"Series",
"/",
"Index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1085-L1176 | train |
pandas-dev/pandas | pandas/core/strings.py | str_find | def str_find(arr, sub, start=0, end=None, side='left'):
"""
Return indexes in each strings in the Series/Index where the
substring is fully contained between [start:end]. Return -1 on failure.
Parameters
----------
sub : str
Substring being searched.
start : int
Left edge in... | python | def str_find(arr, sub, start=0, end=None, side='left'):
"""
Return indexes in each strings in the Series/Index where the
substring is fully contained between [start:end]. Return -1 on failure.
Parameters
----------
sub : str
Substring being searched.
start : int
Left edge in... | [
"def",
"str_find",
"(",
"arr",
",",
"sub",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
",",
"side",
"=",
"'left'",
")",
":",
"if",
"not",
"isinstance",
"(",
"sub",
",",
"str",
")",
":",
"msg",
"=",
"'expected a string object, not {0}'",
"raise",
... | Return indexes in each strings in the Series/Index where the
substring is fully contained between [start:end]. Return -1 on failure.
Parameters
----------
sub : str
Substring being searched.
start : int
Left edge index.
end : int
Right edge index.
side : {'left', 'ri... | [
"Return",
"indexes",
"in",
"each",
"strings",
"in",
"the",
"Series",
"/",
"Index",
"where",
"the",
"substring",
"is",
"fully",
"contained",
"between",
"[",
"start",
":",
"end",
"]",
".",
"Return",
"-",
"1",
"on",
"failure",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1179-L1217 | train |
pandas-dev/pandas | pandas/core/strings.py | str_pad | def str_pad(arr, width, side='left', fillchar=' '):
"""
Pad strings in the Series/Index up to width.
Parameters
----------
width : int
Minimum width of resulting string; additional characters will be filled
with character defined in `fillchar`.
side : {'left', 'right', 'both'}, ... | python | def str_pad(arr, width, side='left', fillchar=' '):
"""
Pad strings in the Series/Index up to width.
Parameters
----------
width : int
Minimum width of resulting string; additional characters will be filled
with character defined in `fillchar`.
side : {'left', 'right', 'both'}, ... | [
"def",
"str_pad",
"(",
"arr",
",",
"width",
",",
"side",
"=",
"'left'",
",",
"fillchar",
"=",
"' '",
")",
":",
"if",
"not",
"isinstance",
"(",
"fillchar",
",",
"str",
")",
":",
"msg",
"=",
"'fillchar must be a character, not {0}'",
"raise",
"TypeError",
"(... | Pad strings in the Series/Index up to width.
Parameters
----------
width : int
Minimum width of resulting string; additional characters will be filled
with character defined in `fillchar`.
side : {'left', 'right', 'both'}, default 'left'
Side from which to fill resulting string.... | [
"Pad",
"strings",
"in",
"the",
"Series",
"/",
"Index",
"up",
"to",
"width",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1240-L1313 | train |
pandas-dev/pandas | pandas/core/strings.py | str_slice | def str_slice(arr, start=None, stop=None, step=None):
"""
Slice substrings from each element in the Series or Index.
Parameters
----------
start : int, optional
Start position for slice operation.
stop : int, optional
Stop position for slice operation.
step : int, optional
... | python | def str_slice(arr, start=None, stop=None, step=None):
"""
Slice substrings from each element in the Series or Index.
Parameters
----------
start : int, optional
Start position for slice operation.
stop : int, optional
Stop position for slice operation.
step : int, optional
... | [
"def",
"str_slice",
"(",
"arr",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
")",
":",
"obj",
"=",
"slice",
"(",
"start",
",",
"stop",
",",
"step",
")",
"f",
"=",
"lambda",
"x",
":",
"x",
"[",
"obj",
"]",
"re... | Slice substrings from each element in the Series or Index.
Parameters
----------
start : int, optional
Start position for slice operation.
stop : int, optional
Stop position for slice operation.
step : int, optional
Step size for slice operation.
Returns
-------
... | [
"Slice",
"substrings",
"from",
"each",
"element",
"in",
"the",
"Series",
"or",
"Index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1345-L1413 | train |
pandas-dev/pandas | pandas/core/strings.py | str_slice_replace | def str_slice_replace(arr, start=None, stop=None, repl=None):
"""
Replace a positional slice of a string with another value.
Parameters
----------
start : int, optional
Left index position to use for the slice. If not specified (None),
the slice is unbounded on the left, i.e. slice ... | python | def str_slice_replace(arr, start=None, stop=None, repl=None):
"""
Replace a positional slice of a string with another value.
Parameters
----------
start : int, optional
Left index position to use for the slice. If not specified (None),
the slice is unbounded on the left, i.e. slice ... | [
"def",
"str_slice_replace",
"(",
"arr",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"repl",
"=",
"None",
")",
":",
"if",
"repl",
"is",
"None",
":",
"repl",
"=",
"''",
"def",
"f",
"(",
"x",
")",
":",
"if",
"x",
"[",
"start",
":",
... | Replace a positional slice of a string with another value.
Parameters
----------
start : int, optional
Left index position to use for the slice. If not specified (None),
the slice is unbounded on the left, i.e. slice from the start
of the string.
stop : int, optional
Rig... | [
"Replace",
"a",
"positional",
"slice",
"of",
"a",
"string",
"with",
"another",
"value",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1416-L1504 | train |
pandas-dev/pandas | pandas/core/strings.py | str_strip | def str_strip(arr, to_strip=None, side='both'):
"""
Strip whitespace (including newlines) from each string in the
Series/Index.
Parameters
----------
to_strip : str or unicode
side : {'left', 'right', 'both'}, default 'both'
Returns
-------
Series or Index
"""
if side =... | python | def str_strip(arr, to_strip=None, side='both'):
"""
Strip whitespace (including newlines) from each string in the
Series/Index.
Parameters
----------
to_strip : str or unicode
side : {'left', 'right', 'both'}, default 'both'
Returns
-------
Series or Index
"""
if side =... | [
"def",
"str_strip",
"(",
"arr",
",",
"to_strip",
"=",
"None",
",",
"side",
"=",
"'both'",
")",
":",
"if",
"side",
"==",
"'both'",
":",
"f",
"=",
"lambda",
"x",
":",
"x",
".",
"strip",
"(",
"to_strip",
")",
"elif",
"side",
"==",
"'left'",
":",
"f"... | Strip whitespace (including newlines) from each string in the
Series/Index.
Parameters
----------
to_strip : str or unicode
side : {'left', 'right', 'both'}, default 'both'
Returns
-------
Series or Index | [
"Strip",
"whitespace",
"(",
"including",
"newlines",
")",
"from",
"each",
"string",
"in",
"the",
"Series",
"/",
"Index",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1507-L1529 | train |
pandas-dev/pandas | pandas/core/strings.py | str_wrap | def str_wrap(arr, width, **kwargs):
r"""
Wrap long strings in the Series/Index to be formatted in
paragraphs with length less than a given width.
This method has the same keyword parameters and defaults as
:class:`textwrap.TextWrapper`.
Parameters
----------
width : int
Maximum... | python | def str_wrap(arr, width, **kwargs):
r"""
Wrap long strings in the Series/Index to be formatted in
paragraphs with length less than a given width.
This method has the same keyword parameters and defaults as
:class:`textwrap.TextWrapper`.
Parameters
----------
width : int
Maximum... | [
"def",
"str_wrap",
"(",
"arr",
",",
"width",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'width'",
"]",
"=",
"width",
"tw",
"=",
"textwrap",
".",
"TextWrapper",
"(",
"*",
"*",
"kwargs",
")",
"return",
"_na_map",
"(",
"lambda",
"s",
":",
"'\\... | r"""
Wrap long strings in the Series/Index to be formatted in
paragraphs with length less than a given width.
This method has the same keyword parameters and defaults as
:class:`textwrap.TextWrapper`.
Parameters
----------
width : int
Maximum line width.
expand_tabs : bool, opt... | [
"r",
"Wrap",
"long",
"strings",
"in",
"the",
"Series",
"/",
"Index",
"to",
"be",
"formatted",
"in",
"paragraphs",
"with",
"length",
"less",
"than",
"a",
"given",
"width",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1532-L1593 | train |
pandas-dev/pandas | pandas/core/strings.py | str_get | def str_get(arr, i):
"""
Extract element from each component at specified position.
Extract element from lists, tuples, or strings in each element in the
Series/Index.
Parameters
----------
i : int
Position of element to extract.
Returns
-------
Series or Index
Ex... | python | def str_get(arr, i):
"""
Extract element from each component at specified position.
Extract element from lists, tuples, or strings in each element in the
Series/Index.
Parameters
----------
i : int
Position of element to extract.
Returns
-------
Series or Index
Ex... | [
"def",
"str_get",
"(",
"arr",
",",
"i",
")",
":",
"def",
"f",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"dict",
")",
":",
"return",
"x",
".",
"get",
"(",
"i",
")",
"elif",
"len",
"(",
"x",
")",
">",
"i",
">=",
"-",
"len",
"("... | Extract element from each component at specified position.
Extract element from lists, tuples, or strings in each element in the
Series/Index.
Parameters
----------
i : int
Position of element to extract.
Returns
-------
Series or Index
Examples
--------
>>> s = p... | [
"Extract",
"element",
"from",
"each",
"component",
"at",
"specified",
"position",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1616-L1673 | train |
pandas-dev/pandas | pandas/core/strings.py | str_decode | def str_decode(arr, encoding, errors="strict"):
"""
Decode character string in the Series/Index using indicated encoding.
Equivalent to :meth:`str.decode` in python2 and :meth:`bytes.decode` in
python3.
Parameters
----------
encoding : str
errors : str, optional
Returns
-------... | python | def str_decode(arr, encoding, errors="strict"):
"""
Decode character string in the Series/Index using indicated encoding.
Equivalent to :meth:`str.decode` in python2 and :meth:`bytes.decode` in
python3.
Parameters
----------
encoding : str
errors : str, optional
Returns
-------... | [
"def",
"str_decode",
"(",
"arr",
",",
"encoding",
",",
"errors",
"=",
"\"strict\"",
")",
":",
"if",
"encoding",
"in",
"_cpython_optimized_decoders",
":",
"# CPython optimized implementation",
"f",
"=",
"lambda",
"x",
":",
"x",
".",
"decode",
"(",
"encoding",
"... | Decode character string in the Series/Index using indicated encoding.
Equivalent to :meth:`str.decode` in python2 and :meth:`bytes.decode` in
python3.
Parameters
----------
encoding : str
errors : str, optional
Returns
-------
Series or Index | [
"Decode",
"character",
"string",
"in",
"the",
"Series",
"/",
"Index",
"using",
"indicated",
"encoding",
".",
"Equivalent",
"to",
":",
"meth",
":",
"str",
".",
"decode",
"in",
"python2",
"and",
":",
"meth",
":",
"bytes",
".",
"decode",
"in",
"python3",
".... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1676-L1697 | train |
pandas-dev/pandas | pandas/core/strings.py | str_encode | def str_encode(arr, encoding, errors="strict"):
"""
Encode character string in the Series/Index using indicated encoding.
Equivalent to :meth:`str.encode`.
Parameters
----------
encoding : str
errors : str, optional
Returns
-------
encoded : Series/Index of objects
"""
... | python | def str_encode(arr, encoding, errors="strict"):
"""
Encode character string in the Series/Index using indicated encoding.
Equivalent to :meth:`str.encode`.
Parameters
----------
encoding : str
errors : str, optional
Returns
-------
encoded : Series/Index of objects
"""
... | [
"def",
"str_encode",
"(",
"arr",
",",
"encoding",
",",
"errors",
"=",
"\"strict\"",
")",
":",
"if",
"encoding",
"in",
"_cpython_optimized_encoders",
":",
"# CPython optimized implementation",
"f",
"=",
"lambda",
"x",
":",
"x",
".",
"encode",
"(",
"encoding",
"... | Encode character string in the Series/Index using indicated encoding.
Equivalent to :meth:`str.encode`.
Parameters
----------
encoding : str
errors : str, optional
Returns
-------
encoded : Series/Index of objects | [
"Encode",
"character",
"string",
"in",
"the",
"Series",
"/",
"Index",
"using",
"indicated",
"encoding",
".",
"Equivalent",
"to",
":",
"meth",
":",
"str",
".",
"encode",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1700-L1720 | train |
pandas-dev/pandas | pandas/core/strings.py | copy | def copy(source):
"Copy a docstring from another source function (if present)"
def do_copy(target):
if source.__doc__:
target.__doc__ = source.__doc__
return target
return do_copy | python | def copy(source):
"Copy a docstring from another source function (if present)"
def do_copy(target):
if source.__doc__:
target.__doc__ = source.__doc__
return target
return do_copy | [
"def",
"copy",
"(",
"source",
")",
":",
"def",
"do_copy",
"(",
"target",
")",
":",
"if",
"source",
".",
"__doc__",
":",
"target",
".",
"__doc__",
"=",
"source",
".",
"__doc__",
"return",
"target",
"return",
"do_copy"
] | Copy a docstring from another source function (if present) | [
"Copy",
"a",
"docstring",
"from",
"another",
"source",
"function",
"(",
"if",
"present",
")"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1759-L1767 | train |
pandas-dev/pandas | pandas/core/strings.py | StringMethods._get_series_list | def _get_series_list(self, others, ignore_index=False):
"""
Auxiliary function for :meth:`str.cat`. Turn potentially mixed input
into a list of Series (elements without an index must match the length
of the calling Series/Index).
Parameters
----------
others : Se... | python | def _get_series_list(self, others, ignore_index=False):
"""
Auxiliary function for :meth:`str.cat`. Turn potentially mixed input
into a list of Series (elements without an index must match the length
of the calling Series/Index).
Parameters
----------
others : Se... | [
"def",
"_get_series_list",
"(",
"self",
",",
"others",
",",
"ignore_index",
"=",
"False",
")",
":",
"# Once str.cat defaults to alignment, this function can be simplified;",
"# will not need `ignore_index` and the second boolean output anymore",
"from",
"pandas",
"import",
"Index",... | Auxiliary function for :meth:`str.cat`. Turn potentially mixed input
into a list of Series (elements without an index must match the length
of the calling Series/Index).
Parameters
----------
others : Series, Index, DataFrame, np.ndarray, list-like or list-like
of ob... | [
"Auxiliary",
"function",
"for",
":",
"meth",
":",
"str",
".",
"cat",
".",
"Turn",
"potentially",
"mixed",
"input",
"into",
"a",
"list",
"of",
"Series",
"(",
"elements",
"without",
"an",
"index",
"must",
"match",
"the",
"length",
"of",
"the",
"calling",
"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1922-L2032 | train |
pandas-dev/pandas | pandas/core/strings.py | StringMethods.cat | def cat(self, others=None, sep=None, na_rep=None, join=None):
"""
Concatenate strings in the Series/Index with given separator.
If `others` is specified, this function concatenates the Series/Index
and elements of `others` element-wise.
If `others` is not passed, then all values... | python | def cat(self, others=None, sep=None, na_rep=None, join=None):
"""
Concatenate strings in the Series/Index with given separator.
If `others` is specified, this function concatenates the Series/Index
and elements of `others` element-wise.
If `others` is not passed, then all values... | [
"def",
"cat",
"(",
"self",
",",
"others",
"=",
"None",
",",
"sep",
"=",
"None",
",",
"na_rep",
"=",
"None",
",",
"join",
"=",
"None",
")",
":",
"from",
"pandas",
"import",
"Index",
",",
"Series",
",",
"concat",
"if",
"isinstance",
"(",
"others",
",... | Concatenate strings in the Series/Index with given separator.
If `others` is specified, this function concatenates the Series/Index
and elements of `others` element-wise.
If `others` is not passed, then all values in the Series/Index are
concatenated into a single string with a given `s... | [
"Concatenate",
"strings",
"in",
"the",
"Series",
"/",
"Index",
"with",
"given",
"separator",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L2034-L2256 | train |
pandas-dev/pandas | pandas/core/strings.py | StringMethods.zfill | def zfill(self, width):
"""
Pad strings in the Series/Index by prepending '0' characters.
Strings in the Series/Index are padded with '0' characters on the
left of the string to reach a total string length `width`. Strings
in the Series/Index with length greater or equal to `wi... | python | def zfill(self, width):
"""
Pad strings in the Series/Index by prepending '0' characters.
Strings in the Series/Index are padded with '0' characters on the
left of the string to reach a total string length `width`. Strings
in the Series/Index with length greater or equal to `wi... | [
"def",
"zfill",
"(",
"self",
",",
"width",
")",
":",
"result",
"=",
"str_pad",
"(",
"self",
".",
"_parent",
",",
"width",
",",
"side",
"=",
"'left'",
",",
"fillchar",
"=",
"'0'",
")",
"return",
"self",
".",
"_wrap_result",
"(",
"result",
")"
] | Pad strings in the Series/Index by prepending '0' characters.
Strings in the Series/Index are padded with '0' characters on the
left of the string to reach a total string length `width`. Strings
in the Series/Index with length greater or equal to `width` are
unchanged.
Paramet... | [
"Pad",
"strings",
"in",
"the",
"Series",
"/",
"Index",
"by",
"prepending",
"0",
"characters",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L2564-L2625 | train |
pandas-dev/pandas | pandas/core/strings.py | StringMethods.normalize | def normalize(self, form):
"""
Return the Unicode normal form for the strings in the Series/Index.
For more information on the forms, see the
:func:`unicodedata.normalize`.
Parameters
----------
form : {'NFC', 'NFKC', 'NFD', 'NFKD'}
Unicode form
... | python | def normalize(self, form):
"""
Return the Unicode normal form for the strings in the Series/Index.
For more information on the forms, see the
:func:`unicodedata.normalize`.
Parameters
----------
form : {'NFC', 'NFKC', 'NFD', 'NFKD'}
Unicode form
... | [
"def",
"normalize",
"(",
"self",
",",
"form",
")",
":",
"import",
"unicodedata",
"f",
"=",
"lambda",
"x",
":",
"unicodedata",
".",
"normalize",
"(",
"form",
",",
"x",
")",
"result",
"=",
"_na_map",
"(",
"f",
",",
"self",
".",
"_parent",
")",
"return"... | Return the Unicode normal form for the strings in the Series/Index.
For more information on the forms, see the
:func:`unicodedata.normalize`.
Parameters
----------
form : {'NFC', 'NFKC', 'NFD', 'NFKD'}
Unicode form
Returns
-------
normalized ... | [
"Return",
"the",
"Unicode",
"normal",
"form",
"for",
"the",
"strings",
"in",
"the",
"Series",
"/",
"Index",
".",
"For",
"more",
"information",
"on",
"the",
"forms",
"see",
"the",
":",
"func",
":",
"unicodedata",
".",
"normalize",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L2798-L2816 | train |
pandas-dev/pandas | pandas/util/_print_versions.py | get_sys_info | def get_sys_info():
"Returns system information as a dict"
blob = []
# get full commit hash
commit = None
if os.path.isdir(".git") and os.path.isdir("pandas"):
try:
pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "),
stdout=subpr... | python | def get_sys_info():
"Returns system information as a dict"
blob = []
# get full commit hash
commit = None
if os.path.isdir(".git") and os.path.isdir("pandas"):
try:
pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "),
stdout=subpr... | [
"def",
"get_sys_info",
"(",
")",
":",
"blob",
"=",
"[",
"]",
"# get full commit hash",
"commit",
"=",
"None",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"\".git\"",
")",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"\"pandas\"",
")",
":",
"try",
":"... | Returns system information as a dict | [
"Returns",
"system",
"information",
"as",
"a",
"dict"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_print_versions.py#L11-L56 | train |
pandas-dev/pandas | pandas/core/groupby/base.py | whitelist_method_generator | def whitelist_method_generator(base, klass, whitelist):
"""
Yields all GroupBy member defs for DataFrame/Series names in whitelist.
Parameters
----------
base : class
base class
klass : class
class where members are defined.
Should be Series or DataFrame
whitelist : ... | python | def whitelist_method_generator(base, klass, whitelist):
"""
Yields all GroupBy member defs for DataFrame/Series names in whitelist.
Parameters
----------
base : class
base class
klass : class
class where members are defined.
Should be Series or DataFrame
whitelist : ... | [
"def",
"whitelist_method_generator",
"(",
"base",
",",
"klass",
",",
"whitelist",
")",
":",
"method_wrapper_template",
"=",
"\"\"\"def %(name)s(%(sig)s) :\n \\\"\"\"\n %(doc)s\n \\\"\"\"\n f = %(self)s.__getattr__('%(name)s')\n return f(%(args)s)\"\"\"",
"property_wrapper_te... | Yields all GroupBy member defs for DataFrame/Series names in whitelist.
Parameters
----------
base : class
base class
klass : class
class where members are defined.
Should be Series or DataFrame
whitelist : list
list of names of klass methods to be constructed
R... | [
"Yields",
"all",
"GroupBy",
"member",
"defs",
"for",
"DataFrame",
"/",
"Series",
"names",
"in",
"whitelist",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/base.py#L96-L157 | train |
pandas-dev/pandas | pandas/core/groupby/base.py | GroupByMixin._dispatch | def _dispatch(name, *args, **kwargs):
"""
Dispatch to apply.
"""
def outer(self, *args, **kwargs):
def f(x):
x = self._shallow_copy(x, groupby=self._groupby)
return getattr(x, name)(*args, **kwargs)
return self._groupby.apply(f)
... | python | def _dispatch(name, *args, **kwargs):
"""
Dispatch to apply.
"""
def outer(self, *args, **kwargs):
def f(x):
x = self._shallow_copy(x, groupby=self._groupby)
return getattr(x, name)(*args, **kwargs)
return self._groupby.apply(f)
... | [
"def",
"_dispatch",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"outer",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"f",
"(",
"x",
")",
":",
"x",
"=",
"self",
".",
"_shallow_copy",
"(... | Dispatch to apply. | [
"Dispatch",
"to",
"apply",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/base.py#L20-L31 | train |
pandas-dev/pandas | pandas/core/groupby/base.py | GroupByMixin._gotitem | def _gotitem(self, key, ndim, subset=None):
"""
Sub-classes to define. Return a sliced object.
Parameters
----------
key : string / list of selections
ndim : 1,2
requested ndim of result
subset : object, default None
subset to act on
... | python | def _gotitem(self, key, ndim, subset=None):
"""
Sub-classes to define. Return a sliced object.
Parameters
----------
key : string / list of selections
ndim : 1,2
requested ndim of result
subset : object, default None
subset to act on
... | [
"def",
"_gotitem",
"(",
"self",
",",
"key",
",",
"ndim",
",",
"subset",
"=",
"None",
")",
":",
"# create a new object to prevent aliasing",
"if",
"subset",
"is",
"None",
":",
"subset",
"=",
"self",
".",
"obj",
"# we need to make a shallow copy of ourselves",
"# wi... | Sub-classes to define. Return a sliced object.
Parameters
----------
key : string / list of selections
ndim : 1,2
requested ndim of result
subset : object, default None
subset to act on | [
"Sub",
"-",
"classes",
"to",
"define",
".",
"Return",
"a",
"sliced",
"object",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/base.py#L33-L67 | train |
pandas-dev/pandas | pandas/compat/__init__.py | to_str | def to_str(s):
"""
Convert bytes and non-string into Python 3 str
"""
if isinstance(s, bytes):
s = s.decode('utf-8')
elif not isinstance(s, str):
s = str(s)
return s | python | def to_str(s):
"""
Convert bytes and non-string into Python 3 str
"""
if isinstance(s, bytes):
s = s.decode('utf-8')
elif not isinstance(s, str):
s = str(s)
return s | [
"def",
"to_str",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"bytes",
")",
":",
"s",
"=",
"s",
".",
"decode",
"(",
"'utf-8'",
")",
"elif",
"not",
"isinstance",
"(",
"s",
",",
"str",
")",
":",
"s",
"=",
"str",
"(",
"s",
")",
"return... | Convert bytes and non-string into Python 3 str | [
"Convert",
"bytes",
"and",
"non",
"-",
"string",
"into",
"Python",
"3",
"str"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/__init__.py#L44-L52 | train |
pandas-dev/pandas | pandas/compat/__init__.py | set_function_name | def set_function_name(f, name, cls):
"""
Bind the name/qualname attributes of the function
"""
f.__name__ = name
f.__qualname__ = '{klass}.{name}'.format(
klass=cls.__name__,
name=name)
f.__module__ = cls.__module__
return f | python | def set_function_name(f, name, cls):
"""
Bind the name/qualname attributes of the function
"""
f.__name__ = name
f.__qualname__ = '{klass}.{name}'.format(
klass=cls.__name__,
name=name)
f.__module__ = cls.__module__
return f | [
"def",
"set_function_name",
"(",
"f",
",",
"name",
",",
"cls",
")",
":",
"f",
".",
"__name__",
"=",
"name",
"f",
".",
"__qualname__",
"=",
"'{klass}.{name}'",
".",
"format",
"(",
"klass",
"=",
"cls",
".",
"__name__",
",",
"name",
"=",
"name",
")",
"f... | Bind the name/qualname attributes of the function | [
"Bind",
"the",
"name",
"/",
"qualname",
"attributes",
"of",
"the",
"function"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/__init__.py#L55-L64 | train |
pandas-dev/pandas | pandas/compat/__init__.py | raise_with_traceback | def raise_with_traceback(exc, traceback=Ellipsis):
"""
Raise exception with existing traceback.
If traceback is not passed, uses sys.exc_info() to get traceback.
"""
if traceback == Ellipsis:
_, _, traceback = sys.exc_info()
raise exc.with_traceback(traceback) | python | def raise_with_traceback(exc, traceback=Ellipsis):
"""
Raise exception with existing traceback.
If traceback is not passed, uses sys.exc_info() to get traceback.
"""
if traceback == Ellipsis:
_, _, traceback = sys.exc_info()
raise exc.with_traceback(traceback) | [
"def",
"raise_with_traceback",
"(",
"exc",
",",
"traceback",
"=",
"Ellipsis",
")",
":",
"if",
"traceback",
"==",
"Ellipsis",
":",
"_",
",",
"_",
",",
"traceback",
"=",
"sys",
".",
"exc_info",
"(",
")",
"raise",
"exc",
".",
"with_traceback",
"(",
"traceba... | Raise exception with existing traceback.
If traceback is not passed, uses sys.exc_info() to get traceback. | [
"Raise",
"exception",
"with",
"existing",
"traceback",
".",
"If",
"traceback",
"is",
"not",
"passed",
"uses",
"sys",
".",
"exc_info",
"()",
"to",
"get",
"traceback",
"."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/compat/__init__.py#L67-L74 | train |
pandas-dev/pandas | pandas/io/excel/_openpyxl.py | _OpenpyxlWriter._convert_to_style | def _convert_to_style(cls, style_dict):
"""
converts a style_dict to an openpyxl style object
Parameters
----------
style_dict : style dictionary to convert
"""
from openpyxl.style import Style
xls_style = Style()
for key, value in style_dict.item... | python | def _convert_to_style(cls, style_dict):
"""
converts a style_dict to an openpyxl style object
Parameters
----------
style_dict : style dictionary to convert
"""
from openpyxl.style import Style
xls_style = Style()
for key, value in style_dict.item... | [
"def",
"_convert_to_style",
"(",
"cls",
",",
"style_dict",
")",
":",
"from",
"openpyxl",
".",
"style",
"import",
"Style",
"xls_style",
"=",
"Style",
"(",
")",
"for",
"key",
",",
"value",
"in",
"style_dict",
".",
"items",
"(",
")",
":",
"for",
"nk",
","... | converts a style_dict to an openpyxl style object
Parameters
----------
style_dict : style dictionary to convert | [
"converts",
"a",
"style_dict",
"to",
"an",
"openpyxl",
"style",
"object",
"Parameters",
"----------",
"style_dict",
":",
"style",
"dictionary",
"to",
"convert"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L38-L56 | train |
pandas-dev/pandas | pandas/io/excel/_openpyxl.py | _OpenpyxlWriter._convert_to_style_kwargs | def _convert_to_style_kwargs(cls, style_dict):
"""
Convert a style_dict to a set of kwargs suitable for initializing
or updating-on-copy an openpyxl v2 style object
Parameters
----------
style_dict : dict
A dict with zero or more of the following keys (or thei... | python | def _convert_to_style_kwargs(cls, style_dict):
"""
Convert a style_dict to a set of kwargs suitable for initializing
or updating-on-copy an openpyxl v2 style object
Parameters
----------
style_dict : dict
A dict with zero or more of the following keys (or thei... | [
"def",
"_convert_to_style_kwargs",
"(",
"cls",
",",
"style_dict",
")",
":",
"_style_key_map",
"=",
"{",
"'borders'",
":",
"'border'",
",",
"}",
"style_kwargs",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"style_dict",
".",
"items",
"(",
")",
":",
"if",
... | Convert a style_dict to a set of kwargs suitable for initializing
or updating-on-copy an openpyxl v2 style object
Parameters
----------
style_dict : dict
A dict with zero or more of the following keys (or their synonyms).
'font'
'fill'
... | [
"Convert",
"a",
"style_dict",
"to",
"a",
"set",
"of",
"kwargs",
"suitable",
"for",
"initializing",
"or",
"updating",
"-",
"on",
"-",
"copy",
"an",
"openpyxl",
"v2",
"style",
"object",
"Parameters",
"----------",
"style_dict",
":",
"dict",
"A",
"dict",
"with"... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L59-L95 | train |
pandas-dev/pandas | pandas/io/excel/_openpyxl.py | _OpenpyxlWriter._convert_to_color | def _convert_to_color(cls, color_spec):
"""
Convert ``color_spec`` to an openpyxl v2 Color object
Parameters
----------
color_spec : str, dict
A 32-bit ARGB hex string, or a dict with zero or more of the
following keys.
'rgb'
... | python | def _convert_to_color(cls, color_spec):
"""
Convert ``color_spec`` to an openpyxl v2 Color object
Parameters
----------
color_spec : str, dict
A 32-bit ARGB hex string, or a dict with zero or more of the
following keys.
'rgb'
... | [
"def",
"_convert_to_color",
"(",
"cls",
",",
"color_spec",
")",
":",
"from",
"openpyxl",
".",
"styles",
"import",
"Color",
"if",
"isinstance",
"(",
"color_spec",
",",
"str",
")",
":",
"return",
"Color",
"(",
"color_spec",
")",
"else",
":",
"return",
"Color... | Convert ``color_spec`` to an openpyxl v2 Color object
Parameters
----------
color_spec : str, dict
A 32-bit ARGB hex string, or a dict with zero or more of the
following keys.
'rgb'
'indexed'
'auto'
'theme'
... | [
"Convert",
"color_spec",
"to",
"an",
"openpyxl",
"v2",
"Color",
"object",
"Parameters",
"----------",
"color_spec",
":",
"str",
"dict",
"A",
"32",
"-",
"bit",
"ARGB",
"hex",
"string",
"or",
"a",
"dict",
"with",
"zero",
"or",
"more",
"of",
"the",
"following... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L98-L123 | train |
pandas-dev/pandas | pandas/io/excel/_openpyxl.py | _OpenpyxlWriter._convert_to_font | def _convert_to_font(cls, font_dict):
"""
Convert ``font_dict`` to an openpyxl v2 Font object
Parameters
----------
font_dict : dict
A dict with zero or more of the following keys (or their synonyms).
'name'
'size' ('sz')
... | python | def _convert_to_font(cls, font_dict):
"""
Convert ``font_dict`` to an openpyxl v2 Font object
Parameters
----------
font_dict : dict
A dict with zero or more of the following keys (or their synonyms).
'name'
'size' ('sz')
... | [
"def",
"_convert_to_font",
"(",
"cls",
",",
"font_dict",
")",
":",
"from",
"openpyxl",
".",
"styles",
"import",
"Font",
"_font_key_map",
"=",
"{",
"'sz'",
":",
"'size'",
",",
"'b'",
":",
"'bold'",
",",
"'i'",
":",
"'italic'",
",",
"'u'",
":",
"'underline... | Convert ``font_dict`` to an openpyxl v2 Font object
Parameters
----------
font_dict : dict
A dict with zero or more of the following keys (or their synonyms).
'name'
'size' ('sz')
'bold' ('b')
'italic' ('i')
... | [
"Convert",
"font_dict",
"to",
"an",
"openpyxl",
"v2",
"Font",
"object",
"Parameters",
"----------",
"font_dict",
":",
"dict",
"A",
"dict",
"with",
"zero",
"or",
"more",
"of",
"the",
"following",
"keys",
"(",
"or",
"their",
"synonyms",
")",
".",
"name",
"si... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L126-L171 | train |
pandas-dev/pandas | pandas/io/excel/_openpyxl.py | _OpenpyxlWriter._convert_to_fill | def _convert_to_fill(cls, fill_dict):
"""
Convert ``fill_dict`` to an openpyxl v2 Fill object
Parameters
----------
fill_dict : dict
A dict with one or more of the following keys (or their synonyms),
'fill_type' ('patternType', 'patterntype')
... | python | def _convert_to_fill(cls, fill_dict):
"""
Convert ``fill_dict`` to an openpyxl v2 Fill object
Parameters
----------
fill_dict : dict
A dict with one or more of the following keys (or their synonyms),
'fill_type' ('patternType', 'patterntype')
... | [
"def",
"_convert_to_fill",
"(",
"cls",
",",
"fill_dict",
")",
":",
"from",
"openpyxl",
".",
"styles",
"import",
"PatternFill",
",",
"GradientFill",
"_pattern_fill_key_map",
"=",
"{",
"'patternType'",
":",
"'fill_type'",
",",
"'patterntype'",
":",
"'fill_type'",
",... | Convert ``fill_dict`` to an openpyxl v2 Fill object
Parameters
----------
fill_dict : dict
A dict with one or more of the following keys (or their synonyms),
'fill_type' ('patternType', 'patterntype')
'start_color' ('fgColor', 'fgcolor')
... | [
"Convert",
"fill_dict",
"to",
"an",
"openpyxl",
"v2",
"Fill",
"object",
"Parameters",
"----------",
"fill_dict",
":",
"dict",
"A",
"dict",
"with",
"one",
"or",
"more",
"of",
"the",
"following",
"keys",
"(",
"or",
"their",
"synonyms",
")",
"fill_type",
"(",
... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L191-L252 | train |
pandas-dev/pandas | pandas/io/excel/_openpyxl.py | _OpenpyxlWriter._convert_to_side | def _convert_to_side(cls, side_spec):
"""
Convert ``side_spec`` to an openpyxl v2 Side object
Parameters
----------
side_spec : str, dict
A string specifying the border style, or a dict with zero or more
of the following keys (or their synonyms).
... | python | def _convert_to_side(cls, side_spec):
"""
Convert ``side_spec`` to an openpyxl v2 Side object
Parameters
----------
side_spec : str, dict
A string specifying the border style, or a dict with zero or more
of the following keys (or their synonyms).
... | [
"def",
"_convert_to_side",
"(",
"cls",
",",
"side_spec",
")",
":",
"from",
"openpyxl",
".",
"styles",
"import",
"Side",
"_side_key_map",
"=",
"{",
"'border_style'",
":",
"'style'",
",",
"}",
"if",
"isinstance",
"(",
"side_spec",
",",
"str",
")",
":",
"retu... | Convert ``side_spec`` to an openpyxl v2 Side object
Parameters
----------
side_spec : str, dict
A string specifying the border style, or a dict with zero or more
of the following keys (or their synonyms).
'style' ('border_style')
'color'
... | [
"Convert",
"side_spec",
"to",
"an",
"openpyxl",
"v2",
"Side",
"object",
"Parameters",
"----------",
"side_spec",
":",
"str",
"dict",
"A",
"string",
"specifying",
"the",
"border",
"style",
"or",
"a",
"dict",
"with",
"zero",
"or",
"more",
"of",
"the",
"followi... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L255-L287 | train |
pandas-dev/pandas | pandas/io/excel/_openpyxl.py | _OpenpyxlWriter._convert_to_border | def _convert_to_border(cls, border_dict):
"""
Convert ``border_dict`` to an openpyxl v2 Border object
Parameters
----------
border_dict : dict
A dict with zero or more of the following keys (or their synonyms).
'left'
'right'
... | python | def _convert_to_border(cls, border_dict):
"""
Convert ``border_dict`` to an openpyxl v2 Border object
Parameters
----------
border_dict : dict
A dict with zero or more of the following keys (or their synonyms).
'left'
'right'
... | [
"def",
"_convert_to_border",
"(",
"cls",
",",
"border_dict",
")",
":",
"from",
"openpyxl",
".",
"styles",
"import",
"Border",
"_border_key_map",
"=",
"{",
"'diagonalup'",
":",
"'diagonalUp'",
",",
"'diagonaldown'",
":",
"'diagonalDown'",
",",
"}",
"border_kwargs",... | Convert ``border_dict`` to an openpyxl v2 Border object
Parameters
----------
border_dict : dict
A dict with zero or more of the following keys (or their synonyms).
'left'
'right'
'top'
'bottom'
'diagonal... | [
"Convert",
"border_dict",
"to",
"an",
"openpyxl",
"v2",
"Border",
"object",
"Parameters",
"----------",
"border_dict",
":",
"dict",
"A",
"dict",
"with",
"zero",
"or",
"more",
"of",
"the",
"following",
"keys",
"(",
"or",
"their",
"synonyms",
")",
".",
"left",... | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L290-L330 | train |
pandas-dev/pandas | pandas/core/apply.py | frame_apply | def frame_apply(obj, func, axis=0, broadcast=None,
raw=False, reduce=None, result_type=None,
ignore_failures=False,
args=None, kwds=None):
""" construct and return a row or column based frame apply object """
axis = obj._get_axis_number(axis)
if axis == 0:
... | python | def frame_apply(obj, func, axis=0, broadcast=None,
raw=False, reduce=None, result_type=None,
ignore_failures=False,
args=None, kwds=None):
""" construct and return a row or column based frame apply object """
axis = obj._get_axis_number(axis)
if axis == 0:
... | [
"def",
"frame_apply",
"(",
"obj",
",",
"func",
",",
"axis",
"=",
"0",
",",
"broadcast",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"reduce",
"=",
"None",
",",
"result_type",
"=",
"None",
",",
"ignore_failures",
"=",
"False",
",",
"args",
"=",
"None"... | construct and return a row or column based frame apply object | [
"construct",
"and",
"return",
"a",
"row",
"or",
"column",
"based",
"frame",
"apply",
"object"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L16-L31 | train |
pandas-dev/pandas | pandas/core/apply.py | FrameApply.get_result | def get_result(self):
""" compute the results """
# dispatch to agg
if is_list_like(self.f) or is_dict_like(self.f):
return self.obj.aggregate(self.f, axis=self.axis,
*self.args, **self.kwds)
# all empty
if len(self.columns) == ... | python | def get_result(self):
""" compute the results """
# dispatch to agg
if is_list_like(self.f) or is_dict_like(self.f):
return self.obj.aggregate(self.f, axis=self.axis,
*self.args, **self.kwds)
# all empty
if len(self.columns) == ... | [
"def",
"get_result",
"(",
"self",
")",
":",
"# dispatch to agg",
"if",
"is_list_like",
"(",
"self",
".",
"f",
")",
"or",
"is_dict_like",
"(",
"self",
".",
"f",
")",
":",
"return",
"self",
".",
"obj",
".",
"aggregate",
"(",
"self",
".",
"f",
",",
"axi... | compute the results | [
"compute",
"the",
"results"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L108-L150 | train |
pandas-dev/pandas | pandas/core/apply.py | FrameApply.apply_empty_result | def apply_empty_result(self):
"""
we have an empty result; at least 1 axis is 0
we will try to apply the function to an empty
series in order to see if this is a reduction function
"""
# we are not asked to reduce or infer reduction
# so just return a copy of th... | python | def apply_empty_result(self):
"""
we have an empty result; at least 1 axis is 0
we will try to apply the function to an empty
series in order to see if this is a reduction function
"""
# we are not asked to reduce or infer reduction
# so just return a copy of th... | [
"def",
"apply_empty_result",
"(",
"self",
")",
":",
"# we are not asked to reduce or infer reduction",
"# so just return a copy of the existing object",
"if",
"self",
".",
"result_type",
"not",
"in",
"[",
"'reduce'",
",",
"None",
"]",
":",
"return",
"self",
".",
"obj",
... | we have an empty result; at least 1 axis is 0
we will try to apply the function to an empty
series in order to see if this is a reduction function | [
"we",
"have",
"an",
"empty",
"result",
";",
"at",
"least",
"1",
"axis",
"is",
"0"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L152-L181 | train |
pandas-dev/pandas | pandas/core/apply.py | FrameApply.apply_raw | def apply_raw(self):
""" apply to the values as a numpy array """
try:
result = reduction.reduce(self.values, self.f, axis=self.axis)
except Exception:
result = np.apply_along_axis(self.f, self.axis, self.values)
# TODO: mixed type case
if result.ndim ==... | python | def apply_raw(self):
""" apply to the values as a numpy array """
try:
result = reduction.reduce(self.values, self.f, axis=self.axis)
except Exception:
result = np.apply_along_axis(self.f, self.axis, self.values)
# TODO: mixed type case
if result.ndim ==... | [
"def",
"apply_raw",
"(",
"self",
")",
":",
"try",
":",
"result",
"=",
"reduction",
".",
"reduce",
"(",
"self",
".",
"values",
",",
"self",
".",
"f",
",",
"axis",
"=",
"self",
".",
"axis",
")",
"except",
"Exception",
":",
"result",
"=",
"np",
".",
... | apply to the values as a numpy array | [
"apply",
"to",
"the",
"values",
"as",
"a",
"numpy",
"array"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L183-L198 | train |
pandas-dev/pandas | pandas/core/apply.py | FrameRowApply.wrap_results_for_axis | def wrap_results_for_axis(self):
""" return the results for the rows """
results = self.results
result = self.obj._constructor(data=results)
if not isinstance(results[0], ABCSeries):
try:
result.index = self.res_columns
except ValueError:
... | python | def wrap_results_for_axis(self):
""" return the results for the rows """
results = self.results
result = self.obj._constructor(data=results)
if not isinstance(results[0], ABCSeries):
try:
result.index = self.res_columns
except ValueError:
... | [
"def",
"wrap_results_for_axis",
"(",
"self",
")",
":",
"results",
"=",
"self",
".",
"results",
"result",
"=",
"self",
".",
"obj",
".",
"_constructor",
"(",
"data",
"=",
"results",
")",
"if",
"not",
"isinstance",
"(",
"results",
"[",
"0",
"]",
",",
"ABC... | return the results for the rows | [
"return",
"the",
"results",
"for",
"the",
"rows"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L335-L352 | train |
pandas-dev/pandas | pandas/core/apply.py | FrameColumnApply.wrap_results_for_axis | def wrap_results_for_axis(self):
""" return the results for the columns """
results = self.results
# we have requested to expand
if self.result_type == 'expand':
result = self.infer_to_same_shape()
# we have a non-series and don't want inference
elif not isi... | python | def wrap_results_for_axis(self):
""" return the results for the columns """
results = self.results
# we have requested to expand
if self.result_type == 'expand':
result = self.infer_to_same_shape()
# we have a non-series and don't want inference
elif not isi... | [
"def",
"wrap_results_for_axis",
"(",
"self",
")",
":",
"results",
"=",
"self",
".",
"results",
"# we have requested to expand",
"if",
"self",
".",
"result_type",
"==",
"'expand'",
":",
"result",
"=",
"self",
".",
"infer_to_same_shape",
"(",
")",
"# we have a non-s... | return the results for the columns | [
"return",
"the",
"results",
"for",
"the",
"columns"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L377-L395 | train |
pandas-dev/pandas | pandas/core/apply.py | FrameColumnApply.infer_to_same_shape | def infer_to_same_shape(self):
""" infer the results to the same shape as the input object """
results = self.results
result = self.obj._constructor(data=results)
result = result.T
# set the index
result.index = self.res_index
# infer dtypes
result = re... | python | def infer_to_same_shape(self):
""" infer the results to the same shape as the input object """
results = self.results
result = self.obj._constructor(data=results)
result = result.T
# set the index
result.index = self.res_index
# infer dtypes
result = re... | [
"def",
"infer_to_same_shape",
"(",
"self",
")",
":",
"results",
"=",
"self",
".",
"results",
"result",
"=",
"self",
".",
"obj",
".",
"_constructor",
"(",
"data",
"=",
"results",
")",
"result",
"=",
"result",
".",
"T",
"# set the index",
"result",
".",
"i... | infer the results to the same shape as the input object | [
"infer",
"the",
"results",
"to",
"the",
"same",
"shape",
"as",
"the",
"input",
"object"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/apply.py#L397-L410 | train |
pandas-dev/pandas | pandas/core/reshape/util.py | cartesian_product | def cartesian_product(X):
"""
Numpy version of itertools.product.
Sometimes faster (for large inputs)...
Parameters
----------
X : list-like of list-likes
Returns
-------
product : list of ndarrays
Examples
--------
>>> cartesian_product([list('ABC'), [1, 2]])
[arr... | python | def cartesian_product(X):
"""
Numpy version of itertools.product.
Sometimes faster (for large inputs)...
Parameters
----------
X : list-like of list-likes
Returns
-------
product : list of ndarrays
Examples
--------
>>> cartesian_product([list('ABC'), [1, 2]])
[arr... | [
"def",
"cartesian_product",
"(",
"X",
")",
":",
"msg",
"=",
"\"Input must be a list-like of list-likes\"",
"if",
"not",
"is_list_like",
"(",
"X",
")",
":",
"raise",
"TypeError",
"(",
"msg",
")",
"for",
"x",
"in",
"X",
":",
"if",
"not",
"is_list_like",
"(",
... | Numpy version of itertools.product.
Sometimes faster (for large inputs)...
Parameters
----------
X : list-like of list-likes
Returns
-------
product : list of ndarrays
Examples
--------
>>> cartesian_product([list('ABC'), [1, 2]])
[array(['A', 'A', 'B', 'B', 'C', 'C'], dty... | [
"Numpy",
"version",
"of",
"itertools",
".",
"product",
".",
"Sometimes",
"faster",
"(",
"for",
"large",
"inputs",
")",
"..."
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/util.py#L8-L56 | train |
pandas-dev/pandas | pandas/io/s3.py | _strip_schema | def _strip_schema(url):
"""Returns the url without the s3:// part"""
result = parse_url(url, allow_fragments=False)
return result.netloc + result.path | python | def _strip_schema(url):
"""Returns the url without the s3:// part"""
result = parse_url(url, allow_fragments=False)
return result.netloc + result.path | [
"def",
"_strip_schema",
"(",
"url",
")",
":",
"result",
"=",
"parse_url",
"(",
"url",
",",
"allow_fragments",
"=",
"False",
")",
"return",
"result",
".",
"netloc",
"+",
"result",
".",
"path"
] | Returns the url without the s3:// part | [
"Returns",
"the",
"url",
"without",
"the",
"s3",
":",
"//",
"part"
] | 9feb3ad92cc0397a04b665803a49299ee7aa1037 | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/s3.py#L11-L14 | train |
fastai/fastai | fastai/vision/models/xception.py | xception | def xception(c, k=8, n_middle=8):
"Preview version of Xception network. Not tested yet - use at own risk. No pretrained model yet."
layers = [
conv(3, k*4, 3, 2),
conv(k*4, k*8, 3),
ConvSkip(k*8, k*16, act=False),
ConvSkip(k*16, k*32),
ConvSkip(k*32, k*91),
]
for ... | python | def xception(c, k=8, n_middle=8):
"Preview version of Xception network. Not tested yet - use at own risk. No pretrained model yet."
layers = [
conv(3, k*4, 3, 2),
conv(k*4, k*8, 3),
ConvSkip(k*8, k*16, act=False),
ConvSkip(k*16, k*32),
ConvSkip(k*32, k*91),
]
for ... | [
"def",
"xception",
"(",
"c",
",",
"k",
"=",
"8",
",",
"n_middle",
"=",
"8",
")",
":",
"layers",
"=",
"[",
"conv",
"(",
"3",
",",
"k",
"*",
"4",
",",
"3",
",",
"2",
")",
",",
"conv",
"(",
"k",
"*",
"4",
",",
"k",
"*",
"8",
",",
"3",
")... | Preview version of Xception network. Not tested yet - use at own risk. No pretrained model yet. | [
"Preview",
"version",
"of",
"Xception",
"network",
".",
"Not",
"tested",
"yet",
"-",
"use",
"at",
"own",
"risk",
".",
"No",
"pretrained",
"model",
"yet",
"."
] | 9fb84a5cdefe5a766cdb792b8f5d8971737b7e67 | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/models/xception.py#L41-L60 | train |
fastai/fastai | old/fastai/nlp.py | LanguageModelData.get_model | def get_model(self, opt_fn, emb_sz, n_hid, n_layers, **kwargs):
""" Method returns a RNN_Learner object, that wraps an instance of the RNN_Encoder module.
Args:
opt_fn (Optimizer): the torch optimizer function to use
emb_sz (int): embedding size
n_hid (int): number o... | python | def get_model(self, opt_fn, emb_sz, n_hid, n_layers, **kwargs):
""" Method returns a RNN_Learner object, that wraps an instance of the RNN_Encoder module.
Args:
opt_fn (Optimizer): the torch optimizer function to use
emb_sz (int): embedding size
n_hid (int): number o... | [
"def",
"get_model",
"(",
"self",
",",
"opt_fn",
",",
"emb_sz",
",",
"n_hid",
",",
"n_layers",
",",
"*",
"*",
"kwargs",
")",
":",
"m",
"=",
"get_language_model",
"(",
"self",
".",
"nt",
",",
"emb_sz",
",",
"n_hid",
",",
"n_layers",
",",
"self",
".",
... | Method returns a RNN_Learner object, that wraps an instance of the RNN_Encoder module.
Args:
opt_fn (Optimizer): the torch optimizer function to use
emb_sz (int): embedding size
n_hid (int): number of hidden inputs
n_layers (int): number of hidden layers
... | [
"Method",
"returns",
"a",
"RNN_Learner",
"object",
"that",
"wraps",
"an",
"instance",
"of",
"the",
"RNN_Encoder",
"module",
"."
] | 9fb84a5cdefe5a766cdb792b8f5d8971737b7e67 | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/old/fastai/nlp.py#L263-L279 | train |
fastai/fastai | old/fastai/nlp.py | LanguageModelData.from_text_files | def from_text_files(cls, path, field, train, validation, test=None, bs=64, bptt=70, **kwargs):
""" Method used to instantiate a LanguageModelData object that can be used for a
supported nlp task.
Args:
path (str): the absolute path in which temporary model data will be saved
... | python | def from_text_files(cls, path, field, train, validation, test=None, bs=64, bptt=70, **kwargs):
""" Method used to instantiate a LanguageModelData object that can be used for a
supported nlp task.
Args:
path (str): the absolute path in which temporary model data will be saved
... | [
"def",
"from_text_files",
"(",
"cls",
",",
"path",
",",
"field",
",",
"train",
",",
"validation",
",",
"test",
"=",
"None",
",",
"bs",
"=",
"64",
",",
"bptt",
"=",
"70",
",",
"*",
"*",
"kwargs",
")",
":",
"trn_ds",
",",
"val_ds",
",",
"test_ds",
... | Method used to instantiate a LanguageModelData object that can be used for a
supported nlp task.
Args:
path (str): the absolute path in which temporary model data will be saved
field (Field): torchtext field
train (str): file location of the training data
... | [
"Method",
"used",
"to",
"instantiate",
"a",
"LanguageModelData",
"object",
"that",
"can",
"be",
"used",
"for",
"a",
"supported",
"nlp",
"task",
"."
] | 9fb84a5cdefe5a766cdb792b8f5d8971737b7e67 | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/old/fastai/nlp.py#L288-L313 | train |
fastai/fastai | fastai/data_block.py | get_files | def get_files(path:PathOrStr, extensions:Collection[str]=None, recurse:bool=False,
include:Optional[Collection[str]]=None)->FilePathList:
"Return list of files in `path` that have a suffix in `extensions`; optionally `recurse`."
if recurse:
res = []
for i,(p,d,f) in enumerate(os.wa... | python | def get_files(path:PathOrStr, extensions:Collection[str]=None, recurse:bool=False,
include:Optional[Collection[str]]=None)->FilePathList:
"Return list of files in `path` that have a suffix in `extensions`; optionally `recurse`."
if recurse:
res = []
for i,(p,d,f) in enumerate(os.wa... | [
"def",
"get_files",
"(",
"path",
":",
"PathOrStr",
",",
"extensions",
":",
"Collection",
"[",
"str",
"]",
"=",
"None",
",",
"recurse",
":",
"bool",
"=",
"False",
",",
"include",
":",
"Optional",
"[",
"Collection",
"[",
"str",
"]",
"]",
"=",
"None",
"... | Return list of files in `path` that have a suffix in `extensions`; optionally `recurse`. | [
"Return",
"list",
"of",
"files",
"in",
"path",
"that",
"have",
"a",
"suffix",
"in",
"extensions",
";",
"optionally",
"recurse",
"."
] | 9fb84a5cdefe5a766cdb792b8f5d8971737b7e67 | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L23-L36 | train |
fastai/fastai | fastai/data_block.py | _databunch_load_empty | def _databunch_load_empty(cls, path, fname:str='export.pkl'):
"Load an empty `DataBunch` from the exported file in `path/fname` with optional `tfms`."
sd = LabelLists.load_empty(path, fn=fname)
return sd.databunch() | python | def _databunch_load_empty(cls, path, fname:str='export.pkl'):
"Load an empty `DataBunch` from the exported file in `path/fname` with optional `tfms`."
sd = LabelLists.load_empty(path, fn=fname)
return sd.databunch() | [
"def",
"_databunch_load_empty",
"(",
"cls",
",",
"path",
",",
"fname",
":",
"str",
"=",
"'export.pkl'",
")",
":",
"sd",
"=",
"LabelLists",
".",
"load_empty",
"(",
"path",
",",
"fn",
"=",
"fname",
")",
"return",
"sd",
".",
"databunch",
"(",
")"
] | Load an empty `DataBunch` from the exported file in `path/fname` with optional `tfms`. | [
"Load",
"an",
"empty",
"DataBunch",
"from",
"the",
"exported",
"file",
"in",
"path",
"/",
"fname",
"with",
"optional",
"tfms",
"."
] | 9fb84a5cdefe5a766cdb792b8f5d8971737b7e67 | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L734-L737 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.