We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Refer to #1889 (comment)
And below is the completed code to do that. Can put it into the codebase and make it as the default option to display dataframe ?
def _sw(df, up_rows=10, down_rows=5, left_cols=4, right_cols=3): ''' display df data at four corners A,B (up_pt) C,D (down_pt) parameters : up_rows=10, down_rows=5, left_cols=4, right_cols=3 sample: df = pd.DataFrame(np.random.randn(20,10), columns=list('ABCDEFGHIJKLMN')[0:10]) df.sw(5,2,3,2) df1 = df.set_index(['A','B'], drop=True, inplace=False) df1.sw(5,2,3,2) '''
ncol, nrow = len(df.columns), len(df) # handling columns if ncol <= (left_cols + right_cols) : up_pt = df.ix[0:up_rows, :] # screen width can contain all columns down_pt = df.ix[-down_rows:, :] else: # screen width can not contain all columns pt_a = df.ix[0:up_rows, 0:left_cols] pt_b = df.ix[0:up_rows, -right_cols:] pt_c = df[-down_rows:].ix[:,0:left_cols] pt_d = df[-down_rows:].ix[:,-right_cols:] up_pt = pt_a.join(pt_b, how='inner') down_pt = pt_c.join(pt_d, how='inner') up_pt.insert(left_cols, '..', '..') down_pt.insert(left_cols, '..', '..') overlap_qty = len(up_pt) + len(down_pt) - len(df) down_pt = down_pt.drop(down_pt.index[range(overlap_qty)]) # remove overlap rows dt_str_list = down_pt.to_string().split('\n') # transfer down_pt to string list # Display up part data print up_pt start_row = (1 if df.index.names[0] is None else 2) # start from 1 if without index # Display omit line if screen height is not enought to display all rows if overlap_qty < 0: print "." * len(dt_str_list[start_row]) # Display down part data row by row for line in dt_str_list[start_row:]: print line # Display foot note print "\n" print "Index :",df.index.names print "Column:",",".join(list(df.columns.values)) print "row: %d col: %d"%(len(df), len(df.columns)) print "\n" return None
DataFrame.sw = _sw #add a method to DataFrame class
The text was updated successfully, but these errors were encountered:
Same as #1889.
Sorry, something went wrong.
No branches or pull requests
Refer to #1889 (comment)
And below is the completed code to do that. Can put it into the codebase and make it as the default option to display dataframe ?
def _sw(df, up_rows=10, down_rows=5, left_cols=4, right_cols=3):
''' display df data at four corners
A,B (up_pt)
C,D (down_pt)
parameters :
up_rows=10, down_rows=5, left_cols=4, right_cols=3
sample:
df = pd.DataFrame(np.random.randn(20,10), columns=list('ABCDEFGHIJKLMN')[0:10])
df.sw(5,2,3,2)
df1 = df.set_index(['A','B'], drop=True, inplace=False)
df1.sw(5,2,3,2)
'''
DataFrame.sw = _sw #add a method to DataFrame class
The text was updated successfully, but these errors were encountered: