Skip to content

Commit

Permalink
Make URL styling method a function
Browse files Browse the repository at this point in the history
  • Loading branch information
tcurvelo committed Oct 20, 2019
1 parent 5378208 commit 69b9401
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/arche/tools/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import pandas as pd


class StylizedDataFrame(pd.DataFrame):
def _make_urls_clickable(self, val):
if isinstance(val, str) and re.search("^https?://", val):
return f'<a target="_blank" href="{val}">{val}</a>'
else:
return val
def make_urls_clickable(val):
if isinstance(val, str) and re.search("^https?://", val):
return f'<a target="_blank" href="{val}">{val}</a>'
else:
return val


class StylizedDataFrame(pd.DataFrame):
def to_html(self, *args, **kwargs):
styler = self.style.format(self._make_urls_clickable)
styler = self.style.format(make_urls_clickable)
return styler.render(*args, **kwargs)

0 comments on commit 69b9401

Please sign in to comment.