Skip to main content
Filter by
Sorted by
Tagged with
5 votes
3 answers
189 views

I want to format a Pandas DataFrame with a hyperlink based on the index. import pandas as pd df = (pd.DataFrame([dict(food='bananas', count=33, color='yellow'), dict(food='apples',...
Jason S's user avatar
  • 191k
0 votes
0 answers
55 views

I've created a large dataframe with a smaller dataframe that represents a summary of some calculations run on the larger dataframe. This will find certain percentages, max/min of some columns, etc. I'...
Mwa's user avatar
  • 1
0 votes
2 answers
103 views

I often want to view a random sample of k rows from a DataFrame rather than just the head/tail, for which I would use df.sample(k). When I chain on .style to this sample, the styler will only see the ...
MuhammedYunus's user avatar
1 vote
1 answer
161 views

SETUP I have the following df: import pandas as pd import numpy as np arrays = [ np.array(["fruit", "fruit", "fruit","vegetable", "vegetable", &...
bismo's user avatar
  • 1,645
1 vote
1 answer
47 views

SETUP I have the following df: import pandas as pd import numpy as np arrays = [ np.array(["fruit", "fruit", "fruit","vegetable", "vegetable", &...
bismo's user avatar
  • 1,645
1 vote
2 answers
120 views

What I am trying to accomplish: I have the following dataframe, df: data = {'person': {0: 'a', 1: 'a', 2: 'a', 3: 'a', 4: 'a', 5: 'a', 6: 'b', 7: 'b', 8: 'b', 9: 'b', 10: 'b', 11:...
bismo's user avatar
  • 1,645
3 votes
2 answers
417 views

As an example: import pandas as pd df = pd.DataFrame({ "Hello World": [1, 2, 3, 4], "And Some More": [10.0, 20.0, 30.0, 40.0], }) df_caption = "Table 1: My Table" df....
sdbbs's user avatar
  • 5,948
1 vote
1 answer
39 views

In my code I am able to white out N/As. You will see this near the bottom of the code. I would also like to add additional formatting to specific columns whereby they are formatted as USD Currency ($,...
NewWorldRonin's user avatar
3 votes
2 answers
1k views

I have a dataframe that I am exporting to Excel. I would also like to style it before the export. I have this code which changes the background color and text color and works fine, but I would like to ...
iBeMeltin's user avatar
  • 2,237
0 votes
3 answers
351 views

I am using Pandas to make an HTML table. I want one of my column headers to be in italics. I can put the whole of a header row in italics like this: import pandas as pd col = pd.MultiIndex.from_arrays(...
Gareth Walker's user avatar
-1 votes
1 answer
66 views

When using the to_excel function of pandas DataFrames, the formatter ExcelFormatter styles the cells in a nice way (for example, it merges repeated multiindex columns). Is it possible to copy this ...
medihde's user avatar
  • 19
0 votes
1 answer
420 views

So I got a 3x3 dataframe that looks like this: import pandas as pd df = pd.DataFrame([[-232.3,43.1,"hre"],[-245.7,-943.7,"jtr"],[956.3,435.2,"fgjh"]], columns=list("...
Purple's user avatar
  • 3
0 votes
1 answer
57 views

I need to change the background's color of the dataframe headers to orange: My df looks like this: Campus Server Port AZ server12 Eth1 AZ1 server12 Eth2 AZ2 server23 ...
user1471980's user avatar
  • 10.7k
1 vote
1 answer
48 views

I want to be able take vales from one column of dataframe and find the exact same values in another dataframe to either highlight the whole row or just the string (whatever is easier/possible). ...
Melissa Arroyo-Mendoza's user avatar
2 votes
1 answer
198 views

I have a dataframe with 3 kind of data types - int64, float64 and object (string). How to apply format for two different data types in one function? Sample: def abc_style_format(cell_val): default ...
Mikhail Le's user avatar
1 vote
2 answers
123 views

I was wondering how to highlight diagonal elements of pandas DataFrame using df.style methods. I already found out how to do it with the main diagonal, but can't manage to highlight the one which ...
Yulia Sergeeva's user avatar
0 votes
1 answer
936 views

I'm using Jupyter Notebook and I have a DataFrame with df.shape = (18,7). All columns are of float64 dtype : def currency_format(x): return "${:,.0f}".format(x/1000000) dfResults....
A36's user avatar
  • 53
0 votes
1 answer
379 views

I have dataframe df_brands and I want to format this df and export to excel-file, but I have a problem I have df_brands: and I format this df: and after this I want save this formatted df in excel-...
Юра Ковалeв's user avatar
1 vote
1 answer
79 views

I want to switch the colour of my entire row everytime the value in column 'column2' changes. Here is an example of how I am trying it to look like: If it helps here is my dataframe: df1 = pd....
pyflo's user avatar
  • 33
0 votes
1 answer
232 views

I've had two styling things clash in a pandas dataframe in jupyter notebook and cancel each other out. One column has a very long column heading, the other column has a small column heading but the ...
cardamom's user avatar
  • 7,511
1 vote
1 answer
648 views

My goal is to get a df.style with background gradient going from red to white (intermediate color) to green. The thing is I want to set white color to the value 0. So, if we had a column with values ...
Davi's user avatar
  • 95
-1 votes
2 answers
663 views

I have a data frame like this: df Server CPU_Usage Memory Usage Prod1 80 30 Prod2 70 10 Prod3 20 12 I need to apply Pandas Style to show % sign next to the numbers ...
user1471980's user avatar
  • 10.7k
0 votes
2 answers
258 views

I have a styled object that some of the cells have nan values. I need to remove the nan values while I keep the style in place. if I do this: new_df.data.replace(np.nan, '', regex=True) this removes ...
user1471980's user avatar
  • 10.7k
-2 votes
1 answer
71 views

I have this data frame: df Server Env. Model Percent_Utilized server123 Prod Cisco. 50 server567. Prod Cisco. 80 serverabc. Prod IBM. 100 ...
user1471980's user avatar
  • 10.7k
2 votes
1 answer
81 views

I have this data frame: df Server Env. Model Percent_Utilized server123 Prod Cisco. 50 server567. Prod Cisco. 80 serverabc. Prod IBM. 100 ...
user1471980's user avatar
  • 10.7k
1 vote
1 answer
196 views

I'm trying to highlight largest value in each column of my DataFrame. It's working well in my laptop but not in my pydroid3 mobile app... data = {'Column1': [10, 15, 8], 'Column2': [20, 5, 12], ...
Dr Brijesh K. Chaurasia's user avatar
0 votes
1 answer
667 views

I am trying to change the column width of my dataframe through the use of pandas' style and set_properties, but the width parameter is the only thing that doesn't seem to work while the rest of the ...
John Do's user avatar
1 vote
0 answers
166 views

I have a pandas DataFrame that I styled to generate a latex table with it. I notice that when I don't name the index, the results is a one line header with the first column empty Unnamed index ...
Biorix's user avatar
  • 21
0 votes
1 answer
243 views

I have the following dataframe: import pandas as pd import numpy as np df = pd.DataFrame( { ("A", "Current"): [1, 2, 3], ("A", "Prev"): [1, ...
phildowd's user avatar
0 votes
1 answer
85 views

I have a df as follows Group Date Data1 Data2 A 01-01-2023 22 23 A 01-02-2023 24 20 A 01-03-2023 10 20 A 01-04-2023 30 32 B 02-03-2023 24.5 26.5 B 02-04-2023 26.5 23....
Yogesh Kamboj's user avatar
1 vote
1 answer
37 views

I have a very huge dictionary which I am trying to highlight few rows with matching keys. To highlight specific rows in the HTML table generated from a dictionary, I am using below code. After running ...
user2678648's user avatar
1 vote
1 answer
125 views

I am trying to color cells based on the value of the specific cell. I have a dataframe that includes data for the same product for two different dates. I want to highlight the cell for the latest date ...
ayz123's user avatar
  • 11
0 votes
1 answer
220 views

I have a dataset, that contains only images. I need to input it as a dataframe. I tried to do this with load_files function from sklearn: data = load_files(path) And tried to create a dataframe with ...
neonbones's user avatar
1 vote
2 answers
611 views

How to color a specific text a in pandas df ? The following code colors the whole cell. I'm trying to color only a specific word in the column. import pandas as pd # Create a DataFrame (sample data) ...
Menachem Sperka's user avatar
0 votes
3 answers
710 views

I wanted to style a pandas table, but I'm not able to reshape it every other row, color it this way or set borders for it. I'd be thankful if anyone helps me with this. I uploaded both tables below. ...
Avid Programmer's user avatar
1 vote
2 answers
40 views

Suppose I have a pandas DF with the below data: `data = { 'Crypto': ['ARB', 'ETH', 'ETH'], 'Position': ['Long 10.0X', 'Short 25.0X', 'Short 2.0X'], 'Size Crypto': ['1,075,328.5024 ARB', '...
Francisco4535's user avatar
1 vote
2 answers
539 views

I have a dataframe df which looks like following. Parameter M1 M2 M3 Relative Vmin Relative Vmax 0 P1 1.5 3.1 3.0 1.0 100.0 1 P2 2.2 4.1 4.2 ...
castoridae's user avatar
0 votes
1 answer
78 views

Using the Kaggle EPL dataset and epl=df.dropna().reset_index(drop=True). I'm trying to create a heatmap similar to this: The columns needed to create the heatmap from the dataset would be as follows: ...
Suj's user avatar
  • 37
0 votes
1 answer
264 views

I have highlighted pandas dataframe using conditional statement (highlight one column as yellow if other column value is True). Before exporting to Excel I want to remove the conditional column I used....
Michael's user avatar
  • 85
1 vote
2 answers
843 views

Hi I am trying to style a pandas data frame based on some condition and write the output to excel. I followed the solution here and got it partially done: applying-style-to-a-pandas-dataframe-row-wise....
Soumya's user avatar
  • 393
1 vote
1 answer
453 views

I have two dataframes the same size (3 by 3), one is Logical (True/False) and the other is numerical: My script allows the user to input a specific coordinate from the Logical Matrix in order to ...
Carlos Alfonzo's user avatar
0 votes
1 answer
858 views

I have created a pivot table dataframe and I want to add custom styling to it. I want to iterate over each row and column values and compare the data value from the previous column value. If the value ...
RH-NewDeveloper's user avatar
0 votes
3 answers
801 views

I am trying to get the latex file for the following table/dataframe: df = pd.DataFrame(np.random.rand(10,2)*5, index=pd.date_range(start="2021-01-01", periods=10), ...
User981636's user avatar
  • 3,689
3 votes
2 answers
2k views

I am using pandas 1.5.3 in Flask. This code creates a sticky index column but not sticky column headers: bigdf = pd.DataFrame(np.random.randn(100, 100)) dfhtml = bigdf.style.set_sticky(axis="...
Steve Wright's user avatar
0 votes
1 answer
177 views

For rows in a pandas dataframe that have a given value in a given column, I cannot figure out how to make those rows both colored yellow and bold type. The following coding successfully colors a row ...
raml5's user avatar
  • 13
3 votes
1 answer
288 views

I have a MultiIndex Python Dataframe displaying like this: What can I do to pull up the index names ("index1", "index2") and delete the empty row above the dataframe values to get ...
Sabrina's user avatar
  • 31
1 vote
0 answers
48 views

I tried styling my dataframes df.style\ .applymap(add_color,\ subset=[column names])\ .format('{0:,.0f}',na_rep='-') I tried to export this style after storing it to excel but ...
Arul Raj's user avatar
1 vote
1 answer
177 views

I would like to add borders to specific cells and when adjacent, border the adjacent group without internal borders. Here is my code so far... import pandas as pd df = pd.DataFrame({"TransNo&...
Tyler's user avatar
  • 21
1 vote
1 answer
69 views

I have a df that looks like this: df = pd.DataFrame({'Before':['one three four', 'apple banana milk'], 'After': ['one two three four five', 'soda banana apple juice milk'], ...
Staw6874's user avatar
2 votes
1 answer
82 views

I'm trying to style a simple multiplication table. I have the following rule, and if a cell doesn't satisfy it, I must colorize it in a different color. Example 1: Given numbers 10 and 11, the rule ...
Irina's user avatar
  • 35

1
2 3 4 5
9