From 86ecf054a1943c51b061a4e672ddb2f9d5b9a06f Mon Sep 17 00:00:00 2001 From: Dale Jung Date: Sun, 10 Sep 2023 13:27:48 -0400 Subject: [PATCH] Added ability for objects to override how they show up in dataframe --- pandas/io/formats/printing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/io/formats/printing.py b/pandas/io/formats/printing.py index b57797b7ec717..5f8344d2f5a88 100644 --- a/pandas/io/formats/printing.py +++ b/pandas/io/formats/printing.py @@ -210,6 +210,10 @@ def as_escaped_string( if hasattr(thing, "__next__"): return str(thing) + + if hasattr(thing, "__pandas_repr__"): + return str(thing.__pandas_repr__()) + elif isinstance(thing, dict) and _nest_lvl < get_option( "display.pprint_nest_depth" ):