当前位置: 首页>>代码示例>>Python>>正文


Python printing.adjoin方法代码示例

本文整理汇总了Python中pandas.io.formats.printing.adjoin方法的典型用法代码示例。如果您正苦于以下问题:Python printing.adjoin方法的具体用法?Python printing.adjoin怎么用?Python printing.adjoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.io.formats.printing的用法示例。


在下文中一共展示了printing.adjoin方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_adjoin

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def test_adjoin():
    data = [['a', 'b', 'c'], ['dd', 'ee', 'ff'], ['ggg', 'hhh', 'iii']]
    expected = 'a  dd  ggg\nb  ee  hhh\nc  ff  iii'

    adjoined = printing.adjoin(2, *data)

    assert (adjoined == expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:test_printing.py

示例2: test_adjoin_unicode

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def test_adjoin_unicode(self):
        data = [[u'あ', 'b', 'c'], ['dd', u'ええ', 'ff'], ['ggg', 'hhh', u'いいい']]
        expected = u'あ  dd  ggg\nb  ええ  hhh\nc  ff  いいい'
        adjoined = printing.adjoin(2, *data)
        assert adjoined == expected

        adj = fmt.EastAsianTextAdjustment()

        expected = u"""あ  dd    ggg
b   ええ  hhh
c   ff    いいい"""

        adjoined = adj.adjoin(2, *data)
        assert adjoined == expected
        cols = adjoined.split('\n')
        assert adj.len(cols[0]) == 13
        assert adj.len(cols[1]) == 13
        assert adj.len(cols[2]) == 16

        expected = u"""あ       dd         ggg
b        ええ       hhh
c        ff         いいい"""

        adjoined = adj.adjoin(7, *data)
        assert adjoined == expected
        cols = adjoined.split('\n')
        assert adj.len(cols[0]) == 23
        assert adj.len(cols[1]) == 23
        assert adj.len(cols[2]) == 26 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:31,代码来源:test_printing.py

示例3: test_ambiguous_width

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def test_ambiguous_width(self):
        adj = fmt.EastAsianTextAdjustment()
        assert adj.len(u'¡¡ab') == 4

        with cf.option_context('display.unicode.ambiguous_as_wide', True):
            adj = fmt.EastAsianTextAdjustment()
            assert adj.len(u'¡¡ab') == 6

        data = [[u'あ', 'b', 'c'], ['dd', u'ええ', 'ff'],
                ['ggg', u'¡¡ab', u'いいい']]
        expected = u'あ  dd    ggg \nb   ええ  ¡¡ab\nc   ff    いいい'
        adjoined = adj.adjoin(2, *data)
        assert adjoined == expected 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_printing.py

示例4: to_string

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def to_string(self):
        series = self.tr_series
        footer = self._get_footer()

        if len(series) == 0:
            return 'Series([], ' + footer + ')'

        fmt_index, have_header = self._get_formatted_index()
        fmt_values = self._get_formatted_values()

        if self.truncate_v:
            n_header_rows = 0
            row_num = self.tr_row_num
            width = self.adj.len(fmt_values[row_num - 1])
            if width > 3:
                dot_str = '...'
            else:
                dot_str = '..'
            # Series uses mode=center because it has single value columns
            # DataFrame uses mode=left
            dot_str = self.adj.justify([dot_str], width, mode='center')[0]
            fmt_values.insert(row_num + n_header_rows, dot_str)
            fmt_index.insert(row_num + 1, '')

        if self.index:
            result = self.adj.adjoin(3, *[fmt_index[1:], fmt_values])
        else:
            result = self.adj.adjoin(3, fmt_values)

        if self.header and have_header:
            result = fmt_index[0] + '\n' + result

        if footer:
            result += '\n' + footer

        return compat.text_type(u('').join(result)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:38,代码来源:format.py

示例5: _join_multiline

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def _join_multiline(self, *strcols):
        lwidth = self.line_width
        adjoin_width = 1
        strcols = list(strcols)
        if self.index:
            idx = strcols.pop(0)
            lwidth -= np.array([self.adj.len(x)
                                for x in idx]).max() + adjoin_width

        col_widths = [np.array([self.adj.len(x) for x in col]).max() if
                      len(col) > 0 else 0 for col in strcols]
        col_bins = _binify(col_widths, lwidth)
        nbins = len(col_bins)

        if self.truncate_v:
            nrows = self.max_rows_adj + 1
        else:
            nrows = len(self.frame)

        str_lst = []
        st = 0
        for i, ed in enumerate(col_bins):
            row = strcols[st:ed]
            if self.index:
                row.insert(0, idx)
            if nbins > 1:
                if ed <= len(strcols) and i < nbins - 1:
                    row.append([' \\'] + ['  '] * (nrows - 1))
                else:
                    row.append([' '] * nrows)
            str_lst.append(self.adj.adjoin(adjoin_width, *row))
            st = ed
        return '\n\n'.join(str_lst) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:35,代码来源:format.py

示例6: _get_formatted_column_labels

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def _get_formatted_column_labels(self, frame):
        from pandas.core.index import _sparsify

        columns = frame.columns

        if isinstance(columns, ABCMultiIndex):
            fmt_columns = columns.format(sparsify=False, adjoin=False)
            fmt_columns = lzip(*fmt_columns)
            dtypes = self.frame.dtypes._values

            # if we have a Float level, they don't use leading space at all
            restrict_formatting = any(l.is_floating for l in columns.levels)
            need_leadsp = dict(zip(fmt_columns, map(is_numeric_dtype, dtypes)))

            def space_format(x, y):
                if (y not in self.formatters and
                        need_leadsp[x] and not restrict_formatting):
                    return ' ' + y
                return y

            str_columns = list(zip(*[[space_format(x, y) for y in x]
                                     for x in fmt_columns]))
            if self.sparsify and len(str_columns):
                str_columns = _sparsify(str_columns)

            str_columns = [list(x) for x in zip(*str_columns)]
        else:
            fmt_columns = columns.format()
            dtypes = self.frame.dtypes
            need_leadsp = dict(zip(fmt_columns, map(is_numeric_dtype, dtypes)))
            str_columns = [[' ' + x if not self._get_formatter(i) and
                            need_leadsp[x] else x]
                           for i, (col, x) in enumerate(zip(columns,
                                                            fmt_columns))]

        if self.show_row_idx_names:
            for x in str_columns:
                x.append('')

        # self.str_columns = str_columns
        return str_columns 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:43,代码来源:format.py

示例7: _get_formatted_index

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def _get_formatted_index(self, frame):
        # Note: this is only used by to_string() and to_latex(), not by
        # to_html().
        index = frame.index
        columns = frame.columns
        fmt = self._get_formatter('__index__')

        if isinstance(index, ABCMultiIndex):
            fmt_index = index.format(
                sparsify=self.sparsify, adjoin=False,
                names=self.show_row_idx_names, formatter=fmt)
        else:
            fmt_index = [index.format(
                name=self.show_row_idx_names, formatter=fmt)]

        fmt_index = [tuple(_make_fixed_width(list(x), justify='left',
                                             minimum=(self.col_space or 0),
                                             adj=self.adj)) for x in fmt_index]

        adjoined = self.adj.adjoin(1, *fmt_index).split('\n')

        # empty space for columns
        if self.show_col_idx_names:
            col_header = ['{x}'.format(x=x)
                          for x in self._get_column_name_list()]
        else:
            col_header = [''] * columns.nlevels

        if self.header:
            return col_header + adjoined
        else:
            return adjoined 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:34,代码来源:format.py

示例8: info

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def info(self):
        """
        Print detailed information on the store.

        .. versionadded:: 0.21.0
        """
        output = '{type}\nFile path: {path}\n'.format(
            type=type(self), path=pprint_thing(self._path))
        if self.is_open:
            lkeys = sorted(list(self.keys()))
            if len(lkeys):
                keys = []
                values = []

                for k in lkeys:
                    try:
                        s = self.get_storer(k)
                        if s is not None:
                            keys.append(pprint_thing(s.pathname or k))
                            values.append(
                                pprint_thing(s or 'invalid_HDFStore node'))
                    except Exception as detail:
                        keys.append(k)
                        values.append(
                            "[invalid_HDFStore node: {detail}]".format(
                                detail=pprint_thing(detail)))

                output += adjoin(12, keys, values)
            else:
                output += 'Empty'
        else:
            output += "File is CLOSED"

        return output

    # private methods ###### 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:38,代码来源:pytables.py

示例9: to_string

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def to_string(self):
        series = self.tr_series
        footer = self._get_footer()

        if len(series) == 0:
            return 'Series([], ' + footer + ')'

        fmt_index, have_header = self._get_formatted_index()
        fmt_values = self._get_formatted_values()

        if self.truncate_v:
            n_header_rows = 0
            row_num = self.tr_row_num
            width = self.adj.len(fmt_values[row_num - 1])
            if width > 3:
                dot_str = '...'
            else:
                dot_str = '..'
            # Series uses mode=center because it has single value columns
            # DataFrame uses mode=left
            dot_str = self.adj.justify([dot_str], width, mode='center')[0]
            fmt_values.insert(row_num + n_header_rows, dot_str)
            fmt_index.insert(row_num + 1, '')

        if self.index:
            result = self.adj.adjoin(3, *[fmt_index[1:], fmt_values])
        else:
            result = self.adj.adjoin(3, fmt_values).replace('\n ',
                                                            '\n').strip()

        if self.header and have_header:
            result = fmt_index[0] + '\n' + result

        if footer:
            result += '\n' + footer

        return compat.text_type(u('').join(result)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:39,代码来源:format.py

示例10: _get_formatted_column_labels

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def _get_formatted_column_labels(self, frame):
        from pandas.core.index import _sparsify

        columns = frame.columns

        if isinstance(columns, MultiIndex):
            fmt_columns = columns.format(sparsify=False, adjoin=False)
            fmt_columns = lzip(*fmt_columns)
            dtypes = self.frame.dtypes._values

            # if we have a Float level, they don't use leading space at all
            restrict_formatting = any(l.is_floating for l in columns.levels)
            need_leadsp = dict(zip(fmt_columns, map(is_numeric_dtype, dtypes)))

            def space_format(x, y):
                if (y not in self.formatters and
                        need_leadsp[x] and not restrict_formatting):
                    return ' ' + y
                return y

            str_columns = list(zip(*[[space_format(x, y) for y in x]
                                     for x in fmt_columns]))
            if self.sparsify and len(str_columns):
                str_columns = _sparsify(str_columns)

            str_columns = [list(x) for x in zip(*str_columns)]
        else:
            fmt_columns = columns.format()
            dtypes = self.frame.dtypes
            need_leadsp = dict(zip(fmt_columns, map(is_numeric_dtype, dtypes)))
            str_columns = [[' ' + x if not self._get_formatter(i) and
                            need_leadsp[x] else x]
                           for i, (col, x) in enumerate(zip(columns,
                                                            fmt_columns))]

        if self.show_index_names and self.has_index_names:
            for x in str_columns:
                x.append('')

        # self.str_columns = str_columns
        return str_columns 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:43,代码来源:format.py

示例11: _get_formatted_index

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def _get_formatted_index(self, frame):
        # Note: this is only used by to_string() and to_latex(), not by
        # to_html().
        index = frame.index
        columns = frame.columns

        show_index_names = self.show_index_names and self.has_index_names
        show_col_names = (self.show_index_names and self.has_column_names)

        fmt = self._get_formatter('__index__')

        if isinstance(index, MultiIndex):
            fmt_index = index.format(sparsify=self.sparsify, adjoin=False,
                                     names=show_index_names, formatter=fmt)
        else:
            fmt_index = [index.format(name=show_index_names, formatter=fmt)]
        fmt_index = [tuple(_make_fixed_width(list(x), justify='left',
                                             minimum=(self.col_space or 0),
                                             adj=self.adj)) for x in fmt_index]

        adjoined = self.adj.adjoin(1, *fmt_index).split('\n')

        # empty space for columns
        if show_col_names:
            col_header = ['{x}'.format(x=x)
                          for x in self._get_column_name_list()]
        else:
            col_header = [''] * columns.nlevels

        if self.header:
            return col_header + adjoined
        else:
            return adjoined 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:35,代码来源:format.py

示例12: info

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def info(self):
        """
        print detailed information on the store

        .. versionadded:: 0.21.0
        """
        output = '%s\nFile path: %s\n' % (type(self), pprint_thing(self._path))
        if self.is_open:
            lkeys = sorted(list(self.keys()))
            if len(lkeys):
                keys = []
                values = []

                for k in lkeys:
                    try:
                        s = self.get_storer(k)
                        if s is not None:
                            keys.append(pprint_thing(s.pathname or k))
                            values.append(
                                pprint_thing(s or 'invalid_HDFStore node'))
                    except Exception as detail:
                        keys.append(k)
                        values.append("[invalid_HDFStore node: %s]"
                                      % pprint_thing(detail))

                output += adjoin(12, keys, values)
            else:
                output += 'Empty'
        else:
            output += "File is CLOSED"

        return output

    # private methods ###### 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:36,代码来源:pytables.py

示例13: adjoin

# 需要导入模块: from pandas.io.formats import printing [as 别名]
# 或者: from pandas.io.formats.printing import adjoin [as 别名]
def adjoin(self, space, *lists, **kwargs):
        return adjoin(space, *lists, strlen=self.len,
                      justfunc=self.justify, **kwargs) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:5,代码来源:format.py


注:本文中的pandas.io.formats.printing.adjoin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。