本文整理汇总了Python中pandas.core.common.adjoin函数的典型用法代码示例。如果您正苦于以下问题:Python adjoin函数的具体用法?Python adjoin怎么用?Python adjoin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了adjoin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: side_by_side
def side_by_side(*objs, **kwds):
'''
created by wes mickinney, it only exists here becuase I use this function all the time.
'''
from pandas.core.common import adjoin
space = kwds.get('space', 4)
reprs = [repr(obj).split('\n') for obj in objs]
print adjoin(space, *reprs)开发者ID:omar-florez,项目名称:AGC_KaggleAux,代码行数:8,代码来源:kaggleaux.py
示例2: to_string
def to_string(self, force_unicode=False):
"""
Render a DataFrame to a console-friendly tabular output.
"""
frame = self.frame
to_write = []
if len(frame.columns) == 0 or len(frame.index) == 0:
info_line = (u'Empty %s\nColumns: %s\nIndex: %s'
% (type(self.frame).__name__,
frame.columns, frame.index))
to_write.append(info_line)
else:
# may include levels names also
str_index = self._get_formatted_index()
str_columns = self._get_formatted_column_labels()
stringified = []
for i, c in enumerate(self.columns):
if self.header:
fmt_values = self._format_col(i)
cheader = str_columns[i]
max_len = max(max(_strlen(x) for x in fmt_values),
max(len(x) for x in cheader))
if self.justify == 'left':
cheader = [x.ljust(max_len) for x in cheader]
else:
cheader = [x.rjust(max_len) for x in cheader]
fmt_values = cheader + fmt_values
stringified.append(_make_fixed_width(fmt_values,
self.justify))
else:
stringified = [_make_fixed_width(self._format_col(i),
self.justify)
for i, c in enumerate(self.columns)]
if self.index:
to_write.append(adjoin(1, str_index, *stringified))
else:
to_write.append(adjoin(1, *stringified))
if not py3compat.PY3:
if force_unicode:
to_write = [unicode(s) for s in to_write]
else:
# generally everything is plain strings, which has ascii
# encoding. problem is when there is a char with value over 127
# - everything then gets converted to unicode.
try:
for s in to_write:
str(s)
except UnicodeError:
to_write = [unicode(s) for s in to_write]
self.buf.writelines(to_write)开发者ID:hal2001,项目名称:pandas,代码行数:57,代码来源:format.py
示例3: test_adjoin
def test_adjoin():
data = [['a', 'b', 'c'], ['dd', 'ee', 'ff'], ['ggg', 'hhh', 'iii']]
expected = 'a dd ggg\nb ee hhh\nc ff iii'
adjoined = common.adjoin(2, *data)
assert (adjoined == expected)开发者ID:npinger,项目名称:pandas,代码行数:7,代码来源:test_common.py
示例4: to_string
def to_string(self):
"""
Render a DataFrame to a console-friendly tabular output.
"""
frame = self.frame
format_col = self._get_column_formatter()
to_write = []
if len(frame.columns) == 0 or len(frame.index) == 0:
info_line = "Empty %s\nColumns: %s\nIndex: %s"
to_write.append(info_line % (type(self.frame).__name__, repr(frame.columns), repr(frame.index)))
else:
# may include levels names also
str_index = self._get_formatted_index()
str_columns = self._get_formatted_column_labels()
stringified = [str_columns[i] + format_col(c) for i, c in enumerate(self.columns)]
to_write.append(adjoin(1, str_index, *stringified))
for s in to_write:
if isinstance(s, unicode):
to_write = [unicode(s) for s in to_write]
break
self.buf.writelines(to_write)开发者ID:ralphbean,项目名称:pandas,代码行数:27,代码来源:format.py
示例5: test_adjoin
def test_adjoin():
data = [["a", "b", "c"], ["dd", "ee", "ff"], ["ggg", "hhh", "iii"]]
expected = "a dd ggg\nb ee hhh\nc ff iii"
adjoined = com.adjoin(2, *data)
assert adjoined == expected开发者ID:spencerlyon2,项目名称:pandas,代码行数:7,代码来源:test_common.py
示例6: _get_formatted_index
def _get_formatted_index(self):
# Note: this is only used by to_string(), not by to_html().
index = self.frame.index
columns = self.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.formatters.get('__index__', None)
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)]
adjoined = adjoin(1, *fmt_index).split('\n')
# empty space for columns
if show_col_names:
col_header = ['%s' % 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:evelynmitchell,项目名称:pandas,代码行数:28,代码来源:format.py
示例7: test_adjoin
def test_adjoin(self):
data = [['a', 'b', 'c'], ['dd', 'ee', 'ff'], ['ggg', 'hhh', 'iii']]
expected = 'a dd ggg\nb ee hhh\nc ff iii'
adjoined = com.adjoin(2, *data)
self.assertEqual(adjoined, expected)开发者ID:8ballbb,项目名称:ProjectRothar,代码行数:7,代码来源:test_common.py
示例8: _join_multiline
def _join_multiline(self, *strcols):
lwidth = self.line_width
strcols = list(strcols)
if self.index:
idx = strcols.pop(0)
lwidth -= np.array([len(x) for x in idx]).max()
col_widths = [np.array([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)
str_lst = []
st = 0
for i, ed in enumerate(col_bins):
row = strcols[st:ed]
row.insert(0, idx)
if nbins > 1:
if ed 0:
keys = []
values = []
for k, v in sorted(self.handle.root._v_children.iteritems()):
kind = v._v_attrs.pandas_type
keys.append(str(k))
values.append(_NAME_MAP[kind])
output += adjoin(5, keys, values)
else:
output += 'Empty'
return output开发者ID:xuanhan863,项目名称:pandas,代码行数:17,代码来源:pytables.py
示例15: side_by_side
def side_by_side(*objs, **kwds):
space = kwds.get('space', 4)
reprs = [repr(obj).split('\n') for obj in objs]
print adjoin(space, *reprs)开发者ID:jeromeku,项目名称:209fp,代码行数:4,代码来源:oldhelperfile.py
注:本文中的pandas.core.common.adjoin函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。
|