Feature Type
-
[x] Adding new functionality to pandas
-
[ ] Changing existing functionality in pandas
-
[ ] Removing existing functionality in pandas
Problem Description
I often work with time series and want to see at a glance where and how they begin and end.
Feature Description
That's why I registered an "ends" accessor, which provides me with both ends in one call as a combination of "head" and "tail". It's really simple, but very usefull to me:
class _EndsAccessor:
def __init__(self, pandas_obj):
self._obj = pandas_obj
def __call__(self, n=2):
return pd.concat([self._obj.head(n), self._obj.tail(n)])
@pd.api.extensions.register_dataframe_accessor("ends")
class EndsAccessorDataframe(_EndsAccessor):
pass
@pd.api.extensions.register_series_accessor("ends")
class EndsAccessorSeries(_EndsAccessor):
pass
Alternative Solutions
We leave it as it is and I continue using the solution shown above.
Additional Context
No response
Comment From: jbrockmendel
Im skeptical of this. The API is already big and we generally avoid adding methods with an easy alternative already available. Will leave this open in case others disagree.
Comment From: simonjayhawkins
agree with @jbrockmendel and that we should prioritize minimal APIs and expect users to compose functionality using existing methods.
pd.concat([df.head(n), df.tail(n)])
is simple and readable, so no reason IMO that developers should not opt for that pattern directly.
Comment From: mroeschke
Seems like there not much buy in for this so closing