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

I am building my own legend for a complicated figure where some lines have a hexadecimal color (e.g. #009933). To build the legend I have a column 'color' that has the same hexadecimal color as the ...
Patrickens's user avatar
4 votes
2 answers
2k views

I have a dataFrame with 6 columns. And I want to do conditional formatting on two columns of them. So my dataFrame looks like this And I want to highlight duplicate values from College and College_F2 ...
Twinkle Lahariya's user avatar
7 votes
2 answers
6k views

I would like to use a diverging colormap to color the background of a pandas dataframe. The aspect that makes this trickier than one would think is the centering. In the example below, a red to blue ...
Ziggy Eunicien's user avatar
15 votes
1 answer
11k views

I am trying to print a pandas dataframe with a background gradient for better readability. I tried to apply what I found in the docs to a simple use case, but I can't get jupyter notebook to actually ...
emilaz's user avatar
  • 2,182
5 votes
2 answers
2k views

The public documentation for pandas.io.formats.style.Styler.format says subset : IndexSlice An argument to DataFrame.loc that restricts which elements formatter is applied to. But looking at the ...
Jason S's user avatar
  • 191k
3 votes
1 answer
1k views

I'm using the following to color the cells in a dataframe: import seaborn as sns cm1 = sns.diverging_palette(h_pos=130, h_neg=10, s=99, l=55, n=99, as_cmap=True) df_s = (df.style ....
Paul3349's user avatar
  • 481
2 votes
1 answer
2k views

I want to apply color gradients(Green to yellow to red : based on the values) in multiple subsections of a pandas dataframe. In each of those subsections the values are going to be between 0 and 1. So ...
Dravidian's user avatar
  • 9,955
8 votes
3 answers
13k views

I have a small-shaped (5 rows, 3 columns) dataframe which I can display by calling df in jupyter cell. I would like to enlarge (font size) this output for presentation purpose. Is it possible?
matt525252's user avatar
7 votes
2 answers
2k views

Is it possible to display pandas styles in an iPython console? The following code in a Jupyter notebook import pandas as pd import numpy as np np.random.seed(24) df = pd.DataFrame({'A': np.linspace(...
divingTobi's user avatar
  • 2,350
3 votes
3 answers
3k views

I want to style my table with Pandas with the following example from this site: https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html Now, the problem is, that I use Pycharm. So after ...
Derick Kolln's user avatar
2 votes
1 answer
1k views

I image that this might be a complex issue. I want to have five different colors for a specific column. cld_ght in the dataframe. Here is the dataframe: icao msg_type time dt ddd ...
John's user avatar
  • 157
1 vote
1 answer
932 views

Hello friends, I would like to apply a styling function on a data frame that contains numeric and non numeric column types. How can I avoid the error below? Error: TypeError: ("'>' not supported ...
user9185511's user avatar
6 votes
1 answer
2k views

I can't visualize data frames with Styles in PyCharm. I'm using the following user guide: http://pandas-docs.github.io/pandas-docs-travis/user_guide/style.html I only get a Pandas styler object (...
user12130649's user avatar
2 votes
1 answer
4k views

I am trying to output a pandas dataframe with colored cells to the console using the pandas Styler feature. When I run code examples in Spyder 3.2.6 running python 2.7, instead of seeing the dataframe ...
trock2000's user avatar
  • 312
2 votes
0 answers
151 views

I want to use the color coding from a pandas style object and apply the exact same coloring to the corresponding cells in another dataframe with the same size. The data is different in the two ...
Theis Hjortkjær's user avatar
2 votes
2 answers
2k views

I have a dataframe in pandas that looks a bit like this: A B C 1 0.5 0.6 1 0.7 0.1 2 0.3 0.2 3 0.1 0.3 3 0.2 0.1 When you print a pandas dataframe in jupyter, ...
Sledge's user avatar
  • 1,355
20 votes
3 answers
8k views

Pandas has two nice functionalities I use a lot - that's the df.style... option and the df.to_latex() call. But I do not know how to combine both. The .style option makes looking at tables much more ...
muuh's user avatar
  • 1,083
1 vote
2 answers
1k views

I have generated a pandas dataframe and I want to use pd.DataFrame().style to highlight some cells. v1 v2 v3 v4 v5 v1 0 1 1 1 0 v2 0 0 1 1 1 v3 0 0 0 0 0 v4 0 0 ...
Sos's user avatar
  • 1,959
3 votes
2 answers
6k views

How can I render a Pandas df where one of the columns' style.bar.color property is computed based on some condition? Example: df.style.bar(subset=['before', 'after'], color='#ff781c', vmin=0.0, vmax=...
rodrigo-silveira's user avatar
8 votes
3 answers
12k views

I'm experimenting/learning Python with a data set containing customers information. The DataFrame structure is the following (these are made up records): import pandas as pd df1 = pd.DataFrame({'...
glpsx's user avatar
  • 679
11 votes
1 answer
1k views

I'm using jupyter nbconvert --to pdf --TemplateExporter.exclude_input=True Scorecard.ipynb to export my notebook to a pdf. Everything runs fine, but when looking in the pdf the dataframes are shown ...
user11924246's user avatar
4 votes
1 answer
1k views

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 ...
mistertim's user avatar
  • 5,303
3 votes
1 answer
874 views

How to force min and max value range when styling a dataframe column ? Example : df = pd.DataFrame(columns = ['column'], data = [-1, 0, 1, 2]) df.style.background_gradient(cmap='coolwarm_r') This ...
Vincent's user avatar
  • 1,624
1 vote
0 answers
2k views

I am creating a conditional formatting table in Python using pandas and seaborn which gives me a pandas.io.formats.style.Styler object. I need to export this as an image file . I cannot use imgkit, ...
Pawan_Malviya's user avatar
5 votes
3 answers
2k views

I have a pandas.DataFrame with values in it, say: df = pd.DataFrame(np.random.randn(5, 3), columns=['a', 'b', 'c']) In [160]: df Out[160]: a b c 0 -0.316527 -0.721590 1....
benjaminmgross's user avatar
3 votes
1 answer
3k views

In a jupyter notebook, I have a function which prepares the input features and targets matrices for a tensorflow model. Inside this function, I would like to display a correlation matrix with a ...
David's user avatar
  • 523
1 vote
2 answers
2k views

I have a dataframe with several columns and a list with colors associated with each column. I want to highlight the non-blank cells in each column with the associated color. I've tried iterating over ...
bcparker21's user avatar
7 votes
3 answers
2k views

I was wondering how to highlight diagonal elements of pandas dataframe using df.style method. I found this official link where they discuss how to highlight maximum value, but I am having difficulty ...
BhishanPoudel's user avatar
0 votes
0 answers
512 views

I am trying to run this example bit of code import pandas as pd import numpy as np np.random.seed(24) df = pd.DataFrame({'A': np.linspace(1, 10, 10)}) df = pd.concat([df, pd.DataFrame(np.random....
EddyWD's user avatar
  • 317
0 votes
1 answer
735 views

I´m using imgkit to create a pdf with images created from html that comes from a dataframe. I need whole specific rows to be bold [rows: 0 and 7] but haven't achieved it. What am I missing? html = df....
Gabra's user avatar
  • 101
0 votes
1 answer
1k views

I am trying to apply a Bar Style to all of the data in the dataframe, except the last row, which is supposed to be the Total row. import pandas as pd import numpy as np data = pd.DataFrame(np.random....
soky's user avatar
  • 5
9 votes
1 answer
15k views

Whenever I try to perform any operation after styling in my code, I see this error: AttributeError: 'Styler' object has no attribute 'drop' In this instance I was trying to drop a column after ...
Rajesh D's user avatar
  • 121
4 votes
2 answers
4k views

I am working with a very big data set (18000 rows of data) which I only want to show a couple of rows such as 5 or 10 first rows. I was trying to use pandas.DataFrame().head(10) method but I am doing ...
Arad Haselirad's user avatar
4 votes
1 answer
4k views

I have pandas dataframe, and I would like to give a background gradient color based on absolute value.Imagine, my desire value is 6 in column A in the data frame. As number move from desire value, ...
ahad pashayev's user avatar
10 votes
4 answers
3k views

When I change the style of a pandas.DataFrame, for instance like so # color these columns color_columns = ['roi', 'percent_of_ath'] (portfolio_df .style ...
Ugur's user avatar
  • 2,054
5 votes
1 answer
4k views

I have one pandas dataframe that I want to style the format based on the values of another dataframe of the same shape/size. I'm trying to use applymap. Here's an example: t1= pd.DataFrame({'x':['A'...
Den Thap's user avatar
  • 153
1 vote
2 answers
6k views

import pandas as pd import xlsxwriter from datetime import datetime import sys path = sys.argv[1] xl = pd.ExcelFile(path) df = xl.parse("Sheet1") df.columns = ['Nume', 'Tip de', 'Unit', 'Speciale ...
POV's user avatar
  • 12.1k
15 votes
4 answers
10k views

I have the following code to dump the dataframe results into a table in HTML, such that the columns in TIME_FRAMES are colored according to a colormap from seaborn. import seaborn as sns TIME_FRAMES ...
Filipe Aleixo's user avatar
6 votes
1 answer
8k views

I have been struggling with how to style highlight pandas rows based on index names. I know how to highlight selected rows but when I have to highlight based on the index, the code is not working. ...
BhishanPoudel's user avatar
2 votes
2 answers
3k views

I have a large number of dataframes to output in Jupyter. The columns are a mix of strings, ints, and floats. The floats need mostly to be '%.2f', but a small subset require specific formatting -- ...
Autumn's user avatar
  • 3,826
20 votes
1 answer
23k views

I have extracted xlsx data into pandas dataframe and used style.format to format particular columns into percentages and dollars. So now my dataframe is converted to styler object, because I need to ...
Roohi's user avatar
  • 221
8 votes
2 answers
18k views

I am using pandas styler to give some columns a background color, based on the name of the column header. While this works as intended, the background color of the column header doesn't change. Here ...
Mr Curious's user avatar
11 votes
1 answer
10k views

Per this example the to_excel method should save the Excel file with background color. However, my saved Excel file does not have any color in it. I tried to write using both openpyxl and xlsxwriter ...
Chandu's user avatar
  • 113
3 votes
1 answer
1k views

I currently have: def color_cell(val): color = 'lightgreen' if val ==0 else 'white' return 'background-color: %s' % color s = df.style.applymap(color_cell) Which gives the following ...
a1234's user avatar
  • 821
1 vote
1 answer
681 views

I am displaying a pandas dataframe in jupyter lab. Some cells have very long text, and if I put: df.style it will make the rows very high. Setting: df.style.set_table_styles([dict(selector="tr&...
Kai Aeberli's user avatar
  • 1,220
2 votes
2 answers
7k views

I have a code where I am writing a xlsx file : ... ... df.to_excel(finalname,index=False,header=False) Example: I would like to write the excel file with color, but just in the first row, like the ...
Davi Amaral's user avatar
3 votes
1 answer
13k views

I would like to combine pandas df.style objects that use the following methods - df.style.background_gradient and df.style.bar and export the result to html. I'm successful when I have separate ...
Alex M's user avatar
  • 187
7 votes
1 answer
6k views

I'm trying to export a stylish data frame to an Excel file using the script below: import pandas as pd import numpy as np np.random.seed(24) df = pd.DataFrame({'A': np.linspace(1, 10, 10)}) ...
Localhost's user avatar
  • 105
3 votes
1 answer
5k views

I'm trying to highlight some values in some columns in data frame using pandas styles like: import pandas as pd import numpy as np np.random.seed(24) df = pd.DataFrame({'A': np.linspace(1, 10, 10)}...
Localhost's user avatar
  • 105
3 votes
2 answers
1k views

When using dataframe.style, accented characters are shown correctly on Jupyter: df = pandas.DataFrame([['Madrid', 'León']], index=['Spain'], columns=['BigCity', 'SmallCity']) df.style ...
CarlosE's user avatar
  • 970

1
5 6
7
8 9