-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Add an ends function that shows both head and tail of the df #18691
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
I thought we discussed this before, but can't find such issue. That said, this is closely related to #17023. Because if we reduce the default number of rows, I think such a feature becomes less needed IMO. In general, we are not very keen on adding more methods to DataFrame, unless there is a very clear need. |
FWIW, my utils file has a context manager for this: def show(df):
with pd.option_context("display.max_rows", 10):
display(df) And I called it with |
this seems quite duplicate of what we already have, by default the repr already does this. using |
Perhaps it might be worth adding a line to the docs as it seems quite an obscure but very useful trick. I would suggest referring to head in the docs for tail and vice versa and adding the comment about I'm happy to try my hand at that addition if there is some general support for the idea. |
Worth a mention that this issue also relates to: #42837 The idea is that there is a way to preserve vertical screen space when inspecting 'tall' (many rows, few cols) data frames. |
Add the following function to pd. dataFrame and pd.Series
Problem description
Often both the beginning and end of a df are of interest, fore example in a time series.
This leads to calling df.head() df.tail() in two seperate notebook cells. This is not only tedious, but also leads to a cluttered notebook. A function that returns both of these + a print on the number of rows and columns, thus allowing a check if the index matches the number of rows.
Example
1500 rows x 6 columns
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Windows
OS-release: 8.1
machine: AMD64
processor: Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.21.0
pytest: 3.3.1
pip: 9.0.1
setuptools: 38.2.4
Cython: 0.26.1
numpy: 1.12.1
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 6.1.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: