Last active
April 12, 2022 17:11
-
-
Save dardanxhymshiti/729f966740ace7579711186356b73920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def highlight_columns(df, rows=20, color='lightgreen', columns_to_shadow=[], columns_to_show=[]): | |
highlight = lambda slice_of_df: 'background-color: %s' % color | |
sample_df = df.head(rows) | |
if len(columns_to_show) != 0: | |
sample_df = sample_df[columns_to_show] | |
highlighted_df = sample_df.style.applymap(highlight, subset=pd.IndexSlice[:, columns_to_shadow]) | |
return highlighted_df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment