Skip to content

add some type annotations io/formats/format.py #27418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove properties
  • Loading branch information
simonjayhawkins committed Jul 19, 2019
commit 480c80833ef74a3e7b86b0e7911a9e8edf0851ce
25 changes: 8 additions & 17 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,14 @@ def __init__(

self._chk_truncate()

@property
def truncate_v(self) -> bool:
return hasattr(self, "tr_row_num")

def _chk_truncate(self) -> None:
from pandas.core.reshape.concat import concat

min_rows = self.min_rows
max_rows = self.max_rows
# truncation determined by max_rows, actual truncated number of rows
# used below by min_rows
self.truncate_v = False
series = self.series
if max_rows and (len(series) > max_rows):
if min_rows:
Expand All @@ -247,6 +244,7 @@ def _chk_truncate(self) -> None:
row_num = max_rows // 2
series = concat((series.iloc[:row_num], series.iloc[-row_num:]))
self.tr_row_num = row_num
self.truncate_v = True

self.tr_series = series

Expand Down Expand Up @@ -508,19 +506,7 @@ def __init__(
self._chk_truncate()
self.adj = _get_adjustment()

@property
def truncate_v(self) -> bool:
return hasattr(self, "tr_row_num")

@property
def truncate_h(self) -> bool:
return hasattr(self, "tr_col_num")

@property
def is_truncated(self) -> bool:
return self.truncate_h or self.truncate_v

def _chk_truncate(self):
def _chk_truncate(self) -> None:
"""
Checks whether the frame should be truncated. If so, slices
the frame up.
Expand Down Expand Up @@ -564,6 +550,8 @@ def _chk_truncate(self):
max_cols_adj = self.max_cols_adj
max_rows_adj = self.max_rows_adj

self.truncate_h = False
self.truncate_v = False
frame = self.frame
if max_cols_adj and (len(self.columns) > max_cols_adj):
if max_cols_adj == 1:
Expand All @@ -575,6 +563,7 @@ def _chk_truncate(self):
(frame.iloc[:, :col_num], frame.iloc[:, -col_num:]), axis=1
)
self.tr_col_num = col_num
self.truncate_h = True

if max_rows_adj and (len(frame) > max_rows_adj):
if max_rows_adj == 1:
Expand All @@ -584,8 +573,10 @@ def _chk_truncate(self):
row_num = max_rows_adj // 2
frame = concat((frame.iloc[:row_num, :], frame.iloc[-row_num:, :]))
self.tr_row_num = row_num
self.truncate_v = True

self.tr_frame = frame
self.is_truncated = self.truncate_h or self.truncate_v

def _to_str_columns(self) -> List[List[str]]:
"""
Expand Down