-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Add a DataFrame.show() method pls! #1889
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
Comments
Will keep it in mind-- happily accept a pull request, too, if you get around to it. |
Below is the snippet that I currently use, pls be noted that not implement the row-wise function yet (the difficulty is that I don't know how to set/insert a row of '..' def sw(df,first_rows = 20,last_rows =10,first_cols =3,last_cols =2):
DataFrame.show = sw |
@halleygithub you want to make this into a PR? You're almost there, just need to add a few test cases. Thanks in advance! |
yes, pls feel free to further process as you want. I am a newbie to Pandas & github , not a programmer seriously. Feel good that I can contribute to the package. |
It would be great for a contributor to take @halleygithub 's code here, add a test case, and submit it as a pull request. |
Where is col_seq_set() ? Couldn't find it with grep -r "col_seq_set" pandas/* |
@dundo4he it seems to me that it's a function that @halleygithub wrote and hasn't shared yet. It's "probably" not too hard to figure out what it was, based on the output @halleygithub provided. Does that seem to be doable? If not, we should figure something else out. |
def _col_seq_set(df, col_list, seq_list):
DataFrame.col_seq_set = _col_seq_set |
Thanks, @halleygithub ! I'll just provide the same code with a preformatting tag: def _col_seq_set(df, col_list, seq_list): ''' set dataframe col_list's sequence of 'df' by seq_list ''' df_col = list(df.columns) fn_col = [x for x in df_col if x not in col_list] for i in range(len(col_list)): fn_col.insert(seq_list[i], col_list[i]) return df[fn_col] DataFrame.col_seq_set = _col_seq_set Also, @halleygithub , is it OK if we reuse your code under the same terms as pandas, available at https://github.com/pydata/pandas/blob/master/LICENSE ? |
Sure, you can. I will feel good if I can help any. (Sorry for my ugly code :-) ) |
Oh, you just don't need "_col_seq_set()" at all, it is a function in my application to sort the columns sequence in batch. And in the "show()" method, you only need to put the pall[".."] column at first_cols+1 position intead of "pall = col_seq_set(pall,['..'],[first_cols])". |
Please correct me if I am wrong. It seems that numpy.ndarray type automatically adjusts to fit the screen if the ndarray is too large. Can we borrow that mechanism?
|
yes, I also notice that . but I dislike numpy default format for
|
Closed by #5550 |
'print df' will give something like below if the dataframe 'df' is big to fit into the screen :
<class 'pandas.core.frame.DataFrame'>
MultiIndex: 41955 entries, (u'000002', u'20061231') to (u'603366', u'20120630')
Columns: 147 entries, STK_ID to EPS
dtypes: float64(135), object(12)
But most of the time, I want to have a glimpse of the data , which help to know what happened to the dataframe.
Can Pandas developers add a 'show()' method to DataFrame object to display part of the data inside ? Namely, show the four corner (up_left, up_right, down_left, down_right) data, and use '...' to represent the omitted part ?
somewhat like :
STK_ID RPT_Date
000002 20061231 000002 20061231 万科A .. -0.692 0.526
20070331 000002 20070331 万科A .. -0.741 0.140
20070630 000002 20070630 万科A .. -0.454 0.254
............... ............. ............... ........... ... .......... .....
20071231 000002 20071231 万科A .. -1.519 0.705
20080331 000002 20080331 万科A .. -0.207 0.105
The text was updated successfully, but these errors were encountered: