4

I've got a pandas DataFrame with a column that's a url, and I've written the following formatter to present it in my notebook as a link:

def make_clickable(val):
    # target _blank to open new window
    return '<a target="_blank" href="{}">{}</a>'.format(val, val)
all_data.style.format({'url': make_clickable})

This nicely prints out my table with the urls made clickable, but what I'd really like to do is to make this style persist as the default for that frame, so that it's used for the _repr_html of my dataframe (and slices of it) throughout the same notebook.

Does anyone know if that's possible?

1 Answer 1

1

As far as I know it's not possible to register a default style. We overrode _repr_html_ instead, replacing clickable_urls argument.

            table_id=None,
            render_links=render_links,
        )

https://github.com/pandas-dev/pandas/blob/c23649143781c658f792e8f7a5b4368ed01f719c/pandas/core/frame.py

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.