partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
MPLPlot._has_plotted_object
check whether ax has data
pandas/plotting/_core.py
def _has_plotted_object(self, ax): """check whether ax has data""" return (len(ax.lines) != 0 or len(ax.artists) != 0 or len(ax.containers) != 0)
def _has_plotted_object(self, ax): """check whether ax has data""" return (len(ax.lines) != 0 or len(ax.artists) != 0 or len(ax.containers) != 0)
[ "check", "whether", "ax", "has", "data" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L260-L264
[ "def", "_has_plotted_object", "(", "self", ",", "ax", ")", ":", "return", "(", "len", "(", "ax", ".", "lines", ")", "!=", "0", "or", "len", "(", "ax", ".", "artists", ")", "!=", "0", "or", "len", "(", "ax", ".", "containers", ")", "!=", "0", ")...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
MPLPlot.result
Return result axes
pandas/plotting/_core.py
def result(self): """ Return result axes """ if self.subplots: if self.layout is not None and not is_list_like(self.ax): return self.axes.reshape(*self.layout) else: return self.axes else: sec_true = isinstance(s...
def result(self): """ Return result axes """ if self.subplots: if self.layout is not None and not is_list_like(self.ax): return self.axes.reshape(*self.layout) else: return self.axes else: sec_true = isinstance(s...
[ "Return", "result", "axes" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L336-L353
[ "def", "result", "(", "self", ")", ":", "if", "self", ".", "subplots", ":", "if", "self", ".", "layout", "is", "not", "None", "and", "not", "is_list_like", "(", "self", ".", "ax", ")", ":", "return", "self", ".", "axes", ".", "reshape", "(", "*", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
MPLPlot._post_plot_logic_common
Common post process for each axes
pandas/plotting/_core.py
def _post_plot_logic_common(self, ax, data): """Common post process for each axes""" def get_label(i): try: return pprint_thing(data.index[i]) except Exception: return '' if self.orientation == 'vertical' or self.orientation is None: ...
def _post_plot_logic_common(self, ax, data): """Common post process for each axes""" def get_label(i): try: return pprint_thing(data.index[i]) except Exception: return '' if self.orientation == 'vertical' or self.orientation is None: ...
[ "Common", "post", "process", "for", "each", "axes" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L402-L435
[ "def", "_post_plot_logic_common", "(", "self", ",", "ax", ",", "data", ")", ":", "def", "get_label", "(", "i", ")", ":", "try", ":", "return", "pprint_thing", "(", "data", ".", "index", "[", "i", "]", ")", "except", "Exception", ":", "return", "''", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
MPLPlot._adorn_subplots
Common post process unrelated to data
pandas/plotting/_core.py
def _adorn_subplots(self): """Common post process unrelated to data""" if len(self.axes) > 0: all_axes = self._get_subplots() nrows, ncols = self._get_axes_layout() _handle_shared_axes(axarr=all_axes, nplots=len(all_axes), naxes=nrows *...
def _adorn_subplots(self): """Common post process unrelated to data""" if len(self.axes) > 0: all_axes = self._get_subplots() nrows, ncols = self._get_axes_layout() _handle_shared_axes(axarr=all_axes, nplots=len(all_axes), naxes=nrows *...
[ "Common", "post", "process", "unrelated", "to", "data" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L441-L487
[ "def", "_adorn_subplots", "(", "self", ")", ":", "if", "len", "(", "self", ".", "axes", ")", ">", "0", ":", "all_axes", "=", "self", ".", "_get_subplots", "(", ")", "nrows", ",", "ncols", "=", "self", ".", "_get_axes_layout", "(", ")", "_handle_shared_...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
MPLPlot._apply_axis_properties
Tick creation within matplotlib is reasonably expensive and is internally deferred until accessed as Ticks are created/destroyed multiple times per draw. It's therefore beneficial for us to avoid accessing unless we will act on the Tick.
pandas/plotting/_core.py
def _apply_axis_properties(self, axis, rot=None, fontsize=None): """ Tick creation within matplotlib is reasonably expensive and is internally deferred until accessed as Ticks are created/destroyed multiple times per draw. It's therefore beneficial for us to avoid accessing u...
def _apply_axis_properties(self, axis, rot=None, fontsize=None): """ Tick creation within matplotlib is reasonably expensive and is internally deferred until accessed as Ticks are created/destroyed multiple times per draw. It's therefore beneficial for us to avoid accessing u...
[ "Tick", "creation", "within", "matplotlib", "is", "reasonably", "expensive", "and", "is", "internally", "deferred", "until", "accessed", "as", "Ticks", "are", "created", "/", "destroyed", "multiple", "times", "per", "draw", ".", "It", "s", "therefore", "benefici...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L489-L503
[ "def", "_apply_axis_properties", "(", "self", ",", "axis", ",", "rot", "=", "None", ",", "fontsize", "=", "None", ")", ":", "if", "rot", "is", "not", "None", "or", "fontsize", "is", "not", "None", ":", "# rot=0 is a valid setting, hence the explicit None check",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
MPLPlot._get_ax_layer
get left (primary) or right (secondary) axes
pandas/plotting/_core.py
def _get_ax_layer(cls, ax, primary=True): """get left (primary) or right (secondary) axes""" if primary: return getattr(ax, 'left_ax', ax) else: return getattr(ax, 'right_ax', ax)
def _get_ax_layer(cls, ax, primary=True): """get left (primary) or right (secondary) axes""" if primary: return getattr(ax, 'left_ax', ax) else: return getattr(ax, 'right_ax', ax)
[ "get", "left", "(", "primary", ")", "or", "right", "(", "secondary", ")", "axes" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L644-L649
[ "def", "_get_ax_layer", "(", "cls", ",", "ax", ",", "primary", "=", "True", ")", ":", "if", "primary", ":", "return", "getattr", "(", "ax", ",", "'left_ax'", ",", "ax", ")", "else", ":", "return", "getattr", "(", "ax", ",", "'right_ax'", ",", "ax", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
MPLPlot._apply_style_colors
Manage style and color based on column number and its label. Returns tuple of appropriate style and kwds which "color" may be added.
pandas/plotting/_core.py
def _apply_style_colors(self, colors, kwds, col_num, label): """ Manage style and color based on column number and its label. Returns tuple of appropriate style and kwds which "color" may be added. """ style = None if self.style is not None: if isinstance(self...
def _apply_style_colors(self, colors, kwds, col_num, label): """ Manage style and color based on column number and its label. Returns tuple of appropriate style and kwds which "color" may be added. """ style = None if self.style is not None: if isinstance(self...
[ "Manage", "style", "and", "color", "based", "on", "column", "number", "and", "its", "label", ".", "Returns", "tuple", "of", "appropriate", "style", "and", "kwds", "which", "color", "may", "be", "added", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L672-L693
[ "def", "_apply_style_colors", "(", "self", ",", "colors", ",", "kwds", ",", "col_num", ",", "label", ")", ":", "style", "=", "None", "if", "self", ".", "style", "is", "not", "None", ":", "if", "isinstance", "(", "self", ".", "style", ",", "list", ")"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
MPLPlot._parse_errorbars
Look for error keyword arguments and return the actual errorbar data or return the error DataFrame/dict Error bars can be specified in several ways: Series: the user provides a pandas.Series object of the same length as the data ndarray: provides a np.ndarray...
pandas/plotting/_core.py
def _parse_errorbars(self, label, err): """ Look for error keyword arguments and return the actual errorbar data or return the error DataFrame/dict Error bars can be specified in several ways: Series: the user provides a pandas.Series object of the same l...
def _parse_errorbars(self, label, err): """ Look for error keyword arguments and return the actual errorbar data or return the error DataFrame/dict Error bars can be specified in several ways: Series: the user provides a pandas.Series object of the same l...
[ "Look", "for", "error", "keyword", "arguments", "and", "return", "the", "actual", "errorbar", "data", "or", "return", "the", "error", "DataFrame", "/", "dict" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L703-L776
[ "def", "_parse_errorbars", "(", "self", ",", "label", ",", "err", ")", ":", "if", "err", "is", "None", ":", "return", "None", "def", "match_labels", "(", "data", ",", "e", ")", ":", "e", "=", "e", ".", "reindex", "(", "data", ".", "index", ")", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
HistPlot._make_plot_keywords
merge BoxPlot/KdePlot properties to passed kwds
pandas/plotting/_core.py
def _make_plot_keywords(self, kwds, y): """merge BoxPlot/KdePlot properties to passed kwds""" # y is required for KdePlot kwds['bottom'] = self.bottom kwds['bins'] = self.bins return kwds
def _make_plot_keywords(self, kwds, y): """merge BoxPlot/KdePlot properties to passed kwds""" # y is required for KdePlot kwds['bottom'] = self.bottom kwds['bins'] = self.bins return kwds
[ "merge", "BoxPlot", "/", "KdePlot", "properties", "to", "passed", "kwds" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L1395-L1400
[ "def", "_make_plot_keywords", "(", "self", ",", "kwds", ",", "y", ")", ":", "# y is required for KdePlot", "kwds", "[", "'bottom'", "]", "=", "self", ".", "bottom", "kwds", "[", "'bins'", "]", "=", "self", ".", "bins", "return", "kwds" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FramePlotMethods.line
Plot DataFrame columns as lines. This function is useful to plot lines using DataFrame's values as coordinates. Parameters ---------- x : int or str, optional Columns to use for the horizontal axis. Either the location or the label of the columns to be u...
pandas/plotting/_core.py
def line(self, x=None, y=None, **kwds): """ Plot DataFrame columns as lines. This function is useful to plot lines using DataFrame's values as coordinates. Parameters ---------- x : int or str, optional Columns to use for the horizontal axis. ...
def line(self, x=None, y=None, **kwds): """ Plot DataFrame columns as lines. This function is useful to plot lines using DataFrame's values as coordinates. Parameters ---------- x : int or str, optional Columns to use for the horizontal axis. ...
[ "Plot", "DataFrame", "columns", "as", "lines", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L2970-L3031
[ "def", "line", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'line'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "*", "*", "kwds", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FramePlotMethods.bar
Vertical bar plot. A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the plot shows the specific categories being compared, and the ...
pandas/plotting/_core.py
def bar(self, x=None, y=None, **kwds): """ Vertical bar plot. A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the pl...
def bar(self, x=None, y=None, **kwds): """ Vertical bar plot. A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the pl...
[ "Vertical", "bar", "plot", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3033-L3116
[ "def", "bar", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'bar'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "*", "*", "kwds", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FramePlotMethods.barh
Make a horizontal bar plot. A horizontal bar plot is a plot that presents quantitative data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the plot shows the specific categories being...
pandas/plotting/_core.py
def barh(self, x=None, y=None, **kwds): """ Make a horizontal bar plot. A horizontal bar plot is a plot that presents quantitative data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One ...
def barh(self, x=None, y=None, **kwds): """ Make a horizontal bar plot. A horizontal bar plot is a plot that presents quantitative data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One ...
[ "Make", "a", "horizontal", "bar", "plot", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3118-L3196
[ "def", "barh", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'barh'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "*", "*", "kwds", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FramePlotMethods.hist
Draw one histogram of the DataFrame's columns. A histogram is a representation of the distribution of data. This function groups the values of all given Series in the DataFrame into bins and draws all bins in one :class:`matplotlib.axes.Axes`. This is useful when the DataFrame's Series ...
pandas/plotting/_core.py
def hist(self, by=None, bins=10, **kwds): """ Draw one histogram of the DataFrame's columns. A histogram is a representation of the distribution of data. This function groups the values of all given Series in the DataFrame into bins and draws all bins in one :class:`matplotlib.a...
def hist(self, by=None, bins=10, **kwds): """ Draw one histogram of the DataFrame's columns. A histogram is a representation of the distribution of data. This function groups the values of all given Series in the DataFrame into bins and draws all bins in one :class:`matplotlib.a...
[ "Draw", "one", "histogram", "of", "the", "DataFrame", "s", "columns", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3248-L3293
[ "def", "hist", "(", "self", ",", "by", "=", "None", ",", "bins", "=", "10", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'hist'", ",", "by", "=", "by", ",", "bins", "=", "bins", ",", "*", "*", "kwds", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FramePlotMethods.area
Draw a stacked area plot. An area plot displays quantitative data visually. This function wraps the matplotlib area function. Parameters ---------- x : label or position, optional Coordinates for the X axis. By default uses the index. y : label or position, ...
pandas/plotting/_core.py
def area(self, x=None, y=None, **kwds): """ Draw a stacked area plot. An area plot displays quantitative data visually. This function wraps the matplotlib area function. Parameters ---------- x : label or position, optional Coordinates for the X axis...
def area(self, x=None, y=None, **kwds): """ Draw a stacked area plot. An area plot displays quantitative data visually. This function wraps the matplotlib area function. Parameters ---------- x : label or position, optional Coordinates for the X axis...
[ "Draw", "a", "stacked", "area", "plot", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3341-L3412
[ "def", "area", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'area'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "*", "*", "kwds", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FramePlotMethods.scatter
Create a scatter plot with varying marker point size and color. The coordinates of each point are defined by two dataframe columns and filled circles are used to represent each point. This kind of plot is useful to see complex correlations between two variables. Points could be for inst...
pandas/plotting/_core.py
def scatter(self, x, y, s=None, c=None, **kwds): """ Create a scatter plot with varying marker point size and color. The coordinates of each point are defined by two dataframe columns and filled circles are used to represent each point. This kind of plot is useful to see complex...
def scatter(self, x, y, s=None, c=None, **kwds): """ Create a scatter plot with varying marker point size and color. The coordinates of each point are defined by two dataframe columns and filled circles are used to represent each point. This kind of plot is useful to see complex...
[ "Create", "a", "scatter", "plot", "with", "varying", "marker", "point", "size", "and", "color", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3463-L3542
[ "def", "scatter", "(", "self", ",", "x", ",", "y", ",", "s", "=", "None", ",", "c", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "self", "(", "kind", "=", "'scatter'", ",", "x", "=", "x", ",", "y", "=", "y", ",", "c", "=", "c",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
FramePlotMethods.hexbin
Generate a hexagonal binning plot. Generate a hexagonal binning plot of `x` versus `y`. If `C` is `None` (the default), this is a histogram of the number of occurrences of the observations at ``(x[i], y[i])``. If `C` is specified, specifies values at given coordinates ``(x[i], ...
pandas/plotting/_core.py
def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwds): """ Generate a hexagonal binning plot. Generate a hexagonal binning plot of `x` versus `y`. If `C` is `None` (the default), this is a histogram of the number of occurrences of the obser...
def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwds): """ Generate a hexagonal binning plot. Generate a hexagonal binning plot of `x` versus `y`. If `C` is `None` (the default), this is a histogram of the number of occurrences of the obser...
[ "Generate", "a", "hexagonal", "binning", "plot", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3544-L3631
[ "def", "hexbin", "(", "self", ",", "x", ",", "y", ",", "C", "=", "None", ",", "reduce_C_function", "=", "None", ",", "gridsize", "=", "None", ",", "*", "*", "kwds", ")", ":", "if", "reduce_C_function", "is", "not", "None", ":", "kwds", "[", "'reduc...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_objs_combined_axis
Extract combined index: return intersection or union (depending on the value of "intersect") of indexes on given axis, or None if all objects lack indexes (e.g. they are numpy arrays). Parameters ---------- objs : list of objects Each object will only be considered if it has a _get_axis ...
pandas/core/indexes/api.py
def _get_objs_combined_axis(objs, intersect=False, axis=0, sort=True): """ Extract combined index: return intersection or union (depending on the value of "intersect") of indexes on given axis, or None if all objects lack indexes (e.g. they are numpy arrays). Parameters ---------- objs : li...
def _get_objs_combined_axis(objs, intersect=False, axis=0, sort=True): """ Extract combined index: return intersection or union (depending on the value of "intersect") of indexes on given axis, or None if all objects lack indexes (e.g. they are numpy arrays). Parameters ---------- objs : li...
[ "Extract", "combined", "index", ":", "return", "intersection", "or", "union", "(", "depending", "on", "the", "value", "of", "intersect", ")", "of", "indexes", "on", "given", "axis", "or", "None", "if", "all", "objects", "lack", "indexes", "(", "e", ".", ...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L44-L70
[ "def", "_get_objs_combined_axis", "(", "objs", ",", "intersect", "=", "False", ",", "axis", "=", "0", ",", "sort", "=", "True", ")", ":", "obs_idxes", "=", "[", "obj", ".", "_get_axis", "(", "axis", ")", "for", "obj", "in", "objs", "if", "hasattr", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_distinct_objs
Return a list with distinct elements of "objs" (different ids). Preserves order.
pandas/core/indexes/api.py
def _get_distinct_objs(objs): """ Return a list with distinct elements of "objs" (different ids). Preserves order. """ ids = set() res = [] for obj in objs: if not id(obj) in ids: ids.add(id(obj)) res.append(obj) return res
def _get_distinct_objs(objs): """ Return a list with distinct elements of "objs" (different ids). Preserves order. """ ids = set() res = [] for obj in objs: if not id(obj) in ids: ids.add(id(obj)) res.append(obj) return res
[ "Return", "a", "list", "with", "distinct", "elements", "of", "objs", "(", "different", "ids", ")", ".", "Preserves", "order", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L73-L84
[ "def", "_get_distinct_objs", "(", "objs", ")", ":", "ids", "=", "set", "(", ")", "res", "=", "[", "]", "for", "obj", "in", "objs", ":", "if", "not", "id", "(", "obj", ")", "in", "ids", ":", "ids", ".", "add", "(", "id", "(", "obj", ")", ")", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_combined_index
Return the union or intersection of indexes. Parameters ---------- indexes : list of Index or list objects When intersect=True, do not accept list of lists. intersect : bool, default False If True, calculate the intersection between indexes. Otherwise, calculate the union. s...
pandas/core/indexes/api.py
def _get_combined_index(indexes, intersect=False, sort=False): """ Return the union or intersection of indexes. Parameters ---------- indexes : list of Index or list objects When intersect=True, do not accept list of lists. intersect : bool, default False If True, calculate the ...
def _get_combined_index(indexes, intersect=False, sort=False): """ Return the union or intersection of indexes. Parameters ---------- indexes : list of Index or list objects When intersect=True, do not accept list of lists. intersect : bool, default False If True, calculate the ...
[ "Return", "the", "union", "or", "intersection", "of", "indexes", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L87-L125
[ "def", "_get_combined_index", "(", "indexes", ",", "intersect", "=", "False", ",", "sort", "=", "False", ")", ":", "# TODO: handle index names!", "indexes", "=", "_get_distinct_objs", "(", "indexes", ")", "if", "len", "(", "indexes", ")", "==", "0", ":", "in...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_union_indexes
Return the union of indexes. The behavior of sort and names is not consistent. Parameters ---------- indexes : list of Index or list objects sort : bool, default True Whether the result index should come out sorted or not. Returns ------- Index
pandas/core/indexes/api.py
def _union_indexes(indexes, sort=True): """ Return the union of indexes. The behavior of sort and names is not consistent. Parameters ---------- indexes : list of Index or list objects sort : bool, default True Whether the result index should come out sorted or not. Returns ...
def _union_indexes(indexes, sort=True): """ Return the union of indexes. The behavior of sort and names is not consistent. Parameters ---------- indexes : list of Index or list objects sort : bool, default True Whether the result index should come out sorted or not. Returns ...
[ "Return", "the", "union", "of", "indexes", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L128-L202
[ "def", "_union_indexes", "(", "indexes", ",", "sort", "=", "True", ")", ":", "if", "len", "(", "indexes", ")", "==", "0", ":", "raise", "AssertionError", "(", "'Must have at least 1 Index to union'", ")", "if", "len", "(", "indexes", ")", "==", "1", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_sanitize_and_check
Verify the type of indexes and convert lists to Index. Cases: - [list, list, ...]: Return ([list, list, ...], 'list') - [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...]) Lists are sorted and converted to Index. - [Index, Index, ...]: Return ([Index, Index, ...], TYPE) ...
pandas/core/indexes/api.py
def _sanitize_and_check(indexes): """ Verify the type of indexes and convert lists to Index. Cases: - [list, list, ...]: Return ([list, list, ...], 'list') - [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...]) Lists are sorted and converted to Index. - [Index, Index, .....
def _sanitize_and_check(indexes): """ Verify the type of indexes and convert lists to Index. Cases: - [list, list, ...]: Return ([list, list, ...], 'list') - [list, Index, ...]: Return _sanitize_and_check([Index, Index, ...]) Lists are sorted and converted to Index. - [Index, Index, .....
[ "Verify", "the", "type", "of", "indexes", "and", "convert", "lists", "to", "Index", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L205-L240
[ "def", "_sanitize_and_check", "(", "indexes", ")", ":", "kinds", "=", "list", "(", "{", "type", "(", "index", ")", "for", "index", "in", "indexes", "}", ")", "if", "list", "in", "kinds", ":", "if", "len", "(", "kinds", ")", ">", "1", ":", "indexes"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_consensus_names
Give a consensus 'names' to indexes. If there's exactly one non-empty 'names', return this, otherwise, return empty. Parameters ---------- indexes : list of Index objects Returns ------- list A list representing the consensus 'names' found.
pandas/core/indexes/api.py
def _get_consensus_names(indexes): """ Give a consensus 'names' to indexes. If there's exactly one non-empty 'names', return this, otherwise, return empty. Parameters ---------- indexes : list of Index objects Returns ------- list A list representing the consensus 'nam...
def _get_consensus_names(indexes): """ Give a consensus 'names' to indexes. If there's exactly one non-empty 'names', return this, otherwise, return empty. Parameters ---------- indexes : list of Index objects Returns ------- list A list representing the consensus 'nam...
[ "Give", "a", "consensus", "names", "to", "indexes", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L243-L266
[ "def", "_get_consensus_names", "(", "indexes", ")", ":", "# find the non-none names, need to tupleify to make", "# the set hashable, then reverse on return", "consensus_names", "=", "{", "tuple", "(", "i", ".", "names", ")", "for", "i", "in", "indexes", "if", "com", "."...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_all_indexes_same
Determine if all indexes contain the same elements. Parameters ---------- indexes : list of Index objects Returns ------- bool True if all indexes contain the same elements, False otherwise.
pandas/core/indexes/api.py
def _all_indexes_same(indexes): """ Determine if all indexes contain the same elements. Parameters ---------- indexes : list of Index objects Returns ------- bool True if all indexes contain the same elements, False otherwise. """ first = indexes[0] for index in ind...
def _all_indexes_same(indexes): """ Determine if all indexes contain the same elements. Parameters ---------- indexes : list of Index objects Returns ------- bool True if all indexes contain the same elements, False otherwise. """ first = indexes[0] for index in ind...
[ "Determine", "if", "all", "indexes", "contain", "the", "same", "elements", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/api.py#L269-L286
[ "def", "_all_indexes_same", "(", "indexes", ")", ":", "first", "=", "indexes", "[", "0", "]", "for", "index", "in", "indexes", "[", "1", ":", "]", ":", "if", "not", "first", ".", "equals", "(", "index", ")", ":", "return", "False", "return", "True" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_convert_params
Convert SQL and params args to DBAPI2.0 compliant format.
pandas/io/sql.py
def _convert_params(sql, params): """Convert SQL and params args to DBAPI2.0 compliant format.""" args = [sql] if params is not None: if hasattr(params, 'keys'): # test if params is a mapping args += [params] else: args += [list(params)] return args
def _convert_params(sql, params): """Convert SQL and params args to DBAPI2.0 compliant format.""" args = [sql] if params is not None: if hasattr(params, 'keys'): # test if params is a mapping args += [params] else: args += [list(params)] return args
[ "Convert", "SQL", "and", "params", "args", "to", "DBAPI2", ".", "0", "compliant", "format", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L57-L65
[ "def", "_convert_params", "(", "sql", ",", "params", ")", ":", "args", "=", "[", "sql", "]", "if", "params", "is", "not", "None", ":", "if", "hasattr", "(", "params", ",", "'keys'", ")", ":", "# test if params is a mapping", "args", "+=", "[", "params", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_process_parse_dates_argument
Process parse_dates argument for read_sql functions
pandas/io/sql.py
def _process_parse_dates_argument(parse_dates): """Process parse_dates argument for read_sql functions""" # handle non-list entries for parse_dates gracefully if parse_dates is True or parse_dates is None or parse_dates is False: parse_dates = [] elif not hasattr(parse_dates, '__iter__'): ...
def _process_parse_dates_argument(parse_dates): """Process parse_dates argument for read_sql functions""" # handle non-list entries for parse_dates gracefully if parse_dates is True or parse_dates is None or parse_dates is False: parse_dates = [] elif not hasattr(parse_dates, '__iter__'): ...
[ "Process", "parse_dates", "argument", "for", "read_sql", "functions" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L68-L76
[ "def", "_process_parse_dates_argument", "(", "parse_dates", ")", ":", "# handle non-list entries for parse_dates gracefully", "if", "parse_dates", "is", "True", "or", "parse_dates", "is", "None", "or", "parse_dates", "is", "False", ":", "parse_dates", "=", "[", "]", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_parse_date_columns
Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns.
pandas/io/sql.py
def _parse_date_columns(data_frame, parse_dates): """ Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns. """ parse_dates = _process_parse_dates_argument(parse_dates) # we want to coerce datetime64_tz dtypes for now to UTC # we could ...
def _parse_date_columns(data_frame, parse_dates): """ Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns. """ parse_dates = _process_parse_dates_argument(parse_dates) # we want to coerce datetime64_tz dtypes for now to UTC # we could ...
[ "Force", "non", "-", "datetime", "columns", "to", "be", "read", "as", "such", ".", "Supports", "both", "string", "formatted", "and", "integer", "timestamp", "columns", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L98-L116
[ "def", "_parse_date_columns", "(", "data_frame", ",", "parse_dates", ")", ":", "parse_dates", "=", "_process_parse_dates_argument", "(", "parse_dates", ")", "# we want to coerce datetime64_tz dtypes for now to UTC", "# we could in theory do a 'nice' conversion from a FixedOffset tz", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_wrap_result
Wrap result set of query in a DataFrame.
pandas/io/sql.py
def _wrap_result(data, columns, index_col=None, coerce_float=True, parse_dates=None): """Wrap result set of query in a DataFrame.""" frame = DataFrame.from_records(data, columns=columns, coerce_float=coerce_float) frame = _parse_date_columns(frame, parse...
def _wrap_result(data, columns, index_col=None, coerce_float=True, parse_dates=None): """Wrap result set of query in a DataFrame.""" frame = DataFrame.from_records(data, columns=columns, coerce_float=coerce_float) frame = _parse_date_columns(frame, parse...
[ "Wrap", "result", "set", "of", "query", "in", "a", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L119-L131
[ "def", "_wrap_result", "(", "data", ",", "columns", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ")", ":", "frame", "=", "DataFrame", ".", "from_records", "(", "data", ",", "columns", "=", "columns", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
execute
Execute the given SQL query using the provided connection object. Parameters ---------- sql : string SQL query to be executed. con : SQLAlchemy connectable(engine/connection) or sqlite3 connection Using SQLAlchemy makes it possible to use any DB supported by the library. ...
pandas/io/sql.py
def execute(sql, con, cur=None, params=None): """ Execute the given SQL query using the provided connection object. Parameters ---------- sql : string SQL query to be executed. con : SQLAlchemy connectable(engine/connection) or sqlite3 connection Using SQLAlchemy makes it possib...
def execute(sql, con, cur=None, params=None): """ Execute the given SQL query using the provided connection object. Parameters ---------- sql : string SQL query to be executed. con : SQLAlchemy connectable(engine/connection) or sqlite3 connection Using SQLAlchemy makes it possib...
[ "Execute", "the", "given", "SQL", "query", "using", "the", "provided", "connection", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L134-L159
[ "def", "execute", "(", "sql", ",", "con", ",", "cur", "=", "None", ",", "params", "=", "None", ")", ":", "if", "cur", "is", "None", ":", "pandas_sql", "=", "pandasSQL_builder", "(", "con", ")", "else", ":", "pandas_sql", "=", "pandasSQL_builder", "(", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
read_sql_table
Read SQL database table into a DataFrame. Given a table name and a SQLAlchemy connectable, returns a DataFrame. This function does not support DBAPI connections. Parameters ---------- table_name : str Name of SQL table in database. con : SQLAlchemy connectable or str A database...
pandas/io/sql.py
def read_sql_table(table_name, con, schema=None, index_col=None, coerce_float=True, parse_dates=None, columns=None, chunksize=None): """ Read SQL database table into a DataFrame. Given a table name and a SQLAlchemy connectable, returns a DataFrame. This function do...
def read_sql_table(table_name, con, schema=None, index_col=None, coerce_float=True, parse_dates=None, columns=None, chunksize=None): """ Read SQL database table into a DataFrame. Given a table name and a SQLAlchemy connectable, returns a DataFrame. This function do...
[ "Read", "SQL", "database", "table", "into", "a", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L165-L244
[ "def", "read_sql_table", "(", "table_name", ",", "con", ",", "schema", "=", "None", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ",", "columns", "=", "None", ",", "chunksize", "=", "None", ")", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
read_sql_query
Read SQL query into a DataFrame. Returns a DataFrame corresponding to the result set of the query string. Optionally provide an `index_col` parameter to use one of the columns as the index, otherwise default integer index will be used. Parameters ---------- sql : string SQL query or SQLAlchemy...
pandas/io/sql.py
def read_sql_query(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, chunksize=None): """Read SQL query into a DataFrame. Returns a DataFrame corresponding to the result set of the query string. Optionally provide an `index_col` parameter to use one of the c...
def read_sql_query(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, chunksize=None): """Read SQL query into a DataFrame. Returns a DataFrame corresponding to the result set of the query string. Optionally provide an `index_col` parameter to use one of the c...
[ "Read", "SQL", "query", "into", "a", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L247-L305
[ "def", "read_sql_query", "(", "sql", ",", "con", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "params", "=", "None", ",", "parse_dates", "=", "None", ",", "chunksize", "=", "None", ")", ":", "pandas_sql", "=", "pandasSQL_builder", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
read_sql
Read SQL query or database table into a DataFrame. This function is a convenience wrapper around ``read_sql_table`` and ``read_sql_query`` (for backward compatibility). It will delegate to the specific function depending on the provided input. A SQL query will be routed to ``read_sql_query``, while a d...
pandas/io/sql.py
def read_sql(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, columns=None, chunksize=None): """ Read SQL query or database table into a DataFrame. This function is a convenience wrapper around ``read_sql_table`` and ``read_sql_query`` (for backward compatibility...
def read_sql(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, columns=None, chunksize=None): """ Read SQL query or database table into a DataFrame. This function is a convenience wrapper around ``read_sql_table`` and ``read_sql_query`` (for backward compatibility...
[ "Read", "SQL", "query", "or", "database", "table", "into", "a", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L308-L388
[ "def", "read_sql", "(", "sql", ",", "con", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "params", "=", "None", ",", "parse_dates", "=", "None", ",", "columns", "=", "None", ",", "chunksize", "=", "None", ")", ":", "pandas_sql",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
to_sql
Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame, Series name : string Name of SQL table. con : SQLAlchemy connectable(engine/connection) or database string URI or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to u...
pandas/io/sql.py
def to_sql(frame, name, con, schema=None, if_exists='fail', index=True, index_label=None, chunksize=None, dtype=None, method=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame, Series name : string Name of SQL table. ...
def to_sql(frame, name, con, schema=None, if_exists='fail', index=True, index_label=None, chunksize=None, dtype=None, method=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame, Series name : string Name of SQL table. ...
[ "Write", "records", "stored", "in", "a", "DataFrame", "to", "a", "SQL", "database", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L391-L451
[ "def", "to_sql", "(", "frame", ",", "name", ",", "con", ",", "schema", "=", "None", ",", "if_exists", "=", "'fail'", ",", "index", "=", "True", ",", "index_label", "=", "None", ",", "chunksize", "=", "None", ",", "dtype", "=", "None", ",", "method", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
has_table
Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table. con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only...
pandas/io/sql.py
def has_table(table_name, con, schema=None): """ Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table. con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported ...
def has_table(table_name, con, schema=None): """ Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table. con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported ...
[ "Check", "if", "DataBase", "has", "named", "table", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L454-L475
[ "def", "has_table", "(", "table_name", ",", "con", ",", "schema", "=", "None", ")", ":", "pandas_sql", "=", "pandasSQL_builder", "(", "con", ",", "schema", "=", "schema", ")", "return", "pandas_sql", ".", "has_table", "(", "table_name", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_engine_builder
Returns a SQLAlchemy engine from a URI (if con is a string) else it just return con without modifying it.
pandas/io/sql.py
def _engine_builder(con): """ Returns a SQLAlchemy engine from a URI (if con is a string) else it just return con without modifying it. """ global _SQLALCHEMY_INSTALLED if isinstance(con, str): try: import sqlalchemy except ImportError: _SQLALCHEMY_INSTALL...
def _engine_builder(con): """ Returns a SQLAlchemy engine from a URI (if con is a string) else it just return con without modifying it. """ global _SQLALCHEMY_INSTALLED if isinstance(con, str): try: import sqlalchemy except ImportError: _SQLALCHEMY_INSTALL...
[ "Returns", "a", "SQLAlchemy", "engine", "from", "a", "URI", "(", "if", "con", "is", "a", "string", ")", "else", "it", "just", "return", "con", "without", "modifying", "it", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L481-L496
[ "def", "_engine_builder", "(", "con", ")", ":", "global", "_SQLALCHEMY_INSTALLED", "if", "isinstance", "(", "con", ",", "str", ")", ":", "try", ":", "import", "sqlalchemy", "except", "ImportError", ":", "_SQLALCHEMY_INSTALLED", "=", "False", "else", ":", "con"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
pandasSQL_builder
Convenience function to return the correct PandasSQL subclass based on the provided parameters.
pandas/io/sql.py
def pandasSQL_builder(con, schema=None, meta=None, is_cursor=False): """ Convenience function to return the correct PandasSQL subclass based on the provided parameters. """ # When support for DBAPI connections is removed, # is_cursor should not be necessary. con = _engi...
def pandasSQL_builder(con, schema=None, meta=None, is_cursor=False): """ Convenience function to return the correct PandasSQL subclass based on the provided parameters. """ # When support for DBAPI connections is removed, # is_cursor should not be necessary. con = _engi...
[ "Convenience", "function", "to", "return", "the", "correct", "PandasSQL", "subclass", "based", "on", "the", "provided", "parameters", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L499-L513
[ "def", "pandasSQL_builder", "(", "con", ",", "schema", "=", "None", ",", "meta", "=", "None", ",", "is_cursor", "=", "False", ")", ":", "# When support for DBAPI connections is removed,", "# is_cursor should not be necessary.", "con", "=", "_engine_builder", "(", "con...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
get_schema
Get the SQL db table schema for the given frame. Parameters ---------- frame : DataFrame name : string name of SQL table keys : string or sequence, default: None columns to use a primary key con: an open SQL database connection object or a SQLAlchemy connectable Using SQ...
pandas/io/sql.py
def get_schema(frame, name, keys=None, con=None, dtype=None): """ Get the SQL db table schema for the given frame. Parameters ---------- frame : DataFrame name : string name of SQL table keys : string or sequence, default: None columns to use a primary key con: an open S...
def get_schema(frame, name, keys=None, con=None, dtype=None): """ Get the SQL db table schema for the given frame. Parameters ---------- frame : DataFrame name : string name of SQL table keys : string or sequence, default: None columns to use a primary key con: an open S...
[ "Get", "the", "SQL", "db", "table", "schema", "for", "the", "given", "frame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1564-L1586
[ "def", "get_schema", "(", "frame", ",", "name", ",", "keys", "=", "None", ",", "con", "=", "None", ",", "dtype", "=", "None", ")", ":", "pandas_sql", "=", "pandasSQL_builder", "(", "con", "=", "con", ")", "return", "pandas_sql", ".", "_create_sql_schema"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLTable._execute_insert
Execute SQL statement inserting data Parameters ---------- conn : sqlalchemy.engine.Engine or sqlalchemy.engine.Connection keys : list of str Column names data_iter : generator of list Each item contains a list of values to be inserted
pandas/io/sql.py
def _execute_insert(self, conn, keys, data_iter): """Execute SQL statement inserting data Parameters ---------- conn : sqlalchemy.engine.Engine or sqlalchemy.engine.Connection keys : list of str Column names data_iter : generator of list Each item c...
def _execute_insert(self, conn, keys, data_iter): """Execute SQL statement inserting data Parameters ---------- conn : sqlalchemy.engine.Engine or sqlalchemy.engine.Connection keys : list of str Column names data_iter : generator of list Each item c...
[ "Execute", "SQL", "statement", "inserting", "data" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L578-L590
[ "def", "_execute_insert", "(", "self", ",", "conn", ",", "keys", ",", "data_iter", ")", ":", "data", "=", "[", "dict", "(", "zip", "(", "keys", ",", "row", ")", ")", "for", "row", "in", "data_iter", "]", "conn", ".", "execute", "(", "self", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLTable._query_iterator
Return generator through chunked result set.
pandas/io/sql.py
def _query_iterator(self, result, chunksize, columns, coerce_float=True, parse_dates=None): """Return generator through chunked result set.""" while True: data = result.fetchmany(chunksize) if not data: break else: ...
def _query_iterator(self, result, chunksize, columns, coerce_float=True, parse_dates=None): """Return generator through chunked result set.""" while True: data = result.fetchmany(chunksize) if not data: break else: ...
[ "Return", "generator", "through", "chunked", "result", "set", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L679-L696
[ "def", "_query_iterator", "(", "self", ",", "result", ",", "chunksize", ",", "columns", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ")", ":", "while", "True", ":", "data", "=", "result", ".", "fetchmany", "(", "chunksize", ")", "if...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLTable._harmonize_columns
Make the DataFrame's column types align with the SQL table column types. Need to work around limited NA value support. Floats are always fine, ints must always be floats if there are Null values. Booleans are hard because converting bool column with None replaces all Nones with f...
pandas/io/sql.py
def _harmonize_columns(self, parse_dates=None): """ Make the DataFrame's column types align with the SQL table column types. Need to work around limited NA value support. Floats are always fine, ints must always be floats if there are Null values. Booleans are hard becaus...
def _harmonize_columns(self, parse_dates=None): """ Make the DataFrame's column types align with the SQL table column types. Need to work around limited NA value support. Floats are always fine, ints must always be floats if there are Null values. Booleans are hard becaus...
[ "Make", "the", "DataFrame", "s", "column", "types", "align", "with", "the", "SQL", "table", "column", "types", ".", "Need", "to", "work", "around", "limited", "NA", "value", "support", ".", "Floats", "are", "always", "fine", "ints", "must", "always", "be",...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L803-L851
[ "def", "_harmonize_columns", "(", "self", ",", "parse_dates", "=", "None", ")", ":", "parse_dates", "=", "_process_parse_dates_argument", "(", "parse_dates", ")", "for", "sql_col", "in", "self", ".", "table", ".", "columns", ":", "col_name", "=", "sql_col", "....
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLDatabase.read_table
Read SQL database table into a DataFrame. Parameters ---------- table_name : string Name of SQL table in database. index_col : string, optional, default: None Column to set as index. coerce_float : boolean, default True Attempts to convert val...
pandas/io/sql.py
def read_table(self, table_name, index_col=None, coerce_float=True, parse_dates=None, columns=None, schema=None, chunksize=None): """Read SQL database table into a DataFrame. Parameters ---------- table_name : string Name of SQL table in...
def read_table(self, table_name, index_col=None, coerce_float=True, parse_dates=None, columns=None, schema=None, chunksize=None): """Read SQL database table into a DataFrame. Parameters ---------- table_name : string Name of SQL table in...
[ "Read", "SQL", "database", "table", "into", "a", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L982-L1029
[ "def", "read_table", "(", "self", ",", "table_name", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ",", "columns", "=", "None", ",", "schema", "=", "None", ",", "chunksize", "=", "None", ")", ":", "ta...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLDatabase._query_iterator
Return generator through chunked result set
pandas/io/sql.py
def _query_iterator(result, chunksize, columns, index_col=None, coerce_float=True, parse_dates=None): """Return generator through chunked result set""" while True: data = result.fetchmany(chunksize) if not data: break else: ...
def _query_iterator(result, chunksize, columns, index_col=None, coerce_float=True, parse_dates=None): """Return generator through chunked result set""" while True: data = result.fetchmany(chunksize) if not data: break else: ...
[ "Return", "generator", "through", "chunked", "result", "set" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1032-L1043
[ "def", "_query_iterator", "(", "result", ",", "chunksize", ",", "columns", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ")", ":", "while", "True", ":", "data", "=", "result", ".", "fetchmany", "(", "ch...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLDatabase.read_query
Read SQL query into a DataFrame. Parameters ---------- sql : string SQL query to be executed. index_col : string, optional, default: None Column name to use as index for the returned DataFrame object. coerce_float : boolean, default True Attem...
pandas/io/sql.py
def read_query(self, sql, index_col=None, coerce_float=True, parse_dates=None, params=None, chunksize=None): """Read SQL query into a DataFrame. Parameters ---------- sql : string SQL query to be executed. index_col : string, optional, default: Non...
def read_query(self, sql, index_col=None, coerce_float=True, parse_dates=None, params=None, chunksize=None): """Read SQL query into a DataFrame. Parameters ---------- sql : string SQL query to be executed. index_col : string, optional, default: Non...
[ "Read", "SQL", "query", "into", "a", "DataFrame", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1045-L1102
[ "def", "read_query", "(", "self", ",", "sql", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ",", "params", "=", "None", ",", "chunksize", "=", "None", ")", ":", "args", "=", "_convert_params", "(", "s...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLDatabase.to_sql
Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame name : string Name of SQL table. if_exists : {'fail', 'replace', 'append'}, default 'fail' - fail: If table exists, do nothing. - replace: If table ...
pandas/io/sql.py
def to_sql(self, frame, name, if_exists='fail', index=True, index_label=None, schema=None, chunksize=None, dtype=None, method=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame name : st...
def to_sql(self, frame, name, if_exists='fail', index=True, index_label=None, schema=None, chunksize=None, dtype=None, method=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame name : st...
[ "Write", "records", "stored", "in", "a", "DataFrame", "to", "a", "SQL", "database", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1106-L1181
[ "def", "to_sql", "(", "self", ",", "frame", ",", "name", ",", "if_exists", "=", "'fail'", ",", "index", "=", "True", ",", "index_label", "=", "None", ",", "schema", "=", "None", ",", "chunksize", "=", "None", ",", "dtype", "=", "None", ",", "method",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLiteTable._create_table_setup
Return a list of SQL statements that creates a table reflecting the structure of a DataFrame. The first entry will be a CREATE TABLE statement while the rest will be CREATE INDEX statements.
pandas/io/sql.py
def _create_table_setup(self): """ Return a list of SQL statements that creates a table reflecting the structure of a DataFrame. The first entry will be a CREATE TABLE statement while the rest will be CREATE INDEX statements. """ column_names_and_types = self._get_column...
def _create_table_setup(self): """ Return a list of SQL statements that creates a table reflecting the structure of a DataFrame. The first entry will be a CREATE TABLE statement while the rest will be CREATE INDEX statements. """ column_names_and_types = self._get_column...
[ "Return", "a", "list", "of", "SQL", "statements", "that", "creates", "a", "table", "reflecting", "the", "structure", "of", "a", "DataFrame", ".", "The", "first", "entry", "will", "be", "a", "CREATE", "TABLE", "statement", "while", "the", "rest", "will", "b...
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1311-L1353
[ "def", "_create_table_setup", "(", "self", ")", ":", "column_names_and_types", "=", "self", ".", "_get_column_names_and_types", "(", "self", ".", "_sql_type_name", ")", "pat", "=", "re", ".", "compile", "(", "r'\\s+'", ")", "column_names", "=", "[", "col_name", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLiteDatabase._query_iterator
Return generator through chunked result set
pandas/io/sql.py
def _query_iterator(cursor, chunksize, columns, index_col=None, coerce_float=True, parse_dates=None): """Return generator through chunked result set""" while True: data = cursor.fetchmany(chunksize) if type(data) == tuple: data = list(data...
def _query_iterator(cursor, chunksize, columns, index_col=None, coerce_float=True, parse_dates=None): """Return generator through chunked result set""" while True: data = cursor.fetchmany(chunksize) if type(data) == tuple: data = list(data...
[ "Return", "generator", "through", "chunked", "result", "set" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1438-L1452
[ "def", "_query_iterator", "(", "cursor", ",", "chunksize", ",", "columns", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "parse_dates", "=", "None", ")", ":", "while", "True", ":", "data", "=", "cursor", ".", "fetchmany", "(", "ch...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
SQLiteDatabase.to_sql
Write records stored in a DataFrame to a SQL database. Parameters ---------- frame: DataFrame name: string Name of SQL table. if_exists: {'fail', 'replace', 'append'}, default 'fail' fail: If table exists, do nothing. replace: If table exists,...
pandas/io/sql.py
def to_sql(self, frame, name, if_exists='fail', index=True, index_label=None, schema=None, chunksize=None, dtype=None, method=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame: DataFrame name: stri...
def to_sql(self, frame, name, if_exists='fail', index=True, index_label=None, schema=None, chunksize=None, dtype=None, method=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame: DataFrame name: stri...
[ "Write", "records", "stored", "in", "a", "DataFrame", "to", "a", "SQL", "database", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L1481-L1537
[ "def", "to_sql", "(", "self", ",", "frame", ",", "name", ",", "if_exists", "=", "'fail'", ",", "index", "=", "True", ",", "index_label", "=", "None", ",", "schema", "=", "None", ",", "chunksize", "=", "None", ",", "dtype", "=", "None", ",", "method",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_maybe_to_categorical
Coerce to a categorical if a series is given. Internal use ONLY.
pandas/core/arrays/categorical.py
def _maybe_to_categorical(array): """ Coerce to a categorical if a series is given. Internal use ONLY. """ if isinstance(array, (ABCSeries, ABCCategoricalIndex)): return array._values elif isinstance(array, np.ndarray): return Categorical(array) return array
def _maybe_to_categorical(array): """ Coerce to a categorical if a series is given. Internal use ONLY. """ if isinstance(array, (ABCSeries, ABCCategoricalIndex)): return array._values elif isinstance(array, np.ndarray): return Categorical(array) return array
[ "Coerce", "to", "a", "categorical", "if", "a", "series", "is", "given", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L131-L141
[ "def", "_maybe_to_categorical", "(", "array", ")", ":", "if", "isinstance", "(", "array", ",", "(", "ABCSeries", ",", "ABCCategoricalIndex", ")", ")", ":", "return", "array", ".", "_values", "elif", "isinstance", "(", "array", ",", "np", ".", "ndarray", ")...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
contains
Helper for membership check for ``key`` in ``cat``. This is a helper method for :method:`__contains__` and :class:`CategoricalIndex.__contains__`. Returns True if ``key`` is in ``cat.categories`` and the location of ``key`` in ``categories`` is in ``container``. Parameters ---------- cat ...
pandas/core/arrays/categorical.py
def contains(cat, key, container): """ Helper for membership check for ``key`` in ``cat``. This is a helper method for :method:`__contains__` and :class:`CategoricalIndex.__contains__`. Returns True if ``key`` is in ``cat.categories`` and the location of ``key`` in ``categories`` is in ``conta...
def contains(cat, key, container): """ Helper for membership check for ``key`` in ``cat``. This is a helper method for :method:`__contains__` and :class:`CategoricalIndex.__contains__`. Returns True if ``key`` is in ``cat.categories`` and the location of ``key`` in ``categories`` is in ``conta...
[ "Helper", "for", "membership", "check", "for", "key", "in", "cat", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L144-L192
[ "def", "contains", "(", "cat", ",", "key", ",", "container", ")", ":", "hash", "(", "key", ")", "# get location of key in categories.", "# If a KeyError, the key isn't in categories, so logically", "# can't be in container either.", "try", ":", "loc", "=", "cat", ".", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_get_codes_for_values
utility routine to turn values into codes given the specified categories
pandas/core/arrays/categorical.py
def _get_codes_for_values(values, categories): """ utility routine to turn values into codes given the specified categories """ from pandas.core.algorithms import _get_data_algo, _hashtables dtype_equal = is_dtype_equal(values.dtype, categories.dtype) if dtype_equal: # To prevent errone...
def _get_codes_for_values(values, categories): """ utility routine to turn values into codes given the specified categories """ from pandas.core.algorithms import _get_data_algo, _hashtables dtype_equal = is_dtype_equal(values.dtype, categories.dtype) if dtype_equal: # To prevent errone...
[ "utility", "routine", "to", "turn", "values", "into", "codes", "given", "the", "specified", "categories" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2549-L2582
[ "def", "_get_codes_for_values", "(", "values", ",", "categories", ")", ":", "from", "pandas", ".", "core", ".", "algorithms", "import", "_get_data_algo", ",", "_hashtables", "dtype_equal", "=", "is_dtype_equal", "(", "values", ".", "dtype", ",", "categories", "....
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_recode_for_categories
Convert a set of codes for to a new set of categories Parameters ---------- codes : array old_categories, new_categories : Index Returns ------- new_codes : array Examples -------- >>> old_cat = pd.Index(['b', 'a', 'c']) >>> new_cat = pd.Index(['a', 'b']) >>> codes = n...
pandas/core/arrays/categorical.py
def _recode_for_categories(codes, old_categories, new_categories): """ Convert a set of codes for to a new set of categories Parameters ---------- codes : array old_categories, new_categories : Index Returns ------- new_codes : array Examples -------- >>> old_cat = pd....
def _recode_for_categories(codes, old_categories, new_categories): """ Convert a set of codes for to a new set of categories Parameters ---------- codes : array old_categories, new_categories : Index Returns ------- new_codes : array Examples -------- >>> old_cat = pd....
[ "Convert", "a", "set", "of", "codes", "for", "to", "a", "new", "set", "of", "categories" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2585-L2617
[ "def", "_recode_for_categories", "(", "codes", ",", "old_categories", ",", "new_categories", ")", ":", "from", "pandas", ".", "core", ".", "algorithms", "import", "take_1d", "if", "len", "(", "old_categories", ")", "==", "0", ":", "# All null anyway, so just retai...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_factorize_from_iterable
Factorize an input `values` into `categories` and `codes`. Preserves categorical dtype in `categories`. *This is an internal function* Parameters ---------- values : list-like Returns ------- codes : ndarray categories : Index If `values` has a categorical dtype, then `cat...
pandas/core/arrays/categorical.py
def _factorize_from_iterable(values): """ Factorize an input `values` into `categories` and `codes`. Preserves categorical dtype in `categories`. *This is an internal function* Parameters ---------- values : list-like Returns ------- codes : ndarray categories : Index ...
def _factorize_from_iterable(values): """ Factorize an input `values` into `categories` and `codes`. Preserves categorical dtype in `categories`. *This is an internal function* Parameters ---------- values : list-like Returns ------- codes : ndarray categories : Index ...
[ "Factorize", "an", "input", "values", "into", "categories", "and", "codes", ".", "Preserves", "categorical", "dtype", "in", "categories", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2635-L2670
[ "def", "_factorize_from_iterable", "(", "values", ")", ":", "from", "pandas", ".", "core", ".", "indexes", ".", "category", "import", "CategoricalIndex", "if", "not", "is_list_like", "(", "values", ")", ":", "raise", "TypeError", "(", "\"Input must be list-like\""...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_factorize_from_iterables
A higher-level wrapper over `_factorize_from_iterable`. *This is an internal function* Parameters ---------- iterables : list-like of list-likes Returns ------- codes_list : list of ndarrays categories_list : list of Indexes Notes ----- See `_factorize_from_iterable` for ...
pandas/core/arrays/categorical.py
def _factorize_from_iterables(iterables): """ A higher-level wrapper over `_factorize_from_iterable`. *This is an internal function* Parameters ---------- iterables : list-like of list-likes Returns ------- codes_list : list of ndarrays categories_list : list of Indexes N...
def _factorize_from_iterables(iterables): """ A higher-level wrapper over `_factorize_from_iterable`. *This is an internal function* Parameters ---------- iterables : list-like of list-likes Returns ------- codes_list : list of ndarrays categories_list : list of Indexes N...
[ "A", "higher", "-", "level", "wrapper", "over", "_factorize_from_iterable", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2673-L2695
[ "def", "_factorize_from_iterables", "(", "iterables", ")", ":", "if", "len", "(", "iterables", ")", "==", "0", ":", "# For consistency, it should return a list of 2 lists.", "return", "[", "[", "]", ",", "[", "]", "]", "return", "map", "(", "list", ",", "lzip"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.copy
Copy constructor.
pandas/core/arrays/categorical.py
def copy(self): """ Copy constructor. """ return self._constructor(values=self._codes.copy(), dtype=self.dtype, fastpath=True)
def copy(self): """ Copy constructor. """ return self._constructor(values=self._codes.copy(), dtype=self.dtype, fastpath=True)
[ "Copy", "constructor", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L455-L461
[ "def", "copy", "(", "self", ")", ":", "return", "self", ".", "_constructor", "(", "values", "=", "self", ".", "_codes", ".", "copy", "(", ")", ",", "dtype", "=", "self", ".", "dtype", ",", "fastpath", "=", "True", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.astype
Coerce this type to another dtype Parameters ---------- dtype : numpy dtype or pandas type copy : bool, default True By default, astype always returns a newly allocated object. If copy is set to False and dtype is categorical, the original object is r...
pandas/core/arrays/categorical.py
def astype(self, dtype, copy=True): """ Coerce this type to another dtype Parameters ---------- dtype : numpy dtype or pandas type copy : bool, default True By default, astype always returns a newly allocated object. If copy is set to False and dt...
def astype(self, dtype, copy=True): """ Coerce this type to another dtype Parameters ---------- dtype : numpy dtype or pandas type copy : bool, default True By default, astype always returns a newly allocated object. If copy is set to False and dt...
[ "Coerce", "this", "type", "to", "another", "dtype" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L463-L485
[ "def", "astype", "(", "self", ",", "dtype", ",", "copy", "=", "True", ")", ":", "if", "is_categorical_dtype", "(", "dtype", ")", ":", "# GH 10696/18593", "dtype", "=", "self", ".", "dtype", ".", "update_dtype", "(", "dtype", ")", "self", "=", "self", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._from_inferred_categories
Construct a Categorical from inferred values. For inferred categories (`dtype` is None) the categories are sorted. For explicit `dtype`, the `inferred_categories` are cast to the appropriate type. Parameters ---------- inferred_categories : Index inferred_codes ...
pandas/core/arrays/categorical.py
def _from_inferred_categories(cls, inferred_categories, inferred_codes, dtype, true_values=None): """ Construct a Categorical from inferred values. For inferred categories (`dtype` is None) the categories are sorted. For explicit `dtype`, the `inferred_...
def _from_inferred_categories(cls, inferred_categories, inferred_codes, dtype, true_values=None): """ Construct a Categorical from inferred values. For inferred categories (`dtype` is None) the categories are sorted. For explicit `dtype`, the `inferred_...
[ "Construct", "a", "Categorical", "from", "inferred", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L528-L586
[ "def", "_from_inferred_categories", "(", "cls", ",", "inferred_categories", ",", "inferred_codes", ",", "dtype", ",", "true_values", "=", "None", ")", ":", "from", "pandas", "import", "Index", ",", "to_numeric", ",", "to_datetime", ",", "to_timedelta", "cats", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.from_codes
Make a Categorical type from codes and categories or dtype. This constructor is useful if you already have codes and categories/dtype and so do not need the (computation intensive) factorization step, which is usually done on the constructor. If your data does not follow this conventio...
pandas/core/arrays/categorical.py
def from_codes(cls, codes, categories=None, ordered=None, dtype=None): """ Make a Categorical type from codes and categories or dtype. This constructor is useful if you already have codes and categories/dtype and so do not need the (computation intensive) factorization step, whi...
def from_codes(cls, codes, categories=None, ordered=None, dtype=None): """ Make a Categorical type from codes and categories or dtype. This constructor is useful if you already have codes and categories/dtype and so do not need the (computation intensive) factorization step, whi...
[ "Make", "a", "Categorical", "type", "from", "codes", "and", "categories", "or", "dtype", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L589-L655
[ "def", "from_codes", "(", "cls", ",", "codes", ",", "categories", "=", "None", ",", "ordered", "=", "None", ",", "dtype", "=", "None", ")", ":", "dtype", "=", "CategoricalDtype", ".", "_from_values_or_dtype", "(", "categories", "=", "categories", ",", "ord...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._get_codes
Get the codes. Returns ------- codes : integer array view A non writable view of the `codes` array.
pandas/core/arrays/categorical.py
def _get_codes(self): """ Get the codes. Returns ------- codes : integer array view A non writable view of the `codes` array. """ v = self._codes.view() v.flags.writeable = False return v
def _get_codes(self): """ Get the codes. Returns ------- codes : integer array view A non writable view of the `codes` array. """ v = self._codes.view() v.flags.writeable = False return v
[ "Get", "the", "codes", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L659-L670
[ "def", "_get_codes", "(", "self", ")", ":", "v", "=", "self", ".", "_codes", ".", "view", "(", ")", "v", ".", "flags", ".", "writeable", "=", "False", "return", "v" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._set_categories
Sets new categories inplace Parameters ---------- fastpath : bool, default False Don't perform validation of the categories for uniqueness or nulls Examples -------- >>> c = pd.Categorical(['a', 'b']) >>> c [a, b] Categories (2, object...
pandas/core/arrays/categorical.py
def _set_categories(self, categories, fastpath=False): """ Sets new categories inplace Parameters ---------- fastpath : bool, default False Don't perform validation of the categories for uniqueness or nulls Examples -------- >>> c = pd.Categor...
def _set_categories(self, categories, fastpath=False): """ Sets new categories inplace Parameters ---------- fastpath : bool, default False Don't perform validation of the categories for uniqueness or nulls Examples -------- >>> c = pd.Categor...
[ "Sets", "new", "categories", "inplace" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L680-L712
[ "def", "_set_categories", "(", "self", ",", "categories", ",", "fastpath", "=", "False", ")", ":", "if", "fastpath", ":", "new_dtype", "=", "CategoricalDtype", ".", "_from_fastpath", "(", "categories", ",", "self", ".", "ordered", ")", "else", ":", "new_dtyp...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._set_dtype
Internal method for directly updating the CategoricalDtype Parameters ---------- dtype : CategoricalDtype Notes ----- We don't do any validation here. It's assumed that the dtype is a (valid) instance of `CategoricalDtype`.
pandas/core/arrays/categorical.py
def _set_dtype(self, dtype): """ Internal method for directly updating the CategoricalDtype Parameters ---------- dtype : CategoricalDtype Notes ----- We don't do any validation here. It's assumed that the dtype is a (valid) instance of `Categori...
def _set_dtype(self, dtype): """ Internal method for directly updating the CategoricalDtype Parameters ---------- dtype : CategoricalDtype Notes ----- We don't do any validation here. It's assumed that the dtype is a (valid) instance of `Categori...
[ "Internal", "method", "for", "directly", "updating", "the", "CategoricalDtype" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L714-L729
[ "def", "_set_dtype", "(", "self", ",", "dtype", ")", ":", "codes", "=", "_recode_for_categories", "(", "self", ".", "codes", ",", "self", ".", "categories", ",", "dtype", ".", "categories", ")", "return", "type", "(", "self", ")", "(", "codes", ",", "d...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.set_ordered
Set the ordered attribute to the boolean value. Parameters ---------- value : bool Set whether this categorical is ordered (True) or not (False). inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this ...
pandas/core/arrays/categorical.py
def set_ordered(self, value, inplace=False): """ Set the ordered attribute to the boolean value. Parameters ---------- value : bool Set whether this categorical is ordered (True) or not (False). inplace : bool, default False Whether or not to set th...
def set_ordered(self, value, inplace=False): """ Set the ordered attribute to the boolean value. Parameters ---------- value : bool Set whether this categorical is ordered (True) or not (False). inplace : bool, default False Whether or not to set th...
[ "Set", "the", "ordered", "attribute", "to", "the", "boolean", "value", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L731-L748
[ "def", "set_ordered", "(", "self", ",", "value", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "new_dtype", "=", "CategoricalDtype", "(", "self", ".", "categories", ",", "ordered", "=", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.as_ordered
Set the Categorical to be ordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to True.
pandas/core/arrays/categorical.py
def as_ordered(self, inplace=False): """ Set the Categorical to be ordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to True. """ ...
def as_ordered(self, inplace=False): """ Set the Categorical to be ordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to True. """ ...
[ "Set", "the", "Categorical", "to", "be", "ordered", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L750-L761
[ "def", "as_ordered", "(", "self", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "return", "self", ".", "set_ordered", "(", "True", ",", "inplace", "=", "inplace", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.as_unordered
Set the Categorical to be unordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to False.
pandas/core/arrays/categorical.py
def as_unordered(self, inplace=False): """ Set the Categorical to be unordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to False. ...
def as_unordered(self, inplace=False): """ Set the Categorical to be unordered. Parameters ---------- inplace : bool, default False Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to False. ...
[ "Set", "the", "Categorical", "to", "be", "unordered", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L763-L774
[ "def", "as_unordered", "(", "self", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "return", "self", ".", "set_ordered", "(", "False", ",", "inplace", "=", "inplace", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.set_categories
Set the categories to the specified new_categories. `new_categories` can include new categories (which will result in unused categories) or remove old categories (which results in values set to NaN). If `rename==True`, the categories will simple be renamed (less or more items than in ol...
pandas/core/arrays/categorical.py
def set_categories(self, new_categories, ordered=None, rename=False, inplace=False): """ Set the categories to the specified new_categories. `new_categories` can include new categories (which will result in unused categories) or remove old categories (which result...
def set_categories(self, new_categories, ordered=None, rename=False, inplace=False): """ Set the categories to the specified new_categories. `new_categories` can include new categories (which will result in unused categories) or remove old categories (which result...
[ "Set", "the", "categories", "to", "the", "specified", "new_categories", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L776-L846
[ "def", "set_categories", "(", "self", ",", "new_categories", ",", "ordered", "=", "None", ",", "rename", "=", "False", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "ordered", "i...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.rename_categories
Rename categories. Parameters ---------- new_categories : list-like, dict-like or callable * list-like: all items must be unique and the number of items in the new categories must match the existing number of categories. * dict-like: specifies a mapping from...
pandas/core/arrays/categorical.py
def rename_categories(self, new_categories, inplace=False): """ Rename categories. Parameters ---------- new_categories : list-like, dict-like or callable * list-like: all items must be unique and the number of items in the new categories must match the ...
def rename_categories(self, new_categories, inplace=False): """ Rename categories. Parameters ---------- new_categories : list-like, dict-like or callable * list-like: all items must be unique and the number of items in the new categories must match the ...
[ "Rename", "categories", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L848-L940
[ "def", "rename_categories", "(", "self", ",", "new_categories", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "cat", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.reorder_categories
Reorder categories as specified in new_categories. `new_categories` need to include all old categories and no new category items. Parameters ---------- new_categories : Index-like The categories in new order. ordered : bool, optional Whether or not...
pandas/core/arrays/categorical.py
def reorder_categories(self, new_categories, ordered=None, inplace=False): """ Reorder categories as specified in new_categories. `new_categories` need to include all old categories and no new category items. Parameters ---------- new_categories : Index-like ...
def reorder_categories(self, new_categories, ordered=None, inplace=False): """ Reorder categories as specified in new_categories. `new_categories` need to include all old categories and no new category items. Parameters ---------- new_categories : Index-like ...
[ "Reorder", "categories", "as", "specified", "in", "new_categories", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L942-L983
[ "def", "reorder_categories", "(", "self", ",", "new_categories", ",", "ordered", "=", "None", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "set", "(", "self", ".", "dtype", ".",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.add_categories
Add new categories. `new_categories` will be included at the last/highest place in the categories and will be unused directly after this call. Parameters ---------- new_categories : category or list-like of category The new categories to be included. inplace ...
pandas/core/arrays/categorical.py
def add_categories(self, new_categories, inplace=False): """ Add new categories. `new_categories` will be included at the last/highest place in the categories and will be unused directly after this call. Parameters ---------- new_categories : category or list-li...
def add_categories(self, new_categories, inplace=False): """ Add new categories. `new_categories` will be included at the last/highest place in the categories and will be unused directly after this call. Parameters ---------- new_categories : category or list-li...
[ "Add", "new", "categories", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L985-L1033
[ "def", "add_categories", "(", "self", ",", "new_categories", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "not", "is_list_like", "(", "new_categories", ")", ":", "new_categories", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.remove_categories
Remove the specified categories. `removals` must be included in the old categories. Values which were in the removed categories will be set to NaN Parameters ---------- removals : category or list of categories The categories which should be removed. inplace ...
pandas/core/arrays/categorical.py
def remove_categories(self, removals, inplace=False): """ Remove the specified categories. `removals` must be included in the old categories. Values which were in the removed categories will be set to NaN Parameters ---------- removals : category or list of cate...
def remove_categories(self, removals, inplace=False): """ Remove the specified categories. `removals` must be included in the old categories. Values which were in the removed categories will be set to NaN Parameters ---------- removals : category or list of cate...
[ "Remove", "the", "specified", "categories", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1035-L1086
[ "def", "remove_categories", "(", "self", ",", "removals", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "not", "is_list_like", "(", "removals", ")", ":", "removals", "=", "[", "r...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.remove_unused_categories
Remove categories which are not used. Parameters ---------- inplace : bool, default False Whether or not to drop unused categories inplace or return a copy of this categorical with unused categories dropped. Returns ------- cat : Categorical with u...
pandas/core/arrays/categorical.py
def remove_unused_categories(self, inplace=False): """ Remove categories which are not used. Parameters ---------- inplace : bool, default False Whether or not to drop unused categories inplace or return a copy of this categorical with unused categories dro...
def remove_unused_categories(self, inplace=False): """ Remove categories which are not used. Parameters ---------- inplace : bool, default False Whether or not to drop unused categories inplace or return a copy of this categorical with unused categories dro...
[ "Remove", "categories", "which", "are", "not", "used", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1088-L1124
[ "def", "remove_unused_categories", "(", "self", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "cat", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "idx", ",", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.map
Map categories using input correspondence (dict, Series, or function). Maps the categories to new categories. If the mapping correspondence is one-to-one the result is a :class:`~pandas.Categorical` which has the same order property as the original, otherwise a :class:`~pandas.Index` is...
pandas/core/arrays/categorical.py
def map(self, mapper): """ Map categories using input correspondence (dict, Series, or function). Maps the categories to new categories. If the mapping correspondence is one-to-one the result is a :class:`~pandas.Categorical` which has the same order property as the original, ot...
def map(self, mapper): """ Map categories using input correspondence (dict, Series, or function). Maps the categories to new categories. If the mapping correspondence is one-to-one the result is a :class:`~pandas.Categorical` which has the same order property as the original, ot...
[ "Map", "categories", "using", "input", "correspondence", "(", "dict", "Series", "or", "function", ")", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1126-L1206
[ "def", "map", "(", "self", ",", "mapper", ")", ":", "new_categories", "=", "self", ".", "categories", ".", "map", "(", "mapper", ")", "try", ":", "return", "self", ".", "from_codes", "(", "self", ".", "_codes", ".", "copy", "(", ")", ",", "categories...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.shift
Shift Categorical by desired number of periods. Parameters ---------- periods : int Number of periods to move, can be positive or negative fill_value : object, optional The scalar value to use for newly introduced missing values. .. versionadded:: 0....
pandas/core/arrays/categorical.py
def shift(self, periods, fill_value=None): """ Shift Categorical by desired number of periods. Parameters ---------- periods : int Number of periods to move, can be positive or negative fill_value : object, optional The scalar value to use for new...
def shift(self, periods, fill_value=None): """ Shift Categorical by desired number of periods. Parameters ---------- periods : int Number of periods to move, can be positive or negative fill_value : object, optional The scalar value to use for new...
[ "Shift", "Categorical", "by", "desired", "number", "of", "periods", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1230-L1267
[ "def", "shift", "(", "self", ",", "periods", ",", "fill_value", "=", "None", ")", ":", "# since categoricals always have ndim == 1, an axis parameter", "# doesn't make any sense here.", "codes", "=", "self", ".", "codes", "if", "codes", ".", "ndim", ">", "1", ":", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.memory_usage
Memory usage of my values Parameters ---------- deep : bool Introspect the data deeply, interrogate `object` dtypes for system-level memory consumption Returns ------- bytes used Notes ----- Memory usage does not include ...
pandas/core/arrays/categorical.py
def memory_usage(self, deep=False): """ Memory usage of my values Parameters ---------- deep : bool Introspect the data deeply, interrogate `object` dtypes for system-level memory consumption Returns ------- bytes used No...
def memory_usage(self, deep=False): """ Memory usage of my values Parameters ---------- deep : bool Introspect the data deeply, interrogate `object` dtypes for system-level memory consumption Returns ------- bytes used No...
[ "Memory", "usage", "of", "my", "values" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1331-L1355
[ "def", "memory_usage", "(", "self", ",", "deep", "=", "False", ")", ":", "return", "self", ".", "_codes", ".", "nbytes", "+", "self", ".", "dtype", ".", "categories", ".", "memory_usage", "(", "deep", "=", "deep", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.value_counts
Return a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : bool, default True Don't include counts of NaN. Returns ------- counts : Series See Also ...
pandas/core/arrays/categorical.py
def value_counts(self, dropna=True): """ Return a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : bool, default True Don't include counts of NaN. Returns ...
def value_counts(self, dropna=True): """ Return a Series containing counts of each category. Every category will have an entry, even those with a count of 0. Parameters ---------- dropna : bool, default True Don't include counts of NaN. Returns ...
[ "Return", "a", "Series", "containing", "counts", "of", "each", "category", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1438-L1475
[ "def", "value_counts", "(", "self", ",", "dropna", "=", "True", ")", ":", "from", "numpy", "import", "bincount", "from", "pandas", "import", "Series", ",", "CategoricalIndex", "code", ",", "cat", "=", "self", ".", "_codes", ",", "self", ".", "categories", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.get_values
Return the values. For internal compatibility with pandas formatting. Returns ------- numpy.array A numpy array of the same dtype as categorical.categories.dtype or Index if datetime / periods.
pandas/core/arrays/categorical.py
def get_values(self): """ Return the values. For internal compatibility with pandas formatting. Returns ------- numpy.array A numpy array of the same dtype as categorical.categories.dtype or Index if datetime / periods. """ # if w...
def get_values(self): """ Return the values. For internal compatibility with pandas formatting. Returns ------- numpy.array A numpy array of the same dtype as categorical.categories.dtype or Index if datetime / periods. """ # if w...
[ "Return", "the", "values", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1477-L1495
[ "def", "get_values", "(", "self", ")", ":", "# if we are a datetime and period index, return Index to keep metadata", "if", "is_datetimelike", "(", "self", ".", "categories", ")", ":", "return", "self", ".", "categories", ".", "take", "(", "self", ".", "_codes", ","...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.sort_values
Sort the Categorical by category value returning a new Categorical by default. While an ordering is applied to the category values, sorting in this context refers more to organizing and grouping together based on matching category values. Thus, this function can be called on an ...
pandas/core/arrays/categorical.py
def sort_values(self, inplace=False, ascending=True, na_position='last'): """ Sort the Categorical by category value returning a new Categorical by default. While an ordering is applied to the category values, sorting in this context refers more to organizing and grouping togeth...
def sort_values(self, inplace=False, ascending=True, na_position='last'): """ Sort the Categorical by category value returning a new Categorical by default. While an ordering is applied to the category values, sorting in this context refers more to organizing and grouping togeth...
[ "Sort", "the", "Categorical", "by", "category", "value", "returning", "a", "new", "Categorical", "by", "default", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1554-L1642
[ "def", "sort_values", "(", "self", ",", "inplace", "=", "False", ",", "ascending", "=", "True", ",", "na_position", "=", "'last'", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "if", "na_position", "not", "in", "["...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._values_for_rank
For correctly ranking ordered categorical data. See GH#15420 Ordered categorical data should be ranked on the basis of codes with -1 translated to NaN. Returns ------- numpy.array
pandas/core/arrays/categorical.py
def _values_for_rank(self): """ For correctly ranking ordered categorical data. See GH#15420 Ordered categorical data should be ranked on the basis of codes with -1 translated to NaN. Returns ------- numpy.array """ from pandas import Series ...
def _values_for_rank(self): """ For correctly ranking ordered categorical data. See GH#15420 Ordered categorical data should be ranked on the basis of codes with -1 translated to NaN. Returns ------- numpy.array """ from pandas import Series ...
[ "For", "correctly", "ranking", "ordered", "categorical", "data", ".", "See", "GH#15420" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1644-L1671
[ "def", "_values_for_rank", "(", "self", ")", ":", "from", "pandas", "import", "Series", "if", "self", ".", "ordered", ":", "values", "=", "self", ".", "codes", "mask", "=", "values", "==", "-", "1", "if", "mask", ".", "any", "(", ")", ":", "values", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.fillna
Fill NA/NaN values using the specified method. Parameters ---------- value : scalar, dict, Series If a scalar value is passed it is used to fill all missing values. Alternatively, a Series or dict can be used to fill in different values for each index. The va...
pandas/core/arrays/categorical.py
def fillna(self, value=None, method=None, limit=None): """ Fill NA/NaN values using the specified method. Parameters ---------- value : scalar, dict, Series If a scalar value is passed it is used to fill all missing values. Alternatively, a Series or dict...
def fillna(self, value=None, method=None, limit=None): """ Fill NA/NaN values using the specified method. Parameters ---------- value : scalar, dict, Series If a scalar value is passed it is used to fill all missing values. Alternatively, a Series or dict...
[ "Fill", "NA", "/", "NaN", "values", "using", "the", "specified", "method", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1711-L1790
[ "def", "fillna", "(", "self", ",", "value", "=", "None", ",", "method", "=", "None", ",", "limit", "=", "None", ")", ":", "value", ",", "method", "=", "validate_fillna_kwargs", "(", "value", ",", "method", ",", "validate_scalar_dict_value", "=", "False", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.take_nd
Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow_fill`. allow_fill : bool, default None How to handle negative...
pandas/core/arrays/categorical.py
def take_nd(self, indexer, allow_fill=None, fill_value=None): """ Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow...
def take_nd(self, indexer, allow_fill=None, fill_value=None): """ Take elements from the Categorical. Parameters ---------- indexer : sequence of int The indices in `self` to take. The meaning of negative values in `indexer` depends on the value of `allow...
[ "Take", "elements", "from", "the", "Categorical", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1792-L1889
[ "def", "take_nd", "(", "self", ",", "indexer", ",", "allow_fill", "=", "None", ",", "fill_value", "=", "None", ")", ":", "indexer", "=", "np", ".", "asarray", "(", "indexer", ",", "dtype", "=", "np", ".", "intp", ")", "if", "allow_fill", "is", "None"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._slice
Return a slice of myself. For internal compatibility with numpy arrays.
pandas/core/arrays/categorical.py
def _slice(self, slicer): """ Return a slice of myself. For internal compatibility with numpy arrays. """ # only allow 1 dimensional slicing, but can # in a 2-d case be passd (slice(None),....) if isinstance(slicer, tuple) and len(slicer) == 2: if no...
def _slice(self, slicer): """ Return a slice of myself. For internal compatibility with numpy arrays. """ # only allow 1 dimensional slicing, but can # in a 2-d case be passd (slice(None),....) if isinstance(slicer, tuple) and len(slicer) == 2: if no...
[ "Return", "a", "slice", "of", "myself", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1893-L1909
[ "def", "_slice", "(", "self", ",", "slicer", ")", ":", "# only allow 1 dimensional slicing, but can", "# in a 2-d case be passd (slice(None),....)", "if", "isinstance", "(", "slicer", ",", "tuple", ")", "and", "len", "(", "slicer", ")", "==", "2", ":", "if", "not"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._tidy_repr
a short repr displaying only max_vals and an optional (but default footer)
pandas/core/arrays/categorical.py
def _tidy_repr(self, max_vals=10, footer=True): """ a short repr displaying only max_vals and an optional (but default footer) """ num = max_vals // 2 head = self[:num]._get_repr(length=False, footer=False) tail = self[-(max_vals - num):]._get_repr(length=False, footer=Fa...
def _tidy_repr(self, max_vals=10, footer=True): """ a short repr displaying only max_vals and an optional (but default footer) """ num = max_vals // 2 head = self[:num]._get_repr(length=False, footer=False) tail = self[-(max_vals - num):]._get_repr(length=False, footer=Fa...
[ "a", "short", "repr", "displaying", "only", "max_vals", "and", "an", "optional", "(", "but", "default", "footer", ")" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1933-L1946
[ "def", "_tidy_repr", "(", "self", ",", "max_vals", "=", "10", ",", "footer", "=", "True", ")", ":", "num", "=", "max_vals", "//", "2", "head", "=", "self", "[", ":", "num", "]", ".", "_get_repr", "(", "length", "=", "False", ",", "footer", "=", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._repr_categories
return the base repr for the categories
pandas/core/arrays/categorical.py
def _repr_categories(self): """ return the base repr for the categories """ max_categories = (10 if get_option("display.max_categories") == 0 else get_option("display.max_categories")) from pandas.io.formats import format as fmt if len(self.categ...
def _repr_categories(self): """ return the base repr for the categories """ max_categories = (10 if get_option("display.max_categories") == 0 else get_option("display.max_categories")) from pandas.io.formats import format as fmt if len(self.categ...
[ "return", "the", "base", "repr", "for", "the", "categories" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1948-L1965
[ "def", "_repr_categories", "(", "self", ")", ":", "max_categories", "=", "(", "10", "if", "get_option", "(", "\"display.max_categories\"", ")", "==", "0", "else", "get_option", "(", "\"display.max_categories\"", ")", ")", "from", "pandas", ".", "io", ".", "for...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._repr_categories_info
Returns a string representation of the footer.
pandas/core/arrays/categorical.py
def _repr_categories_info(self): """ Returns a string representation of the footer. """ category_strs = self._repr_categories() dtype = getattr(self.categories, 'dtype_str', str(self.categories.dtype)) levheader = "Categories ({length}, {dtype}):...
def _repr_categories_info(self): """ Returns a string representation of the footer. """ category_strs = self._repr_categories() dtype = getattr(self.categories, 'dtype_str', str(self.categories.dtype)) levheader = "Categories ({length}, {dtype}):...
[ "Returns", "a", "string", "representation", "of", "the", "footer", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1967-L1998
[ "def", "_repr_categories_info", "(", "self", ")", ":", "category_strs", "=", "self", ".", "_repr_categories", "(", ")", "dtype", "=", "getattr", "(", "self", ".", "categories", ",", "'dtype_str'", ",", "str", "(", "self", ".", "categories", ".", "dtype", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._maybe_coerce_indexer
return an indexer coerced to the codes dtype
pandas/core/arrays/categorical.py
def _maybe_coerce_indexer(self, indexer): """ return an indexer coerced to the codes dtype """ if isinstance(indexer, np.ndarray) and indexer.dtype.kind == 'i': indexer = indexer.astype(self._codes.dtype) return indexer
def _maybe_coerce_indexer(self, indexer): """ return an indexer coerced to the codes dtype """ if isinstance(indexer, np.ndarray) and indexer.dtype.kind == 'i': indexer = indexer.astype(self._codes.dtype) return indexer
[ "return", "an", "indexer", "coerced", "to", "the", "codes", "dtype" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2031-L2037
[ "def", "_maybe_coerce_indexer", "(", "self", ",", "indexer", ")", ":", "if", "isinstance", "(", "indexer", ",", "np", ".", "ndarray", ")", "and", "indexer", ".", "dtype", ".", "kind", "==", "'i'", ":", "indexer", "=", "indexer", ".", "astype", "(", "se...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical._reverse_indexer
Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(list('aabca')) In [2]: c Out[2]: ...
pandas/core/arrays/categorical.py
def _reverse_indexer(self): """ Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(li...
def _reverse_indexer(self): """ Compute the inverse of a categorical, returning a dict of categories -> indexers. *This is an internal function* Returns ------- dict of categories -> indexers Example ------- In [1]: c = pd.Categorical(li...
[ "Compute", "the", "inverse", "of", "a", "categorical", "returning", "a", "dict", "of", "categories", "-", ">", "indexers", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2119-L2155
[ "def", "_reverse_indexer", "(", "self", ")", ":", "categories", "=", "self", ".", "categories", "r", ",", "counts", "=", "libalgos", ".", "groupsort_indexer", "(", "self", ".", "codes", ".", "astype", "(", "'int64'", ")", ",", "categories", ".", "size", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.min
The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Categorical`
pandas/core/arrays/categorical.py
def min(self, numeric_only=None, **kwargs): """ The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Ca...
def min(self, numeric_only=None, **kwargs): """ The minimum value of the object. Only ordered `Categoricals` have a minimum! Raises ------ TypeError If the `Categorical` is not `ordered`. Returns ------- min : the minimum of this `Ca...
[ "The", "minimum", "value", "of", "the", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2165-L2189
[ "def", "min", "(", "self", ",", "numeric_only", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "check_for_ordered", "(", "'min'", ")", "if", "numeric_only", ":", "good", "=", "self", ".", "_codes", "!=", "-", "1", "pointer", "=", "self"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.mode
Returns the mode(s) of the Categorical. Always returns `Categorical` even if only one value. Parameters ---------- dropna : bool, default True Don't consider counts of NaN/NaT. .. versionadded:: 0.24.0 Returns ------- modes : `Categoric...
pandas/core/arrays/categorical.py
def mode(self, dropna=True): """ Returns the mode(s) of the Categorical. Always returns `Categorical` even if only one value. Parameters ---------- dropna : bool, default True Don't consider counts of NaN/NaT. .. versionadded:: 0.24.0 R...
def mode(self, dropna=True): """ Returns the mode(s) of the Categorical. Always returns `Categorical` even if only one value. Parameters ---------- dropna : bool, default True Don't consider counts of NaN/NaT. .. versionadded:: 0.24.0 R...
[ "Returns", "the", "mode", "(", "s", ")", "of", "the", "Categorical", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2217-L2241
[ "def", "mode", "(", "self", ",", "dropna", "=", "True", ")", ":", "import", "pandas", ".", "_libs", ".", "hashtable", "as", "htable", "codes", "=", "self", ".", "_codes", "if", "dropna", ":", "good", "=", "self", ".", "_codes", "!=", "-", "1", "cod...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.unique
Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, categories keeps existing orde...
pandas/core/arrays/categorical.py
def unique(self): """ Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, ca...
def unique(self): """ Return the ``Categorical`` which ``categories`` and ``codes`` are unique. Unused categories are NOT returned. - unordered category: values and categories are sorted by appearance order. - ordered category: values are sorted by appearance order, ca...
[ "Return", "the", "Categorical", "which", "categories", "and", "codes", "are", "unique", ".", "Unused", "categories", "are", "NOT", "returned", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2243-L2297
[ "def", "unique", "(", "self", ")", ":", "# unlike np.unique, unique1d does not sort", "unique_codes", "=", "unique1d", "(", "self", ".", "codes", ")", "cat", "=", "self", ".", "copy", "(", ")", "# keep nan in codes", "cat", ".", "_codes", "=", "unique_codes", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.equals
Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool
pandas/core/arrays/categorical.py
def equals(self, other): """ Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool """ if self.is_dtype_equal(other): if self.categories.equals(other.categories): ...
def equals(self, other): """ Returns True if categorical arrays are equal. Parameters ---------- other : `Categorical` Returns ------- bool """ if self.is_dtype_equal(other): if self.categories.equals(other.categories): ...
[ "Returns", "True", "if", "categorical", "arrays", "are", "equal", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2308-L2329
[ "def", "equals", "(", "self", ",", "other", ")", ":", "if", "self", ".", "is_dtype_equal", "(", "other", ")", ":", "if", "self", ".", "categories", ".", "equals", "(", "other", ".", "categories", ")", ":", "# fastpath to avoid re-coding", "other_codes", "=...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.is_dtype_equal
Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool
pandas/core/arrays/categorical.py
def is_dtype_equal(self, other): """ Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool """ try: return hash(self.dtype) ...
def is_dtype_equal(self, other): """ Returns True if categoricals are the same dtype same categories, and same ordered Parameters ---------- other : Categorical Returns ------- bool """ try: return hash(self.dtype) ...
[ "Returns", "True", "if", "categoricals", "are", "the", "same", "dtype", "same", "categories", "and", "same", "ordered" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2331-L2348
[ "def", "is_dtype_equal", "(", "self", ",", "other", ")", ":", "try", ":", "return", "hash", "(", "self", ".", "dtype", ")", "==", "hash", "(", "other", ".", "dtype", ")", "except", "(", "AttributeError", ",", "TypeError", ")", ":", "return", "False" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.describe
Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category.
pandas/core/arrays/categorical.py
def describe(self): """ Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category. """ counts = self.value_counts(dropna=False) freqs = counts / float(counts.sum()) from pand...
def describe(self): """ Describes this Categorical Returns ------- description: `DataFrame` A dataframe with frequency and counts by category. """ counts = self.value_counts(dropna=False) freqs = counts / float(counts.sum()) from pand...
[ "Describes", "this", "Categorical" ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2350-L2367
[ "def", "describe", "(", "self", ")", ":", "counts", "=", "self", ".", "value_counts", "(", "dropna", "=", "False", ")", "freqs", "=", "counts", "/", "float", "(", "counts", ".", "sum", "(", ")", ")", "from", "pandas", ".", "core", ".", "reshape", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
Categorical.isin
Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : set or list-like The sequence of v...
pandas/core/arrays/categorical.py
def isin(self, values): """ Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : se...
def isin(self, values): """ Check whether `values` are contained in Categorical. Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of `values` exactly. Parameters ---------- values : se...
[ "Check", "whether", "values", "are", "contained", "in", "Categorical", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2387-L2438
[ "def", "isin", "(", "self", ",", "values", ")", ":", "from", "pandas", ".", "core", ".", "internals", ".", "construction", "import", "sanitize_array", "if", "not", "is_list_like", "(", "values", ")", ":", "raise", "TypeError", "(", "\"only list-like objects ar...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
to_timedelta
Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Timedelta type. Parameters ---------- arg : str, timedelta, li...
pandas/core/tools/timedeltas.py
def to_timedelta(arg, unit='ns', box=True, errors='raise'): """ Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Tim...
def to_timedelta(arg, unit='ns', box=True, errors='raise'): """ Convert argument to timedelta. Timedeltas are absolute differences in times, expressed in difference units (e.g. days, hours, minutes, seconds). This method converts an argument from a recognized timedelta format / value into a Tim...
[ "Convert", "argument", "to", "timedelta", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L20-L128
[ "def", "to_timedelta", "(", "arg", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ")", ":", "unit", "=", "parse_timedelta_unit", "(", "unit", ")", "if", "errors", "not", "in", "(", "'ignore'", ",", "'raise'", ",", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_coerce_scalar_to_timedelta_type
Convert string 'r' to a timedelta object.
pandas/core/tools/timedeltas.py
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'): """Convert string 'r' to a timedelta object.""" try: result = Timedelta(r, unit) if not box: # explicitly view as timedelta64 for case when result is pd.NaT result = result.asm8.view('timedelta...
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'): """Convert string 'r' to a timedelta object.""" try: result = Timedelta(r, unit) if not box: # explicitly view as timedelta64 for case when result is pd.NaT result = result.asm8.view('timedelta...
[ "Convert", "string", "r", "to", "a", "timedelta", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L131-L148
[ "def", "_coerce_scalar_to_timedelta_type", "(", "r", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ")", ":", "try", ":", "result", "=", "Timedelta", "(", "r", ",", "unit", ")", "if", "not", "box", ":", "# explicitly ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
_convert_listlike
Convert a list of objects to a timedelta index object.
pandas/core/tools/timedeltas.py
def _convert_listlike(arg, unit='ns', box=True, errors='raise', name=None): """Convert a list of objects to a timedelta index object.""" if isinstance(arg, (list, tuple)) or not hasattr(arg, 'dtype'): # This is needed only to ensure that in the case where we end up # returning arg (errors == "...
def _convert_listlike(arg, unit='ns', box=True, errors='raise', name=None): """Convert a list of objects to a timedelta index object.""" if isinstance(arg, (list, tuple)) or not hasattr(arg, 'dtype'): # This is needed only to ensure that in the case where we end up # returning arg (errors == "...
[ "Convert", "a", "list", "of", "objects", "to", "a", "timedelta", "index", "object", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/tools/timedeltas.py#L151-L180
[ "def", "_convert_listlike", "(", "arg", ",", "unit", "=", "'ns'", ",", "box", "=", "True", ",", "errors", "=", "'raise'", ",", "name", "=", "None", ")", ":", "if", "isinstance", "(", "arg", ",", "(", "list", ",", "tuple", ")", ")", "or", "not", "...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
generate_range
Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default None) end : datetime (default None) periods : int, (default None) offse...
pandas/tseries/offsets.py
def generate_range(start=None, end=None, periods=None, offset=BDay()): """ Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default ...
def generate_range(start=None, end=None, periods=None, offset=BDay()): """ Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default ...
[ "Generates", "a", "sequence", "of", "dates", "corresponding", "to", "the", "specified", "time", "offset", ".", "Similar", "to", "dateutil", ".", "rrule", "except", "uses", "pandas", "DateOffset", "objects", "to", "represent", "time", "increments", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L2412-L2478
[ "def", "generate_range", "(", "start", "=", "None", ",", "end", "=", "None", ",", "periods", "=", "None", ",", "offset", "=", "BDay", "(", ")", ")", ":", "from", "pandas", ".", "tseries", ".", "frequencies", "import", "to_offset", "offset", "=", "to_of...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DateOffset.apply_index
Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex
pandas/tseries/offsets.py
def apply_index(self, i): """ Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex """...
def apply_index(self, i): """ Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex """...
[ "Vectorized", "apply", "of", "DateOffset", "to", "DatetimeIndex", "raises", "NotImplentedError", "for", "offsets", "without", "a", "vectorized", "implementation", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L245-L304
[ "def", "apply_index", "(", "self", ",", "i", ")", ":", "if", "type", "(", "self", ")", "is", "not", "DateOffset", ":", "raise", "NotImplementedError", "(", "\"DateOffset subclass {name} \"", "\"does not have a vectorized \"", "\"implementation\"", ".", "format", "("...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DateOffset.rollback
Roll provided date backward to next offset only if not on offset.
pandas/tseries/offsets.py
def rollback(self, dt): """ Roll provided date backward to next offset only if not on offset. """ dt = as_timestamp(dt) if not self.onOffset(dt): dt = dt - self.__class__(1, normalize=self.normalize, **self.kwds) return dt
def rollback(self, dt): """ Roll provided date backward to next offset only if not on offset. """ dt = as_timestamp(dt) if not self.onOffset(dt): dt = dt - self.__class__(1, normalize=self.normalize, **self.kwds) return dt
[ "Roll", "provided", "date", "backward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L333-L340
[ "def", "rollback", "(", "self", ",", "dt", ")", ":", "dt", "=", "as_timestamp", "(", "dt", ")", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "dt", "=", "dt", "-", "self", ".", "__class__", "(", "1", ",", "normalize", "=", "self", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
DateOffset.rollforward
Roll provided date forward to next offset only if not on offset.
pandas/tseries/offsets.py
def rollforward(self, dt): """ Roll provided date forward to next offset only if not on offset. """ dt = as_timestamp(dt) if not self.onOffset(dt): dt = dt + self.__class__(1, normalize=self.normalize, **self.kwds) return dt
def rollforward(self, dt): """ Roll provided date forward to next offset only if not on offset. """ dt = as_timestamp(dt) if not self.onOffset(dt): dt = dt + self.__class__(1, normalize=self.normalize, **self.kwds) return dt
[ "Roll", "provided", "date", "forward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L342-L349
[ "def", "rollforward", "(", "self", ",", "dt", ")", ":", "dt", "=", "as_timestamp", "(", "dt", ")", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "dt", "=", "dt", "+", "self", ".", "__class__", "(", "1", ",", "normalize", "=", "self",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BusinessHourMixin.next_bday
Used for moving to next business day.
pandas/tseries/offsets.py
def next_bday(self): """ Used for moving to next business day. """ if self.n >= 0: nb_offset = 1 else: nb_offset = -1 if self._prefix.startswith('C'): # CustomBusinessHour return CustomBusinessDay(n=nb_offset, ...
def next_bday(self): """ Used for moving to next business day. """ if self.n >= 0: nb_offset = 1 else: nb_offset = -1 if self._prefix.startswith('C'): # CustomBusinessHour return CustomBusinessDay(n=nb_offset, ...
[ "Used", "for", "moving", "to", "next", "business", "day", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L579-L594
[ "def", "next_bday", "(", "self", ")", ":", "if", "self", ".", "n", ">=", "0", ":", "nb_offset", "=", "1", "else", ":", "nb_offset", "=", "-", "1", "if", "self", ".", "_prefix", ".", "startswith", "(", "'C'", ")", ":", "# CustomBusinessHour", "return"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BusinessHourMixin._next_opening_time
If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight.
pandas/tseries/offsets.py
def _next_opening_time(self, other): """ If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight. ...
def _next_opening_time(self, other): """ If n is positive, return tomorrow's business day opening time. Otherwise yesterday's business day's opening time. Opening time always locates on BusinessDay. Otherwise, closing time may not if business hour extends over midnight. ...
[ "If", "n", "is", "positive", "return", "tomorrow", "s", "business", "day", "opening", "time", ".", "Otherwise", "yesterday", "s", "business", "day", "s", "opening", "time", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L605-L621
[ "def", "_next_opening_time", "(", "self", ",", "other", ")", ":", "if", "not", "self", ".", "next_bday", ".", "onOffset", "(", "other", ")", ":", "other", "=", "other", "+", "self", ".", "next_bday", "else", ":", "if", "self", ".", "n", ">=", "0", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
train
BusinessHourMixin._get_business_hours_by_sec
Return business hours in a day by seconds.
pandas/tseries/offsets.py
def _get_business_hours_by_sec(self): """ Return business hours in a day by seconds. """ if self._get_daytime_flag: # create dummy datetime to calculate businesshours in a day dtstart = datetime(2014, 4, 1, self.start.hour, self.start.minute) until = d...
def _get_business_hours_by_sec(self): """ Return business hours in a day by seconds. """ if self._get_daytime_flag: # create dummy datetime to calculate businesshours in a day dtstart = datetime(2014, 4, 1, self.start.hour, self.start.minute) until = d...
[ "Return", "business", "hours", "in", "a", "day", "by", "seconds", "." ]
pandas-dev/pandas
python
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L639-L651
[ "def", "_get_business_hours_by_sec", "(", "self", ")", ":", "if", "self", ".", "_get_daytime_flag", ":", "# create dummy datetime to calculate businesshours in a day", "dtstart", "=", "datetime", "(", "2014", ",", "4", ",", "1", ",", "self", ".", "start", ".", "ho...
9feb3ad92cc0397a04b665803a49299ee7aa1037