-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
adding left and right view to DataFrame, equivalent to head() and tail() #7005
Conversation
ok, nice...can you add tests for them? (can just copy paste from head/tail)? |
oops, my bad. will add them. |
""" | ||
Return first n columns | ||
""" | ||
l = self.shape[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe these should ONLY apply to Frames? (e.g. left/right don't make sense for Series)? so you can move this to core/frame.py
and open another issue to (or here)
add them to core/groupby.py/_dataframe_apply_whitelist
(and then the tests in test_groupby.py``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the core/frame.py issue I understand and completely agree.
What you tried to say after that completely escapes me, sorry. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahah....
we allow certain methods that be used on a groupby object,
e.g.
df.groupby('A').head()
is allowed
that is what the whitelist is for (if you try to use other methods they will raise an error; prevents people from using random methods on groupby objects.
but on second thought...don't worry about this anyhow....
I am now using it so often, I want to have the corner cases as well:
What do you think? |
I personally think adding 6 more methods to DataFrame just for this is a bit too much. Only I think we should think a bit more carefully about this, also related to the default DataFrame display (#6547) and the issues @jreback linked to. Also, if the default DataFrame display will be truncated centrally (#5603), you actually already have somehow left and right in one view? |
Why not have a corner method that you can pass iloc indices to? Top left would be corner(5,5) bottom left would be corner(-5,5) and so on. You could even implement head on terms of this by accepting None |
isn't this what we wanted |
Actually corner doesn't really save you anything. Nevermind |
To motivate this further, real-time data analysis is a lot about understanding what your current operation is doing to the data, and a quick view showing me all 4 corners goes a long way towards this. In this respect, if this can be implemented with one extra command and the default being to show me 2 or 3 rows or columns in the corners, I'm all for it and would recommend to reject my PR. But I also would like to stress that in terms of data visualization I would not find it wise to penny-count the number of methods, I don' think there's many more important things in data analysis than to show how it reacts to the applied operations, so IMHO it would be saving 'at the wrong end'. Nevertheless, I believe @jorisvandenbossche 's comment of 6 added methods for this was more commenting on the lack of power that my PR adds compared to the linked PRs, and here I totally agree. So, what is the status of the centrally truncated view (i.e. a 4-corner-view), when will it come or is it available in a branch/fork? Incidentally, I was wondering: Is it possible to automatically adapt the current automatic number of displayed lines and columns as a percent value of the current notebook's width/length? |
FWIW, I would too object about adding more "root" methods, but namespace-like |
@immerrr I think that is an excellent idea! |
@michaelaye if you'd like to convert this to use a |
What about this for a quick method hack chain??? # Display left five columns
df.transpose().head().transpose()
# Display right five columns
df.transpose().tail().transpose() |
I am working with a lot of columns recently and just thought of these little helpers, basically the same as head() and tail(), but for columns.
Additionally, I fixed a small pep8 issue in head()