本文整理汇总了Python中pandas.io.formats.console.get_console_size方法的典型用法代码示例。如果您正苦于以下问题:Python console.get_console_size方法的具体用法?Python console.get_console_size怎么用?Python console.get_console_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.io.formats.console
的用法示例。
在下文中一共展示了console.get_console_size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _display
# 需要导入模块: from pandas.io.formats import console [as 别名]
# 或者: from pandas.io.formats.console import get_console_size [as 别名]
def _display(self, max_rows=10, max_width=None, max_colwidth=50):
summary = ["<regionmask.{}>".format(type(self).__name__)]
if max_rows is None:
max_rows = len(self)
if max_width is None:
max_width, _ = console.get_console_size()
summary += _display_metadata(self.name, self.source, max_width=max_width)
summary.append("")
summary += _display_regions_gp(self, max_rows, max_width, max_colwidth)
summary.append("")
summary.append("[{:d} regions]".format(len(self)))
return "\n".join(summary)
示例2: __repr__
# 需要导入模块: from pandas.io.formats import console [as 别名]
# 或者: from pandas.io.formats.console import get_console_size [as 别名]
def __repr__(self):
from pandas.io.formats import console
num_rows = pandas.get_option("display.max_rows") or 10
num_cols = pandas.get_option("display.max_columns") or 20
if pandas.get_option("display.max_columns") is None and pandas.get_option(
"display.expand_frame_repr"
):
width, _ = console.get_console_size()
col_counter = 0
i = 0
while col_counter < width:
col_counter += len(str(self.columns[i])) + 1
i += 1
num_cols = i
i = len(self.columns) - 1
col_counter = 0
while col_counter < width:
col_counter += len(str(self.columns[i])) + 1
i -= 1
num_cols += len(self.columns) - i
result = repr(self._build_repr_df(num_rows, num_cols))
if len(self.index) > num_rows or len(self.columns) > num_cols:
# The split here is so that we don't repr pandas row lengths.
return result.rsplit("\n\n", 1)[0] + "\n\n[{0} rows x {1} columns]".format(
len(self.index), len(self.columns)
)
else:
return result
示例3: __repr__
# 需要导入模块: from pandas.io.formats import console [as 别名]
# 或者: from pandas.io.formats.console import get_console_size [as 别名]
def __repr__(self):
"""
From pandas
"""
buf = StringIO()
# max_rows and max_cols determine the maximum size of the pretty printed tabular
# representation of the dataframe. pandas defaults are 60 and 20 respectively.
# dataframes where len(df) > max_rows shows a truncated view with 10 rows shown.
max_rows = pd.get_option("display.max_rows")
max_cols = pd.get_option("display.max_columns")
min_rows = pd.get_option("display.min_rows")
if len(self) > max_rows:
max_rows = min_rows
show_dimensions = pd.get_option("display.show_dimensions")
if pd.get_option("display.expand_frame_repr"):
width, _ = console.get_console_size()
else:
width = None
self.to_string(
buf=buf,
max_rows=max_rows,
max_cols=max_cols,
line_width=width,
show_dimensions=show_dimensions,
)
return buf.getvalue()