Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
1k views

I have a dataframe that contains threshold values for 20+ elements that's formatted like so df1: Li Se Be Upper 30 40 10 Lower 10 5 1 I have another dataframe which contains values for those elements ...
Gingerhaze's user avatar
2 votes
3 answers
858 views

I'm trying to highlight specific number with different color in my dataframe below: import pandas as pd df = pd.DataFrame([[10,3,1], [3,7,2], [2,4,4]], columns=list("ABC")) I can highlight ...
Kelvin Lo's user avatar
  • 199
0 votes
1 answer
961 views

Looking to create a table like this in Jupiter Notebook based on a pandas DataFrame. While styler has much on how to format data, much typically done in excel/word is formatting text to make it ...
Jaime's user avatar
  • 1
1 vote
2 answers
403 views

I'm trying to apply Pandas style to my dataset and add a column with a string with the matching result. This is what I want to achieve: Link Below is my code, an expert from stackflow assisted me to ...
Kelvin Lo's user avatar
  • 199
2 votes
1 answer
751 views

I'm trying to add a new column after dataframe gets df.style. However, I got an error message: 'Styler' object does not support item assignment Below is my code: import pandas as pd df = pd....
Kelvin Lo's user avatar
  • 199
1 vote
1 answer
3k views

I'm trying to highlight specific cells for each column with different condition which their value matches the condition for each row. Below image is what I want to achieve: The table I attempt to ...
Kelvin Lo's user avatar
  • 199
1 vote
1 answer
1k views

I tried different seaborn functions and pandas style functions. I want to apply a heatmap with center=0 (positive value gets red heatmap, negative values gets blue heatmap) while keeping all the ...
Cherry Wu's user avatar
  • 4,114
1 vote
2 answers
165 views

I have 2 columns that I want to compare (SO Status & Past_Week_SO). I want to show "Past_Week_SO" with red color when the data is different from the "SO Status". This is my ...
user16413195's user avatar
0 votes
1 answer
460 views

I am using the Pandas DataFrame styler and want to make every other column (based on the first level of a multi index rather than hard code) have a gray background. I know that with CSS you can use ...
nerrez's user avatar
  • 15
1 vote
2 answers
262 views

I have the following code that formats my df correctly, only it changes the rounding of my values from being 2 dp to adding 4 zeros to each value. Anyone know how to adjust the function to not add the ...
batrick_pateman's user avatar
0 votes
1 answer
84 views

Updated: I have a huge dataframe, providing small version of it. header = [np.array([' ',' ',' ','X','X','Y','Y']), np.array(['A','B','C','D','E','F','G'])] df = pd.DataFrame(columns=header) ...
Maleficent's user avatar
0 votes
1 answer
572 views

On a Pandas dataframe I would like to apply a style on a specific column, on a multi-criteria taken from different columns values. table = product sales revenues fruit 10 6 eggs ...
GK31's user avatar
  • 11
0 votes
1 answer
854 views

I have NAN values in my dataframe columns and i need to replace it with empty string. I need to perform subtraction on these columns, so when replacing with empty string i am getting error: ...
Maleficent's user avatar
2 votes
3 answers
11k views

I want to change the background styling color of the pandas table. Example: df = pd.DataFrame({ 'group': ['A','B','C','D'], 'var1': [38, 1.5, 30, 4], 'var2': [29, 10, 9, 34], 'var3': [8, 39, 23, 24], '...
Federico Vega's user avatar
1 vote
1 answer
222 views

I rounded numbers before applying pandas styles, it worked fine. However, after applying styles, the numbers got unrounded. I don't get it. example data d = {'col1': ['a', 'b', 'c']*2, 'col2': [1.111, ...
Osca's user avatar
  • 1,744
4 votes
2 answers
8k views

I am trying to highlight the single whole cell in pandas based on text. For example, if Recommend is 'SELL', I want to highlight in red and green for 'BUY'. Appreciate if someone can guide me on this. ...
Omerge's user avatar
  • 89
0 votes
1 answer
2k views

I am generating an email report using pandas –to_html function. I am looking for solutions and struck at a point(screenshot attached) where I want to combine cell values in the dataframe(just like ...
Prakhar Jhudele's user avatar
1 vote
1 answer
416 views

I would like to color my rows based on my list of integer such that: if my integer is = [3, 10, 12] the coloring of pandas style should be: I was trying to do what How to highlight both a row and a ...
jajamaharaja's user avatar
0 votes
2 answers
1k views

I'd like to style a Pandas DataFrame display with a background color that is based on the logarithm (base 10) of a value, rather than the data frame value itself. The numeric display should show the ...
Donna's user avatar
  • 1,630
5 votes
3 answers
35k views

This is a follow up question on applying background color to a dataframe based on condition I am able to apply style based on the below: f = lambda v: 'background-color: %s' % 'green' if v=='col' else ...
EXODIA's user avatar
  • 966
0 votes
1 answer
460 views

Pardon me I am new to handle html through pandas and having trouble generating required format I have dataframe like below Category Date Avg Price - growth (%) Profit Overall profit A ...
Prakhar Jhudele's user avatar
1 vote
1 answer
4k views

I want apply some filter conditions on specific cols. Based on filter I want to highlight that cell. I took this example from another post: styled = (df.style .applymap(lambda v: '...
EXODIA's user avatar
  • 966
2 votes
1 answer
1k views

I have a dataframe as below import pandas as pd import seaborn as sns import numpy as np df = sns.load_dataset("diamonds") df.head() carat cut color clarity depth table price ...
Ailurophile's user avatar
  • 3,025
2 votes
1 answer
1k views

I want to highlight the cells based on the values of another column in a dataframe. Like in the below example, I want to highlight the prodkey1 and product1 cells if the value of p1_ourproduct is ...
Becky's user avatar
  • 31
3 votes
2 answers
781 views

I have a csv file that I'm trying to read into a dataframe and style in jupyter notebook. The csv file data is: [[' ', 'Name', 'Title', 'Date', 'Transaction', 'Price', 'Shares', '$ Value'], [0, 'Sneed ...
Broderick Bonelli's user avatar
1 vote
1 answer
4k views

I want to highlight the maximum value in each row as green and the minimum value as red. import numpy as np import pandas as pd value = np.random.normal(size=(5,5)) #Generate random data df = pd....
Vinson Ciawandy's user avatar
2 votes
1 answer
3k views

I have the following dataframe: df=pd.DataFrame({'c1':['a','b','c'], 'c2':['aa', 'bb','cc'] }) And I have the following function to color cells: def color_cell(cell, c): if cell ...
Ani's user avatar
  • 179
8 votes
1 answer
3k views

Update: The issue seems to be with displaying the HTML with styling rendered by pandas in Google Chrome and Microsoft Edge. JupyterLab in Firefox correctly displays all of the styled rows and ...
Trenton McKinney's user avatar
1 vote
1 answer
2k views

I have a dataframe 'df' like this How do I s set he background color of the column 'wt' based on the column 'item'. If 'item' is 'apple', the value in the 'wt' column should have a background colour ...
imdevskp's user avatar
  • 2,253
0 votes
2 answers
2k views

I want to flag the anomalies in the "desired" columns (desired_D to desired_L). Here, an anomaly is defined as any value <1500 and >400000 in each row. See below for the dataset: ...
RayX500's user avatar
  • 319
0 votes
2 answers
3k views

I would like to apply the same background color to cells that have for each PEOPLE instance the name and the related name. I have tried to df.style.applymap, it does not return an error but it does ...
Christina J's user avatar
4 votes
2 answers
7k views

How do I hide the column labels via pandas style? There is a hide_index() method that removes the index row, unfortunately the hide_column() label removes the entire column (both the header and the ...
vgoklani's user avatar
  • 11.9k
0 votes
1 answer
489 views

I want to highlight dataframe cells contained in a specific list, to get better performance, I want this only happens to specific column. I understand we should set df.style background-color: yellow ...
x86_64's user avatar
  • 105
4 votes
2 answers
6k views

I created a DataFrame in pandas for which I want to color the cells using a color index (low values red, high values green). I succeeded in doing so, however the coloring prevents me to format the ...
gardangerous's user avatar
5 votes
1 answer
2k views

this is my style code to make positive numbers appear green and negative numbers appear red if i just print out df it would show the numbers like this: 25.72,36.28,0.17 with the style however they are ...
xreboorn's user avatar
0 votes
1 answer
215 views

Want to pandas style Currency : Rupee \u20B9 (How to print currency symbol and an n-digit decimal number right aligned in Python) format_dict = {'Premium Per Rep':'{0:,.0f}'} f1=f.style....
Shivam Anand's user avatar
4 votes
1 answer
5k views

I went to apply a style.format to one of my columns in the df (to add commas), but after calling df second time –– it seems that the style.format is not permanent? When I do assign the style.format to ...
Yves's user avatar
  • 47
1 vote
1 answer
1k views

data = {'Rest (N=11570)': {4: '7369 (62.28%)', 1: '7016 (59.98%)', 37: '734 (6.14%)', 40: '9829 (79.09%)', 43: '37 (2.42%)', 5: '3080 (25.29%)', 6: '1273 (9.43%)', 12: '6992 (62.61%)', 15: '777 (5.47%)...
user1828605's user avatar
  • 1,735
7 votes
3 answers
10k views

I'm using pandas style in a jupyter notebook to emphasize the borders between subgroups in this dataframe: (technically speaking: to draw borders at every changed multiindex but disregarding the ...
Lutz's user avatar
  • 116
0 votes
3 answers
3k views

I am running Python 3.6.5 and Pandas 0.25.2. On attempting to style a pandas dataframe I am getting a specific error which can be generated by simplifying to this code: import pandas as pd import ...
agftrading's user avatar
3 votes
1 answer
1k views

This documentation shows how to apply styles pandas.DataFrame. How can we select the yellow cells from df? df = pd.DataFrame({"A": [1, 2, 3, 4, 5], "B": [1, 7, 14, 5, 3]}) def ...
E.K.'s user avatar
  • 4,379
2 votes
1 answer
1k views

I have defined a function to get value_counts for each column with Count, Percentage % as below: import pandas as pd import seaborn as sns import numpy as np from IPython.display import display df = ...
Ailurophile's user avatar
  • 3,025
0 votes
1 answer
217 views

I have a webserver that displays tables of data with some formatting. The formatting is colouring certain cells. The tables are stored as dataframes and the formatting is applied using a pandas styler....
finiteisaac's user avatar
3 votes
1 answer
10k views

I am creating an app with Streamlit and I wish to print out a pandas dataframe in which I can change the background color of each cell of the dataframe. I found out that this is supported by pandas ...
clank's user avatar
  • 83
1 vote
0 answers
219 views

I am trying to edit an excel file using pandas. What I would like to do is, for a chosen column and a specific threshold have all the cells in that column with values lower than the threshold to be ...
Aaron 's user avatar
  • 11
3 votes
0 answers
328 views

I need to style a Pandas dataframe that has a multi-index column arrangement. As an example of my dataframe, consider: df = pd.DataFrame([[True for a in range(12)]]) df.columns = pd.MultiIndex....
autonopy's user avatar
  • 514
0 votes
1 answer
1k views

Hi so I'm working on writing a custom jinja template that inherits from Pandas base template. My default template looks as {% extends "html.tpl" %} {% block table %} <style type="...
Melendowski's user avatar
0 votes
2 answers
2k views

I am apply the following formatting to the pandas data frame. The data is as follow: {'In / Out': {'AAA': 'Out', 'BBB': 'In', 'Total1': 'Out', 'CCC': 'In', 'DDD': 'In', 'Total2': 'In'}, '...
user1769197's user avatar
  • 2,253
5 votes
2 answers
17k views

I'm following instructions at https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html to set up style for my data frame to become html. It worked well, except that the table's border of ...
abisko's user avatar
  • 743
0 votes
1 answer
974 views

I have a multi-index pivot table that I am making from a dataframe as shown below: pivot_summary = pd.pivot_table(df, index=['Team', 'Associate Name'], columns=['Date'], values=['Call Transfers'], ...
GeeSama's user avatar
  • 39

1
3 4
5
6 7
9