Skip to content

ENH: display.timedelta_format similar to display.float_format #63465

@sam-s

Description

@sam-s

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I can set display.float_format to "{:.1f}".format to get a very short output, but timedelta64[ns] is still printed as 0 days 00:05:09.812000 instead of 5m (as it would if I could set display.timedelta_format to my own function).

Feature Description

Add display.timedelta_format, display.timestamp_format &c that can be set to a callable that takes an object of the specified type and returns a string.

Alternative Solutions

Alternatively, replace display.float_format with a generic display.format which would receive an object (int or float or Timestamp or Timedelta or whatever) and return either a string or NotImplemented to indicate that the default (built-in) method is to be used.

Alternatively, display.format can be a dict wher display.format[float] has the same meaning as display.float_format now.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions