Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
CLN: Refactor string special methods to common decorator + safe unicode everywhere #4090
Comments
|
I had this change in my refactor of series - but u r welcome to do separately should be a top level pandas base class ( really should be PandasObject but that is used now) that PandasObject, NDFrame, Index and such inherit from with methods like this |
|
One problem is that core/generic imports MultiIndex...should the baseclass go in a different file to avoid the circular import? |
|
should be like a mix-in I think Index makes sense as well here On Jun 30, 2013, at 8:41 PM, Jeff Tratner notifications@github.com wrote:
|
|
Okay, should be totally simple to adapt. |
|
yes maybe core/base.py ? |
|
@jreback haha, I had just starting editing core/base right before I saw your note. |
|
@jreback we could rename |
|
that works |
|
FYI there are also some other public objects that prob should inherit from this as well Categorical, HDFStore (maybe) others I am sure |
|
Yeah, I'd caught those. Covered by Series, Frame and Panel via On Sun, Jun 30, 2013 at 8:57 PM, jreback notifications@github.com wrote:
|
|
there be a real base class mixin shouldn't be too complicated |
|
@jreback what? Slightly confused. I was thinking fo: class StringMixin(object): # adds string methods
class PandasObject(StringMixin) # baseclass for Index, Categorical, PandasContainer, etc.
class PandasContainer(PandasObject): # baseclass for NDFrame |
|
yep that's good first 2 in core/base 3rd replaces current PandasObject def |
jtratner commentedJul 1, 2013
I was implementing some new objects for another PR and noticed that string methods are duplicated throughout (particularly on objects that don't inherit from each other). Wrote this up on this branch - https://github.com/jtratner/pandas/tree/refactor_string_magic_methods .
If you thing this is worthwhile, I'll split it up a little, add a bit better documentation and submit.
This is used multiple times:
Unicode tends to vary, but often is like this:
Additionally, a number of objects aren't using a unicode-safe representation of themselves, so this would resolve that as well. Would this be useful to include?