pandas

Pandas percentage change matrix

Pandas percentage change matrix Question: I have a data frame: product cost 0 product a 56 1 product b 59 2 product c 104 I’d like to make a percentage change matrix like: product a product b product c product a -5.08% -46.15% product b 5.36% -43.30% product c 85.71% 76.27% There could be n …

Total answers: 4

Pandas to_excel formatting float values

Pandas to_excel formatting float values Question: I’m exporting a dataframe to an excel file using to_excel from pandas but I need that all the number values (float64) to be formatted (without specifing each columns because that will be variable) as a string (BRL currency) when exported. import pandas as pd df = pd.DataFrame({‘Numero’: {0: ‘044121’, …

Total answers: 3

Conditional merging with pandas

Conditional merging with pandas Question: I have a pandas dataframe as below which details additional calls into an area: CommsDate Area Day0 Incremental Day1 Incremental Day2 Incremental 01/01/24 Sales 43 36 29 01/01/24 Service 85 74 66 02/01/24 Sales 56 42 31 02/01/24 Service 73 62 49 03/01/24 Sales 48 32 24 03/01/24 Service 67 …

Total answers: 1

TKinter – Column width = 0 leaves yellow pixels

TKinter – Column width = 0 leaves yellow pixels Question: I am trying to only show certain columns when pressing one of the buttons on the right side, for that reason I implemented to hide the other columns by reducing their column width to 0. While this works for hiding the columns, it leaves yellow …

Total answers: 1

How to prevent matplotlib from plotting the "day number" on an axis

How to prevent matplotlib from plotting the "day number" on an axis Question: I am seeing a slightly annoying issue when plotting some data with matplotlib. As shown in the example output below, the x-axis has a slightly unexpected format. The labels are (for example) 04 12:30. The 04 being the day of the month. …

Total answers: 1

apply different function on each row

apply different function on each row Question: I have a dataframe with 2 columns field and value(number of rows maximum 10). I need to perform some checks depending on the field(ie need to apply different function on each row) and store its result in status column. Below is sample: data = { ‘field’: [‘a’, ‘b’], …

Total answers: 3

Interweave groups in Pandas

Interweave groups in Pandas Question: I have a DataFrame that I want "intereaved" row-wise by groups. For example, this DataFrame: Group Score A 10 A 9 A 8 B 7 B 6 B 5 The desired result would be grabbing the first of A, and the first of B, then the second of A, then …

Total answers: 2