repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
pandas-dev/pandas
doc/make.py
DocBuilder._run_os
def _run_os(*args): """ Execute a command as a OS terminal. Parameters ---------- *args : list of str Command and parameters to be executed Examples -------- >>> DocBuilder()._run_os('python', '--version') """ subprocess.check...
python
def _run_os(*args): """ Execute a command as a OS terminal. Parameters ---------- *args : list of str Command and parameters to be executed Examples -------- >>> DocBuilder()._run_os('python', '--version') """ subprocess.check...
[ "def", "_run_os", "(", "*", "args", ")", ":", "subprocess", ".", "check_call", "(", "args", ",", "stdout", "=", "sys", ".", "stdout", ",", "stderr", "=", "sys", ".", "stderr", ")" ]
Execute a command as a OS terminal. Parameters ---------- *args : list of str Command and parameters to be executed Examples -------- >>> DocBuilder()._run_os('python', '--version')
[ "Execute", "a", "command", "as", "a", "OS", "terminal", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L91-L104
train
pandas-dev/pandas
doc/make.py
DocBuilder._sphinx_build
def _sphinx_build(self, kind): """ Call sphinx to build documentation. Attribute `num_jobs` from the class is used. Parameters ---------- kind : {'html', 'latex'} Examples -------- >>> DocBuilder(num_jobs=4)._sphinx_build('html') """ ...
python
def _sphinx_build(self, kind): """ Call sphinx to build documentation. Attribute `num_jobs` from the class is used. Parameters ---------- kind : {'html', 'latex'} Examples -------- >>> DocBuilder(num_jobs=4)._sphinx_build('html') """ ...
[ "def", "_sphinx_build", "(", "self", ",", "kind", ")", ":", "if", "kind", "not", "in", "(", "'html'", ",", "'latex'", ")", ":", "raise", "ValueError", "(", "'kind must be html or latex, '", "'not {}'", ".", "format", "(", "kind", ")", ")", "cmd", "=", "[...
Call sphinx to build documentation. Attribute `num_jobs` from the class is used. Parameters ---------- kind : {'html', 'latex'} Examples -------- >>> DocBuilder(num_jobs=4)._sphinx_build('html')
[ "Call", "sphinx", "to", "build", "documentation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L106-L133
train
pandas-dev/pandas
doc/make.py
DocBuilder._open_browser
def _open_browser(self, single_doc_html): """ Open a browser tab showing single """ url = os.path.join('file://', DOC_PATH, 'build', 'html', single_doc_html) webbrowser.open(url, new=2)
python
def _open_browser(self, single_doc_html): """ Open a browser tab showing single """ url = os.path.join('file://', DOC_PATH, 'build', 'html', single_doc_html) webbrowser.open(url, new=2)
[ "def", "_open_browser", "(", "self", ",", "single_doc_html", ")", ":", "url", "=", "os", ".", "path", ".", "join", "(", "'file://'", ",", "DOC_PATH", ",", "'build'", ",", "'html'", ",", "single_doc_html", ")", "webbrowser", ".", "open", "(", "url", ",", ...
Open a browser tab showing single
[ "Open", "a", "browser", "tab", "showing", "single" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L135-L141
train
pandas-dev/pandas
doc/make.py
DocBuilder._get_page_title
def _get_page_title(self, page): """ Open the rst file `page` and extract its title. """ fname = os.path.join(SOURCE_PATH, '{}.rst'.format(page)) option_parser = docutils.frontend.OptionParser( components=(docutils.parsers.rst.Parser,)) doc = docutils.utils.ne...
python
def _get_page_title(self, page): """ Open the rst file `page` and extract its title. """ fname = os.path.join(SOURCE_PATH, '{}.rst'.format(page)) option_parser = docutils.frontend.OptionParser( components=(docutils.parsers.rst.Parser,)) doc = docutils.utils.ne...
[ "def", "_get_page_title", "(", "self", ",", "page", ")", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "SOURCE_PATH", ",", "'{}.rst'", ".", "format", "(", "page", ")", ")", "option_parser", "=", "docutils", ".", "frontend", ".", "OptionParser",...
Open the rst file `page` and extract its title.
[ "Open", "the", "rst", "file", "page", "and", "extract", "its", "title", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L143-L167
train
pandas-dev/pandas
doc/make.py
DocBuilder._add_redirects
def _add_redirects(self): """ Create in the build directory an html file with a redirect, for every row in REDIRECTS_FILE. """ html = ''' <html> <head> <meta http-equiv="refresh" content="0;URL={url}"/> </head> <body> ...
python
def _add_redirects(self): """ Create in the build directory an html file with a redirect, for every row in REDIRECTS_FILE. """ html = ''' <html> <head> <meta http-equiv="refresh" content="0;URL={url}"/> </head> <body> ...
[ "def", "_add_redirects", "(", "self", ")", ":", "html", "=", "'''\n <html>\n <head>\n <meta http-equiv=\"refresh\" content=\"0;URL={url}\"/>\n </head>\n <body>\n <p>\n The page has been moved to <a href=\"{url}\...
Create in the build directory an html file with a redirect, for every row in REDIRECTS_FILE.
[ "Create", "in", "the", "build", "directory", "an", "html", "file", "with", "a", "redirect", "for", "every", "row", "in", "REDIRECTS_FILE", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L169-L212
train
pandas-dev/pandas
doc/make.py
DocBuilder.html
def html(self): """ Build HTML documentation. """ ret_code = self._sphinx_build('html') zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip') if os.path.exists(zip_fname): os.remove(zip_fname) if self.single_doc_html is not None: self...
python
def html(self): """ Build HTML documentation. """ ret_code = self._sphinx_build('html') zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip') if os.path.exists(zip_fname): os.remove(zip_fname) if self.single_doc_html is not None: self...
[ "def", "html", "(", "self", ")", ":", "ret_code", "=", "self", ".", "_sphinx_build", "(", "'html'", ")", "zip_fname", "=", "os", ".", "path", ".", "join", "(", "BUILD_PATH", ",", "'html'", ",", "'pandas.zip'", ")", "if", "os", ".", "path", ".", "exis...
Build HTML documentation.
[ "Build", "HTML", "documentation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L214-L227
train
pandas-dev/pandas
doc/make.py
DocBuilder.latex
def latex(self, force=False): """ Build PDF documentation. """ if sys.platform == 'win32': sys.stderr.write('latex build has not been tested on windows\n') else: ret_code = self._sphinx_build('latex') os.chdir(os.path.join(BUILD_PATH, 'latex'))...
python
def latex(self, force=False): """ Build PDF documentation. """ if sys.platform == 'win32': sys.stderr.write('latex build has not been tested on windows\n') else: ret_code = self._sphinx_build('latex') os.chdir(os.path.join(BUILD_PATH, 'latex'))...
[ "def", "latex", "(", "self", ",", "force", "=", "False", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "sys", ".", "stderr", ".", "write", "(", "'latex build has not been tested on windows\\n'", ")", "else", ":", "ret_code", "=", "self", "....
Build PDF documentation.
[ "Build", "PDF", "documentation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L229-L247
train
pandas-dev/pandas
doc/make.py
DocBuilder.clean
def clean(): """ Clean documentation generated files. """ shutil.rmtree(BUILD_PATH, ignore_errors=True) shutil.rmtree(os.path.join(SOURCE_PATH, 'reference', 'api'), ignore_errors=True)
python
def clean(): """ Clean documentation generated files. """ shutil.rmtree(BUILD_PATH, ignore_errors=True) shutil.rmtree(os.path.join(SOURCE_PATH, 'reference', 'api'), ignore_errors=True)
[ "def", "clean", "(", ")", ":", "shutil", ".", "rmtree", "(", "BUILD_PATH", ",", "ignore_errors", "=", "True", ")", "shutil", ".", "rmtree", "(", "os", ".", "path", ".", "join", "(", "SOURCE_PATH", ",", "'reference'", ",", "'api'", ")", ",", "ignore_err...
Clean documentation generated files.
[ "Clean", "documentation", "generated", "files", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L256-L262
train
pandas-dev/pandas
doc/make.py
DocBuilder.zip_html
def zip_html(self): """ Compress HTML documentation into a zip file. """ zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip') if os.path.exists(zip_fname): os.remove(zip_fname) dirname = os.path.join(BUILD_PATH, 'html') fnames = os.listdir(dirnam...
python
def zip_html(self): """ Compress HTML documentation into a zip file. """ zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip') if os.path.exists(zip_fname): os.remove(zip_fname) dirname = os.path.join(BUILD_PATH, 'html') fnames = os.listdir(dirnam...
[ "def", "zip_html", "(", "self", ")", ":", "zip_fname", "=", "os", ".", "path", ".", "join", "(", "BUILD_PATH", ",", "'html'", ",", "'pandas.zip'", ")", "if", "os", ".", "path", ".", "exists", "(", "zip_fname", ")", ":", "os", ".", "remove", "(", "z...
Compress HTML documentation into a zip file.
[ "Compress", "HTML", "documentation", "into", "a", "zip", "file", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L264-L278
train
pandas-dev/pandas
pandas/io/formats/latex.py
LatexFormatter.write_result
def write_result(self, buf): """ Render a DataFrame to a LaTeX tabular/longtable environment output. """ # string representation of the columns if len(self.frame.columns) == 0 or len(self.frame.index) == 0: info_line = ('Empty {name}\nColumns: {col}\nIndex: {idx}' ...
python
def write_result(self, buf): """ Render a DataFrame to a LaTeX tabular/longtable environment output. """ # string representation of the columns if len(self.frame.columns) == 0 or len(self.frame.index) == 0: info_line = ('Empty {name}\nColumns: {col}\nIndex: {idx}' ...
[ "def", "write_result", "(", "self", ",", "buf", ")", ":", "# string representation of the columns", "if", "len", "(", "self", ".", "frame", ".", "columns", ")", "==", "0", "or", "len", "(", "self", ".", "frame", ".", "index", ")", "==", "0", ":", "info...
Render a DataFrame to a LaTeX tabular/longtable environment output.
[ "Render", "a", "DataFrame", "to", "a", "LaTeX", "tabular", "/", "longtable", "environment", "output", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L40-L163
train
pandas-dev/pandas
pandas/io/formats/latex.py
LatexFormatter._format_multicolumn
def _format_multicolumn(self, row, ilevels): r""" Combine columns belonging to a group to a single multicolumn entry according to self.multicolumn_format e.g.: a & & & b & c & will become \multicolumn{3}{l}{a} & b & \multicolumn{2}{l}{c} """ row...
python
def _format_multicolumn(self, row, ilevels): r""" Combine columns belonging to a group to a single multicolumn entry according to self.multicolumn_format e.g.: a & & & b & c & will become \multicolumn{3}{l}{a} & b & \multicolumn{2}{l}{c} """ row...
[ "def", "_format_multicolumn", "(", "self", ",", "row", ",", "ilevels", ")", ":", "row2", "=", "list", "(", "row", "[", ":", "ilevels", "]", ")", "ncol", "=", "1", "coltext", "=", "''", "def", "append_col", "(", ")", ":", "# write multicolumn if needed", ...
r""" Combine columns belonging to a group to a single multicolumn entry according to self.multicolumn_format e.g.: a & & & b & c & will become \multicolumn{3}{l}{a} & b & \multicolumn{2}{l}{c}
[ "r", "Combine", "columns", "belonging", "to", "a", "group", "to", "a", "single", "multicolumn", "entry", "according", "to", "self", ".", "multicolumn_format" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L165-L201
train
pandas-dev/pandas
pandas/io/formats/latex.py
LatexFormatter._format_multirow
def _format_multirow(self, row, ilevels, i, rows): r""" Check following rows, whether row should be a multirow e.g.: becomes: a & 0 & \multirow{2}{*}{a} & 0 & & 1 & & 1 & b & 0 & \cline{1-2} b & 0 & """ for j in range(ileve...
python
def _format_multirow(self, row, ilevels, i, rows): r""" Check following rows, whether row should be a multirow e.g.: becomes: a & 0 & \multirow{2}{*}{a} & 0 & & 1 & & 1 & b & 0 & \cline{1-2} b & 0 & """ for j in range(ileve...
[ "def", "_format_multirow", "(", "self", ",", "row", ",", "ilevels", ",", "i", ",", "rows", ")", ":", "for", "j", "in", "range", "(", "ilevels", ")", ":", "if", "row", "[", "j", "]", ".", "strip", "(", ")", ":", "nrow", "=", "1", "for", "r", "...
r""" Check following rows, whether row should be a multirow e.g.: becomes: a & 0 & \multirow{2}{*}{a} & 0 & & 1 & & 1 & b & 0 & \cline{1-2} b & 0 &
[ "r", "Check", "following", "rows", "whether", "row", "should", "be", "a", "multirow" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L203-L227
train
pandas-dev/pandas
pandas/io/formats/latex.py
LatexFormatter._print_cline
def _print_cline(self, buf, i, icol): """ Print clines after multirow-blocks are finished """ for cl in self.clinebuf: if cl[0] == i: buf.write('\\cline{{{cl:d}-{icol:d}}}\n' .format(cl=cl[1], icol=icol)) # remove entries that...
python
def _print_cline(self, buf, i, icol): """ Print clines after multirow-blocks are finished """ for cl in self.clinebuf: if cl[0] == i: buf.write('\\cline{{{cl:d}-{icol:d}}}\n' .format(cl=cl[1], icol=icol)) # remove entries that...
[ "def", "_print_cline", "(", "self", ",", "buf", ",", "i", ",", "icol", ")", ":", "for", "cl", "in", "self", ".", "clinebuf", ":", "if", "cl", "[", "0", "]", "==", "i", ":", "buf", ".", "write", "(", "'\\\\cline{{{cl:d}-{icol:d}}}\\n'", ".", "format",...
Print clines after multirow-blocks are finished
[ "Print", "clines", "after", "multirow", "-", "blocks", "are", "finished" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L229-L238
train
pandas-dev/pandas
pandas/io/parsers.py
_validate_integer
def _validate_integer(name, val, min_val=0): """ Checks whether the 'name' parameter for parsing is either an integer OR float that can SAFELY be cast to an integer without losing accuracy. Raises a ValueError if that is not the case. Parameters ---------- name : string Paramete...
python
def _validate_integer(name, val, min_val=0): """ Checks whether the 'name' parameter for parsing is either an integer OR float that can SAFELY be cast to an integer without losing accuracy. Raises a ValueError if that is not the case. Parameters ---------- name : string Paramete...
[ "def", "_validate_integer", "(", "name", ",", "val", ",", "min_val", "=", "0", ")", ":", "msg", "=", "\"'{name:s}' must be an integer >={min_val:d}\"", ".", "format", "(", "name", "=", "name", ",", "min_val", "=", "min_val", ")", "if", "val", "is", "not", ...
Checks whether the 'name' parameter for parsing is either an integer OR float that can SAFELY be cast to an integer without losing accuracy. Raises a ValueError if that is not the case. Parameters ---------- name : string Parameter name (used for error reporting) val : int or float ...
[ "Checks", "whether", "the", "name", "parameter", "for", "parsing", "is", "either", "an", "integer", "OR", "float", "that", "can", "SAFELY", "be", "cast", "to", "an", "integer", "without", "losing", "accuracy", ".", "Raises", "a", "ValueError", "if", "that", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L349-L376
train
pandas-dev/pandas
pandas/io/parsers.py
_validate_names
def _validate_names(names): """ Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ---...
python
def _validate_names(names): """ Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ---...
[ "def", "_validate_names", "(", "names", ")", ":", "if", "names", "is", "not", "None", ":", "if", "len", "(", "names", ")", "!=", "len", "(", "set", "(", "names", ")", ")", ":", "msg", "=", "(", "\"Duplicate names specified. This \"", "\"will raise an error...
Check if the `names` parameter contains duplicates. If duplicates are found, we issue a warning before returning. Parameters ---------- names : array-like or None An array containing a list of the names used for the output DataFrame. Returns ------- names : array-like or None ...
[ "Check", "if", "the", "names", "parameter", "contains", "duplicates", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L379-L402
train
pandas-dev/pandas
pandas/io/parsers.py
_read
def _read(filepath_or_buffer: FilePathOrBuffer, kwds): """Generic reader of line files.""" encoding = kwds.get('encoding', None) if encoding is not None: encoding = re.sub('_', '-', encoding).lower() kwds['encoding'] = encoding compression = kwds.get('compression', 'infer') compress...
python
def _read(filepath_or_buffer: FilePathOrBuffer, kwds): """Generic reader of line files.""" encoding = kwds.get('encoding', None) if encoding is not None: encoding = re.sub('_', '-', encoding).lower() kwds['encoding'] = encoding compression = kwds.get('compression', 'infer') compress...
[ "def", "_read", "(", "filepath_or_buffer", ":", "FilePathOrBuffer", ",", "kwds", ")", ":", "encoding", "=", "kwds", ".", "get", "(", "'encoding'", ",", "None", ")", "if", "encoding", "is", "not", "None", ":", "encoding", "=", "re", ".", "sub", "(", "'_...
Generic reader of line files.
[ "Generic", "reader", "of", "line", "files", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L405-L452
train
pandas-dev/pandas
pandas/io/parsers.py
read_fwf
def read_fwf(filepath_or_buffer: FilePathOrBuffer, colspecs='infer', widths=None, infer_nrows=100, **kwds): r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. ...
python
def read_fwf(filepath_or_buffer: FilePathOrBuffer, colspecs='infer', widths=None, infer_nrows=100, **kwds): r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. ...
[ "def", "read_fwf", "(", "filepath_or_buffer", ":", "FilePathOrBuffer", ",", "colspecs", "=", "'infer'", ",", "widths", "=", "None", ",", "infer_nrows", "=", "100", ",", "*", "*", "kwds", ")", ":", "# Check input arguments.", "if", "colspecs", "is", "None", "...
r""" Read a table of fixed-width formatted lines into DataFrame. Also supports optionally iterating or breaking of the file into chunks. Additional help can be found in the `online docs for IO Tools <http://pandas.pydata.org/pandas-docs/stable/io.html>`_. Parameters ---------- filepat...
[ "r", "Read", "a", "table", "of", "fixed", "-", "width", "formatted", "lines", "into", "DataFrame", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L735-L813
train
pandas-dev/pandas
pandas/io/parsers.py
_is_potential_multi_index
def _is_potential_multi_index(columns): """ Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not co...
python
def _is_potential_multi_index(columns): """ Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not co...
[ "def", "_is_potential_multi_index", "(", "columns", ")", ":", "return", "(", "len", "(", "columns", ")", "and", "not", "isinstance", "(", "columns", ",", "MultiIndex", ")", "and", "all", "(", "isinstance", "(", "c", ",", "tuple", ")", "for", "c", "in", ...
Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex Returns ------- boolean : Whether or not columns could become a MultiIndex
[ "Check", "whether", "or", "not", "the", "columns", "parameter", "could", "be", "converted", "into", "a", "MultiIndex", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1190-L1205
train
pandas-dev/pandas
pandas/io/parsers.py
_evaluate_usecols
def _evaluate_usecols(usecols, names): """ Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'. """ if callable(usecols): ...
python
def _evaluate_usecols(usecols, names): """ Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'. """ if callable(usecols): ...
[ "def", "_evaluate_usecols", "(", "usecols", ",", "names", ")", ":", "if", "callable", "(", "usecols", ")", ":", "return", "{", "i", "for", "i", ",", "name", "in", "enumerate", "(", "names", ")", "if", "usecols", "(", "name", ")", "}", "return", "usec...
Check whether or not the 'usecols' parameter is a callable. If so, enumerates the 'names' parameter and returns a set of indices for each entry in 'names' that evaluates to True. If not a callable, returns 'usecols'.
[ "Check", "whether", "or", "not", "the", "usecols", "parameter", "is", "a", "callable", ".", "If", "so", "enumerates", "the", "names", "parameter", "and", "returns", "a", "set", "of", "indices", "for", "each", "entry", "in", "names", "that", "evaluates", "t...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1208-L1218
train
pandas-dev/pandas
pandas/io/parsers.py
_validate_usecols_names
def _validate_usecols_names(usecols, names): """ Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. nam...
python
def _validate_usecols_names(usecols, names): """ Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. nam...
[ "def", "_validate_usecols_names", "(", "usecols", ",", "names", ")", ":", "missing", "=", "[", "c", "for", "c", "in", "usecols", "if", "c", "not", "in", "names", "]", "if", "len", "(", "missing", ")", ">", "0", ":", "raise", "ValueError", "(", "\"Use...
Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing. Parameters ---------- usecols : iterable of usecols The columns to validate are present in names. names : iterable of names The column names to check ...
[ "Validates", "that", "all", "usecols", "are", "present", "in", "a", "given", "list", "of", "names", ".", "If", "not", "raise", "a", "ValueError", "that", "shows", "what", "usecols", "are", "missing", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1221-L1250
train
pandas-dev/pandas
pandas/io/parsers.py
_validate_usecols_arg
def _validate_usecols_arg(usecols): """ Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- useco...
python
def _validate_usecols_arg(usecols): """ Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- useco...
[ "def", "_validate_usecols_arg", "(", "usecols", ")", ":", "msg", "=", "(", "\"'usecols' must either be list-like of all strings, all unicode, \"", "\"all integers or a callable.\"", ")", "if", "usecols", "is", "not", "None", ":", "if", "callable", "(", "usecols", ")", "...
Validate the 'usecols' parameter. Checks whether or not the 'usecols' parameter contains all integers (column selection by index), strings (column by name) or is a callable. Raises a ValueError if that is not the case. Parameters ---------- usecols : list-like, callable, or None List o...
[ "Validate", "the", "usecols", "parameter", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1284-L1330
train
pandas-dev/pandas
pandas/io/parsers.py
_validate_parse_dates_arg
def _validate_parse_dates_arg(parse_dates): """ Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case. """ msg = ("Only booleans, lists, and " "dictionaries are accepted " "for the 'parse_dates' parameter") if...
python
def _validate_parse_dates_arg(parse_dates): """ Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case. """ msg = ("Only booleans, lists, and " "dictionaries are accepted " "for the 'parse_dates' parameter") if...
[ "def", "_validate_parse_dates_arg", "(", "parse_dates", ")", ":", "msg", "=", "(", "\"Only booleans, lists, and \"", "\"dictionaries are accepted \"", "\"for the 'parse_dates' parameter\"", ")", "if", "parse_dates", "is", "not", "None", ":", "if", "is_scalar", "(", "parse...
Check whether or not the 'parse_dates' parameter is a non-boolean scalar. Raises a ValueError if that is the case.
[ "Check", "whether", "or", "not", "the", "parse_dates", "parameter", "is", "a", "non", "-", "boolean", "scalar", ".", "Raises", "a", "ValueError", "if", "that", "is", "the", "case", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1333-L1351
train
pandas-dev/pandas
pandas/io/parsers.py
_stringify_na_values
def _stringify_na_values(na_values): """ return a stringified and numeric for these values """ result = [] for x in na_values: result.append(str(x)) result.append(x) try: v = float(x) # we are like 999 here if v == int(v): v = int(...
python
def _stringify_na_values(na_values): """ return a stringified and numeric for these values """ result = [] for x in na_values: result.append(str(x)) result.append(x) try: v = float(x) # we are like 999 here if v == int(v): v = int(...
[ "def", "_stringify_na_values", "(", "na_values", ")", ":", "result", "=", "[", "]", "for", "x", "in", "na_values", ":", "result", ".", "append", "(", "str", "(", "x", ")", ")", "result", ".", "append", "(", "x", ")", "try", ":", "v", "=", "float", ...
return a stringified and numeric for these values
[ "return", "a", "stringified", "and", "numeric", "for", "these", "values" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3425-L3447
train
pandas-dev/pandas
pandas/io/parsers.py
_get_na_values
def _get_na_values(col, na_values, na_fvalues, keep_default_na): """ Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict ...
python
def _get_na_values(col, na_values, na_fvalues, keep_default_na): """ Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict ...
[ "def", "_get_na_values", "(", "col", ",", "na_values", ",", "na_fvalues", ",", "keep_default_na", ")", ":", "if", "isinstance", "(", "na_values", ",", "dict", ")", ":", "if", "col", "in", "na_values", ":", "return", "na_values", "[", "col", "]", ",", "na...
Get the NaN values for a given column. Parameters ---------- col : str The name of the column. na_values : array-like, dict The object listing the NaN values as strings. na_fvalues : array-like, dict The object listing the NaN values as floats. keep_default_na : bool ...
[ "Get", "the", "NaN", "values", "for", "a", "given", "column", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3450-L3483
train
pandas-dev/pandas
pandas/io/parsers.py
ParserBase._extract_multi_indexer_columns
def _extract_multi_indexer_columns(self, header, index_names, col_names, passed_names=False): """ extract and return the names, index_names, col_names header is a list-of-lists returned from the parsers """ if len(header) < 2: return header[...
python
def _extract_multi_indexer_columns(self, header, index_names, col_names, passed_names=False): """ extract and return the names, index_names, col_names header is a list-of-lists returned from the parsers """ if len(header) < 2: return header[...
[ "def", "_extract_multi_indexer_columns", "(", "self", ",", "header", ",", "index_names", ",", "col_names", ",", "passed_names", "=", "False", ")", ":", "if", "len", "(", "header", ")", "<", "2", ":", "return", "header", "[", "0", "]", ",", "index_names", ...
extract and return the names, index_names, col_names header is a list-of-lists returned from the parsers
[ "extract", "and", "return", "the", "names", "index_names", "col_names", "header", "is", "a", "list", "-", "of", "-", "lists", "returned", "from", "the", "parsers" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1451-L1504
train
pandas-dev/pandas
pandas/io/parsers.py
ParserBase._infer_types
def _infer_types(self, values, na_values, try_num_bool=True): """ Infer types of values, possibly casting Parameters ---------- values : ndarray na_values : set try_num_bool : bool, default try try to cast values to numeric (first preference) or boolea...
python
def _infer_types(self, values, na_values, try_num_bool=True): """ Infer types of values, possibly casting Parameters ---------- values : ndarray na_values : set try_num_bool : bool, default try try to cast values to numeric (first preference) or boolea...
[ "def", "_infer_types", "(", "self", ",", "values", ",", "na_values", ",", "try_num_bool", "=", "True", ")", ":", "na_count", "=", "0", "if", "issubclass", "(", "values", ".", "dtype", ".", "type", ",", "(", "np", ".", "number", ",", "np", ".", "bool_...
Infer types of values, possibly casting Parameters ---------- values : ndarray na_values : set try_num_bool : bool, default try try to cast values to numeric (first preference) or boolean Returns: -------- converted : ndarray na_count ...
[ "Infer", "types", "of", "values", "possibly", "casting" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1719-L1764
train
pandas-dev/pandas
pandas/io/parsers.py
ParserBase._cast_types
def _cast_types(self, values, cast_type, column): """ Cast values to specified type Parameters ---------- values : ndarray cast_type : string or np.dtype dtype to cast values to column : string column name - used only for error reporting ...
python
def _cast_types(self, values, cast_type, column): """ Cast values to specified type Parameters ---------- values : ndarray cast_type : string or np.dtype dtype to cast values to column : string column name - used only for error reporting ...
[ "def", "_cast_types", "(", "self", ",", "values", ",", "cast_type", ",", "column", ")", ":", "if", "is_categorical_dtype", "(", "cast_type", ")", ":", "known_cats", "=", "(", "isinstance", "(", "cast_type", ",", "CategoricalDtype", ")", "and", "cast_type", "...
Cast values to specified type Parameters ---------- values : ndarray cast_type : string or np.dtype dtype to cast values to column : string column name - used only for error reporting Returns ------- converted : ndarray
[ "Cast", "values", "to", "specified", "type" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1766-L1821
train
pandas-dev/pandas
pandas/io/parsers.py
CParserWrapper._set_noconvert_columns
def _set_noconvert_columns(self): """ Set the columns that should not undergo dtype conversions. Currently, any column that is involved with date parsing will not undergo such conversions. """ names = self.orig_names if self.usecols_dtype == 'integer': ...
python
def _set_noconvert_columns(self): """ Set the columns that should not undergo dtype conversions. Currently, any column that is involved with date parsing will not undergo such conversions. """ names = self.orig_names if self.usecols_dtype == 'integer': ...
[ "def", "_set_noconvert_columns", "(", "self", ")", ":", "names", "=", "self", ".", "orig_names", "if", "self", ".", "usecols_dtype", "==", "'integer'", ":", "# A set of integers will be converted to a list in", "# the correct order every single time.", "usecols", "=", "li...
Set the columns that should not undergo dtype conversions. Currently, any column that is involved with date parsing will not undergo such conversions.
[ "Set", "the", "columns", "that", "should", "not", "undergo", "dtype", "conversions", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L1951-L2003
train
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._handle_usecols
def _handle_usecols(self, columns, usecols_key): """ Sets self._col_indices usecols_key is used if there are string usecols. """ if self.usecols is not None: if callable(self.usecols): col_indices = _evaluate_usecols(self.usecols, usecols_key) ...
python
def _handle_usecols(self, columns, usecols_key): """ Sets self._col_indices usecols_key is used if there are string usecols. """ if self.usecols is not None: if callable(self.usecols): col_indices = _evaluate_usecols(self.usecols, usecols_key) ...
[ "def", "_handle_usecols", "(", "self", ",", "columns", ",", "usecols_key", ")", ":", "if", "self", ".", "usecols", "is", "not", "None", ":", "if", "callable", "(", "self", ".", "usecols", ")", ":", "col_indices", "=", "_evaluate_usecols", "(", "self", "....
Sets self._col_indices usecols_key is used if there are string usecols.
[ "Sets", "self", ".", "_col_indices" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2678-L2707
train
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._check_for_bom
def _check_for_bom(self, first_row): """ Checks whether the file begins with the BOM character. If it does, remove it. In addition, if there is quoting in the field subsequent to the BOM, remove it as well because it technically takes place at the beginning of the name, n...
python
def _check_for_bom(self, first_row): """ Checks whether the file begins with the BOM character. If it does, remove it. In addition, if there is quoting in the field subsequent to the BOM, remove it as well because it technically takes place at the beginning of the name, n...
[ "def", "_check_for_bom", "(", "self", ",", "first_row", ")", ":", "# first_row will be a list, so we need to check", "# that that list is not empty before proceeding.", "if", "not", "first_row", ":", "return", "first_row", "# The first element of this row is the one that could have t...
Checks whether the file begins with the BOM character. If it does, remove it. In addition, if there is quoting in the field subsequent to the BOM, remove it as well because it technically takes place at the beginning of the name, not the middle of it.
[ "Checks", "whether", "the", "file", "begins", "with", "the", "BOM", "character", ".", "If", "it", "does", "remove", "it", ".", "In", "addition", "if", "there", "is", "quoting", "in", "the", "field", "subsequent", "to", "the", "BOM", "remove", "it", "as",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2718-L2768
train
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._alert_malformed
def _alert_malformed(self, msg, row_num): """ Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message t...
python
def _alert_malformed(self, msg, row_num): """ Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message t...
[ "def", "_alert_malformed", "(", "self", ",", "msg", ",", "row_num", ")", ":", "if", "self", ".", "error_bad_lines", ":", "raise", "ParserError", "(", "msg", ")", "elif", "self", ".", "warn_bad_lines", ":", "base", "=", "'Skipping line {row_num}: '", ".", "fo...
Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message to display. row_num : The row number where the parsing ...
[ "Alert", "a", "user", "about", "a", "malformed", "row", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2837-L2856
train
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._next_iter_line
def _next_iter_line(self, row_num): """ Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- ...
python
def _next_iter_line(self, row_num): """ Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- ...
[ "def", "_next_iter_line", "(", "self", ",", "row_num", ")", ":", "try", ":", "return", "next", "(", "self", ".", "data", ")", "except", "csv", ".", "Error", "as", "e", ":", "if", "self", ".", "warn_bad_lines", "or", "self", ".", "error_bad_lines", ":",...
Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- row_num : The row number of the line being parsed.
[ "Wrapper", "around", "iterating", "through", "self", ".", "data", "(", "CSV", "source", ")", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2858-L2892
train
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._remove_empty_lines
def _remove_empty_lines(self, lines): """ Iterate through the lines and remove any that are either empty or contain only one whitespace value Parameters ---------- lines : array-like The array of lines that we are to filter. Returns ------- ...
python
def _remove_empty_lines(self, lines): """ Iterate through the lines and remove any that are either empty or contain only one whitespace value Parameters ---------- lines : array-like The array of lines that we are to filter. Returns ------- ...
[ "def", "_remove_empty_lines", "(", "self", ",", "lines", ")", ":", "ret", "=", "[", "]", "for", "l", "in", "lines", ":", "# Remove empty lines and lines with only one whitespace value", "if", "(", "len", "(", "l", ")", ">", "1", "or", "len", "(", "l", ")",...
Iterate through the lines and remove any that are either empty or contain only one whitespace value Parameters ---------- lines : array-like The array of lines that we are to filter. Returns ------- filtered_lines : array-like The same ar...
[ "Iterate", "through", "the", "lines", "and", "remove", "any", "that", "are", "either", "empty", "or", "contain", "only", "one", "whitespace", "value" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2912-L2934
train
pandas-dev/pandas
pandas/io/parsers.py
PythonParser._get_index_name
def _get_index_name(self, columns): """ Try several cases to get lines: 0) There are headers on row 0 and row 1 and their total summed lengths equals the length of the next line. Treat row 0 as columns and row 1 as indices 1) Look for implicit index: there are more colum...
python
def _get_index_name(self, columns): """ Try several cases to get lines: 0) There are headers on row 0 and row 1 and their total summed lengths equals the length of the next line. Treat row 0 as columns and row 1 as indices 1) Look for implicit index: there are more colum...
[ "def", "_get_index_name", "(", "self", ",", "columns", ")", ":", "orig_names", "=", "list", "(", "columns", ")", "columns", "=", "list", "(", "columns", ")", "try", ":", "line", "=", "self", ".", "_next_line", "(", ")", "except", "StopIteration", ":", ...
Try several cases to get lines: 0) There are headers on row 0 and row 1 and their total summed lengths equals the length of the next line. Treat row 0 as columns and row 1 as indices 1) Look for implicit index: there are more columns on row 1 than row 0. If this is true, assume ...
[ "Try", "several", "cases", "to", "get", "lines", ":" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2973-L3035
train
pandas-dev/pandas
pandas/io/parsers.py
FixedWidthReader.get_rows
def get_rows(self, infer_nrows, skiprows=None): """ Read rows from self.f, skipping as specified. We distinguish buffer_rows (the first <= infer_nrows lines) from the rows returned to detect_colspecs because it's simpler to leave the other locations with skiprows logic a...
python
def get_rows(self, infer_nrows, skiprows=None): """ Read rows from self.f, skipping as specified. We distinguish buffer_rows (the first <= infer_nrows lines) from the rows returned to detect_colspecs because it's simpler to leave the other locations with skiprows logic a...
[ "def", "get_rows", "(", "self", ",", "infer_nrows", ",", "skiprows", "=", "None", ")", ":", "if", "skiprows", "is", "None", ":", "skiprows", "=", "set", "(", ")", "buffer_rows", "=", "[", "]", "detect_rows", "=", "[", "]", "for", "i", ",", "row", "...
Read rows from self.f, skipping as specified. We distinguish buffer_rows (the first <= infer_nrows lines) from the rows returned to detect_colspecs because it's simpler to leave the other locations with skiprows logic alone than to modify them to deal with the fact we skipped so...
[ "Read", "rows", "from", "self", ".", "f", "skipping", "as", "specified", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L3535-L3571
train
pandas-dev/pandas
doc/source/conf.py
linkcode_resolve
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object """ if domain != 'py': return None modname = info['module'] fullname = info['fullname'] submod = sys.modules.get(modname) if submod is None: return None obj = submod for pa...
python
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object """ if domain != 'py': return None modname = info['module'] fullname = info['fullname'] submod = sys.modules.get(modname) if submod is None: return None obj = submod for pa...
[ "def", "linkcode_resolve", "(", "domain", ",", "info", ")", ":", "if", "domain", "!=", "'py'", ":", "return", "None", "modname", "=", "info", "[", "'module'", "]", "fullname", "=", "info", "[", "'fullname'", "]", "submod", "=", "sys", ".", "modules", "...
Determine the URL corresponding to Python object
[ "Determine", "the", "URL", "corresponding", "to", "Python", "object" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/source/conf.py#L629-L678
train
pandas-dev/pandas
doc/source/conf.py
process_class_docstrings
def process_class_docstrings(app, what, name, obj, options, lines): """ For those classes for which we use :: :template: autosummary/class_without_autosummary.rst the documented attributes/methods have to be listed in the class docstring. However, if one of those lists is empty, we use 'None', ...
python
def process_class_docstrings(app, what, name, obj, options, lines): """ For those classes for which we use :: :template: autosummary/class_without_autosummary.rst the documented attributes/methods have to be listed in the class docstring. However, if one of those lists is empty, we use 'None', ...
[ "def", "process_class_docstrings", "(", "app", ",", "what", ",", "name", ",", "obj", ",", "options", ",", "lines", ")", ":", "if", "what", "==", "\"class\"", ":", "joined", "=", "'\\n'", ".", "join", "(", "lines", ")", "templates", "=", "[", "\"\"\".. ...
For those classes for which we use :: :template: autosummary/class_without_autosummary.rst the documented attributes/methods have to be listed in the class docstring. However, if one of those lists is empty, we use 'None', which then generates warnings in sphinx / ugly html output. This "autodoc-p...
[ "For", "those", "classes", "for", "which", "we", "use", "::" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/source/conf.py#L688-L724
train
pandas-dev/pandas
pandas/io/msgpack/__init__.py
pack
def pack(o, stream, **kwargs): """ Pack object `o` and write it to `stream` See :class:`Packer` for options. """ packer = Packer(**kwargs) stream.write(packer.pack(o))
python
def pack(o, stream, **kwargs): """ Pack object `o` and write it to `stream` See :class:`Packer` for options. """ packer = Packer(**kwargs) stream.write(packer.pack(o))
[ "def", "pack", "(", "o", ",", "stream", ",", "*", "*", "kwargs", ")", ":", "packer", "=", "Packer", "(", "*", "*", "kwargs", ")", "stream", ".", "write", "(", "packer", ".", "pack", "(", "o", ")", ")" ]
Pack object `o` and write it to `stream` See :class:`Packer` for options.
[ "Pack", "object", "o", "and", "write", "it", "to", "stream" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/msgpack/__init__.py#L26-L33
train
pandas-dev/pandas
pandas/core/internals/concat.py
get_mgr_concatenation_plan
def get_mgr_concatenation_plan(mgr, indexers): """ Construct concatenation plan for given block manager and indexers. Parameters ---------- mgr : BlockManager indexers : dict of {axis: indexer} Returns ------- plan : list of (BlockPlacement, JoinUnit) tuples """ # Calculat...
python
def get_mgr_concatenation_plan(mgr, indexers): """ Construct concatenation plan for given block manager and indexers. Parameters ---------- mgr : BlockManager indexers : dict of {axis: indexer} Returns ------- plan : list of (BlockPlacement, JoinUnit) tuples """ # Calculat...
[ "def", "get_mgr_concatenation_plan", "(", "mgr", ",", "indexers", ")", ":", "# Calculate post-reindex shape , save for item axis which will be separate", "# for each block anyway.", "mgr_shape", "=", "list", "(", "mgr", ".", "shape", ")", "for", "ax", ",", "indexer", "in"...
Construct concatenation plan for given block manager and indexers. Parameters ---------- mgr : BlockManager indexers : dict of {axis: indexer} Returns ------- plan : list of (BlockPlacement, JoinUnit) tuples
[ "Construct", "concatenation", "plan", "for", "given", "block", "manager", "and", "indexers", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L21-L98
train
pandas-dev/pandas
pandas/core/internals/concat.py
concatenate_join_units
def concatenate_join_units(join_units, concat_axis, copy): """ Concatenate values from several join units along selected axis. """ if concat_axis == 0 and len(join_units) > 1: # Concatenating join units along ax0 is handled in _merge_blocks. raise AssertionError("Concatenating join units...
python
def concatenate_join_units(join_units, concat_axis, copy): """ Concatenate values from several join units along selected axis. """ if concat_axis == 0 and len(join_units) > 1: # Concatenating join units along ax0 is handled in _merge_blocks. raise AssertionError("Concatenating join units...
[ "def", "concatenate_join_units", "(", "join_units", ",", "concat_axis", ",", "copy", ")", ":", "if", "concat_axis", "==", "0", "and", "len", "(", "join_units", ")", ">", "1", ":", "# Concatenating join units along ax0 is handled in _merge_blocks.", "raise", "Assertion...
Concatenate values from several join units along selected axis.
[ "Concatenate", "values", "from", "several", "join", "units", "along", "selected", "axis", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L229-L257
train
pandas-dev/pandas
pandas/core/internals/concat.py
get_empty_dtype_and_na
def get_empty_dtype_and_na(join_units): """ Return dtype and N/A values to use when concatenating specified units. Returned N/A value may be None which means there was no casting involved. Returns ------- dtype na """ if len(join_units) == 1: blk = join_units[0].block ...
python
def get_empty_dtype_and_na(join_units): """ Return dtype and N/A values to use when concatenating specified units. Returned N/A value may be None which means there was no casting involved. Returns ------- dtype na """ if len(join_units) == 1: blk = join_units[0].block ...
[ "def", "get_empty_dtype_and_na", "(", "join_units", ")", ":", "if", "len", "(", "join_units", ")", "==", "1", ":", "blk", "=", "join_units", "[", "0", "]", ".", "block", "if", "blk", "is", "None", ":", "return", "np", ".", "float64", ",", "np", ".", ...
Return dtype and N/A values to use when concatenating specified units. Returned N/A value may be None which means there was no casting involved. Returns ------- dtype na
[ "Return", "dtype", "and", "N", "/", "A", "values", "to", "use", "when", "concatenating", "specified", "units", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L260-L363
train
pandas-dev/pandas
pandas/core/internals/concat.py
is_uniform_join_units
def is_uniform_join_units(join_units): """ Check if the join units consist of blocks of uniform type that can be concatenated using Block.concat_same_type instead of the generic concatenate_join_units (which uses `_concat._concat_compat`). """ return ( # all blocks need to have the same...
python
def is_uniform_join_units(join_units): """ Check if the join units consist of blocks of uniform type that can be concatenated using Block.concat_same_type instead of the generic concatenate_join_units (which uses `_concat._concat_compat`). """ return ( # all blocks need to have the same...
[ "def", "is_uniform_join_units", "(", "join_units", ")", ":", "return", "(", "# all blocks need to have the same type", "all", "(", "type", "(", "ju", ".", "block", ")", "is", "type", "(", "join_units", "[", "0", "]", ".", "block", ")", "for", "ju", "in", "...
Check if the join units consist of blocks of uniform type that can be concatenated using Block.concat_same_type instead of the generic concatenate_join_units (which uses `_concat._concat_compat`).
[ "Check", "if", "the", "join", "units", "consist", "of", "blocks", "of", "uniform", "type", "that", "can", "be", "concatenated", "using", "Block", ".", "concat_same_type", "instead", "of", "the", "generic", "concatenate_join_units", "(", "which", "uses", "_concat...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L366-L384
train
pandas-dev/pandas
pandas/core/internals/concat.py
trim_join_unit
def trim_join_unit(join_unit, length): """ Reduce join_unit's shape along item axis to length. Extra items that didn't fit are returned as a separate block. """ if 0 not in join_unit.indexers: extra_indexers = join_unit.indexers if join_unit.block is None: extra_block ...
python
def trim_join_unit(join_unit, length): """ Reduce join_unit's shape along item axis to length. Extra items that didn't fit are returned as a separate block. """ if 0 not in join_unit.indexers: extra_indexers = join_unit.indexers if join_unit.block is None: extra_block ...
[ "def", "trim_join_unit", "(", "join_unit", ",", "length", ")", ":", "if", "0", "not", "in", "join_unit", ".", "indexers", ":", "extra_indexers", "=", "join_unit", ".", "indexers", "if", "join_unit", ".", "block", "is", "None", ":", "extra_block", "=", "Non...
Reduce join_unit's shape along item axis to length. Extra items that didn't fit are returned as a separate block.
[ "Reduce", "join_unit", "s", "shape", "along", "item", "axis", "to", "length", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L395-L421
train
pandas-dev/pandas
pandas/core/internals/concat.py
combine_concat_plans
def combine_concat_plans(plans, concat_axis): """ Combine multiple concatenation plans into one. existing_plan is updated in-place. """ if len(plans) == 1: for p in plans[0]: yield p[0], [p[1]] elif concat_axis == 0: offset = 0 for plan in plans: ...
python
def combine_concat_plans(plans, concat_axis): """ Combine multiple concatenation plans into one. existing_plan is updated in-place. """ if len(plans) == 1: for p in plans[0]: yield p[0], [p[1]] elif concat_axis == 0: offset = 0 for plan in plans: ...
[ "def", "combine_concat_plans", "(", "plans", ",", "concat_axis", ")", ":", "if", "len", "(", "plans", ")", "==", "1", ":", "for", "p", "in", "plans", "[", "0", "]", ":", "yield", "p", "[", "0", "]", ",", "[", "p", "[", "1", "]", "]", "elif", ...
Combine multiple concatenation plans into one. existing_plan is updated in-place.
[ "Combine", "multiple", "concatenation", "plans", "into", "one", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L424-L484
train
pandas-dev/pandas
pandas/plotting/_style.py
_Options.use
def use(self, key, value): """ Temporarily set a parameter value using the with statement. Aliasing allowed. """ old_value = self[key] try: self[key] = value yield self finally: self[key] = old_value
python
def use(self, key, value): """ Temporarily set a parameter value using the with statement. Aliasing allowed. """ old_value = self[key] try: self[key] = value yield self finally: self[key] = old_value
[ "def", "use", "(", "self", ",", "key", ",", "value", ")", ":", "old_value", "=", "self", "[", "key", "]", "try", ":", "self", "[", "key", "]", "=", "value", "yield", "self", "finally", ":", "self", "[", "key", "]", "=", "old_value" ]
Temporarily set a parameter value using the with statement. Aliasing allowed.
[ "Temporarily", "set", "a", "parameter", "value", "using", "the", "with", "statement", ".", "Aliasing", "allowed", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_style.py#L151-L161
train
pandas-dev/pandas
pandas/io/stata.py
_stata_elapsed_date_to_datetime_vec
def _stata_elapsed_date_to_datetime_vec(dates, fmt): """ Convert from SIF to datetime. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series The Stata Internal Format date to convert to datetime according to fmt fmt : str The format to convert to. Can be, t...
python
def _stata_elapsed_date_to_datetime_vec(dates, fmt): """ Convert from SIF to datetime. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series The Stata Internal Format date to convert to datetime according to fmt fmt : str The format to convert to. Can be, t...
[ "def", "_stata_elapsed_date_to_datetime_vec", "(", "dates", ",", "fmt", ")", ":", "MIN_YEAR", ",", "MAX_YEAR", "=", "Timestamp", ".", "min", ".", "year", ",", "Timestamp", ".", "max", ".", "year", "MAX_DAY_DELTA", "=", "(", "Timestamp", ".", "max", "-", "d...
Convert from SIF to datetime. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series The Stata Internal Format date to convert to datetime according to fmt fmt : str The format to convert to. Can be, tc, td, tw, tm, tq, th, ty Returns Returns ------...
[ "Convert", "from", "SIF", "to", "datetime", ".", "http", ":", "//", "www", ".", "stata", ".", "com", "/", "help", ".", "cgi?datetime" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L203-L364
train
pandas-dev/pandas
pandas/io/stata.py
_datetime_to_stata_elapsed_vec
def _datetime_to_stata_elapsed_vec(dates, fmt): """ Convert from datetime to SIF. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series Series or array containing datetime.datetime or datetime64[ns] to convert to the Stata Internal Format given by fmt fmt :...
python
def _datetime_to_stata_elapsed_vec(dates, fmt): """ Convert from datetime to SIF. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series Series or array containing datetime.datetime or datetime64[ns] to convert to the Stata Internal Format given by fmt fmt :...
[ "def", "_datetime_to_stata_elapsed_vec", "(", "dates", ",", "fmt", ")", ":", "index", "=", "dates", ".", "index", "NS_PER_DAY", "=", "24", "*", "3600", "*", "1000", "*", "1000", "*", "1000", "US_PER_DAY", "=", "NS_PER_DAY", "/", "1000", "def", "parse_dates...
Convert from datetime to SIF. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series Series or array containing datetime.datetime or datetime64[ns] to convert to the Stata Internal Format given by fmt fmt : str The format to convert to. Can be, tc, td, tw, t...
[ "Convert", "from", "datetime", "to", "SIF", ".", "http", ":", "//", "www", ".", "stata", ".", "com", "/", "help", ".", "cgi?datetime" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L367-L461
train
pandas-dev/pandas
pandas/io/stata.py
_cast_to_stata_types
def _cast_to_stata_types(data): """Checks the dtypes of the columns of a pandas DataFrame for compatibility with the data types and ranges supported by Stata, and converts if necessary. Parameters ---------- data : DataFrame The DataFrame to check and convert Notes ----- Nu...
python
def _cast_to_stata_types(data): """Checks the dtypes of the columns of a pandas DataFrame for compatibility with the data types and ranges supported by Stata, and converts if necessary. Parameters ---------- data : DataFrame The DataFrame to check and convert Notes ----- Nu...
[ "def", "_cast_to_stata_types", "(", "data", ")", ":", "ws", "=", "''", "# original, if small, if large", "conversion_data", "=", "(", "(", "np", ".", "bool", ",", "np", ".", "int8", ",", "np", ".", "int8", ")", ",", "(", "np", ".", "uint8"...
Checks the dtypes of the columns of a pandas DataFrame for compatibility with the data types and ranges supported by Stata, and converts if necessary. Parameters ---------- data : DataFrame The DataFrame to check and convert Notes ----- Numeric columns in Stata must be one of i...
[ "Checks", "the", "dtypes", "of", "the", "columns", "of", "a", "pandas", "DataFrame", "for", "compatibility", "with", "the", "data", "types", "and", "ranges", "supported", "by", "Stata", "and", "converts", "if", "necessary", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L508-L592
train
pandas-dev/pandas
pandas/io/stata.py
_dtype_to_stata_type
def _dtype_to_stata_type(dtype, column): """ Convert dtype types to stata types. Returns the byte of the given ordinal. See TYPE_MAP and comments for an explanation. This is also explained in the dta spec. 1 - 244 are strings of this length Pandas Stata 251 - for int8...
python
def _dtype_to_stata_type(dtype, column): """ Convert dtype types to stata types. Returns the byte of the given ordinal. See TYPE_MAP and comments for an explanation. This is also explained in the dta spec. 1 - 244 are strings of this length Pandas Stata 251 - for int8...
[ "def", "_dtype_to_stata_type", "(", "dtype", ",", "column", ")", ":", "# TODO: expand to handle datetime to integer conversion", "if", "dtype", ".", "type", "==", "np", ".", "object_", ":", "# try to coerce it to the biggest string", "# not memory efficient, what else could we"...
Convert dtype types to stata types. Returns the byte of the given ordinal. See TYPE_MAP and comments for an explanation. This is also explained in the dta spec. 1 - 244 are strings of this length Pandas Stata 251 - for int8 byte 252 - for int16 int 253 - for ...
[ "Convert", "dtype", "types", "to", "stata", "types", ".", "Returns", "the", "byte", "of", "the", "given", "ordinal", ".", "See", "TYPE_MAP", "and", "comments", "for", "an", "explanation", ".", "This", "is", "also", "explained", "in", "the", "dta", "spec", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1832-L1866
train
pandas-dev/pandas
pandas/io/stata.py
_dtype_to_default_stata_fmt
def _dtype_to_default_stata_fmt(dtype, column, dta_version=114, force_strl=False): """ Map numpy dtype to stata's default format for this type. Not terribly important since users can change this in Stata. Semantics are object -> "%DDs" where DD is the length of the stri...
python
def _dtype_to_default_stata_fmt(dtype, column, dta_version=114, force_strl=False): """ Map numpy dtype to stata's default format for this type. Not terribly important since users can change this in Stata. Semantics are object -> "%DDs" where DD is the length of the stri...
[ "def", "_dtype_to_default_stata_fmt", "(", "dtype", ",", "column", ",", "dta_version", "=", "114", ",", "force_strl", "=", "False", ")", ":", "# TODO: Refactor to combine type with format", "# TODO: expand this to handle a default datetime format?", "if", "dta_version", "<", ...
Map numpy dtype to stata's default format for this type. Not terribly important since users can change this in Stata. Semantics are object -> "%DDs" where DD is the length of the string. If not a string, raise ValueError float64 -> "%10.0g" float32 -> "%9.0g" int64 -> "%9.0g" ...
[ "Map", "numpy", "dtype", "to", "stata", "s", "default", "format", "for", "this", "type", ".", "Not", "terribly", "important", "since", "users", "can", "change", "this", "in", "Stata", ".", "Semantics", "are" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1869-L1922
train
pandas-dev/pandas
pandas/io/stata.py
_pad_bytes_new
def _pad_bytes_new(name, length): """ Takes a bytes instance and pads it with null bytes until it's length chars. """ if isinstance(name, str): name = bytes(name, 'utf-8') return name + b'\x00' * (length - len(name))
python
def _pad_bytes_new(name, length): """ Takes a bytes instance and pads it with null bytes until it's length chars. """ if isinstance(name, str): name = bytes(name, 'utf-8') return name + b'\x00' * (length - len(name))
[ "def", "_pad_bytes_new", "(", "name", ",", "length", ")", ":", "if", "isinstance", "(", "name", ",", "str", ")", ":", "name", "=", "bytes", "(", "name", ",", "'utf-8'", ")", "return", "name", "+", "b'\\x00'", "*", "(", "length", "-", "len", "(", "n...
Takes a bytes instance and pads it with null bytes until it's length chars.
[ "Takes", "a", "bytes", "instance", "and", "pads", "it", "with", "null", "bytes", "until", "it", "s", "length", "chars", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2477-L2483
train
pandas-dev/pandas
pandas/io/stata.py
StataValueLabel.generate_value_label
def generate_value_label(self, byteorder, encoding): """ Parameters ---------- byteorder : str Byte order of the output encoding : str File encoding Returns ------- value_label : bytes Bytes containing the formatted val...
python
def generate_value_label(self, byteorder, encoding): """ Parameters ---------- byteorder : str Byte order of the output encoding : str File encoding Returns ------- value_label : bytes Bytes containing the formatted val...
[ "def", "generate_value_label", "(", "self", ",", "byteorder", ",", "encoding", ")", ":", "self", ".", "_encoding", "=", "encoding", "bio", "=", "BytesIO", "(", ")", "null_string", "=", "'\\x00'", "null_byte", "=", "b'\\x00'", "# len", "bio", ".", "write", ...
Parameters ---------- byteorder : str Byte order of the output encoding : str File encoding Returns ------- value_label : bytes Bytes containing the formatted value label
[ "Parameters", "----------", "byteorder", ":", "str", "Byte", "order", "of", "the", "output", "encoding", ":", "str", "File", "encoding" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L662-L713
train
pandas-dev/pandas
pandas/io/stata.py
StataReader._setup_dtype
def _setup_dtype(self): """Map between numpy and state dtypes""" if self._dtype is not None: return self._dtype dtype = [] # Convert struct data types to numpy data type for i, typ in enumerate(self.typlist): if typ in self.NUMPY_TYPE_MAP: dtype....
python
def _setup_dtype(self): """Map between numpy and state dtypes""" if self._dtype is not None: return self._dtype dtype = [] # Convert struct data types to numpy data type for i, typ in enumerate(self.typlist): if typ in self.NUMPY_TYPE_MAP: dtype....
[ "def", "_setup_dtype", "(", "self", ")", ":", "if", "self", ".", "_dtype", "is", "not", "None", ":", "return", "self", ".", "_dtype", "dtype", "=", "[", "]", "# Convert struct data types to numpy data type", "for", "i", ",", "typ", "in", "enumerate", "(", ...
Map between numpy and state dtypes
[ "Map", "between", "numpy", "and", "state", "dtypes" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1307-L1322
train
pandas-dev/pandas
pandas/io/stata.py
StataReader._do_convert_categoricals
def _do_convert_categoricals(self, data, value_label_dict, lbllist, order_categoricals): """ Converts categorical columns to Categorical type. """ value_labels = list(value_label_dict.keys()) cat_converted_data = [] for col, label in zip(d...
python
def _do_convert_categoricals(self, data, value_label_dict, lbllist, order_categoricals): """ Converts categorical columns to Categorical type. """ value_labels = list(value_label_dict.keys()) cat_converted_data = [] for col, label in zip(d...
[ "def", "_do_convert_categoricals", "(", "self", ",", "data", ",", "value_label_dict", ",", "lbllist", ",", "order_categoricals", ")", ":", "value_labels", "=", "list", "(", "value_label_dict", ".", "keys", "(", ")", ")", "cat_converted_data", "=", "[", "]", "f...
Converts categorical columns to Categorical type.
[ "Converts", "categorical", "columns", "to", "Categorical", "type", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L1698-L1740
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter._write
def _write(self, to_write): """ Helper to call encode before writing to file for Python 3 compat. """ self._file.write(to_write.encode(self._encoding or self._default_encoding))
python
def _write(self, to_write): """ Helper to call encode before writing to file for Python 3 compat. """ self._file.write(to_write.encode(self._encoding or self._default_encoding))
[ "def", "_write", "(", "self", ",", "to_write", ")", ":", "self", ".", "_file", ".", "write", "(", "to_write", ".", "encode", "(", "self", ".", "_encoding", "or", "self", ".", "_default_encoding", ")", ")" ]
Helper to call encode before writing to file for Python 3 compat.
[ "Helper", "to", "call", "encode", "before", "writing", "to", "file", "for", "Python", "3", "compat", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2018-L2023
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter._prepare_categoricals
def _prepare_categoricals(self, data): """Check for categorical columns, retain categorical information for Stata file and convert categorical data to int""" is_cat = [is_categorical_dtype(data[col]) for col in data] self._is_col_cat = is_cat self._value_labels = [] if n...
python
def _prepare_categoricals(self, data): """Check for categorical columns, retain categorical information for Stata file and convert categorical data to int""" is_cat = [is_categorical_dtype(data[col]) for col in data] self._is_col_cat = is_cat self._value_labels = [] if n...
[ "def", "_prepare_categoricals", "(", "self", ",", "data", ")", ":", "is_cat", "=", "[", "is_categorical_dtype", "(", "data", "[", "col", "]", ")", "for", "col", "in", "data", "]", "self", ".", "_is_col_cat", "=", "is_cat", "self", ".", "_value_labels", "...
Check for categorical columns, retain categorical information for Stata file and convert categorical data to int
[ "Check", "for", "categorical", "columns", "retain", "categorical", "information", "for", "Stata", "file", "and", "convert", "categorical", "data", "to", "int" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2025-L2061
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter._replace_nans
def _replace_nans(self, data): # return data """Checks floating point data columns for nans, and replaces these with the generic Stata for missing value (.)""" for c in data: dtype = data[c].dtype if dtype in (np.float32, np.float64): if dtype == n...
python
def _replace_nans(self, data): # return data """Checks floating point data columns for nans, and replaces these with the generic Stata for missing value (.)""" for c in data: dtype = data[c].dtype if dtype in (np.float32, np.float64): if dtype == n...
[ "def", "_replace_nans", "(", "self", ",", "data", ")", ":", "# return data", "for", "c", "in", "data", ":", "dtype", "=", "data", "[", "c", "]", ".", "dtype", "if", "dtype", "in", "(", "np", ".", "float32", ",", "np", ".", "float64", ")", ":", "i...
Checks floating point data columns for nans, and replaces these with the generic Stata for missing value (.)
[ "Checks", "floating", "point", "data", "columns", "for", "nans", "and", "replaces", "these", "with", "the", "generic", "Stata", "for", "missing", "value", "(", ".", ")" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2063-L2076
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter._check_column_names
def _check_column_names(self, data): """ Checks column names to ensure that they are valid Stata column names. This includes checks for: * Non-string names * Stata keywords * Variables that start with numbers * Variables with names that are too lon...
python
def _check_column_names(self, data): """ Checks column names to ensure that they are valid Stata column names. This includes checks for: * Non-string names * Stata keywords * Variables that start with numbers * Variables with names that are too lon...
[ "def", "_check_column_names", "(", "self", ",", "data", ")", ":", "converted_names", "=", "{", "}", "columns", "=", "list", "(", "data", ".", "columns", ")", "original_columns", "=", "columns", "[", ":", "]", "duplicate_var_id", "=", "0", "for", "j", ","...
Checks column names to ensure that they are valid Stata column names. This includes checks for: * Non-string names * Stata keywords * Variables that start with numbers * Variables with names that are too long When an illegal variable name is detected, it ...
[ "Checks", "column", "names", "to", "ensure", "that", "they", "are", "valid", "Stata", "column", "names", ".", "This", "includes", "checks", "for", ":", "*", "Non", "-", "string", "names", "*", "Stata", "keywords", "*", "Variables", "that", "start", "with",...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2082-L2157
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter._close
def _close(self): """ Close the file if it was created by the writer. If a buffer or file-like object was passed in, for example a GzipFile, then leave this file open for the caller to close. In either case, attempt to flush the file contents to ensure they are written to disk ...
python
def _close(self): """ Close the file if it was created by the writer. If a buffer or file-like object was passed in, for example a GzipFile, then leave this file open for the caller to close. In either case, attempt to flush the file contents to ensure they are written to disk ...
[ "def", "_close", "(", "self", ")", ":", "# Some file-like objects might not support flush", "try", ":", "self", ".", "_file", ".", "flush", "(", ")", "except", "AttributeError", ":", "pass", "if", "self", ".", "_own_file", ":", "self", ".", "_file", ".", "cl...
Close the file if it was created by the writer. If a buffer or file-like object was passed in, for example a GzipFile, then leave this file open for the caller to close. In either case, attempt to flush the file contents to ensure they are written to disk (if supported)
[ "Close", "the", "file", "if", "it", "was", "created", "by", "the", "writer", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2249-L2264
train
pandas-dev/pandas
pandas/io/stata.py
StataStrLWriter.generate_table
def generate_table(self): """ Generates the GSO lookup table for the DataFRame Returns ------- gso_table : OrderedDict Ordered dictionary using the string found as keys and their lookup position (v,o) as values gso_df : DataFrame DataF...
python
def generate_table(self): """ Generates the GSO lookup table for the DataFRame Returns ------- gso_table : OrderedDict Ordered dictionary using the string found as keys and their lookup position (v,o) as values gso_df : DataFrame DataF...
[ "def", "generate_table", "(", "self", ")", ":", "gso_table", "=", "self", ".", "_gso_table", "gso_df", "=", "self", ".", "df", "columns", "=", "list", "(", "gso_df", ".", "columns", ")", "selected", "=", "gso_df", "[", "self", ".", "columns", "]", "col...
Generates the GSO lookup table for the DataFRame Returns ------- gso_table : OrderedDict Ordered dictionary using the string found as keys and their lookup position (v,o) as values gso_df : DataFrame DataFrame where strl columns have been converted to...
[ "Generates", "the", "GSO", "lookup", "table", "for", "the", "DataFRame" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2546-L2596
train
pandas-dev/pandas
pandas/io/stata.py
StataStrLWriter.generate_blob
def generate_blob(self, gso_table): """ Generates the binary blob of GSOs that is written to the dta file. Parameters ---------- gso_table : OrderedDict Ordered dictionary (str, vo) Returns ------- gso : bytes Binary content of dt...
python
def generate_blob(self, gso_table): """ Generates the binary blob of GSOs that is written to the dta file. Parameters ---------- gso_table : OrderedDict Ordered dictionary (str, vo) Returns ------- gso : bytes Binary content of dt...
[ "def", "generate_blob", "(", "self", ",", "gso_table", ")", ":", "# Format information", "# Length includes null term", "# 117", "# GSOvvvvooootllllxxxxxxxxxxxxxxx...x", "# 3 u4 u4 u1 u4 string + null term", "#", "# 118, 119", "# GSOvvvvooooooootllllxxxxxxxxxxxxxxx...x", "# 3 u...
Generates the binary blob of GSOs that is written to the dta file. Parameters ---------- gso_table : OrderedDict Ordered dictionary (str, vo) Returns ------- gso : bytes Binary content of dta file to be placed between strl tags Notes ...
[ "Generates", "the", "binary", "blob", "of", "GSOs", "that", "is", "written", "to", "the", "dta", "file", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2604-L2666
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._tag
def _tag(val, tag): """Surround val with <tag></tag>""" if isinstance(val, str): val = bytes(val, 'utf-8') return (bytes('<' + tag + '>', 'utf-8') + val + bytes('</' + tag + '>', 'utf-8'))
python
def _tag(val, tag): """Surround val with <tag></tag>""" if isinstance(val, str): val = bytes(val, 'utf-8') return (bytes('<' + tag + '>', 'utf-8') + val + bytes('</' + tag + '>', 'utf-8'))
[ "def", "_tag", "(", "val", ",", "tag", ")", ":", "if", "isinstance", "(", "val", ",", "str", ")", ":", "val", "=", "bytes", "(", "val", ",", "'utf-8'", ")", "return", "(", "bytes", "(", "'<'", "+", "tag", "+", "'>'", ",", "'utf-8'", ")", "+", ...
Surround val with <tag></tag>
[ "Surround", "val", "with", "<tag", ">", "<", "/", "tag", ">" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2761-L2766
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._write_header
def _write_header(self, data_label=None, time_stamp=None): """Write the file header""" byteorder = self._byteorder self._file.write(bytes('<stata_dta>', 'utf-8')) bio = BytesIO() # ds_format - 117 bio.write(self._tag(bytes('117', 'utf-8'), 'release')) # byteorder ...
python
def _write_header(self, data_label=None, time_stamp=None): """Write the file header""" byteorder = self._byteorder self._file.write(bytes('<stata_dta>', 'utf-8')) bio = BytesIO() # ds_format - 117 bio.write(self._tag(bytes('117', 'utf-8'), 'release')) # byteorder ...
[ "def", "_write_header", "(", "self", ",", "data_label", "=", "None", ",", "time_stamp", "=", "None", ")", ":", "byteorder", "=", "self", ".", "_byteorder", "self", ".", "_file", ".", "write", "(", "bytes", "(", "'<stata_dta>'", ",", "'utf-8'", ")", ")", ...
Write the file header
[ "Write", "the", "file", "header" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2772-L2808
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._write_map
def _write_map(self): """Called twice during file write. The first populates the values in the map with 0s. The second call writes the final map locations when all blocks have been written.""" if self._map is None: self._map = OrderedDict((('stata_data', 0), ...
python
def _write_map(self): """Called twice during file write. The first populates the values in the map with 0s. The second call writes the final map locations when all blocks have been written.""" if self._map is None: self._map = OrderedDict((('stata_data', 0), ...
[ "def", "_write_map", "(", "self", ")", ":", "if", "self", ".", "_map", "is", "None", ":", "self", ".", "_map", "=", "OrderedDict", "(", "(", "(", "'stata_data'", ",", "0", ")", ",", "(", "'map'", ",", "self", ".", "_file", ".", "tell", "(", ")", ...
Called twice during file write. The first populates the values in the map with 0s. The second call writes the final map locations when all blocks have been written.
[ "Called", "twice", "during", "file", "write", ".", "The", "first", "populates", "the", "values", "in", "the", "map", "with", "0s", ".", "The", "second", "call", "writes", "the", "final", "map", "locations", "when", "all", "blocks", "have", "been", "written...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2810-L2835
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._update_strl_names
def _update_strl_names(self): """Update column names for conversion to strl if they might have been changed to comply with Stata naming rules""" # Update convert_strl if names changed for orig, new in self._converted_names.items(): if orig in self._convert_strl: ...
python
def _update_strl_names(self): """Update column names for conversion to strl if they might have been changed to comply with Stata naming rules""" # Update convert_strl if names changed for orig, new in self._converted_names.items(): if orig in self._convert_strl: ...
[ "def", "_update_strl_names", "(", "self", ")", ":", "# Update convert_strl if names changed", "for", "orig", ",", "new", "in", "self", ".", "_converted_names", ".", "items", "(", ")", ":", "if", "orig", "in", "self", ".", "_convert_strl", ":", "idx", "=", "s...
Update column names for conversion to strl if they might have been changed to comply with Stata naming rules
[ "Update", "column", "names", "for", "conversion", "to", "strl", "if", "they", "might", "have", "been", "changed", "to", "comply", "with", "Stata", "naming", "rules" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2948-L2955
train
pandas-dev/pandas
pandas/io/stata.py
StataWriter117._convert_strls
def _convert_strls(self, data): """Convert columns to StrLs if either very large or in the convert_strl variable""" convert_cols = [ col for i, col in enumerate(data) if self.typlist[i] == 32768 or col in self._convert_strl] if convert_cols: ssw = Sta...
python
def _convert_strls(self, data): """Convert columns to StrLs if either very large or in the convert_strl variable""" convert_cols = [ col for i, col in enumerate(data) if self.typlist[i] == 32768 or col in self._convert_strl] if convert_cols: ssw = Sta...
[ "def", "_convert_strls", "(", "self", ",", "data", ")", ":", "convert_cols", "=", "[", "col", "for", "i", ",", "col", "in", "enumerate", "(", "data", ")", "if", "self", ".", "typlist", "[", "i", "]", "==", "32768", "or", "col", "in", "self", ".", ...
Convert columns to StrLs if either very large or in the convert_strl variable
[ "Convert", "columns", "to", "StrLs", "if", "either", "very", "large", "or", "in", "the", "convert_strl", "variable" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2957-L2969
train
pandas-dev/pandas
pandas/plotting/_converter.py
register
def register(explicit=True): """ Register Pandas Formatters and Converters with matplotlib This function modifies the global ``matplotlib.units.registry`` dictionary. Pandas adds custom converters for * pd.Timestamp * pd.Period * np.datetime64 * datetime.datetime * datetime.date ...
python
def register(explicit=True): """ Register Pandas Formatters and Converters with matplotlib This function modifies the global ``matplotlib.units.registry`` dictionary. Pandas adds custom converters for * pd.Timestamp * pd.Period * np.datetime64 * datetime.datetime * datetime.date ...
[ "def", "register", "(", "explicit", "=", "True", ")", ":", "# Renamed in pandas.plotting.__init__", "global", "_WARN", "if", "explicit", ":", "_WARN", "=", "False", "pairs", "=", "get_pairs", "(", ")", "for", "type_", ",", "cls", "in", "pairs", ":", "convert...
Register Pandas Formatters and Converters with matplotlib This function modifies the global ``matplotlib.units.registry`` dictionary. Pandas adds custom converters for * pd.Timestamp * pd.Period * np.datetime64 * datetime.datetime * datetime.date * datetime.time See Also -----...
[ "Register", "Pandas", "Formatters", "and", "Converters", "with", "matplotlib" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L54-L84
train
pandas-dev/pandas
pandas/plotting/_converter.py
deregister
def deregister(): """ Remove pandas' formatters and converters Removes the custom converters added by :func:`register`. This attempts to set the state of the registry back to the state before pandas registered its own units. Converters for pandas' own types like Timestamp and Period are removed...
python
def deregister(): """ Remove pandas' formatters and converters Removes the custom converters added by :func:`register`. This attempts to set the state of the registry back to the state before pandas registered its own units. Converters for pandas' own types like Timestamp and Period are removed...
[ "def", "deregister", "(", ")", ":", "# Renamed in pandas.plotting.__init__", "for", "type_", ",", "cls", "in", "get_pairs", "(", ")", ":", "# We use type to catch our classes directly, no inheritance", "if", "type", "(", "units", ".", "registry", ".", "get", "(", "t...
Remove pandas' formatters and converters Removes the custom converters added by :func:`register`. This attempts to set the state of the registry back to the state before pandas registered its own units. Converters for pandas' own types like Timestamp and Period are removed completely. Converters for ty...
[ "Remove", "pandas", "formatters", "and", "converters" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L87-L113
train
pandas-dev/pandas
pandas/plotting/_converter.py
_dt_to_float_ordinal
def _dt_to_float_ordinal(dt): """ Convert :mod:`datetime` to the Gregorian date as UTC float days, preserving hours, minutes, seconds and microseconds. Return value is a :func:`float`. """ if (isinstance(dt, (np.ndarray, Index, ABCSeries) ) and is_datetime64_ns_dtype(dt)): ...
python
def _dt_to_float_ordinal(dt): """ Convert :mod:`datetime` to the Gregorian date as UTC float days, preserving hours, minutes, seconds and microseconds. Return value is a :func:`float`. """ if (isinstance(dt, (np.ndarray, Index, ABCSeries) ) and is_datetime64_ns_dtype(dt)): ...
[ "def", "_dt_to_float_ordinal", "(", "dt", ")", ":", "if", "(", "isinstance", "(", "dt", ",", "(", "np", ".", "ndarray", ",", "Index", ",", "ABCSeries", ")", ")", "and", "is_datetime64_ns_dtype", "(", "dt", ")", ")", ":", "base", "=", "dates", ".", "e...
Convert :mod:`datetime` to the Gregorian date as UTC float days, preserving hours, minutes, seconds and microseconds. Return value is a :func:`float`.
[ "Convert", ":", "mod", ":", "datetime", "to", "the", "Gregorian", "date", "as", "UTC", "float", "days", "preserving", "hours", "minutes", "seconds", "and", "microseconds", ".", "Return", "value", "is", "a", ":", "func", ":", "float", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L269-L280
train
pandas-dev/pandas
pandas/plotting/_converter.py
_get_default_annual_spacing
def _get_default_annual_spacing(nyears): """ Returns a default spacing between consecutive ticks for annual data. """ if nyears < 11: (min_spacing, maj_spacing) = (1, 1) elif nyears < 20: (min_spacing, maj_spacing) = (1, 2) elif nyears < 50: (min_spacing, maj_spacing) = (...
python
def _get_default_annual_spacing(nyears): """ Returns a default spacing between consecutive ticks for annual data. """ if nyears < 11: (min_spacing, maj_spacing) = (1, 1) elif nyears < 20: (min_spacing, maj_spacing) = (1, 2) elif nyears < 50: (min_spacing, maj_spacing) = (...
[ "def", "_get_default_annual_spacing", "(", "nyears", ")", ":", "if", "nyears", "<", "11", ":", "(", "min_spacing", ",", "maj_spacing", ")", "=", "(", "1", ",", "1", ")", "elif", "nyears", "<", "20", ":", "(", "min_spacing", ",", "maj_spacing", ")", "="...
Returns a default spacing between consecutive ticks for annual data.
[ "Returns", "a", "default", "spacing", "between", "consecutive", "ticks", "for", "annual", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L537-L556
train
pandas-dev/pandas
pandas/plotting/_converter.py
period_break
def period_break(dates, period): """ Returns the indices where the given period changes. Parameters ---------- dates : PeriodIndex Array of intervals to monitor. period : string Name of the period to monitor. """ current = getattr(dates, period) previous = getattr(da...
python
def period_break(dates, period): """ Returns the indices where the given period changes. Parameters ---------- dates : PeriodIndex Array of intervals to monitor. period : string Name of the period to monitor. """ current = getattr(dates, period) previous = getattr(da...
[ "def", "period_break", "(", "dates", ",", "period", ")", ":", "current", "=", "getattr", "(", "dates", ",", "period", ")", "previous", "=", "getattr", "(", "dates", "-", "1", "*", "dates", ".", "freq", ",", "period", ")", "return", "np", ".", "nonzer...
Returns the indices where the given period changes. Parameters ---------- dates : PeriodIndex Array of intervals to monitor. period : string Name of the period to monitor.
[ "Returns", "the", "indices", "where", "the", "given", "period", "changes", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L559-L572
train
pandas-dev/pandas
pandas/plotting/_converter.py
has_level_label
def has_level_label(label_flags, vmin): """ Returns true if the ``label_flags`` indicate there is at least one label for this level. if the minimum view limit is not an exact integer, then the first tick label won't be shown, so we must adjust for that. """ if label_flags.size == 0 or (labe...
python
def has_level_label(label_flags, vmin): """ Returns true if the ``label_flags`` indicate there is at least one label for this level. if the minimum view limit is not an exact integer, then the first tick label won't be shown, so we must adjust for that. """ if label_flags.size == 0 or (labe...
[ "def", "has_level_label", "(", "label_flags", ",", "vmin", ")", ":", "if", "label_flags", ".", "size", "==", "0", "or", "(", "label_flags", ".", "size", "==", "1", "and", "label_flags", "[", "0", "]", "==", "0", "and", "vmin", "%", "1", ">", "0.0", ...
Returns true if the ``label_flags`` indicate there is at least one label for this level. if the minimum view limit is not an exact integer, then the first tick label won't be shown, so we must adjust for that.
[ "Returns", "true", "if", "the", "label_flags", "indicate", "there", "is", "at", "least", "one", "label", "for", "this", "level", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L575-L588
train
pandas-dev/pandas
pandas/plotting/_converter.py
DatetimeConverter.axisinfo
def axisinfo(unit, axis): """ Return the :class:`~matplotlib.units.AxisInfo` for *unit*. *unit* is a tzinfo instance or None. The *axis* argument is required but not used. """ tz = unit majloc = PandasAutoDateLocator(tz=tz) majfmt = PandasAutoDateFormatt...
python
def axisinfo(unit, axis): """ Return the :class:`~matplotlib.units.AxisInfo` for *unit*. *unit* is a tzinfo instance or None. The *axis* argument is required but not used. """ tz = unit majloc = PandasAutoDateLocator(tz=tz) majfmt = PandasAutoDateFormatt...
[ "def", "axisinfo", "(", "unit", ",", "axis", ")", ":", "tz", "=", "unit", "majloc", "=", "PandasAutoDateLocator", "(", "tz", "=", "tz", ")", "majfmt", "=", "PandasAutoDateFormatter", "(", "majloc", ",", "tz", "=", "tz", ")", "datemin", "=", "pydt", "."...
Return the :class:`~matplotlib.units.AxisInfo` for *unit*. *unit* is a tzinfo instance or None. The *axis* argument is required but not used.
[ "Return", "the", ":", "class", ":", "~matplotlib", ".", "units", ".", "AxisInfo", "for", "*", "unit", "*", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L340-L355
train
pandas-dev/pandas
pandas/plotting/_converter.py
PandasAutoDateLocator.get_locator
def get_locator(self, dmin, dmax): 'Pick the best locator based on a distance.' _check_implicitly_registered() delta = relativedelta(dmax, dmin) num_days = (delta.years * 12.0 + delta.months) * 31.0 + delta.days num_sec = (delta.hours * 60.0 + delta.minutes) * 60.0 + delta.secon...
python
def get_locator(self, dmin, dmax): 'Pick the best locator based on a distance.' _check_implicitly_registered() delta = relativedelta(dmax, dmin) num_days = (delta.years * 12.0 + delta.months) * 31.0 + delta.days num_sec = (delta.hours * 60.0 + delta.minutes) * 60.0 + delta.secon...
[ "def", "get_locator", "(", "self", ",", "dmin", ",", "dmax", ")", ":", "_check_implicitly_registered", "(", ")", "delta", "=", "relativedelta", "(", "dmax", ",", "dmin", ")", "num_days", "=", "(", "delta", ".", "years", "*", "12.0", "+", "delta", ".", ...
Pick the best locator based on a distance.
[ "Pick", "the", "best", "locator", "based", "on", "a", "distance", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L369-L387
train
pandas-dev/pandas
pandas/plotting/_converter.py
MilliSecondLocator.autoscale
def autoscale(self): """ Set the view limits to include the data range. """ dmin, dmax = self.datalim_to_dt() if dmin > dmax: dmax, dmin = dmin, dmax # We need to cap at the endpoints of valid datetime # TODO(wesm): unused? # delta = relativ...
python
def autoscale(self): """ Set the view limits to include the data range. """ dmin, dmax = self.datalim_to_dt() if dmin > dmax: dmax, dmin = dmin, dmax # We need to cap at the endpoints of valid datetime # TODO(wesm): unused? # delta = relativ...
[ "def", "autoscale", "(", "self", ")", ":", "dmin", ",", "dmax", "=", "self", ".", "datalim_to_dt", "(", ")", "if", "dmin", ">", "dmax", ":", "dmax", ",", "dmin", "=", "dmin", ",", "dmax", "# We need to cap at the endpoints of valid datetime", "# TODO(wesm): un...
Set the view limits to include the data range.
[ "Set", "the", "view", "limits", "to", "include", "the", "data", "range", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L478-L507
train
pandas-dev/pandas
pandas/plotting/_converter.py
TimeSeries_DateLocator._get_default_locs
def _get_default_locs(self, vmin, vmax): "Returns the default locations of ticks." if self.plot_obj.date_axis_info is None: self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) locator = self.plot_obj.date_axis_info if self.isminor: return np.compr...
python
def _get_default_locs(self, vmin, vmax): "Returns the default locations of ticks." if self.plot_obj.date_axis_info is None: self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) locator = self.plot_obj.date_axis_info if self.isminor: return np.compr...
[ "def", "_get_default_locs", "(", "self", ",", "vmin", ",", "vmax", ")", ":", "if", "self", ".", "plot_obj", ".", "date_axis_info", "is", "None", ":", "self", ".", "plot_obj", ".", "date_axis_info", "=", "self", ".", "finder", "(", "vmin", ",", "vmax", ...
Returns the default locations of ticks.
[ "Returns", "the", "default", "locations", "of", "ticks", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1002-L1012
train
pandas-dev/pandas
pandas/plotting/_converter.py
TimeSeries_DateLocator.autoscale
def autoscale(self): """ Sets the view limits to the nearest multiples of base that contain the data. """ # requires matplotlib >= 0.98.0 (vmin, vmax) = self.axis.get_data_interval() locs = self._get_default_locs(vmin, vmax) (vmin, vmax) = locs[[0, -1]] ...
python
def autoscale(self): """ Sets the view limits to the nearest multiples of base that contain the data. """ # requires matplotlib >= 0.98.0 (vmin, vmax) = self.axis.get_data_interval() locs = self._get_default_locs(vmin, vmax) (vmin, vmax) = locs[[0, -1]] ...
[ "def", "autoscale", "(", "self", ")", ":", "# requires matplotlib >= 0.98.0", "(", "vmin", ",", "vmax", ")", "=", "self", ".", "axis", ".", "get_data_interval", "(", ")", "locs", "=", "self", ".", "_get_default_locs", "(", "vmin", ",", "vmax", ")", "(", ...
Sets the view limits to the nearest multiples of base that contain the data.
[ "Sets", "the", "view", "limits", "to", "the", "nearest", "multiples", "of", "base", "that", "contain", "the", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1035-L1048
train
pandas-dev/pandas
pandas/plotting/_converter.py
TimeSeries_DateFormatter._set_default_format
def _set_default_format(self, vmin, vmax): "Returns the default ticks spacing." if self.plot_obj.date_axis_info is None: self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) info = self.plot_obj.date_axis_info if self.isminor: format = np.compress(i...
python
def _set_default_format(self, vmin, vmax): "Returns the default ticks spacing." if self.plot_obj.date_axis_info is None: self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) info = self.plot_obj.date_axis_info if self.isminor: format = np.compress(i...
[ "def", "_set_default_format", "(", "self", ",", "vmin", ",", "vmax", ")", ":", "if", "self", ".", "plot_obj", ".", "date_axis_info", "is", "None", ":", "self", ".", "plot_obj", ".", "date_axis_info", "=", "self", ".", "finder", "(", "vmin", ",", "vmax", ...
Returns the default ticks spacing.
[ "Returns", "the", "default", "ticks", "spacing", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1084-L1097
train
pandas-dev/pandas
pandas/plotting/_converter.py
TimeSeries_DateFormatter.set_locs
def set_locs(self, locs): 'Sets the locations of the ticks' # don't actually use the locs. This is just needed to work with # matplotlib. Force to use vmin, vmax _check_implicitly_registered() self.locs = locs (vmin, vmax) = vi = tuple(self.axis.get_view_interval()) ...
python
def set_locs(self, locs): 'Sets the locations of the ticks' # don't actually use the locs. This is just needed to work with # matplotlib. Force to use vmin, vmax _check_implicitly_registered() self.locs = locs (vmin, vmax) = vi = tuple(self.axis.get_view_interval()) ...
[ "def", "set_locs", "(", "self", ",", "locs", ")", ":", "# don't actually use the locs. This is just needed to work with", "# matplotlib. Force to use vmin, vmax", "_check_implicitly_registered", "(", ")", "self", ".", "locs", "=", "locs", "(", "vmin", ",", "vmax", ")", ...
Sets the locations of the ticks
[ "Sets", "the", "locations", "of", "the", "ticks" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_converter.py#L1099-L1113
train
pandas-dev/pandas
pandas/io/json/table_schema.py
set_default_names
def set_default_names(data): """Sets index names to 'index' for regular, or 'level_x' for Multi""" if com._all_not_none(*data.index.names): nms = data.index.names if len(nms) == 1 and data.index.name == 'index': warnings.warn("Index name of 'index' is not round-trippable") el...
python
def set_default_names(data): """Sets index names to 'index' for regular, or 'level_x' for Multi""" if com._all_not_none(*data.index.names): nms = data.index.names if len(nms) == 1 and data.index.name == 'index': warnings.warn("Index name of 'index' is not round-trippable") el...
[ "def", "set_default_names", "(", "data", ")", ":", "if", "com", ".", "_all_not_none", "(", "*", "data", ".", "index", ".", "names", ")", ":", "nms", "=", "data", ".", "index", ".", "names", "if", "len", "(", "nms", ")", "==", "1", "and", "data", ...
Sets index names to 'index' for regular, or 'level_x' for Multi
[ "Sets", "index", "names", "to", "index", "for", "regular", "or", "level_x", "for", "Multi" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L71-L89
train
pandas-dev/pandas
pandas/io/json/table_schema.py
convert_json_field_to_pandas_type
def convert_json_field_to_pandas_type(field): """ Converts a JSON field descriptor into its corresponding NumPy / pandas type Parameters ---------- field A JSON field descriptor Returns ------- dtype Raises ----- ValueError If the type of the provided field...
python
def convert_json_field_to_pandas_type(field): """ Converts a JSON field descriptor into its corresponding NumPy / pandas type Parameters ---------- field A JSON field descriptor Returns ------- dtype Raises ----- ValueError If the type of the provided field...
[ "def", "convert_json_field_to_pandas_type", "(", "field", ")", ":", "typ", "=", "field", "[", "'type'", "]", "if", "typ", "==", "'string'", ":", "return", "'object'", "elif", "typ", "==", "'integer'", ":", "return", "'int64'", "elif", "typ", "==", "'number'"...
Converts a JSON field descriptor into its corresponding NumPy / pandas type Parameters ---------- field A JSON field descriptor Returns ------- dtype Raises ----- ValueError If the type of the provided field is unknown or currently unsupported Examples ---...
[ "Converts", "a", "JSON", "field", "descriptor", "into", "its", "corresponding", "NumPy", "/", "pandas", "type" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L120-L180
train
pandas-dev/pandas
pandas/io/json/table_schema.py
build_table_schema
def build_table_schema(data, index=True, primary_key=None, version=True): """ Create a Table schema from ``data``. Parameters ---------- data : Series, DataFrame index : bool, default True Whether to include ``data.index`` in the schema. primary_key : bool or None, default True ...
python
def build_table_schema(data, index=True, primary_key=None, version=True): """ Create a Table schema from ``data``. Parameters ---------- data : Series, DataFrame index : bool, default True Whether to include ``data.index`` in the schema. primary_key : bool or None, default True ...
[ "def", "build_table_schema", "(", "data", ",", "index", "=", "True", ",", "primary_key", "=", "None", ",", "version", "=", "True", ")", ":", "if", "index", "is", "True", ":", "data", "=", "set_default_names", "(", "data", ")", "schema", "=", "{", "}", ...
Create a Table schema from ``data``. Parameters ---------- data : Series, DataFrame index : bool, default True Whether to include ``data.index`` in the schema. primary_key : bool or None, default True column names to designate as the primary key. The default `None` will set ...
[ "Create", "a", "Table", "schema", "from", "data", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L183-L259
train
pandas-dev/pandas
pandas/io/json/table_schema.py
parse_table_schema
def parse_table_schema(json, precise_float): """ Builds a DataFrame from a given schema Parameters ---------- json : A JSON table schema precise_float : boolean Flag controlling precision when decoding string to double values, as dictated by ``read_json`` Returns ...
python
def parse_table_schema(json, precise_float): """ Builds a DataFrame from a given schema Parameters ---------- json : A JSON table schema precise_float : boolean Flag controlling precision when decoding string to double values, as dictated by ``read_json`` Returns ...
[ "def", "parse_table_schema", "(", "json", ",", "precise_float", ")", ":", "table", "=", "loads", "(", "json", ",", "precise_float", "=", "precise_float", ")", "col_order", "=", "[", "field", "[", "'name'", "]", "for", "field", "in", "table", "[", "'schema'...
Builds a DataFrame from a given schema Parameters ---------- json : A JSON table schema precise_float : boolean Flag controlling precision when decoding string to double values, as dictated by ``read_json`` Returns ------- df : DataFrame Raises ------ N...
[ "Builds", "a", "DataFrame", "from", "a", "given", "schema" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/json/table_schema.py#L262-L326
train
pandas-dev/pandas
pandas/core/ops.py
get_op_result_name
def get_op_result_name(left, right): """ Find the appropriate name to pin to an operation result. This result should always be either an Index or a Series. Parameters ---------- left : {Series, Index} right : object Returns ------- name : object Usually a string ""...
python
def get_op_result_name(left, right): """ Find the appropriate name to pin to an operation result. This result should always be either an Index or a Series. Parameters ---------- left : {Series, Index} right : object Returns ------- name : object Usually a string ""...
[ "def", "get_op_result_name", "(", "left", ",", "right", ")", ":", "# `left` is always a pd.Series when called from within ops", "if", "isinstance", "(", "right", ",", "(", "ABCSeries", ",", "pd", ".", "Index", ")", ")", ":", "name", "=", "_maybe_match_name", "(", ...
Find the appropriate name to pin to an operation result. This result should always be either an Index or a Series. Parameters ---------- left : {Series, Index} right : object Returns ------- name : object Usually a string
[ "Find", "the", "appropriate", "name", "to", "pin", "to", "an", "operation", "result", ".", "This", "result", "should", "always", "be", "either", "an", "Index", "or", "a", "Series", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L38-L58
train
pandas-dev/pandas
pandas/core/ops.py
_maybe_match_name
def _maybe_match_name(a, b): """ Try to find a name to attach to the result of an operation between a and b. If only one of these has a `name` attribute, return that name. Otherwise return a consensus name if they match of None if they have different names. Parameters ---------- a : o...
python
def _maybe_match_name(a, b): """ Try to find a name to attach to the result of an operation between a and b. If only one of these has a `name` attribute, return that name. Otherwise return a consensus name if they match of None if they have different names. Parameters ---------- a : o...
[ "def", "_maybe_match_name", "(", "a", ",", "b", ")", ":", "a_has", "=", "hasattr", "(", "a", ",", "'name'", ")", "b_has", "=", "hasattr", "(", "b", ",", "'name'", ")", "if", "a_has", "and", "b_has", ":", "if", "a", ".", "name", "==", "b", ".", ...
Try to find a name to attach to the result of an operation between a and b. If only one of these has a `name` attribute, return that name. Otherwise return a consensus name if they match of None if they have different names. Parameters ---------- a : object b : object Returns ---...
[ "Try", "to", "find", "a", "name", "to", "attach", "to", "the", "result", "of", "an", "operation", "between", "a", "and", "b", ".", "If", "only", "one", "of", "these", "has", "a", "name", "attribute", "return", "that", "name", ".", "Otherwise", "return"...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L61-L93
train
pandas-dev/pandas
pandas/core/ops.py
maybe_upcast_for_op
def maybe_upcast_for_op(obj): """ Cast non-pandas objects to pandas types to unify behavior of arithmetic and comparison operations. Parameters ---------- obj: object Returns ------- out : object Notes ----- Be careful to call this *after* determining the `name` attrib...
python
def maybe_upcast_for_op(obj): """ Cast non-pandas objects to pandas types to unify behavior of arithmetic and comparison operations. Parameters ---------- obj: object Returns ------- out : object Notes ----- Be careful to call this *after* determining the `name` attrib...
[ "def", "maybe_upcast_for_op", "(", "obj", ")", ":", "if", "type", "(", "obj", ")", "is", "datetime", ".", "timedelta", ":", "# GH#22390 cast up to Timedelta to rely on Timedelta", "# implementation; otherwise operation against numeric-dtype", "# raises TypeError", "return", ...
Cast non-pandas objects to pandas types to unify behavior of arithmetic and comparison operations. Parameters ---------- obj: object Returns ------- out : object Notes ----- Be careful to call this *after* determining the `name` attribute to be attached to the result of th...
[ "Cast", "non", "-", "pandas", "objects", "to", "pandas", "types", "to", "unify", "behavior", "of", "arithmetic", "and", "comparison", "operations", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L96-L131
train
pandas-dev/pandas
pandas/core/ops.py
make_invalid_op
def make_invalid_op(name): """ Return a binary method that always raises a TypeError. Parameters ---------- name : str Returns ------- invalid_op : function """ def invalid_op(self, other=None): raise TypeError("cannot perform {name} with this index type: " ...
python
def make_invalid_op(name): """ Return a binary method that always raises a TypeError. Parameters ---------- name : str Returns ------- invalid_op : function """ def invalid_op(self, other=None): raise TypeError("cannot perform {name} with this index type: " ...
[ "def", "make_invalid_op", "(", "name", ")", ":", "def", "invalid_op", "(", "self", ",", "other", "=", "None", ")", ":", "raise", "TypeError", "(", "\"cannot perform {name} with this index type: \"", "\"{typ}\"", ".", "format", "(", "name", "=", "name", ",", "t...
Return a binary method that always raises a TypeError. Parameters ---------- name : str Returns ------- invalid_op : function
[ "Return", "a", "binary", "method", "that", "always", "raises", "a", "TypeError", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L195-L212
train
pandas-dev/pandas
pandas/core/ops.py
_gen_eval_kwargs
def _gen_eval_kwargs(name): """ Find the keyword arguments to pass to numexpr for the given operation. Parameters ---------- name : str Returns ------- eval_kwargs : dict Examples -------- >>> _gen_eval_kwargs("__add__") {} >>> _gen_eval_kwargs("rtruediv") {'r...
python
def _gen_eval_kwargs(name): """ Find the keyword arguments to pass to numexpr for the given operation. Parameters ---------- name : str Returns ------- eval_kwargs : dict Examples -------- >>> _gen_eval_kwargs("__add__") {} >>> _gen_eval_kwargs("rtruediv") {'r...
[ "def", "_gen_eval_kwargs", "(", "name", ")", ":", "kwargs", "=", "{", "}", "# Series and Panel appear to only pass __add__, __radd__, ...", "# but DataFrame gets both these dunder names _and_ non-dunder names", "# add, radd, ...", "name", "=", "name", ".", "replace", "(", "'__'...
Find the keyword arguments to pass to numexpr for the given operation. Parameters ---------- name : str Returns ------- eval_kwargs : dict Examples -------- >>> _gen_eval_kwargs("__add__") {} >>> _gen_eval_kwargs("rtruediv") {'reversed': True, 'truediv': True}
[ "Find", "the", "keyword", "arguments", "to", "pass", "to", "numexpr", "for", "the", "given", "operation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L215-L253
train
pandas-dev/pandas
pandas/core/ops.py
_gen_fill_zeros
def _gen_fill_zeros(name): """ Find the appropriate fill value to use when filling in undefined values in the results of the given operation caused by operating on (generally dividing by) zero. Parameters ---------- name : str Returns ------- fill_value : {None, np.nan, np.inf}...
python
def _gen_fill_zeros(name): """ Find the appropriate fill value to use when filling in undefined values in the results of the given operation caused by operating on (generally dividing by) zero. Parameters ---------- name : str Returns ------- fill_value : {None, np.nan, np.inf}...
[ "def", "_gen_fill_zeros", "(", "name", ")", ":", "name", "=", "name", ".", "strip", "(", "'__'", ")", "if", "'div'", "in", "name", ":", "# truediv, floordiv, div, and reversed variants", "fill_value", "=", "np", ".", "inf", "elif", "'mod'", "in", "name", ":"...
Find the appropriate fill value to use when filling in undefined values in the results of the given operation caused by operating on (generally dividing by) zero. Parameters ---------- name : str Returns ------- fill_value : {None, np.nan, np.inf}
[ "Find", "the", "appropriate", "fill", "value", "to", "use", "when", "filling", "in", "undefined", "values", "in", "the", "results", "of", "the", "given", "operation", "caused", "by", "operating", "on", "(", "generally", "dividing", "by", ")", "zero", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L256-L279
train
pandas-dev/pandas
pandas/core/ops.py
_get_opstr
def _get_opstr(op, cls): """ Find the operation string, if any, to pass to numexpr for this operation. Parameters ---------- op : binary operator cls : class Returns ------- op_str : string or None """ # numexpr is available for non-sparse classes subtyp = getattr(c...
python
def _get_opstr(op, cls): """ Find the operation string, if any, to pass to numexpr for this operation. Parameters ---------- op : binary operator cls : class Returns ------- op_str : string or None """ # numexpr is available for non-sparse classes subtyp = getattr(c...
[ "def", "_get_opstr", "(", "op", ",", "cls", ")", ":", "# numexpr is available for non-sparse classes", "subtyp", "=", "getattr", "(", "cls", ",", "'_subtyp'", ",", "''", ")", "use_numexpr", "=", "'sparse'", "not", "in", "subtyp", "if", "not", "use_numexpr", ":...
Find the operation string, if any, to pass to numexpr for this operation. Parameters ---------- op : binary operator cls : class Returns ------- op_str : string or None
[ "Find", "the", "operation", "string", "if", "any", "to", "pass", "to", "numexpr", "for", "this", "operation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L307-L356
train
pandas-dev/pandas
pandas/core/ops.py
_get_op_name
def _get_op_name(op, special): """ Find the name to attach to this method according to conventions for special and non-special methods. Parameters ---------- op : binary operator special : bool Returns ------- op_name : str """ opname = op.__name__.strip('_') if spe...
python
def _get_op_name(op, special): """ Find the name to attach to this method according to conventions for special and non-special methods. Parameters ---------- op : binary operator special : bool Returns ------- op_name : str """ opname = op.__name__.strip('_') if spe...
[ "def", "_get_op_name", "(", "op", ",", "special", ")", ":", "opname", "=", "op", ".", "__name__", ".", "strip", "(", "'_'", ")", "if", "special", ":", "opname", "=", "'__{opname}__'", ".", "format", "(", "opname", "=", "opname", ")", "return", "opname"...
Find the name to attach to this method according to conventions for special and non-special methods. Parameters ---------- op : binary operator special : bool Returns ------- op_name : str
[ "Find", "the", "name", "to", "attach", "to", "this", "method", "according", "to", "conventions", "for", "special", "and", "non", "-", "special", "methods", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L359-L376
train
pandas-dev/pandas
pandas/core/ops.py
_make_flex_doc
def _make_flex_doc(op_name, typ): """ Make the appropriate substitutions for the given operation and class-typ into either _flex_doc_SERIES or _flex_doc_FRAME to return the docstring to attach to a generated method. Parameters ---------- op_name : str {'__add__', '__sub__', ... '__eq__', '_...
python
def _make_flex_doc(op_name, typ): """ Make the appropriate substitutions for the given operation and class-typ into either _flex_doc_SERIES or _flex_doc_FRAME to return the docstring to attach to a generated method. Parameters ---------- op_name : str {'__add__', '__sub__', ... '__eq__', '_...
[ "def", "_make_flex_doc", "(", "op_name", ",", "typ", ")", ":", "op_name", "=", "op_name", ".", "replace", "(", "'__'", ",", "''", ")", "op_desc", "=", "_op_descriptions", "[", "op_name", "]", "if", "op_desc", "[", "'reversed'", "]", ":", "equiv", "=", ...
Make the appropriate substitutions for the given operation and class-typ into either _flex_doc_SERIES or _flex_doc_FRAME to return the docstring to attach to a generated method. Parameters ---------- op_name : str {'__add__', '__sub__', ... '__eq__', '__ne__', ...} typ : str {series, 'dataframe...
[ "Make", "the", "appropriate", "substitutions", "for", "the", "given", "operation", "and", "class", "-", "typ", "into", "either", "_flex_doc_SERIES", "or", "_flex_doc_FRAME", "to", "return", "the", "docstring", "to", "attach", "to", "a", "generated", "method", "....
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1029-L1082
train
pandas-dev/pandas
pandas/core/ops.py
fill_binop
def fill_binop(left, right, fill_value): """ If a non-None fill_value is given, replace null entries in left and right with this value, but only in positions where _one_ of left/right is null, not both. Parameters ---------- left : array-like right : array-like fill_value : object ...
python
def fill_binop(left, right, fill_value): """ If a non-None fill_value is given, replace null entries in left and right with this value, but only in positions where _one_ of left/right is null, not both. Parameters ---------- left : array-like right : array-like fill_value : object ...
[ "def", "fill_binop", "(", "left", ",", "right", ",", "fill_value", ")", ":", "# TODO: can we make a no-copy implementation?", "if", "fill_value", "is", "not", "None", ":", "left_mask", "=", "isna", "(", "left", ")", "right_mask", "=", "isna", "(", "right", ")"...
If a non-None fill_value is given, replace null entries in left and right with this value, but only in positions where _one_ of left/right is null, not both. Parameters ---------- left : array-like right : array-like fill_value : object Returns ------- left : array-like rig...
[ "If", "a", "non", "-", "None", "fill_value", "is", "given", "replace", "null", "entries", "in", "left", "and", "right", "with", "this", "value", "but", "only", "in", "positions", "where", "_one_", "of", "left", "/", "right", "is", "null", "not", "both", ...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1088-L1120
train
pandas-dev/pandas
pandas/core/ops.py
mask_cmp_op
def mask_cmp_op(x, y, op, allowed_types): """ Apply the function `op` to only non-null points in x and y. Parameters ---------- x : array-like y : array-like op : binary operation allowed_types : class or tuple of classes Returns ------- result : ndarray[bool] """ #...
python
def mask_cmp_op(x, y, op, allowed_types): """ Apply the function `op` to only non-null points in x and y. Parameters ---------- x : array-like y : array-like op : binary operation allowed_types : class or tuple of classes Returns ------- result : ndarray[bool] """ #...
[ "def", "mask_cmp_op", "(", "x", ",", "y", ",", "op", ",", "allowed_types", ")", ":", "# TODO: Can we make the allowed_types arg unnecessary?", "xrav", "=", "x", ".", "ravel", "(", ")", "result", "=", "np", ".", "empty", "(", "x", ".", "size", ",", "dtype",...
Apply the function `op` to only non-null points in x and y. Parameters ---------- x : array-like y : array-like op : binary operation allowed_types : class or tuple of classes Returns ------- result : ndarray[bool]
[ "Apply", "the", "function", "op", "to", "only", "non", "-", "null", "points", "in", "x", "and", "y", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1123-L1155
train
pandas-dev/pandas
pandas/core/ops.py
masked_arith_op
def masked_arith_op(x, y, op): """ If the given arithmetic operation fails, attempt it again on only the non-null elements of the input array(s). Parameters ---------- x : np.ndarray y : np.ndarray, Series, Index op : binary operator """ # For Series `x` is 1D so ravel() is a no...
python
def masked_arith_op(x, y, op): """ If the given arithmetic operation fails, attempt it again on only the non-null elements of the input array(s). Parameters ---------- x : np.ndarray y : np.ndarray, Series, Index op : binary operator """ # For Series `x` is 1D so ravel() is a no...
[ "def", "masked_arith_op", "(", "x", ",", "y", ",", "op", ")", ":", "# For Series `x` is 1D so ravel() is a no-op; calling it anyway makes", "# the logic valid for both Series and DataFrame ops.", "xrav", "=", "x", ".", "ravel", "(", ")", "assert", "isinstance", "(", "x", ...
If the given arithmetic operation fails, attempt it again on only the non-null elements of the input array(s). Parameters ---------- x : np.ndarray y : np.ndarray, Series, Index op : binary operator
[ "If", "the", "given", "arithmetic", "operation", "fails", "attempt", "it", "again", "on", "only", "the", "non", "-", "null", "elements", "of", "the", "input", "array", "(", "s", ")", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1158-L1213
train
pandas-dev/pandas
pandas/core/ops.py
invalid_comparison
def invalid_comparison(left, right, op): """ If a comparison has mismatched types and is not necessarily meaningful, follow python3 conventions by: - returning all-False for equality - returning all-True for inequality - raising TypeError otherwise Parameters ---------- ...
python
def invalid_comparison(left, right, op): """ If a comparison has mismatched types and is not necessarily meaningful, follow python3 conventions by: - returning all-False for equality - returning all-True for inequality - raising TypeError otherwise Parameters ---------- ...
[ "def", "invalid_comparison", "(", "left", ",", "right", ",", "op", ")", ":", "if", "op", "is", "operator", ".", "eq", ":", "res_values", "=", "np", ".", "zeros", "(", "left", ".", "shape", ",", "dtype", "=", "bool", ")", "elif", "op", "is", "operat...
If a comparison has mismatched types and is not necessarily meaningful, follow python3 conventions by: - returning all-False for equality - returning all-True for inequality - raising TypeError otherwise Parameters ---------- left : array-like right : scalar, array-like ...
[ "If", "a", "comparison", "has", "mismatched", "types", "and", "is", "not", "necessarily", "meaningful", "follow", "python3", "conventions", "by", ":" ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1216-L1242
train
pandas-dev/pandas
pandas/core/ops.py
should_series_dispatch
def should_series_dispatch(left, right, op): """ Identify cases where a DataFrame operation should dispatch to its Series counterpart. Parameters ---------- left : DataFrame right : DataFrame op : binary operator Returns ------- override : bool """ if left._is_mixed...
python
def should_series_dispatch(left, right, op): """ Identify cases where a DataFrame operation should dispatch to its Series counterpart. Parameters ---------- left : DataFrame right : DataFrame op : binary operator Returns ------- override : bool """ if left._is_mixed...
[ "def", "should_series_dispatch", "(", "left", ",", "right", ",", "op", ")", ":", "if", "left", ".", "_is_mixed_type", "or", "right", ".", "_is_mixed_type", ":", "return", "True", "if", "not", "len", "(", "left", ".", "columns", ")", "or", "not", "len", ...
Identify cases where a DataFrame operation should dispatch to its Series counterpart. Parameters ---------- left : DataFrame right : DataFrame op : binary operator Returns ------- override : bool
[ "Identify", "cases", "where", "a", "DataFrame", "operation", "should", "dispatch", "to", "its", "Series", "counterpart", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1248-L1282
train
pandas-dev/pandas
pandas/core/ops.py
dispatch_to_series
def dispatch_to_series(left, right, func, str_rep=None, axis=None): """ Evaluate the frame operation func(left, right) by evaluating column-by-column, dispatching to the Series implementation. Parameters ---------- left : DataFrame right : scalar or DataFrame func : arithmetic or compar...
python
def dispatch_to_series(left, right, func, str_rep=None, axis=None): """ Evaluate the frame operation func(left, right) by evaluating column-by-column, dispatching to the Series implementation. Parameters ---------- left : DataFrame right : scalar or DataFrame func : arithmetic or compar...
[ "def", "dispatch_to_series", "(", "left", ",", "right", ",", "func", ",", "str_rep", "=", "None", ",", "axis", "=", "None", ")", ":", "# Note: we use iloc to access columns for compat with cases", "# with non-unique columns.", "import", "pandas", ".", "core", "....
Evaluate the frame operation func(left, right) by evaluating column-by-column, dispatching to the Series implementation. Parameters ---------- left : DataFrame right : scalar or DataFrame func : arithmetic or comparison operator str_rep : str or None, default None axis : {None, 0, 1, "i...
[ "Evaluate", "the", "frame", "operation", "func", "(", "left", "right", ")", "by", "evaluating", "column", "-", "by", "-", "column", "dispatching", "to", "the", "Series", "implementation", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1285-L1346
train
pandas-dev/pandas
pandas/core/ops.py
dispatch_to_index_op
def dispatch_to_index_op(op, left, right, index_class): """ Wrap Series left in the given index_class to delegate the operation op to the index implementation. DatetimeIndex and TimedeltaIndex perform type checking, timezone handling, overflow checks, etc. Parameters ---------- op : binary...
python
def dispatch_to_index_op(op, left, right, index_class): """ Wrap Series left in the given index_class to delegate the operation op to the index implementation. DatetimeIndex and TimedeltaIndex perform type checking, timezone handling, overflow checks, etc. Parameters ---------- op : binary...
[ "def", "dispatch_to_index_op", "(", "op", ",", "left", ",", "right", ",", "index_class", ")", ":", "left_idx", "=", "index_class", "(", "left", ")", "# avoid accidentally allowing integer add/sub. For datetime64[tz] dtypes,", "# left_idx may inherit a freq from a cached Dateti...
Wrap Series left in the given index_class to delegate the operation op to the index implementation. DatetimeIndex and TimedeltaIndex perform type checking, timezone handling, overflow checks, etc. Parameters ---------- op : binary operator (operator.add, operator.sub, ...) left : Series ri...
[ "Wrap", "Series", "left", "in", "the", "given", "index_class", "to", "delegate", "the", "operation", "op", "to", "the", "index", "implementation", ".", "DatetimeIndex", "and", "TimedeltaIndex", "perform", "type", "checking", "timezone", "handling", "overflow", "ch...
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1349-L1380
train
pandas-dev/pandas
pandas/core/ops.py
dispatch_to_extension_op
def dispatch_to_extension_op(op, left, right): """ Assume that left or right is a Series backed by an ExtensionArray, apply the operator defined by op. """ # The op calls will raise TypeError if the op is not defined # on the ExtensionArray # unbox Series and Index to arrays if isinsta...
python
def dispatch_to_extension_op(op, left, right): """ Assume that left or right is a Series backed by an ExtensionArray, apply the operator defined by op. """ # The op calls will raise TypeError if the op is not defined # on the ExtensionArray # unbox Series and Index to arrays if isinsta...
[ "def", "dispatch_to_extension_op", "(", "op", ",", "left", ",", "right", ")", ":", "# The op calls will raise TypeError if the op is not defined", "# on the ExtensionArray", "# unbox Series and Index to arrays", "if", "isinstance", "(", "left", ",", "(", "ABCSeries", ",", "...
Assume that left or right is a Series backed by an ExtensionArray, apply the operator defined by op.
[ "Assume", "that", "left", "or", "right", "is", "a", "Series", "backed", "by", "an", "ExtensionArray", "apply", "the", "operator", "defined", "by", "op", "." ]
9feb3ad92cc0397a04b665803a49299ee7aa1037
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1383-L1410
train