Skip to content
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

DEPR: Index.format? #55413

Closed
jbrockmendel opened this issue Oct 5, 2023 · 9 comments · Fixed by #55439
Closed

DEPR: Index.format? #55413

jbrockmendel opened this issue Oct 5, 2023 · 9 comments · Fixed by #55439
Labels
Deprecate Functionality to remove in pandas Index Related to the Index class or subclasses Needs Discussion Requires discussion from core team before further action

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Oct 5, 2023

Does anyone actually use this? Internally we use it for some html/latex rendering but we don't use most of the keywords so it would be simpler to refactor to use a private method for those.

I've been trying to unravel the various EA formatting methods to try to use the same patterns everywhere, align keywords, etc. Doing this for Index.format wouldn't be that hard, but it would be easier to just deprecate it if it isn't used externally.

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 5, 2023
@lithomas1 lithomas1 added Deprecate Functionality to remove in pandas Needs Discussion Requires discussion from core team before further action Index Related to the Index class or subclasses and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 5, 2023
@lithomas1
Copy link
Member

@jbrockmendel
Copy link
Member Author

The catboost example looks like they just vendored all of pandas. The others are look like largely matches on the word "format" which isn't using our Index.format.

@lithomas1
Copy link
Member

My bad, there seem to be a lot of false positives from Github code search.

I think this one is an actual usage
https://github.com/couchbase/ns_server/blob/9a336e9ff90d7634807f1b8c513160e8bbe71793/scripts/pressure_from_stats.py#L186

(not that it's a widely used project, just pointing out the existence of code that uses format)

@lithomas1
Copy link
Member

At any rate, I don't really care too much if this is deprecated, though.

@jbrockmendel jbrockmendel mentioned this issue Oct 7, 2023
5 tasks
@rhshadrach
Copy link
Member

cc @attack68

@attack68
Copy link
Contributor

This is used in one place in Styler rendering internally. This is code that predates me, but it's used to be able to get positions in an index so that Styler can display sparsified output.

    if isinstance(index, MultiIndex):
        levels = index.format(sparsify=lib.no_default, adjoin=False)
    else:
        levels = index.format()

@rhshadrach
Copy link
Member

@attack - just in case you missed it, this is from the OP

we don't use most of the keywords so it would be simpler to refactor to use a private method for those.

So I take it you have no objection to making it internal.

@rhshadrach
Copy link
Member

I would expect .format to operate similar to Python's format, and this doesn't. It seems the method would be more appropriate to call .to_string. I'm in favor of the deprecation; if we get use feedback that this is useful, we can consider (but not necessarily must) add to_string or something like that then.

@attack68
Copy link
Contributor

no objection at all to the refactor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Index Related to the Index class or subclasses Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants